From 14422eec4602a979368f85a627c714177c249d62 Mon Sep 17 00:00:00 2001 From: wcko87 Date: Wed, 10 May 2017 10:47:29 +0800 Subject: [PATCH] Add format preview --- rabi_splitter_WPF/MainContext.cs | 29 ++++++++++++++++++++++ rabi_splitter_WPF/VariableExportSetting.cs | 13 ++++++++++ rabi_splitter_WPF/VariableExportTab.xaml | 20 +++++++++++---- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/rabi_splitter_WPF/MainContext.cs b/rabi_splitter_WPF/MainContext.cs index db25e70..5e89d7d 100644 --- a/rabi_splitter_WPF/MainContext.cs +++ b/rabi_splitter_WPF/MainContext.cs @@ -6,9 +6,38 @@ using System.Linq; using System.Text; using System.Windows.Data; using rabi_splitter_WPF.Annotations; +using System.Windows; namespace rabi_splitter_WPF { + [ValueConversion(typeof(bool), typeof(Visibility))] + public class InvertableBooleanToVisibilityConverter : IValueConverter + { + #region IValueConverter Members + // Code taken from http://stackoverflow.com/a/2427307 + enum Parameter + { + VisibleWhenTrue, VisibleWhenFalse + } + + public object Convert(object value, Type targetType, object parameter, + System.Globalization.CultureInfo culture) + { + var boolValue = (bool)value; + var direction = (Parameter)Enum.Parse(typeof(Parameter), (string)parameter); + + if (direction == Parameter.VisibleWhenTrue) return boolValue ? Visibility.Visible : Visibility.Collapsed; + else return boolValue ? Visibility.Collapsed : Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, + System.Globalization.CultureInfo culture) + { + return null; + } + #endregion + } + [ValueConversion(typeof(bool), typeof(bool))] public class InverseBooleanConverter : IValueConverter { diff --git a/rabi_splitter_WPF/VariableExportSetting.cs b/rabi_splitter_WPF/VariableExportSetting.cs index 151d81c..8a05764 100644 --- a/rabi_splitter_WPF/VariableExportSetting.cs +++ b/rabi_splitter_WPF/VariableExportSetting.cs @@ -59,6 +59,7 @@ namespace rabi_splitter_WPF private string _outputFileName; private string _outputFormat; private bool _isExporting; + private bool _isPreviewingFormat; #region Dictionaries private static Dictionary _variableCaptions; @@ -89,6 +90,7 @@ namespace rabi_splitter_WPF _outputFileName = ""; _outputFormat = ""; _isExporting = false; + _isPreviewingFormat = false; } #region Parameters @@ -126,6 +128,17 @@ namespace rabi_splitter_WPF } } + public bool IsPreviewingFormat + { + get { return _isPreviewingFormat; } + set + { + if (value.Equals(_isPreviewingFormat)) return; + _isPreviewingFormat = value; + OnPropertyChanged(nameof(IsPreviewingFormat)); + } + } + public bool IsExporting { get { return _isExporting; } diff --git a/rabi_splitter_WPF/VariableExportTab.xaml b/rabi_splitter_WPF/VariableExportTab.xaml index 0b14d67..85a07fd 100644 --- a/rabi_splitter_WPF/VariableExportTab.xaml +++ b/rabi_splitter_WPF/VariableExportTab.xaml @@ -6,6 +6,9 @@ xmlns:local="clr-namespace:rabi_splitter_WPF" mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="540"> + + +