1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Editors
7 using System.Collections;
8 using System.Diagnostics;
9 using System.Diagnostics.CodeAnalysis;
10 using System.Globalization;
11 using System.Windows.Data;
12 using System.Activities.Presentation;
15 // Converts ints >0 to true, everything else to false. This class is instantiated from XAML.
17 [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
18 internal class NonZeroToBoolConverter : IValueConverter
24 // If set to false, NonZeroToBoolConverter.Convert() converts 0 to false and !0 to true.
25 // If set to true, the result is inverted.
27 [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
30 get { return _invert; }
31 set { _invert = value; }
34 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
36 if (targetType == typeof(bool) && value is int)
38 return (((int)value) > 0) ^ _invert;
44 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
46 throw FxTrace.Exception.AsError(new NotImplementedException());