mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-24 11:32:21 +01:00
Change selected item settings display by using style triggers. Add no preset selected message.
This commit is contained in:
1 parent
fbcc910f94
commit
d5b372b670
6 files changed
+335
-280
No files matched your search
@@ -897,6 +897,15 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No preset selected.
|
||||
/// </summary>
|
||||
public static string NoPresetSelected {
|
||||
get {
|
||||
return ResourceManager.GetString("NoPresetSelected", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Ok.
|
||||
/// </summary>
|
||||
|
||||
@@ -571,4 +571,7 @@ use maj for uppercase version</value>
|
||||
<data name="FFMPEGCustomArgumentsTooltip" xml:space="preserve">
|
||||
<value>Custom FFMPEG command line arguments</value>
|
||||
</data>
|
||||
<data name="NoPresetSelected" xml:space="preserve">
|
||||
<value>No preset selected</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -6,10 +6,13 @@ namespace FileConverter.ViewModels
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Media;
|
||||
|
||||
using CommonServiceLocator;
|
||||
using GalaSoft.MvvmLight;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
using FileConverter.ConversionJobs;
|
||||
|
||||
public class InputExtension : INotifyPropertyChanged
|
||||
public class InputExtension : ObservableObject
|
||||
{
|
||||
private readonly Brush defaultBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0));
|
||||
private readonly Brush errorBrush = new SolidColorBrush(Color.FromRgb(255, 65, 0));
|
||||
@@ -48,54 +51,69 @@ namespace FileConverter.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
get => this.name;
|
||||
|
||||
set
|
||||
{
|
||||
this.name = value;
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public Brush ForegroundBrush
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.foregroundBrush;
|
||||
}
|
||||
get => this.foregroundBrush;
|
||||
|
||||
set
|
||||
{
|
||||
this.foregroundBrush = value;
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string ToolTip
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.toolTip;
|
||||
}
|
||||
get => this.toolTip;
|
||||
|
||||
set
|
||||
{
|
||||
this.toolTip = value;
|
||||
this.OnPropertyChanged();
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
public bool IsChecked
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
get
|
||||
{
|
||||
SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance<SettingsViewModel>();
|
||||
PresetNode selectedPreset = settingsViewModel.SelectedPreset;
|
||||
if (selectedPreset == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return selectedPreset.Preset.InputTypes.Contains(this.name.ToLowerInvariant());
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance<SettingsViewModel>();
|
||||
PresetNode selectedPreset = settingsViewModel.SelectedPreset;
|
||||
|
||||
if (value)
|
||||
{
|
||||
selectedPreset?.Preset.AddInputType(this.name.ToLowerInvariant());
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedPreset?.Preset.RemoveInputType(this.name.ToLowerInvariant());
|
||||
}
|
||||
|
||||
this.RaisePropertyChanged(nameof(this.IsChecked));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
// <copyright file="InputExtensionCategory.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
using System.ComponentModel;
|
||||
using CommonServiceLocator;
|
||||
using FileConverter.Services;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
|
||||
namespace FileConverter.ViewModels
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
@@ -7,8 +12,8 @@ namespace FileConverter.ViewModels
|
||||
|
||||
public class InputExtensionCategory : ObservableObject
|
||||
{
|
||||
private readonly List<InputExtension> inputExtensions = new List<InputExtension>();
|
||||
private string name;
|
||||
private List<InputExtension> inputExtensions = new List<InputExtension>();
|
||||
|
||||
public InputExtensionCategory(string name)
|
||||
{
|
||||
@@ -17,10 +22,7 @@ namespace FileConverter.ViewModels
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
get => this.name;
|
||||
|
||||
set
|
||||
{
|
||||
@@ -29,13 +31,7 @@ namespace FileConverter.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<InputExtension> InputExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inputExtensions;
|
||||
}
|
||||
}
|
||||
public IEnumerable<InputExtension> InputExtensions => this.inputExtensions;
|
||||
|
||||
public IEnumerable<string> InputExtensionNames
|
||||
{
|
||||
@@ -55,9 +51,77 @@ namespace FileConverter.ViewModels
|
||||
{
|
||||
inputExtension = new InputExtension(extension);
|
||||
this.inputExtensions.Add(inputExtension);
|
||||
this.RaisePropertyChanged("InputExtensions");
|
||||
this.RaisePropertyChanged("InputExtensionNames");
|
||||
|
||||
inputExtension.PropertyChanged += this.OnExtensionPropertyChange;
|
||||
|
||||
this.RaisePropertyChanged(nameof(this.InputExtensions));
|
||||
this.RaisePropertyChanged(nameof(this.InputExtensionNames));
|
||||
this.RaisePropertyChanged(nameof(this.IsChecked));
|
||||
}
|
||||
}
|
||||
|
||||
public bool? IsChecked
|
||||
{
|
||||
get
|
||||
{
|
||||
SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance<SettingsViewModel>();
|
||||
PresetNode selectedPreset = settingsViewModel.SelectedPreset;
|
||||
if (selectedPreset == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool all = true;
|
||||
bool none = true;
|
||||
foreach (string extension in this.InputExtensionNames)
|
||||
{
|
||||
bool contains = selectedPreset.Preset.InputTypes.Contains(extension);
|
||||
all &= contains;
|
||||
none &= !contains;
|
||||
}
|
||||
|
||||
if (all)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (none)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance<SettingsViewModel>();
|
||||
PresetNode selectedPreset = settingsViewModel.SelectedPreset;
|
||||
|
||||
foreach (string extension in this.InputExtensionNames)
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
selectedPreset?.Preset.AddInputType(extension);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedPreset?.Preset.RemoveInputType(extension);
|
||||
}
|
||||
}
|
||||
|
||||
// Raise property change for extensions.
|
||||
foreach (InputExtension inputExtension in this.InputExtensions)
|
||||
{
|
||||
inputExtension.RaisePropertyChanged(nameof(inputExtension.IsChecked));
|
||||
}
|
||||
|
||||
this.RaisePropertyChanged(nameof(this.IsChecked));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExtensionPropertyChange(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
this.RaisePropertyChanged(nameof(this.IsChecked));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,178 @@
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<generic:IcoFileSizeSelectorConverter x:Key="IcoFileSizeSelector" />
|
||||
<generic:EqualsConverter x:Key="EqualsConverter"/>
|
||||
|
||||
<DataTemplate x:Key="NoPresetSelectedTemplate" DataType="{x:Type viewModels:SettingsViewModel}">
|
||||
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Height="auto" FontSize="20"
|
||||
Content="{x:Static project:Resources.NoPresetSelected}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="FolderSelectedTemplate" DataType="{x:Type viewModels:SettingsViewModel}">
|
||||
<GroupBox Header="{x:Static project:Resources.PresetFolder}">
|
||||
<Grid DataContext="{Binding SelectedFolder}" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MaxWidth="240"/>
|
||||
<ColumnDefinition Width="2.5*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="{x:Static project:Resources.PresetFolderName}" Grid.Row="0" HorizontalContentAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="5,2,25,2" TextWrapping="Wrap" Width="Auto" FontSize="15"
|
||||
Loaded="SelectedFolderName_OnLoaded"
|
||||
Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="PresetSelectedTemplate" DataType="{x:Type viewModels:SettingsViewModel}">
|
||||
<GroupBox Header="{x:Static project:Resources.Preset}">
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MaxWidth="240"/>
|
||||
<ColumnDefinition Width="2.5*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="{x:Static project:Resources.PresetName}" Grid.Row="0" HorizontalContentAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="5,2,25,2" TextWrapping="Wrap" Width="Auto" FontSize="15"
|
||||
Loaded="SelectedPresetName_OnLoaded"
|
||||
Text="{Binding SelectedPreset.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
|
||||
|
||||
<GroupBox Grid.Row="1" Grid.Column="0" Header="{x:Static project:Resources.InputFormats}" Margin="5">
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="22"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TreeView x:Name="InputTypesTreeView" ItemsSource="{Binding InputCategories}" >
|
||||
<TreeView.Resources>
|
||||
<HierarchicalDataTemplate DataType="{x:Type viewModels:InputExtensionCategory}" ItemsSource="{Binding InputExtensions}">
|
||||
<CheckBox Height="20" VerticalAlignment="Top" Margin="2" IsThreeState="True"
|
||||
Content="{Binding Name, Converter={StaticResource ObjectToLocalizedString}}"
|
||||
IsChecked="{Binding IsChecked, Mode=TwoWay}">
|
||||
</CheckBox>
|
||||
</HierarchicalDataTemplate>
|
||||
<DataTemplate DataType="{x:Type viewModels:InputExtension}">
|
||||
<CheckBox Height="20" VerticalAlignment="Top" Margin="2"
|
||||
Content="{Binding Name}" Foreground="{Binding ForegroundBrush}" ToolTip="{Binding ToolTip}"
|
||||
IsChecked="{Binding IsChecked, Mode=TwoWay}">
|
||||
</CheckBox>
|
||||
</DataTemplate>
|
||||
</TreeView.Resources>
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="TreeViewItem">
|
||||
<Setter Property="IsExpanded" Value="True"/>
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
</TreeView>
|
||||
|
||||
<Label Grid.Row="1" Content="{x:Static project:Resources.ActionWhenConversionSucceedTitle}" ToolTip="{x:Static project:Resources.ActionWhenConversionSucceedDescription}" />
|
||||
<ComboBox Grid.Row="2" ItemsSource="{Binding InputPostConversionActions, Mode=OneTime}"
|
||||
SelectedItem="{Binding SelectedPreset.Preset.InputPostConversionAction, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentPresenter Content="{Binding Converter={StaticResource ObjectToLocalizedString}}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="3" Margin="0,5,0,0">
|
||||
<Hyperlink CommandParameter="https://github.com/Tichau/FileConverter/wiki/Input-file-post-conversion-actions" Command="{Binding OpenUrlCommand, Mode=OneWay}" Foreground="#1E6BB8"><x:Static Member="project:Resources.Help" /></Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="{x:Static project:Resources.OutputFormat}" Grid.Row="1" Grid.Column="1" Margin="5">
|
||||
<StackPanel>
|
||||
<ComboBox Margin="5" Height="29" VerticalAlignment="Top"
|
||||
ItemsSource="{Binding OutputTypes}"
|
||||
SelectedItem="{Binding SelectedPreset.Preset.OutputType, Converter={StaticResource OutputTypeEnumToViewModel}, Mode=TwoWay}">
|
||||
<ComboBox.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Foreground="#004B82" Background="#86C8F6" FontWeight="Bold" Padding="5,5,5,5"
|
||||
Text="{Binding Name, Converter={StaticResource ObjectToLocalizedString}}"/>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</ComboBox.GroupStyle>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type viewModels:OutputTypeViewModel}">
|
||||
<TextBlock Text="{Binding Type}" Padding="10,2,2,2"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<ContentControl Content="{Binding SelectedPreset.Preset}"
|
||||
Style="{StaticResource ConversionSettingsSelectorStyle}">
|
||||
</ContentControl>
|
||||
|
||||
<Separator/>
|
||||
|
||||
<!-- Output file name template -->
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="23"/>
|
||||
<RowDefinition Height="23"/>
|
||||
<RowDefinition Height="23"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="{x:Static project:Resources.FileNameTemplate}" Grid.Row="0" HorizontalContentAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="5,2,25,2" TextWrapping="Wrap" Width="Auto"
|
||||
ToolTip="{x:Static project:Resources.OutputFilePathTemplateHelp}"
|
||||
Text="{Binding SelectedPreset.OutputFileNameTemplate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
|
||||
<Label Content="{x:Static project:Resources.InputExample}" Grid.Row="1" Grid.Column="0" HorizontalContentAlignment="Right" Margin="0,0,5,0" Foreground="Gray" FontSize="10"/>
|
||||
<TextBlock Text="{x:Static project:Resources.OutputFileNameTemplateSample}" Grid.Row="1" Grid.Column="1" Margin="5,0,5,0" Foreground="Gray" FontSize="10" VerticalAlignment="Center"/>
|
||||
<Label Content="{x:Static project:Resources.OutputExample}" Grid.Row="2" Grid.Column="0" HorizontalContentAlignment="Right" Margin="0,0,5,0" Foreground="Gray" FontSize="10"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Margin="5,0,5,0" Foreground="Gray" FontSize="10" VerticalAlignment="Center">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource FileNameConverter}">
|
||||
<Binding Source="{x:Static project:Resources.OutputFileNameTemplateSample}"/>
|
||||
<Binding Path="SelectedPreset.Preset.OutputType" Mode="OneWay"/>
|
||||
<Binding Path="SelectedPreset.Preset.OutputFileNameTemplate" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Margin="5,0,5,0">
|
||||
<Hyperlink CommandParameter="https://github.com/Tichau/FileConverter/wiki/Output-file-path-template" Command="{Binding OpenUrlCommand, Mode=OneWay}" Foreground="#1E6BB8"><x:Static Member="project:Resources.Help" /></Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="SettingsSelectorStyle" TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource NoPresetSelectedTemplate}"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding SelectedFolder, Converter={StaticResource EqualsConverter}}" Value="False">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource FolderSelectedTemplate}"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding SelectedPreset, Converter={StaticResource EqualsConverter}}" Value="False">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource PresetSelectedTemplate}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
|
||||
@@ -167,165 +339,11 @@
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Folder settings -->
|
||||
<GroupBox Header="{x:Static project:Resources.PresetFolder}" Margin="5,5,0,0" Grid.Column="1"
|
||||
Visibility="{Binding SelectedFolder, Converter={StaticResource ReferenceToVisibility}}">
|
||||
<Grid DataContext="{Binding SelectedFolder}" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MaxWidth="240"/>
|
||||
<ColumnDefinition Width="2.5*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="{x:Static project:Resources.PresetFolderName}" Grid.Row="0" HorizontalContentAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBox x:Name="FolderNameTextBox" Grid.Row="0" Grid.Column="1" Margin="5,2,25,2" TextWrapping="Wrap" Width="Auto" FontSize="15"
|
||||
Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<!-- Preset settings -->
|
||||
<GroupBox Header="{x:Static project:Resources.Preset}" Margin="5,5,0,0" Grid.Column="1"
|
||||
Visibility="{Binding SelectedPreset, Converter={StaticResource ReferenceToVisibility}}">
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MaxWidth="240"/>
|
||||
<ColumnDefinition Width="2.5*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="{x:Static project:Resources.PresetName}" Grid.Row="0" HorizontalContentAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBox x:Name="PresetNameTextBox" Grid.Row="0" Grid.Column="1" Margin="5,2,25,2" TextWrapping="Wrap" Width="Auto" FontSize="15"
|
||||
Text="{Binding SelectedPreset.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
|
||||
|
||||
<GroupBox Grid.Row="1" Grid.Column="0" Header="{x:Static project:Resources.InputFormats}" Margin="5">
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="22"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TreeView x:Name="InputTypesTreeView" ItemsSource="{Binding InputCategories}" >
|
||||
<TreeView.Resources>
|
||||
<HierarchicalDataTemplate DataType="{x:Type viewModels:InputExtensionCategory}" ItemsSource="{Binding InputExtensions}">
|
||||
<CheckBox Content="{Binding Name, Converter={StaticResource ObjectToLocalizedString}}" Height="20" VerticalAlignment="Top" Margin="2" Checked="OnInputTypeCategoryChecked" Unchecked="OnInputTypeCategoryUnchecked" IsThreeState="True" >
|
||||
<CheckBox.IsChecked>
|
||||
<MultiBinding Converter="{StaticResource CollectionContainsElementToBool}" Mode="OneWay">
|
||||
<Binding RelativeSource="{RelativeSource AncestorType={x:Type Window}}" Path="DataContext.SelectedPreset.Preset.InputTypes" Mode="OneWay"/>
|
||||
<Binding Path="InputExtensionNames" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</CheckBox.IsChecked>
|
||||
</CheckBox>
|
||||
</HierarchicalDataTemplate>
|
||||
<DataTemplate DataType="{x:Type viewModels:InputExtension}">
|
||||
<CheckBox Content="{Binding Name}" Foreground="{Binding ForegroundBrush}" ToolTip="{Binding ToolTip}" Height="20" VerticalAlignment="Top" Margin="2" Checked="OnInputTypeChecked" Unchecked="OnInputTypeUnchecked">
|
||||
<CheckBox.IsChecked>
|
||||
<MultiBinding Converter="{StaticResource CollectionContainsElementToBool}" Mode="OneWay">
|
||||
<Binding RelativeSource="{RelativeSource AncestorType={x:Type Window}}" Path="DataContext.SelectedPreset.Preset.InputTypes" Mode="OneWay"/>
|
||||
<Binding Path="Name" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</CheckBox.IsChecked>
|
||||
</CheckBox>
|
||||
</DataTemplate>
|
||||
</TreeView.Resources>
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="TreeViewItem">
|
||||
<Setter Property="IsExpanded" Value="True"/>
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
</TreeView>
|
||||
|
||||
<Label Grid.Row="1" Content="{x:Static project:Resources.ActionWhenConversionSucceedTitle}" ToolTip="{x:Static project:Resources.ActionWhenConversionSucceedDescription}" />
|
||||
<ComboBox Grid.Row="2" ItemsSource="{Binding InputPostConversionActions, Mode=OneTime}"
|
||||
SelectedItem="{Binding SelectedPreset.Preset.InputPostConversionAction, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentPresenter Content="{Binding Converter={StaticResource ObjectToLocalizedString}}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="3" Margin="0,5,0,0">
|
||||
<Hyperlink CommandParameter="https://github.com/Tichau/FileConverter/wiki/Input-file-post-conversion-actions" Command="{Binding OpenUrlCommand, Mode=OneWay}" Foreground="#1E6BB8"><x:Static Member="project:Resources.Help" /></Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="{x:Static project:Resources.OutputFormat}" Grid.Row="1" Grid.Column="1" Margin="5">
|
||||
<StackPanel>
|
||||
<ComboBox Margin="5" Height="29" VerticalAlignment="Top"
|
||||
ItemsSource="{Binding OutputTypes}"
|
||||
SelectedItem="{Binding SelectedPreset.Preset.OutputType, Converter={StaticResource OutputTypeEnumToViewModel}, Mode=TwoWay}">
|
||||
<ComboBox.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Foreground="#004B82" Background="#86C8F6" FontWeight="Bold" Padding="5,5,5,5"
|
||||
Text="{Binding Name, Converter={StaticResource ObjectToLocalizedString}}"/>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</ComboBox.GroupStyle>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type viewModels:OutputTypeViewModel}">
|
||||
<TextBlock Text="{Binding Type}" Padding="10,2,2,2"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<ContentControl Content="{Binding SelectedPreset.Preset}"
|
||||
Style="{StaticResource ConversionSettingsSelectorStyle}">
|
||||
</ContentControl>
|
||||
|
||||
<Separator/>
|
||||
|
||||
<!-- Output file name template -->
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="23"/>
|
||||
<RowDefinition Height="23"/>
|
||||
<RowDefinition Height="23"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="{x:Static project:Resources.FileNameTemplate}" Grid.Row="0" HorizontalContentAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="5,2,25,2" TextWrapping="Wrap" Width="Auto"
|
||||
ToolTip="{x:Static project:Resources.OutputFilePathTemplateHelp}"
|
||||
Text="{Binding SelectedPreset.OutputFileNameTemplate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
|
||||
<Label Content="{x:Static project:Resources.InputExample}" Grid.Row="1" Grid.Column="0" HorizontalContentAlignment="Right" Margin="0,0,5,0" Foreground="Gray" FontSize="10"/>
|
||||
<TextBlock Text="{x:Static project:Resources.OutputFileNameTemplateSample}" Grid.Row="1" Grid.Column="1" Margin="5,0,5,0" Foreground="Gray" FontSize="10" VerticalAlignment="Center"/>
|
||||
<Label Content="{x:Static project:Resources.OutputExample}" Grid.Row="2" Grid.Column="0" HorizontalContentAlignment="Right" Margin="0,0,5,0" Foreground="Gray" FontSize="10"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Margin="5,0,5,0" Foreground="Gray" FontSize="10" VerticalAlignment="Center">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource FileNameConverter}">
|
||||
<Binding Source="{x:Static project:Resources.OutputFileNameTemplateSample}"/>
|
||||
<Binding Path="SelectedPreset.Preset.OutputType" Mode="OneWay"/>
|
||||
<Binding Path="SelectedPreset.Preset.OutputFileNameTemplate" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Margin="5,0,5,0">
|
||||
<Hyperlink CommandParameter="https://github.com/Tichau/FileConverter/wiki/Output-file-path-template" Command="{Binding OpenUrlCommand, Mode=OneWay}" Foreground="#1E6BB8"><x:Static Member="project:Resources.Help" /></Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<!-- Selected item settings -->
|
||||
<ContentControl x:Name="SelectedItemSettings" Grid.Column="1" Margin="5,5,0,0"
|
||||
Content="{Binding .}"
|
||||
Style="{StaticResource SettingsSelectorStyle}">
|
||||
</ContentControl>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ namespace FileConverter.Views
|
||||
/// </summary>
|
||||
public partial class SettingsWindow : Window
|
||||
{
|
||||
private TextBox selectedPresetNameTextBox;
|
||||
private TextBox selectedFolderNameTextBox;
|
||||
private string focusMessage;
|
||||
|
||||
private enum DragDropTargetPosition
|
||||
{
|
||||
Before,
|
||||
@@ -35,102 +39,21 @@ namespace FileConverter.Views
|
||||
|
||||
public void DoFocus(string message)
|
||||
{
|
||||
this.focusMessage = message;
|
||||
switch (message)
|
||||
{
|
||||
case "PresetName":
|
||||
this.PresetNameTextBox.Focus();
|
||||
this.PresetNameTextBox.SelectAll();
|
||||
this.selectedPresetNameTextBox?.Focus();
|
||||
this.selectedPresetNameTextBox?.SelectAll();
|
||||
break;
|
||||
|
||||
case "FolderName":
|
||||
this.FolderNameTextBox.Focus();
|
||||
this.FolderNameTextBox.SelectAll();
|
||||
this.selectedFolderNameTextBox?.Focus();
|
||||
this.selectedFolderNameTextBox?.SelectAll();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInputTypeChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SettingsViewModel dataContext = this.DataContext as SettingsViewModel;
|
||||
if (dataContext.SelectedPreset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as CheckBox;
|
||||
if (!checkBox.IsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string inputFormat = (checkBox.Content as string).ToLowerInvariant();
|
||||
|
||||
dataContext.SelectedPreset.Preset.AddInputType(inputFormat);
|
||||
}
|
||||
|
||||
private void OnInputTypeUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SettingsViewModel dataContext = this.DataContext as SettingsViewModel;
|
||||
if (dataContext.SelectedPreset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as CheckBox;
|
||||
if (!checkBox.IsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string inputFormat = (checkBox.Content as string).ToLowerInvariant();
|
||||
|
||||
dataContext.SelectedPreset.Preset.RemoveInputType(inputFormat);
|
||||
}
|
||||
|
||||
private void OnInputTypeCategoryChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SettingsViewModel dataContext = this.DataContext as SettingsViewModel;
|
||||
if (dataContext.SelectedPreset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as CheckBox;
|
||||
string categoryName = checkBox.Content as string;
|
||||
InputExtensionCategory category = dataContext.InputCategories.FirstOrDefault(match => match.Name == categoryName);
|
||||
if (category == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string inputExtension in category.InputExtensionNames)
|
||||
{
|
||||
dataContext.SelectedPreset.Preset.AddInputType(inputExtension);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInputTypeCategoryUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SettingsViewModel dataContext = this.DataContext as SettingsViewModel;
|
||||
if (dataContext.SelectedPreset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as CheckBox;
|
||||
string categoryName = checkBox.Content as string;
|
||||
InputExtensionCategory category = dataContext.InputCategories.FirstOrDefault(match => match.Name == categoryName);
|
||||
if (category == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string inputExtension in category.InputExtensionNames)
|
||||
{
|
||||
dataContext.SelectedPreset.Preset.RemoveInputType(inputExtension);
|
||||
}
|
||||
}
|
||||
|
||||
private void TreeView_MouseMove(object sender, MouseEventArgs args)
|
||||
{
|
||||
if (args.LeftButton == MouseButtonState.Pressed &&
|
||||
@@ -380,5 +303,25 @@ namespace FileConverter.Views
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void SelectedPresetName_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.selectedPresetNameTextBox = (TextBox)sender;
|
||||
if (this.focusMessage == "PresetName")
|
||||
{
|
||||
this.DoFocus(this.focusMessage);
|
||||
this.focusMessage = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectedFolderName_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.selectedFolderNameTextBox = (TextBox)sender;
|
||||
if (this.focusMessage == "FolderName")
|
||||
{
|
||||
this.DoFocus(this.focusMessage);
|
||||
this.focusMessage = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user