mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-19 09:01:32 +01:00
Add conversion presets and settings window.
This commit is contained in:
1 parent
be875bdf03
commit
43f5cb91cd
11 files changed
+388
-55
No files matched your search
@@ -18,12 +18,11 @@ namespace FileConverter
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
|
||||
public partial class Application : System.Windows.Application
|
||||
{
|
||||
public static readonly Version Version = new Version()
|
||||
private static readonly Version Version = new Version()
|
||||
{
|
||||
Major = 0,
|
||||
Minor = 1,
|
||||
@@ -36,6 +35,8 @@ namespace FileConverter
|
||||
|
||||
public Application()
|
||||
{
|
||||
this.ConvertionJobs = this.conversionJobs.AsReadOnly();
|
||||
|
||||
this.Initialize();
|
||||
|
||||
if (this.initialized)
|
||||
@@ -45,12 +46,26 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
public static Version ApplicationVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return Application.Version;
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<ConversionJob> ConvertionJobs
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Settings Settings
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool Verbose
|
||||
{
|
||||
get;
|
||||
@@ -59,8 +74,12 @@ namespace FileConverter
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
this.ConvertionJobs = this.conversionJobs.AsReadOnly();
|
||||
// Load settigns.
|
||||
Diagnostics.Log("Retrieve arguments...");
|
||||
this.Settings = new Settings();
|
||||
this.Settings.Load();
|
||||
|
||||
// Retrieve arguments.
|
||||
Diagnostics.Log("Retrieve arguments...");
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
public class ConversionPreset
|
||||
{
|
||||
public ConversionPreset()
|
||||
{
|
||||
this.Name = "New Preset";
|
||||
}
|
||||
|
||||
public ConversionPreset(string name, OutputType outputType, string[] inputTypes)
|
||||
{
|
||||
this.Name = name;
|
||||
this.OutputType = outputType;
|
||||
this.InputTypes = new List<string>();
|
||||
this.InputTypes.AddRange(inputTypes);
|
||||
}
|
||||
|
||||
[System.Xml.Serialization.XmlAttribute]
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[System.Xml.Serialization.XmlAttribute]
|
||||
public OutputType OutputType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[System.Xml.Serialization.XmlElement]
|
||||
public List<string> InputTypes
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[System.Xml.Serialization.XmlElement]
|
||||
public Setting[] Settings
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public class Setting
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,13 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="ValueConverters\ApplicationVersionToApplicationName.cs" />
|
||||
<Compile Include="ConversionPreset.cs" />
|
||||
<Compile Include="ValueConverters\InputTypesToBool.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="SettingsWindow.xaml.cs">
|
||||
<DependentUpon>SettingsWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Version.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -80,13 +87,17 @@
|
||||
<DependentUpon>Application.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ConversionStateToBrush.cs" />
|
||||
<Compile Include="ValueConverters\ConversionStateToBrush.cs" />
|
||||
<Compile Include="ConversionJob.cs" />
|
||||
<Compile Include="Diagnostics.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="SettingsWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="OutputType.cs" />
|
||||
@@ -120,6 +131,9 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="ApplicationIcon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="ApplicationIcon.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -3,11 +3,15 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="FileConverter.MainWindow"
|
||||
xmlns:local="clr-namespace:FileConverter"
|
||||
x:Name="FileConverterMainWindow" Title="{Binding ApplicationName, ElementName=FileConverterMainWindow, Mode=OneWay}" Height="500" Width="950" MinHeight="250" MinWidth="450" WindowStartupLocation="CenterScreen">
|
||||
x:Name="FileConverterMainWindow" Height="500" Width="950" MinHeight="250" MinWidth="450" WindowStartupLocation="CenterScreen">
|
||||
<Window.Resources>
|
||||
<local:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<local:ConversionStateToBrush x:Key="ConversionStateToColor" />
|
||||
</Window.Resources>
|
||||
<Window.Title>
|
||||
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
|
||||
</Window.Title>
|
||||
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -23,45 +27,45 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Name="Title" Grid.Column="0" Content="Files to convert" VerticalAlignment="Top" Height="30" FontSize="16" FontWeight="Bold"/>
|
||||
<Button Name="SettingsButton" Grid.Column="1" Content="Settings" Margin="0,3" Visibility="Hidden"></Button>
|
||||
<Button Name="SettingsButton" Grid.Column="1" Content="Settings" Margin="0,3" Click="SettingsButton_OnClick"></Button>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer x:Name="ScrollViewer" Grid.Row="1" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
|
||||
<ItemsControl Name="ConverterJobsList">
|
||||
<ItemsControl.DataContext>
|
||||
<local:ConversionJob/>
|
||||
</ItemsControl.DataContext>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel Background="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Background'}" Margin="0,4">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2.5*" MinWidth="300" />
|
||||
<ColumnDefinition Width="*" MinWidth="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ItemsControl Name="ConverterJobsList">
|
||||
<ItemsControl.DataContext>
|
||||
<local:ConversionJob/>
|
||||
</ItemsControl.DataContext>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel Background="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Background'}" Margin="0,4">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2.5*" MinWidth="300" />
|
||||
<ColumnDefinition Width="*" MinWidth="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding OutputFilePath}" FontWeight="Bold" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding OutputFilePath}" FontWeight="Bold" />
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Margin="10,0,0,0">
|
||||
<WrapPanel>
|
||||
<TextBlock Text="Converted from " FontSize="11" FontStyle="Italic" />
|
||||
<TextBlock Text="{Binding InputFilePath}" FontSize="11" FontStyle="Italic" />
|
||||
</WrapPanel>
|
||||
<TextBlock Text="{Binding ExitingMessage}" Foreground="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Margin="10,0,0,0">
|
||||
<WrapPanel>
|
||||
<TextBlock Text="Converted from " FontSize="11" FontStyle="Italic" />
|
||||
<TextBlock Text="{Binding InputFilePath}" FontSize="11" FontStyle="Italic" />
|
||||
</WrapPanel>
|
||||
<TextBlock Text="{Binding ExitingMessage}" Foreground="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding State}" FontWeight="Bold" Foreground="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding State}" FontWeight="Bold" Foreground="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" />
|
||||
|
||||
<ProgressBar Grid.Row="1" Grid.Column="1" Height="18" Width="Auto" Minimum="0" Maximum="1" SmallChange="0.001" Value="{Binding Progress, Mode=OneWay}" Foreground="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" MinWidth="100" LargeChange="0.1" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<ProgressBar Grid.Row="1" Grid.Column="1" Height="18" Width="Auto" Minimum="0" Maximum="1" SmallChange="0.001" Value="{Binding Progress, Mode=OneWay}" Foreground="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" MinWidth="100" LargeChange="0.1" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
|
||||
<Grid Grid.Row="2" Visibility="{Binding VerboseMode, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=FileConverterMainWindow, Mode=OneWay}">
|
||||
|
||||
@@ -12,14 +12,10 @@ namespace FileConverter
|
||||
{
|
||||
private bool verboseMode;
|
||||
|
||||
private string applicationName;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
this.ApplicationName = string.Format("File Converter v{0}", Application.Version.ToString());
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
|
||||
this.ConverterJobsList.ItemsSource = application.ConvertionJobs;
|
||||
@@ -28,20 +24,6 @@ namespace FileConverter
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string ApplicationName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.applicationName;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
this.applicationName = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool VerboseMode
|
||||
{
|
||||
get
|
||||
@@ -65,5 +47,11 @@ namespace FileConverter
|
||||
handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
private void SettingsButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SettingsWindow settingsWindow = new SettingsWindow();
|
||||
settingsWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// <copyright file="Settings.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class Settings
|
||||
{
|
||||
public List<ConversionPreset> conversionPresets = new List<ConversionPreset>();
|
||||
|
||||
public void Load()
|
||||
{
|
||||
// TODO: Load from file.
|
||||
|
||||
this.conversionPresets.Add(new ConversionPreset("To Flac", OutputType.Flac, new string[] { "Mp3", "Wav", "Ogg", "Wma" }));
|
||||
this.conversionPresets.Add(new ConversionPreset("To Ogg", OutputType.Ogg, new string[] { "Mp3", "Wav", "Flac", "Wma" }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<Window x:Name="window" x:Class="FileConverter.SettingsWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:FileConverter"
|
||||
Height="350" Width="538" MinHeight="225" MinWidth="440"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Window.Resources>
|
||||
<local:InputTypesToBool x:Key="InputTypesToBool"/>
|
||||
<local:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
</Window.Resources>
|
||||
<Window.Title>
|
||||
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
|
||||
</Window.Title>
|
||||
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="48"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="48"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image HorizontalAlignment="Left" Height="48" Width="48" VerticalAlignment="Top" Source="ApplicationIcon.png" />
|
||||
<Label Content="Settings" FontSize="20" Margin="4" Grid.Column="1" VerticalAlignment="Center" />
|
||||
<Label HorizontalAlignment="Right" FontStyle="Italic" FontSize="14" Grid.Column="2" VerticalAlignment="Center">
|
||||
<Label.Content>
|
||||
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Presets" Margin="0,5,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="100" Grid.ColumnSpan="2"/>
|
||||
<ListBox Name="PresetList" HorizontalAlignment="Left" Margin="0,36,0,0" Width="100" Grid.ColumnSpan="2" IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding SelectedPreset, ElementName=window}">
|
||||
<ItemsControl.DataContext>
|
||||
<local:ConversionPreset/>
|
||||
</ItemsControl.DataContext>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Label Content="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<!-- Preset settings -->
|
||||
<GroupBox Header="Preset settings" Margin="5,5,0,0" Grid.Column="1">
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="Preset name" Grid.Row="0" HorizontalContentAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBox Grid.Column="1" Margin="5,2,5,2" Text="{Binding SelectedPreset.Name, Mode=TwoWay, ElementName=window}" TextWrapping="Wrap" />
|
||||
|
||||
<GroupBox Grid.Row="1" Grid.Column="0" Header="Input formats" Margin="5">
|
||||
<StackPanel>
|
||||
<CheckBox Content="Flac" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Flac', ElementName=window, Mode=OneWay}"/>
|
||||
<CheckBox Content="Mp3" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Mp3', ElementName=window, Mode=OneWay}"/>
|
||||
<CheckBox Content="Ogg" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Ogg', ElementName=window, Mode=OneWay}"/>
|
||||
<CheckBox Content="Wav" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Wav', ElementName=window, Mode=OneWay}"/>
|
||||
<CheckBox Content="Wma" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Wma', ElementName=window, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="Output format" Grid.Row="1" Grid.Column="1" Margin="5">
|
||||
<ComboBox Name="OutputFormats" Grid.Row="1" Grid.Column="1" Margin="5" Height="25" VerticalAlignment="Top" SelectedItem="{Binding SelectedPreset.OutputType, ElementName=window, Mode=TwoWay}">
|
||||
</ComboBox>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,83 @@
|
||||
// <copyright file="SettingsWindow.xaml.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Controls;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for Settings.xaml
|
||||
/// </summary>
|
||||
public partial class SettingsWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
private ConversionPreset selectedPreset;
|
||||
|
||||
public SettingsWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
this.PresetList.ItemsSource = application.Settings.conversionPresets;
|
||||
|
||||
OutputType[] outputTypes = new[]
|
||||
{
|
||||
OutputType.Flac,
|
||||
OutputType.Mp3,
|
||||
OutputType.Ogg,
|
||||
OutputType.Wav,
|
||||
};
|
||||
|
||||
this.OutputFormats.ItemsSource = outputTypes;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public ConversionPreset SelectedPreset
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.selectedPreset;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.selectedPreset = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChangedEventHandler handler = this.PropertyChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleButton_OnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
|
||||
string inputFormat = checkBox.Content as string;
|
||||
|
||||
if (!this.selectedPreset.InputTypes.Contains(inputFormat))
|
||||
{
|
||||
this.selectedPreset.InputTypes.Add(inputFormat);
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleButton_OnUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
|
||||
string inputFormat = checkBox.Content as string;
|
||||
|
||||
this.selectedPreset.InputTypes.Remove(inputFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// <copyright file="ApplicationVersionToApplicationName.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class ApplicationVersionToApplicationName : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is Version))
|
||||
{
|
||||
return "File Converter";
|
||||
}
|
||||
|
||||
Version version = (Version)value;
|
||||
|
||||
return string.Format("File Converter v{0}", version.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,34 @@
|
||||
// <copyright file="InputTypesToBool.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class InputTypesToBool : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
List<string> intputTypes = value as List<string>;
|
||||
if (intputTypes == null)
|
||||
{
|
||||
throw new ArgumentException("The value must be an list of string.");
|
||||
}
|
||||
|
||||
string referenceTypeName = parameter as string;
|
||||
if (string.IsNullOrEmpty(referenceTypeName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return intputTypes.Contains(referenceTypeName);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user