1 // -------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All Rights Reserved.
3 // -------------------------------------------------------------------
4 //From \\authoring\Sparkle\Source\1.0.1083.0\Common\Source\Framework\Data
5 namespace System.Activities.Presentation.Internal.PropertyEditing.FromExpression.Framework.Data
8 using System.Collections;
9 using System.ComponentModel;
10 using System.Globalization;
11 using System.Reflection;
13 using System.Windows.Controls;
14 using System.Windows.Data;
15 using System.Diagnostics.CodeAnalysis;
19 // Maps an Integer to Visilbity. 0 becomes Hidden, non-zero becomes Visible.
21 [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
22 internal class IntegerToVisibilityConverter : IValueConverter
24 private Visibility zeroValue = Visibility.Collapsed;
26 private Visibility nonzeroValue = Visibility.Visible;
27 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
28 public Visibility ZeroValue
30 get { return this.zeroValue; }
31 set { this.zeroValue = value; }
33 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
34 public Visibility NonzeroValue
36 get { return this.nonzeroValue; }
37 set { this.nonzeroValue = value; }
40 // IValueConverter Implementation
42 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
44 Fx.Assert(false, "Never expecting the inverse transform to be called");
48 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
50 Fx.Assert(value is int, "Ensure that transformed value is an integer");
52 if ((value is int) && (int)value == 0)
54 return this.zeroValue;
58 return this.nonzeroValue;