| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Resources;
- using System;
- using System.Windows.Data;
- namespace Muchinfo.MTPClient.Infrastructure.Converters
- {
- public class WarningSignConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- string result = string.Empty;
- string direction = string.Empty;
- string warningSign = string.Empty;
- string warningValue = string.Empty;
- if (values != null && values.Length == 4)
- {
- if (values[0] is WarningType)
- {
- WarningType warningType = (WarningType)values[0];
- if (warningType == WarningType.Quote)
- {
- Direction value1 = (Direction)values[1];
- switch (value1)
- {
- case Direction.Ask:
- direction = Client_Resource.Infrastructure_sell;
- break;
- case Direction.Bid:
- direction = Client_Resource.Infrastructure_buy;
- break;
- }
- }
- var value = (WarningSign)values[2];
- switch (value)
- {
- case WarningSign.Equal:
- warningSign = "=";
- break;
- case WarningSign.GreaterThan:
- warningSign = ">";
- break;
- case WarningSign.LessThan:
- warningSign = "<";
- break;
- }
- warningValue = values[3].ToString();
- }
- }
- return string.Format("{0}{1}{2}", direction, warningSign, warningValue);
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- string result = string.Empty;
- if (value != null)
- {
- var warningSign = (WarningSign)value;
- switch (warningSign)
- {
- case WarningSign.Equal:
- result = "=";
- break;
- case WarningSign.GreaterThan:
- result = ">";
- break;
- case WarningSign.LessThan:
- result = "<";
- break;
- }
- }
- return result;
- }
- }
- }
|