From 8990efdddae2a64c6e9a260e054759080ec37522 Mon Sep 17 00:00:00 2001 From: Tichau Date: Sun, 13 Dec 2015 11:26:13 +0100 Subject: [PATCH] Add application settings UI. --- .../FileConverter/FileConverter.csproj | 1 + .../Generic/BoolToVisibility.cs | 6 +++- .../Generic/DoubleToTimeString.cs | 28 +++++++++++++++++++ .../FileConverter/Windows/SettingsWindow.xaml | 28 ++++++++++++++----- .../Windows/SettingsWindow.xaml.cs | 16 ++++++++++- 5 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 Application/FileConverter/ValueConverters/Generic/DoubleToTimeString.cs diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj index 7176ab3..3a6d136 100644 --- a/Application/FileConverter/FileConverter.csproj +++ b/Application/FileConverter/FileConverter.csproj @@ -109,6 +109,7 @@ + diff --git a/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs b/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs index f3cd532..5ecfbcc 100644 --- a/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs +++ b/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs @@ -15,9 +15,13 @@ namespace FileConverter.ValueConverters.Generic throw new ArgumentException("The value must be a boolean."); } + string stringParameter = parameter as string; + + string falseResult = stringParameter ?? "Hidden"; + bool booleanValue = (bool)value; - return booleanValue ? "Visible" : "Hidden"; + return booleanValue ? "Visible" : falseResult; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/Application/FileConverter/ValueConverters/Generic/DoubleToTimeString.cs b/Application/FileConverter/ValueConverters/Generic/DoubleToTimeString.cs new file mode 100644 index 0000000..30d0800 --- /dev/null +++ b/Application/FileConverter/ValueConverters/Generic/DoubleToTimeString.cs @@ -0,0 +1,28 @@ +// License: http://www.gnu.org/licenses/gpl.html GPL version 3. + +namespace FileConverter.ValueConverters.Generic +{ + using System; + using System.Globalization; + using System.Windows.Data; + + public class DoubleToTimeString : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (!(value is double)) + { + throw new ArgumentException("The value must be a boolean."); + } + + double doubleValue = (double)value; + + return string.Format("{0} second{1}", doubleValue.ToString("0.#"), doubleValue >= 2 ? "s" : string.Empty); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml b/Application/FileConverter/Windows/SettingsWindow.xaml index a110c47..8ef9cf2 100644 --- a/Application/FileConverter/Windows/SettingsWindow.xaml +++ b/Application/FileConverter/Windows/SettingsWindow.xaml @@ -7,10 +7,11 @@ xmlns:windows="clr-namespace:FileConverter.Windows" xmlns:project="clr-namespace:FileConverter.Properties" xmlns:System="clr-namespace:System;assembly=mscorlib" x:Name="window" x:Class="FileConverter.SettingsWindow" - Height="600" Width="800" MinHeight="480" MinWidth="640" + Width="800" Height="600" MinWidth="640" MinHeight="480" WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico" Closing="SettingsWindow_OnClosing"> + @@ -99,7 +100,7 @@ - + @@ -182,9 +183,11 @@ + + @@ -195,12 +198,13 @@ + @@ -339,8 +343,18 @@ -