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.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
{

@ -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<ExportableVariable, string> _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; }

@ -6,6 +6,9 @@
xmlns:local="clr-namespace:rabi_splitter_WPF"
mc:Ignorable="d"
d:DesignHeight="500" d:DesignWidth="540">
<UserControl.Resources>
<local:InvertableBooleanToVisibilityConverter x:Key="InvertableBooleanToVisibilityConverter"/>
</UserControl.Resources>
<DockPanel>
<StackPanel>
<Button Content="Add" Width="40" Height="40" DockPanel.Dock="Right" Click="AddButton_Click"/>
@ -27,11 +30,18 @@
</StackPanel>
<DockPanel Grid.Column="1" Margin="15,0,15,0">
<DockPanel>
<DockPanel DockPanel.Dock="Top">
<TextBlock DockPanel.Dock="Left" Text="Format"/>
<Button DockPanel.Dock="Right" Content="Default Format" Click="DefaultButton_Click" Width="120" HorizontalAlignment="Right"/>
</DockPanel>
<TextBox Margin="0,5,0,5" Text="{Binding Path=OutputFormat, Mode=TwoWay}" AcceptsReturn="True"/>
<Grid DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="6*" />
<ColumnDefinition Width="5*" />
<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 Grid.Column="2">

Loading…
Cancel
Save