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; } } }