From c3ddbc54f6577866b29c5b85c289c610c7f53f92 Mon Sep 17 00:00:00 2001 From: Alex Schearer Date: Sun, 26 Feb 2017 16:16:54 -0800 Subject: [PATCH] Using converter parameter to invert boolean to visibility. --- .../UnitySizeExplorer.WPF.csproj | 3 +-- ...tor.cs => BooleanToVisibilityConverter.cs} | 10 ++++++++- .../InvertedBooleanToVisibilityConvertor.cs | 21 ------------------- .../Views/Pages/WorkspacePageView.xaml | 11 +++++----- 4 files changed, 15 insertions(+), 30 deletions(-) rename Source/UnitySizeExplorer.WPF/Views/{BooleanToVisibilityConvertor.cs => BooleanToVisibilityConverter.cs} (69%) delete mode 100644 Source/UnitySizeExplorer.WPF/Views/InvertedBooleanToVisibilityConvertor.cs diff --git a/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj b/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj index cada163..6362d03 100644 --- a/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj +++ b/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj @@ -94,8 +94,7 @@ - - + StartPageView.xaml diff --git a/Source/UnitySizeExplorer.WPF/Views/BooleanToVisibilityConvertor.cs b/Source/UnitySizeExplorer.WPF/Views/BooleanToVisibilityConverter.cs similarity index 69% rename from Source/UnitySizeExplorer.WPF/Views/BooleanToVisibilityConvertor.cs rename to Source/UnitySizeExplorer.WPF/Views/BooleanToVisibilityConverter.cs index 8f4db22..b1c2b7b 100644 --- a/Source/UnitySizeExplorer.WPF/Views/BooleanToVisibilityConvertor.cs +++ b/Source/UnitySizeExplorer.WPF/Views/BooleanToVisibilityConverter.cs @@ -5,11 +5,19 @@ using System.Windows; using System.Windows.Data; - public class BooleanToVisibilityConvertor : IValueConverter + public class BooleanToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var boolValue = (bool)value; + if (parameter != null) + { + if (bool.Parse((string)parameter)) + { + boolValue = !boolValue; + } + } + return boolValue ? Visibility.Visible : Visibility.Collapsed; } diff --git a/Source/UnitySizeExplorer.WPF/Views/InvertedBooleanToVisibilityConvertor.cs b/Source/UnitySizeExplorer.WPF/Views/InvertedBooleanToVisibilityConvertor.cs deleted file mode 100644 index e2b60b5..0000000 --- a/Source/UnitySizeExplorer.WPF/Views/InvertedBooleanToVisibilityConvertor.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace SpottedZebra.UnitySizeExplorer.WPF.Views -{ - using System; - using System.Globalization; - using System.Windows; - using System.Windows.Data; - - public class InvertedBooleanToVisibilityConvertor : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - var boolValue = (bool)value; - return boolValue ? Visibility.Collapsed : Visibility.Visible; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Source/UnitySizeExplorer.WPF/Views/Pages/WorkspacePageView.xaml b/Source/UnitySizeExplorer.WPF/Views/Pages/WorkspacePageView.xaml index 2d76c0f..de98b0d 100644 --- a/Source/UnitySizeExplorer.WPF/Views/Pages/WorkspacePageView.xaml +++ b/Source/UnitySizeExplorer.WPF/Views/Pages/WorkspacePageView.xaml @@ -21,18 +21,17 @@ - - + - - - - + + + +