public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var _formatter = Formatter.ToObjectString(); double _value = value.ToDouble(); string[] arrayEndGroup = _formatter.Split('#'); string GroupResult = null; string[] _subgroupArray = arrayEndGroup[0].Split(','); foreach (var SubGroup in _subgroupArray) { GroupResult = IfElseColorConverter.CompareSubGroup(SubGroup, _value); if (GroupResult == null) { continue; } else { break; } } if (GroupResult == null) { if (arrayEndGroup.Length > 1) { GroupResult = arrayEndGroup[1]; } else { GroupResult = ""; } } return(GroupResult.Replace("{0}", value.ToObjectString())); }
public override object ProvideValue(IServiceProvider serviceProvider) { if (IsResource) { _converterXamlResource = new IfElseColorConverter(Formatter); return _converterXamlResource; } else { if (_converterXaml == null) { _converterXaml = new IfElseColorConverter(Formatter); } return _converterXaml; } }