diff --git a/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml b/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml
index ed4e08b..313cd27 100644
--- a/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml
+++ b/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml
@@ -19,8 +19,9 @@
-
-
-
+
+
+
diff --git a/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml.cs b/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml.cs
index bb0a679..81e2259 100644
--- a/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml.cs
+++ b/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml.cs
@@ -25,11 +25,6 @@ namespace FileConverter.Controls
typeof(EncodingQualitySliderControl),
new PropertyMetadata(new PropertyChangedCallback(EncodingQualitySliderControl.OnEncodingModeValueChanged)));
- [Category("Behavior")]
- public event EventHandler BitrateValueChanged;
-
- private bool dontPropagateSliderValueChanged;
-
public EncodingQualitySliderControl()
{
this.InitializeComponent();
@@ -69,9 +64,7 @@ namespace FileConverter.Controls
private static void OnBitrateValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
{
EncodingQualitySliderControl encodingQualitySliderControl = sender as EncodingQualitySliderControl;
- encodingQualitySliderControl.dontPropagateSliderValueChanged = true;
encodingQualitySliderControl.slider.Value = (double)eventArgs.NewValue;
- encodingQualitySliderControl.dontPropagateSliderValueChanged = false;
}
private static object CoerceBitrateValue(DependencyObject sender, object basevalue)
@@ -168,12 +161,6 @@ namespace FileConverter.Controls
}
this.SetCurrentValue(EncodingQualitySliderControl.BitrateProperty, e.NewValue);
-
- if (!this.dontPropagateSliderValueChanged)
- {
- // Only send the bitrate value changed event if the value change come from the slider.
- this.BitrateValueChanged?.Invoke(this, e.NewValue);
- }
}
private double GetNearestTickValue(double value)
diff --git a/Application/FileConverter/ConversionPreset/ConversionPreset.cs b/Application/FileConverter/ConversionPreset/ConversionPreset.cs
index fb71c69..3841355 100644
--- a/Application/FileConverter/ConversionPreset/ConversionPreset.cs
+++ b/Application/FileConverter/ConversionPreset/ConversionPreset.cs
@@ -111,12 +111,35 @@ namespace FileConverter
}
}
+ [XmlIgnore]
public IConversionSettings Settings
{
get
{
return this.settings;
}
+
+ set
+ {
+ if (value == null)
+ {
+ return;
+ }
+
+ foreach (KeyValuePair conversionSetting in value)
+ {
+ if (!this.settings.ContainsKey(conversionSetting.Key))
+ {
+ this.settings.Add(conversionSetting.Key, conversionSetting.Value);
+ }
+ else
+ {
+ this.settings[conversionSetting.Key] = conversionSetting.Value;
+ }
+ }
+
+ this.OnPropertyChanged();
+ }
}
public string this[string columnName]
diff --git a/Application/FileConverter/ConversionPreset/ConversionSettingsOverride.cs b/Application/FileConverter/ConversionPreset/ConversionSettingsOverride.cs
new file mode 100644
index 0000000..4a9ce2e
--- /dev/null
+++ b/Application/FileConverter/ConversionPreset/ConversionSettingsOverride.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FileConverter
+{
+ public struct ConversionSettingsOverride : IConversionSettings
+ {
+ private string key;
+ private string value;
+
+ public ConversionSettingsOverride(string key, string value)
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return this.GetEnumerator();
+ }
+
+ public IEnumerator> GetEnumerator()
+ {
+ yield return new KeyValuePair(this.key, this.value);
+ }
+
+ public int Count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+
+ public bool ContainsKey(string key)
+ {
+ return key == this.key;
+ }
+
+ public bool TryGetValue(string key, out string value)
+ {
+ value = null;
+
+ if (key == this.key)
+ {
+ value = this.value;
+ return true;
+ }
+
+ return false;
+ }
+
+ public string this[string key]
+ {
+ get
+ {
+ if (key == this.key)
+ {
+ return this.value;
+ }
+
+ throw new KeyNotFoundException();
+ }
+ }
+
+ public IEnumerable Keys
+ {
+ get
+ {
+ yield return this.key;
+ }
+ }
+
+ public IEnumerable Values
+ {
+ get
+ {
+ yield return this.value;
+ }
+ }
+ }
+}
diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj
index ff42f13..9ef83fb 100644
--- a/Application/FileConverter/FileConverter.csproj
+++ b/Application/FileConverter/FileConverter.csproj
@@ -78,6 +78,7 @@
+
@@ -88,7 +89,7 @@
-
+
diff --git a/Application/FileConverter/ValueConverters/ConversionSettingsToString.cs b/Application/FileConverter/ValueConverters/ConversionSettingsToString.cs
index 4ed87db..a1dba3f 100644
--- a/Application/FileConverter/ValueConverters/ConversionSettingsToString.cs
+++ b/Application/FileConverter/ValueConverters/ConversionSettingsToString.cs
@@ -51,7 +51,26 @@ namespace FileConverter.ValueConverters
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
- throw new NotImplementedException();
+ if (value == null)
+ {
+ return null;
+ }
+
+ if (!(value is string))
+ {
+ throw new ArgumentException("value");
+ }
+
+ string settingsValue = (string)value;
+
+ if (!(parameter is string))
+ {
+ throw new ArgumentException("parameter");
+ }
+
+ string settingsKey = (string)parameter;
+
+ return new ConversionSettingsOverride(settingsKey, settingsValue);
}
}
}
\ No newline at end of file
diff --git a/Application/FileConverter/ValueConverters/Generic/EqualsConverter.cs b/Application/FileConverter/ValueConverters/Generic/EqualsConverter.cs
index 572be61..76ed984 100644
--- a/Application/FileConverter/ValueConverters/Generic/EqualsConverter.cs
+++ b/Application/FileConverter/ValueConverters/Generic/EqualsConverter.cs
@@ -20,7 +20,18 @@ namespace FileConverter.ValueConverters.Generic
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
- throw new NotImplementedException();
+ if (!(value is bool))
+ {
+ throw new ArgumentException("value");
+ }
+
+ bool equals = (bool)value;
+ if (equals)
+ {
+ return parameter;
+ }
+
+ return null;
}
}
}
diff --git a/Application/FileConverter/ValueConverters/Generic/ObjectToValueType.cs b/Application/FileConverter/ValueConverters/Generic/StringToValueType.cs
similarity index 80%
rename from Application/FileConverter/ValueConverters/Generic/ObjectToValueType.cs
rename to Application/FileConverter/ValueConverters/Generic/StringToValueType.cs
index 6647e28..2a19e63 100644
--- a/Application/FileConverter/ValueConverters/Generic/ObjectToValueType.cs
+++ b/Application/FileConverter/ValueConverters/Generic/StringToValueType.cs
@@ -1,4 +1,4 @@
-// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
namespace FileConverter.ValueConverters.Generic
{
@@ -6,7 +6,7 @@ namespace FileConverter.ValueConverters.Generic
using System.Globalization;
using System.Windows.Data;
- public class ObjectToValueType : IValueConverter
+ public class StringToValueType : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
@@ -32,7 +32,12 @@ namespace FileConverter.ValueConverters.Generic
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
- throw new NotImplementedException();
+ if (value == null)
+ {
+ return null;
+ }
+
+ return value.ToString();
}
}
}
diff --git a/Application/FileConverter/ValueConverters/Generic/ValueConverterGroup.cs b/Application/FileConverter/ValueConverters/Generic/ValueConverterGroup.cs
index 39b7da7..637cfb9 100644
--- a/Application/FileConverter/ValueConverters/Generic/ValueConverterGroup.cs
+++ b/Application/FileConverter/ValueConverters/Generic/ValueConverterGroup.cs
@@ -56,7 +56,7 @@ namespace FileConverter.ValueConverters.Generic
}
object result = value;
- for (int index = this.Count - 1; index >= 0; index++)
+ for (int index = this.Count - 1; index >= 0; index--)
{
IValueConverter converter = this[index];
result = converter.ConvertBack(result, targetType, parameters[index], culture);
diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml b/Application/FileConverter/Windows/SettingsWindow.xaml
index dd65fb5..9932cbc 100644
--- a/Application/FileConverter/Windows/SettingsWindow.xaml
+++ b/Application/FileConverter/Windows/SettingsWindow.xaml
@@ -26,7 +26,7 @@
-
+
@@ -62,14 +62,14 @@
-
-
+
+
-
+ Bitrate="{Binding SelectedPreset.Settings, ConverterParameter='Bitrate|System.Double', Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=190}" />
@@ -78,8 +78,8 @@
-
+
diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml.cs b/Application/FileConverter/Windows/SettingsWindow.xaml.cs
index 31fb9c4..ae1bc00 100644
--- a/Application/FileConverter/Windows/SettingsWindow.xaml.cs
+++ b/Application/FileConverter/Windows/SettingsWindow.xaml.cs
@@ -130,29 +130,6 @@ namespace FileConverter
e.CanExecute = this.settings != null && string.IsNullOrEmpty(this.settings.Error);
}
- private void EncodingTypeRadio_Checked(object sender, RoutedEventArgs e)
- {
- RadioButton radioButton = sender as RadioButton;
- string content = radioButton.Content as string;
- if (content == "VBR")
- {
- this.SelectedPreset?.SetSettingsValue("Encoding", EncodingMode.Mp3VBR.ToString());
- }
- else if (content == "CBR")
- {
- this.SelectedPreset?.SetSettingsValue("Encoding", EncodingMode.Mp3CBR.ToString());
- }
- else
- {
- throw new Exception("Unknown encoding type.");
- }
- }
-
- private void EncodingQualitySlider_ValueChanged(object sender, double bitrateValue)
- {
- this.SelectedPreset?.SetSettingsValue("Bitrate", bitrateValue.ToString("0"));
- }
-
private void SettingsWindow_OnClosing(object sender, CancelEventArgs e)
{
e.Cancel = true;