Add format preview

rabi_display
wcko87 8 years ago
parent 13fac33d6d
commit 14422eec46
  1. 29
      rabi_splitter_WPF/MainContext.cs
  2. 13
      rabi_splitter_WPF/VariableExportSetting.cs
  3. 20
      rabi_splitter_WPF/VariableExportTab.xaml

@ -6,9 +6,38 @@ using System.Linq;
using System.Text; using System.Text;
using System.Windows.Data; using System.Windows.Data;
using rabi_splitter_WPF.Annotations; using rabi_splitter_WPF.Annotations;
using System.Windows;
namespace rabi_splitter_WPF 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))] [ValueConversion(typeof(bool), typeof(bool))]
public class InverseBooleanConverter : IValueConverter public class InverseBooleanConverter : IValueConverter
{ {

@ -59,6 +59,7 @@ namespace rabi_splitter_WPF
private string _outputFileName; private string _outputFileName;
private string _outputFormat; private string _outputFormat;
private bool _isExporting; private bool _isExporting;
private bool _isPreviewingFormat;
#region Dictionaries #region Dictionaries
private static Dictionary<ExportableVariable, string> _variableCaptions; private static Dictionary<ExportableVariable, string> _variableCaptions;
@ -89,6 +90,7 @@ namespace rabi_splitter_WPF
_outputFileName = ""; _outputFileName = "";
_outputFormat = ""; _outputFormat = "";
_isExporting = false; _isExporting = false;
_isPreviewingFormat = false;
} }
#region Parameters #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 public bool IsExporting
{ {
get { return _isExporting; } get { return _isExporting; }

@ -6,6 +6,9 @@
xmlns:local="clr-namespace:rabi_splitter_WPF" xmlns:local="clr-namespace:rabi_splitter_WPF"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="500" d:DesignWidth="540"> d:DesignHeight="500" d:DesignWidth="540">
<UserControl.Resources>
<local:InvertableBooleanToVisibilityConverter x:Key="InvertableBooleanToVisibilityConverter"/>
</UserControl.Resources>
<DockPanel> <DockPanel>
<StackPanel> <StackPanel>
<Button Content="Add" Width="40" Height="40" DockPanel.Dock="Right" Click="AddButton_Click"/> <Button Content="Add" Width="40" Height="40" DockPanel.Dock="Right" Click="AddButton_Click"/>
@ -27,11 +30,18 @@
</StackPanel> </StackPanel>
<DockPanel Grid.Column="1" Margin="15,0,15,0"> <DockPanel Grid.Column="1" Margin="15,0,15,0">
<DockPanel> <DockPanel>
<DockPanel DockPanel.Dock="Top"> <Grid DockPanel.Dock="Top">
<TextBlock DockPanel.Dock="Left" Text="Format"/> <Grid.ColumnDefinitions>
<Button DockPanel.Dock="Right" Content="Default Format" Click="DefaultButton_Click" Width="120" HorizontalAlignment="Right"/> <ColumnDefinition Width="6*" />
</DockPanel> <ColumnDefinition Width="5*" />
<TextBox Margin="0,5,0,5" Text="{Binding Path=OutputFormat, Mode=TwoWay}" AcceptsReturn="True"/> <ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Left" Text="Format"/>
<ToggleButton Grid.Column="1" Margin="0,0,5,0" Content="Preview" IsChecked="{Binding Path=IsPreviewingFormat}"/>
<Button Grid.Column="2" Content="Default" Click="DefaultButton_Click"/>
</Grid>
<TextBox Height="50" DockPanel.Dock="Top" Margin="0,5,0,5" Text="{Binding Path=OutputFormat, Mode=TwoWay}" AcceptsReturn="True" Visibility="{Binding Path=IsPreviewingFormat, Converter={StaticResource InvertableBooleanToVisibilityConverter}, ConverterParameter=VisibleWhenFalse, FallbackValue=Visible}"/>
<TextBlock Height="50" DockPanel.Dock="Top" Margin="0,5,0,5" Text="{Binding Path=OutputFormat, Mode=TwoWay}" Visibility="{Binding Path=IsPreviewingFormat, Converter={StaticResource InvertableBooleanToVisibilityConverter}, ConverterParameter=VisibleWhenTrue, FallbackValue=Collapsed}"/>
</DockPanel> </DockPanel>
</DockPanel> </DockPanel>
<DockPanel Grid.Column="2"> <DockPanel Grid.Column="2">

Loading…
Cancel
Save