From fbcc910f949296b5749bbad36fa3fcd503a0fd56 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Mon, 22 Jul 2019 22:15:51 +0200 Subject: [PATCH 01/35] Handle null as a valid boolean value in BoolToVisibilityConverter. --- .../ValueConverters/Generic/BoolToVisibility.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs b/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs index e278ef6..5a6d03f 100644 --- a/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs +++ b/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs @@ -10,11 +10,13 @@ namespace FileConverter.ValueConverters.Generic { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (!(value is bool)) + if (value != null && !(value is bool)) { throw new ArgumentException("The value must be a boolean."); } + bool booleanValue = (bool?) value ?? false; + string stringParameter = parameter as string; string trueResult = "Visible"; @@ -35,7 +37,6 @@ namespace FileConverter.ValueConverters.Generic } } - bool booleanValue = (bool)value; return booleanValue ? trueResult : falseResult; } From d5b372b670460c2a297ade4922979be116dde329 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Tue, 23 Jul 2019 20:00:02 +0200 Subject: [PATCH 02/35] Change selected item settings display by using style triggers. Add no preset selected message. --- .../Properties/Resources.Designer.cs | 9 + .../FileConverter/Properties/Resources.resx | 3 + .../ViewModels/InputExtension.cs | 60 ++-- .../ViewModels/InputExtensionCategory.cs | 92 ++++- .../FileConverter/Views/SettingsWindow.xaml | 336 +++++++++--------- .../Views/SettingsWindow.xaml.cs | 115 ++---- 6 files changed, 335 insertions(+), 280 deletions(-) diff --git a/Application/FileConverter/Properties/Resources.Designer.cs b/Application/FileConverter/Properties/Resources.Designer.cs index 0c0ca11..0964a38 100644 --- a/Application/FileConverter/Properties/Resources.Designer.cs +++ b/Application/FileConverter/Properties/Resources.Designer.cs @@ -897,6 +897,15 @@ namespace FileConverter.Properties { } } + /// + /// Looks up a localized string similar to No preset selected. + /// + public static string NoPresetSelected { + get { + return ResourceManager.GetString("NoPresetSelected", resourceCulture); + } + } + /// /// Looks up a localized string similar to Ok. /// diff --git a/Application/FileConverter/Properties/Resources.resx b/Application/FileConverter/Properties/Resources.resx index 7412c0e..a3c4912 100644 --- a/Application/FileConverter/Properties/Resources.resx +++ b/Application/FileConverter/Properties/Resources.resx @@ -571,4 +571,7 @@ use maj for uppercase version Custom FFMPEG command line arguments + + No preset selected + \ No newline at end of file diff --git a/Application/FileConverter/ViewModels/InputExtension.cs b/Application/FileConverter/ViewModels/InputExtension.cs index 65cf46b..d3dcd51 100644 --- a/Application/FileConverter/ViewModels/InputExtension.cs +++ b/Application/FileConverter/ViewModels/InputExtension.cs @@ -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(); + PresetNode selectedPreset = settingsViewModel.SelectedPreset; + if (selectedPreset == null) + { + return false; + } + + return selectedPreset.Preset.InputTypes.Contains(this.name.ToLowerInvariant()); + } + + set + { + SettingsViewModel settingsViewModel = ServiceLocator.Current.GetInstance(); + PresetNode selectedPreset = settingsViewModel.SelectedPreset; + + if (value) + { + selectedPreset?.Preset.AddInputType(this.name.ToLowerInvariant()); + } + else + { + selectedPreset?.Preset.RemoveInputType(this.name.ToLowerInvariant()); + } + + this.RaisePropertyChanged(nameof(this.IsChecked)); + } } } } \ No newline at end of file diff --git a/Application/FileConverter/ViewModels/InputExtensionCategory.cs b/Application/FileConverter/ViewModels/InputExtensionCategory.cs index 95c9842..f5c483b 100644 --- a/Application/FileConverter/ViewModels/InputExtensionCategory.cs +++ b/Application/FileConverter/ViewModels/InputExtensionCategory.cs @@ -1,5 +1,10 @@ // License: http://www.gnu.org/licenses/gpl.html GPL version 3. +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 inputExtensions = new List(); private string name; - private List inputExtensions = new List(); 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 InputExtensions - { - get - { - return this.inputExtensions; - } - } + public IEnumerable InputExtensions => this.inputExtensions; public IEnumerable 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(); + 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(); + 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)); + } } } \ No newline at end of file diff --git a/Application/FileConverter/Views/SettingsWindow.xaml b/Application/FileConverter/Views/SettingsWindow.xaml index 63bf555..6dc82af 100644 --- a/Application/FileConverter/Views/SettingsWindow.xaml +++ b/Application/FileConverter/Views/SettingsWindow.xaml @@ -29,6 +29,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -167,165 +339,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/Application/FileConverter/Views/SettingsWindow.xaml.cs b/Application/FileConverter/Views/SettingsWindow.xaml.cs index f820b4e..76a5687 100644 --- a/Application/FileConverter/Views/SettingsWindow.xaml.cs +++ b/Application/FileConverter/Views/SettingsWindow.xaml.cs @@ -19,6 +19,10 @@ namespace FileConverter.Views /// 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; + } + } } } From e773ea49d0179c081fe4f3101e922432751380be Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Thu, 25 Jul 2019 08:05:45 +0200 Subject: [PATCH 03/35] Change the side of the input format tree to follow a preset creation flow (from left to right) --- .../SampleData/SettingsSampleData.xaml | 4 +- .../FileConverter/Views/SettingsWindow.xaml | 114 +++++++++--------- 2 files changed, 60 insertions(+), 58 deletions(-) diff --git a/Application/FileConverter/SampleData/SettingsSampleData.xaml b/Application/FileConverter/SampleData/SettingsSampleData.xaml index 49693e1..b28a3ba 100644 --- a/Application/FileConverter/SampleData/SettingsSampleData.xaml +++ b/Application/FileConverter/SampleData/SettingsSampleData.xaml @@ -55,7 +55,7 @@ - + - + diff --git a/Application/FileConverter/Views/SettingsWindow.xaml b/Application/FileConverter/Views/SettingsWindow.xaml index 6dc82af..5751acd 100644 --- a/Application/FileConverter/Views/SettingsWindow.xaml +++ b/Application/FileConverter/Views/SettingsWindow.xaml @@ -60,70 +60,22 @@ - + - From d9e03e902819db742333dc620b247d7b4facbad4 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Thu, 25 Jul 2019 08:09:24 +0200 Subject: [PATCH 04/35] Put up and down button side by side --- .../FileConverter/Views/SettingsWindow.xaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Application/FileConverter/Views/SettingsWindow.xaml b/Application/FileConverter/Views/SettingsWindow.xaml index 5751acd..4b8b934 100644 --- a/Application/FileConverter/Views/SettingsWindow.xaml +++ b/Application/FileConverter/Views/SettingsWindow.xaml @@ -305,13 +305,19 @@ - - + - - From a217d988ead865fc611ddb7dc2cd0384ce4c8d50 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Thu, 25 Jul 2019 08:18:20 +0200 Subject: [PATCH 05/35] Change ExitApplicationWhenConversionsFinished default value to false since it's not very user friendly for newcomers. --- Application/FileConverter/Settings.cs | 2 +- Application/FileConverter/Settings.default.xml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Application/FileConverter/Settings.cs b/Application/FileConverter/Settings.cs index de8c016..33f1d10 100644 --- a/Application/FileConverter/Settings.cs +++ b/Application/FileConverter/Settings.cs @@ -16,7 +16,7 @@ namespace FileConverter { public const int Version = 4; - private bool exitApplicationWhenConversionsFinished = true; + private bool exitApplicationWhenConversionsFinished = false; private float durationBetweenEndOfConversionsAndApplicationExit = 3f; private ObservableCollection conversionPresets = new ObservableCollection(); private bool checkUpgradeAtStartup = true; diff --git a/Application/FileConverter/Settings.default.xml b/Application/FileConverter/Settings.default.xml index b770030..28298b1 100644 --- a/Application/FileConverter/Settings.default.xml +++ b/Application/FileConverter/Settings.default.xml @@ -1,7 +1,5 @@ - true - 3 2 3gp From 62c2a93a1fa8cb3a47720e7a79f0b206feb1a6a5 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Thu, 25 Jul 2019 08:24:24 +0200 Subject: [PATCH 06/35] Make the diagnostics logs selectable. --- Application/FileConverter/Views/DiagnosticsWindow.xaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Application/FileConverter/Views/DiagnosticsWindow.xaml b/Application/FileConverter/Views/DiagnosticsWindow.xaml index 8e9121f..db0d73f 100644 --- a/Application/FileConverter/Views/DiagnosticsWindow.xaml +++ b/Application/FileConverter/Views/DiagnosticsWindow.xaml @@ -33,9 +33,11 @@ - + - + From 700d327a1bfd2c93fa21c291f67230bf520d69aa Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Thu, 25 Jul 2019 08:37:50 +0200 Subject: [PATCH 07/35] Cleanup --- .../Controls/ConversionJobControl.xaml | 13 +++++++++---- Application/FileConverter/Views/MainWindow.xaml | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Application/FileConverter/Controls/ConversionJobControl.xaml b/Application/FileConverter/Controls/ConversionJobControl.xaml index 0cb02a9..5f684da 100644 --- a/Application/FileConverter/Controls/ConversionJobControl.xaml +++ b/Application/FileConverter/Controls/ConversionJobControl.xaml @@ -57,10 +57,15 @@ - - - + + diff --git a/Application/FileConverter/Views/MainWindow.xaml b/Application/FileConverter/Views/MainWindow.xaml index 77e0df7..e8c240e 100644 --- a/Application/FileConverter/Views/MainWindow.xaml +++ b/Application/FileConverter/Views/MainWindow.xaml @@ -46,11 +46,11 @@ - + + - - - - - - - - - - + + + From 6fc031fa9dae0c23a6391087c6188f692631f666 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Fri, 13 Nov 2020 14:09:32 +0100 Subject: [PATCH 16/35] Align folder name text box the same size as preset name text box --- Application/FileConverter/Views/SettingsWindow.xaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Application/FileConverter/Views/SettingsWindow.xaml b/Application/FileConverter/Views/SettingsWindow.xaml index b3f9127..6665633 100644 --- a/Application/FileConverter/Views/SettingsWindow.xaml +++ b/Application/FileConverter/Views/SettingsWindow.xaml @@ -40,18 +40,20 @@ - + - From c7605c84010c4083b369cda5cbcc969a056b0fcc Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Fri, 13 Nov 2020 15:04:34 +0100 Subject: [PATCH 17/35] Fixed: Typo in localization keys --- .../Controls/EncodingQualitySliderControl.xaml | 2 +- Application/FileConverter/Properties/Resources.Designer.cs | 6 +++--- Application/FileConverter/Properties/Resources.en.resx | 2 +- Application/FileConverter/Properties/Resources.es-ES.resx | 2 +- Application/FileConverter/Properties/Resources.fr.resx | 2 +- Application/FileConverter/Properties/Resources.it-IT.resx | 2 +- Application/FileConverter/Properties/Resources.pt-BR.resx | 2 +- Application/FileConverter/Properties/Resources.pt.resx | 2 +- Application/FileConverter/Properties/Resources.resx | 2 +- FileConverter.sln.DotSettings | 1 + 10 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml b/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml index f78ef4c..bd97ffe 100644 --- a/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml +++ b/Application/FileConverter/Controls/EncodingQualitySliderControl.xaml @@ -23,6 +23,6 @@