[amd64/tramp] hide interpreter specific trampoline behind ifdef
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / PropertyEditing / FromExpression / Framework / Data / BoolToVisibilityHiddenConverter.cs
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
6 {
7     using System;
8     using System.ComponentModel;
9     using System.Globalization;
10     using System.Reflection;
11     using System.Windows;
12     using System.Windows.Controls;
13     using System.Windows.Data;
14     using System.Diagnostics.CodeAnalysis;
15
16     // <summary>
17     // (bool-to-Visibility) Maps true to Visible and false to Hidden.
18     // </summary>
19
20     [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
21     internal class BoolToVisibilityHiddenConverter : IValueConverter
22     {
23         bool invertBoolean = false;
24
25         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
26
27         public bool InvertBoolean
28         {
29             get { return this.invertBoolean; }
30             set { this.invertBoolean = value; }
31         }
32
33         // IValueConverter Implementation
34         public object ConvertBack(object o, Type targetType, object parameter, CultureInfo culture)
35         {
36             Visibility visibility = (Visibility)o;
37             bool result = visibility == Visibility.Visible;
38             if (this.invertBoolean)
39             {
40                 result = !result;
41             }
42             return result;
43         }
44
45         public object Convert(object o, Type targetType, object parameter, CultureInfo culture)
46         {
47             bool show = (bool)o;
48             if (this.invertBoolean)
49             {
50                 show = !show;
51             }
52             return show ? Visibility.Visible : Visibility.Hidden;
53         }
54     }
55
56 }