diff options
author | sr55 <[email protected]> | 2020-08-04 17:38:58 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2020-08-04 17:39:06 +0100 |
commit | 1644b5099ffe6d815f65725321373fdf0dfd54f8 (patch) | |
tree | b09a403a20823875e2053ec0acb3408b9f50c763 | |
parent | 7388225bc6fd520364dbde9243ec365cebe6eafc (diff) |
WinGui: Improvements to the new Preset Management UI.
- Add Category to the preset information pane.
- Allow Preset Category to be changed for User Preset only.
- Add "(Default Preset)" label on the info tab
- Add button to Set Default Preset on the info tab.
- Add Help Icon to open up the docs page (Per Mac UI)
- Misc Fixes
16 files changed, 446 insertions, 142 deletions
diff --git a/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetCategory.cs b/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetCategory.cs index 2cab7d25d..21a8b41f7 100644 --- a/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetCategory.cs +++ b/win/CS/HandBrake.Interop/Interop/Json/Presets/PresetCategory.cs @@ -1,5 +1,5 @@ // -------------------------------------------------------------------------------------------------------------------- -// <copyright file="PresetCategory.cs" company="HandBrake Project (http://handbrake.fr)"> +// <copyright file="PresetCategory.cs" company="HandBrake Project (https://handbrake.fr)"> // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // </copyright> // <summary> diff --git a/win/CS/HandBrakeWPF/Controls/NumberBox.xaml.cs b/win/CS/HandBrakeWPF/Controls/NumberBox.xaml.cs index 938f4b40b..516d784c6 100644 --- a/win/CS/HandBrakeWPF/Controls/NumberBox.xaml.cs +++ b/win/CS/HandBrakeWPF/Controls/NumberBox.xaml.cs @@ -49,13 +49,13 @@ namespace HandBrakeWPF.Controls /// The maximum property.
/// </summary>
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(
- MaximumPropertyName, typeof(double), typeof(NumberBox), new UIPropertyMetadata(double.MaxValue));
+ MaximumPropertyName, typeof(double?), typeof(NumberBox), new UIPropertyMetadata(double.MaxValue));
/// <summary>
/// The minimum property.
/// </summary>
public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(
- MinimumPropertyName, typeof(double), typeof(NumberBox), new UIPropertyMetadata(double.MinValue));
+ MinimumPropertyName, typeof(double?), typeof(NumberBox), new UIPropertyMetadata(double.MinValue));
/// <summary>
/// The modulus property.
@@ -67,7 +67,7 @@ namespace HandBrakeWPF.Controls /// The number property.
/// </summary>
public static readonly DependencyProperty NumberProperty = DependencyProperty.Register(
- "Number", typeof(double), typeof(NumberBox), new PropertyMetadata(OnNumberChanged));
+ "Number", typeof(double?), typeof(NumberBox), new PropertyMetadata(OnNumberChanged));
/// <summary>
/// The select all threshold.
@@ -141,11 +141,11 @@ namespace HandBrakeWPF.Controls /// <summary>
/// Gets or sets the maximum.
/// </summary>
- public double Maximum
+ public double? Maximum
{
get
{
- return (double)this.GetValue(MaximumProperty);
+ return (double?)this.GetValue(MaximumProperty);
}
set
{
@@ -156,11 +156,11 @@ namespace HandBrakeWPF.Controls /// <summary>
/// Gets or sets the minimum.
/// </summary>
- public double Minimum
+ public double? Minimum
{
get
{
- return (double)this.GetValue(MinimumProperty);
+ return (double?)this.GetValue(MinimumProperty);
}
set
{
@@ -203,11 +203,11 @@ namespace HandBrakeWPF.Controls /// <summary>
/// Gets or sets the number.
/// </summary>
- public double Number
+ public double? Number
{
get
{
- return (double)this.GetValue(NumberProperty);
+ return (double?)this.GetValue(NumberProperty);
}
set
@@ -293,19 +293,31 @@ namespace HandBrakeWPF.Controls /// </summary>
private void DecrementNumber()
{
+ if (!this.Number.HasValue)
+ {
+ this.Number = 0; // Default to 0
+ }
+
double newNumber;
if (this.AllowEmpty && this.Number == 0)
{
- newNumber = Math.Min(this.Maximum, -this.Increment);
+ if (this.Maximum.HasValue)
+ {
+ newNumber = Math.Min(this.Maximum.Value, -this.Increment);
+ }
+ else
+ {
+ newNumber = -this.Increment;
+ }
}
else
{
- newNumber = this.Number - this.Increment;
+ newNumber = this.Number.Value - this.Increment;
}
- if (newNumber < this.Minimum)
+ if (this.Minimum.HasValue && newNumber < this.Minimum)
{
- newNumber = this.Minimum;
+ newNumber = this.Minimum.Value;
}
if (newNumber != this.Number)
@@ -372,19 +384,31 @@ namespace HandBrakeWPF.Controls /// </summary>
private void IncrementNumber()
{
+ if (!this.Number.HasValue)
+ {
+ this.Number = 0; // Default to 0
+ }
+
double newNumber;
if (this.AllowEmpty && this.Number == 0)
{
- newNumber = Math.Max(this.Minimum, this.Increment);
+ if (this.Maximum.HasValue)
+ {
+ newNumber = Math.Max(this.Minimum.Value, this.Increment);
+ }
+ else
+ {
+ newNumber = this.Increment;
+ }
}
else
{
- newNumber = this.Number + this.Increment;
+ newNumber = this.Number.Value + this.Increment;
}
- if (newNumber > this.Maximum)
+ if (this.Maximum.HasValue && newNumber > this.Maximum)
{
- newNumber = this.Maximum;
+ newNumber = this.Maximum.Value;
}
if (newNumber != this.Number)
@@ -563,13 +587,18 @@ namespace HandBrakeWPF.Controls /// </summary>
private void RefreshNumberBox()
{
+ if (!this.Number.HasValue)
+ {
+ return;
+ }
+
if (this.AllowEmpty && this.Number == 0)
{
this.numberBox.Text = this.hasFocus ? string.Empty : this.NoneCaption;
}
else
{
- this.numberBox.Text = this.Number.ToString(CultureInfo.InvariantCulture);
+ this.numberBox.Text = this.Number.Value.ToString(CultureInfo.InvariantCulture);
}
this.RefreshNumberBoxColor();
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 0b6ee6fe0..27ccc158b 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -2596,6 +2596,15 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to There is no preset selected.. + /// </summary> + public static string ManagePresetView_NoPresetSelected { + get { + return ResourceManager.GetString("ManagePresetView_NoPresetSelected", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Preset Information:. /// </summary> public static string ManagePresetView_PresetInfo { @@ -4412,6 +4421,15 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to (Default Preset). + /// </summary> + public static string PresetManagerView_DefaultPreset { + get { + return ResourceManager.GetString("PresetManagerView_DefaultPreset", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Delete Preset. /// </summary> public static string PresetManagerView_Delete { @@ -4507,6 +4525,24 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to The category name you entered already exists. Please choose a different name.. + /// </summary> + public static string PresetService_CategoryAlreadyExists { + get { + return ResourceManager.GetString("PresetService_CategoryAlreadyExists", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to The category name was empty. Please provide a name.. + /// </summary> + public static string PresetService_CategoryNameEmpty { + get { + return ResourceManager.GetString("PresetService_CategoryNameEmpty", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Your presets file contained built-in presets. The import function does not support importing these. Please use 'Presets Menu -> Reset Built In-Presets' to restore the standard presets. /// ///Where supported, any user presets will have been imported.. @@ -6197,6 +6233,15 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to Enter a name: . + /// </summary> + public static string TextEntryView_EnterName { + get { + return ResourceManager.GetString("TextEntryView_EnterName", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Unknown Error. /// </summary> public static string UnknownError { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 7668fc69b..04cfbe621 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -2366,4 +2366,19 @@ Fields are limited to: <data name="String1" xml:space="preserve">
<value />
</data>
+ <data name="PresetManagerView_DefaultPreset" xml:space="preserve">
+ <value>(Default Preset)</value>
+ </data>
+ <data name="PresetService_CategoryAlreadyExists" xml:space="preserve">
+ <value>The category name you entered already exists. Please choose a different name.</value>
+ </data>
+ <data name="PresetService_CategoryNameEmpty" xml:space="preserve">
+ <value>The category name was empty. Please provide a name.</value>
+ </data>
+ <data name="TextEntryView_EnterName" xml:space="preserve">
+ <value>Enter a name: </value>
+ </data>
+ <data name="ManagePresetView_NoPresetSelected" xml:space="preserve">
+ <value>There is no preset selected.</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs index 251028438..70d8c2e21 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs @@ -9,6 +9,7 @@ namespace HandBrakeWPF.Services.Presets.Interfaces
{
+ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -22,6 +23,11 @@ namespace HandBrakeWPF.Services.Presets.Interfaces public interface IPresetService
{
/// <summary>
+ /// Subscribe to get notifications when a preset is added.
+ /// </summary>
+ event EventHandler PresetCollectionChanged;
+
+ /// <summary>
/// Gets a Collection of presets.
/// </summary>
ObservableCollection<IPresetObject> Presets { get; }
@@ -191,5 +197,10 @@ namespace HandBrakeWPF.Services.Presets.Interfaces /// </summary>
/// <param name="selectedPreset">The preset we want to select.</param>
void SetSelected(Preset selectedPreset);
+
+ /// <summary>
+ /// Change the category to which a preset belongs.
+ /// </summary>
+ void ChangePresetCategory(Preset preset, string categoryName);
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs index c67298c32..448ac4e99 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs @@ -100,35 +100,5 @@ namespace HandBrakeWPF.Services.Presets.Model {
return this.Name;
}
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- if (obj.GetType() != this.GetType())
- {
- return false;
- }
-
- return Equals((Preset)obj);
- }
-
- public override int GetHashCode()
- {
- return (this.Name != null ? this.Name.GetHashCode() : 0);
- }
-
- protected bool Equals(Preset other)
- {
- return string.Equals(this.Name, other.Name);
- }
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs index 4bb53eced..44535ba1c 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs @@ -52,6 +52,7 @@ namespace HandBrakeWPF.Services.Presets private readonly IUserSettingService userSettingService;
private ILog log = null;
+
public PresetService(IErrorService errorService, IUserSettingService userSettingService, ILog logService)
{
this.log = logService;
@@ -59,6 +60,8 @@ namespace HandBrakeWPF.Services.Presets this.userSettingService = userSettingService;
}
+ public event EventHandler PresetCollectionChanged;
+
public ObservableCollection<IPresetObject> Presets
{
get
@@ -116,6 +119,7 @@ namespace HandBrakeWPF.Services.Presets if (!isLoading)
{
this.SavePresetFiles();
+ this.OnPresetCollectionChanged();
}
return true;
@@ -123,6 +127,7 @@ namespace HandBrakeWPF.Services.Presets else
{
this.Update(preset);
+ this.OnPresetCollectionChanged();
return true;
}
}
@@ -258,10 +263,41 @@ namespace HandBrakeWPF.Services.Presets }
this.SavePresetFiles();
+ this.OnPresetCollectionChanged();
return true;
}
+ public void AddCategory(string categoryName)
+ {
+ if (string.IsNullOrEmpty(categoryName))
+ {
+ this.errorService.ShowMessageBox(
+ Resources.PresetService_CategoryNameEmpty,
+ Resources.Error,
+ MessageBoxButton.OK,
+ MessageBoxImage.Error);
+ }
+
+ PresetDisplayCategory category = this.presets.FirstOrDefault(a => a.Category == categoryName) as PresetDisplayCategory;
+ if (category != null)
+ {
+ this.errorService.ShowMessageBox(
+ Resources.PresetService_CategoryAlreadyExists,
+ Resources.Error,
+ MessageBoxButton.OK,
+ MessageBoxImage.Error);
+
+ return;
+ }
+
+ // Otherwise, if we have category but it doesn't exist, create it.
+ this.presets.Add(new PresetDisplayCategory(categoryName, false, new BindingList<Preset>()));
+
+ // Update the presets file
+ this.SavePresetFiles();
+ }
+
public void RemoveGroup(string categoryName)
{
PresetDisplayCategory category = this.presets.FirstOrDefault(p => p.Category == categoryName) as PresetDisplayCategory;
@@ -439,6 +475,25 @@ namespace HandBrakeWPF.Services.Presets selectedPreset.IsSelected = true;
}
+ public void ChangePresetCategory(Preset preset, string categoryName)
+ {
+ if (string.IsNullOrEmpty(categoryName))
+ {
+ return;
+ }
+
+ if (preset != null)
+ {
+ preset.Category = categoryName;
+ }
+
+ this.Save();
+ this.ClearPresetService();
+ this.Load();
+ this.LoadCategoryStates();
+ this.OnPresetCollectionChanged();
+ }
+
public void SaveCategoryStates()
{
StringCollection expandedPresets = new StringCollection();
@@ -691,6 +746,13 @@ namespace HandBrakeWPF.Services.Presets }
}
+ private void ClearPresetService()
+ {
+ this.flatPresetDict.Clear();
+ this.flatPresetList.Clear();
+ this.presets.Clear();
+ }
+
private void HandlePresetListsForSave(List<Preset> processList, Dictionary<string, PresetCategory> presetCategories, List<HBPreset> uncategorisedPresets)
{
foreach (Preset item in processList)
@@ -796,6 +858,11 @@ namespace HandBrakeWPF.Services.Presets return false;
}
+ private void OnPresetCollectionChanged()
+ {
+ this.PresetCollectionChanged?.Invoke(this, EventArgs.Empty);
+ }
+
protected void ServiceLogMessage(string message)
{
this.log.LogMessage(string.Format("Preset Service: {0}{1}{0}", Environment.NewLine, message));
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs index 7ca879cd6..fb107b64b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs @@ -545,7 +545,7 @@ namespace HandBrakeWPF.ViewModels public void LaunchHelp() { - Process.Start("https://handbrake.fr/docs/en/1.2.0/advanced/audio-subtitle-defaults.html"); + Process.Start("https://handbrake.fr/docs/en/latest/advanced/audio-subtitle-defaults.html"); } #endregion diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPresetManagerViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPresetManagerViewModel.cs index 4966dc5d8..1ccb3c225 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPresetManagerViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPresetManagerViewModel.cs @@ -12,5 +12,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces public interface IPresetManagerViewModel { bool IsOpen { get; set; } + + void SetupWindow(); } } diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index c93f0005e..f25e4559b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1072,6 +1072,7 @@ namespace HandBrakeWPF.ViewModels if (!this.PresetManagerViewModel.IsOpen)
{
this.PresetManagerViewModel.IsOpen = true;
+ this.PresetManagerViewModel.SetupWindow();
this.windowManager.ShowWindow(this.PresetManagerViewModel);
}
else if (this.PresetManagerViewModel.IsOpen)
diff --git a/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs index 3512a6747..8b3890f5e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PresetManagerViewModel.cs @@ -11,6 +11,7 @@ namespace HandBrakeWPF.ViewModels { using System.Collections.Generic; using System.ComponentModel; + using System.Diagnostics; using System.Linq; using System.Windows; @@ -33,6 +34,7 @@ namespace HandBrakeWPF.ViewModels private readonly IPresetService presetService; private readonly IErrorService errorService; private readonly IWindowManager windowManager; + private readonly PresetDisplayCategory addNewCategory = new PresetDisplayCategory(Resources.AddPresetView_AddNewCategory, true, null); private IPresetObject selectedPresetCategory; private Preset selectedPreset; @@ -43,10 +45,6 @@ namespace HandBrakeWPF.ViewModels this.presetService = presetService; this.errorService = errorService; this.windowManager = windowManager; - - this.PresetsCategories = this.presetService.Presets; - this.NotifyOfPropertyChange(() => this.PresetsCategories); - this.presetService.LoadCategoryStates(); this.Title = Resources.PresetManger_Title; } @@ -54,6 +52,29 @@ namespace HandBrakeWPF.ViewModels public IEnumerable<IPresetObject> PresetsCategories { get; set; } + public List<PresetDisplayCategory> UserPresetCategories { get; set; } + + public PresetDisplayCategory SelectedUserPresetCategory + { + get + { + if (this.selectedPreset != null && this.PresetsCategories != null) + { + return this.PresetsCategories.FirstOrDefault(s => s.Category == this.selectedPreset.Category) as PresetDisplayCategory; + } + + return null; + } + + set + { + if (this.selectedPreset != null && value != null && value.Category != this.selectedPreset.Category) + { + this.presetService.ChangePresetCategory(this.selectedPreset, value.Category); + } + } + } + public string SelectedItem { get; set; } public IPresetObject SelectedPresetCategory @@ -74,7 +95,7 @@ namespace HandBrakeWPF.ViewModels } } } - + public Preset SelectedPreset { get => this.selectedPreset; @@ -105,6 +126,9 @@ namespace HandBrakeWPF.ViewModels } this.NotifyOfPropertyChange(() => this.IsBuildIn); + this.NotifyOfPropertyChange(() => this.SelectedUserPresetCategory); + this.NotifyOfPropertyChange(() => this.IsPresetSelected); + this.NotifyOfPropertyChange(() => this.UserPresetCategories); } } @@ -189,7 +213,34 @@ namespace HandBrakeWPF.ViewModels } public bool IsCustomMaxRes { get; private set; } - + + public void SetupWindow() + { + this.PresetsCategories = this.presetService.Presets; + this.NotifyOfPropertyChange(() => this.PresetsCategories); + this.presetService.LoadCategoryStates(); + this.UserPresetCategories = presetService.GetPresetCategories(true).ToList(); // .Union(new List<PresetDisplayCategory> { addNewCategory }).ToList(); + this.presetService.PresetCollectionChanged += this.PresetService_PresetCollectionChanged; + } + + private void PresetService_PresetCollectionChanged(object sender, System.EventArgs e) + { + string presetName = this.selectedPreset?.Name; // Recording such that we can re-select + + this.PresetsCategories = this.presetService.Presets; + this.UserPresetCategories = presetService.GetPresetCategories(true).ToList(); // .Union(new List<PresetDisplayCategory> { addNewCategory }).ToList(); + + this.NotifyOfPropertyChange(() => this.PresetsCategories); + this.NotifyOfPropertyChange(() => this.UserPresetCategories); + this.NotifyOfPropertyChange(() => this.SelectedUserPresetCategory); + + // Reselect the preset as the object has changed due to the reload that occurred. + if (!string.IsNullOrEmpty(presetName)) + { + this.SelectedPreset = this.presetService.FlatPresetList.FirstOrDefault(s => s.Name == presetName); + } + } + public void DeletePreset() { if (this.selectedPreset != null) @@ -361,6 +412,20 @@ namespace HandBrakeWPF.ViewModels { this.presetService.Save(); this.IsOpen = false; + this.presetService.PresetCollectionChanged -= this.PresetService_PresetCollectionChanged; + } + + public void SetCurrentPresetAsDefault() + { + if (this.SelectedPreset != null) + { + this.presetService.SetDefault(this.SelectedPreset); + } + } + + public void LaunchHelp() + { + Process.Start("https://handbrake.fr/docs/en/latest/advanced/custom-presets.html"); } private void SetDefaultPreset() diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesDefaultsViewModel.cs index 102ae68ac..3e842da19 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesDefaultsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesDefaultsViewModel.cs @@ -194,7 +194,7 @@ namespace HandBrakeWPF.ViewModels public void LaunchHelp() { - Process.Start("https://handbrake.fr/docs/en/1.2.0/advanced/audio-subtitle-defaults.html"); + Process.Start("https://handbrake.fr/docs/en/latest/advanced/audio-subtitle-defaults.html"); } #endregion diff --git a/win/CS/HandBrakeWPF/Views/AddPresetView.xaml b/win/CS/HandBrakeWPF/Views/AddPresetView.xaml index 004502374..7d06cc35d 100644 --- a/win/CS/HandBrakeWPF/Views/AddPresetView.xaml +++ b/win/CS/HandBrakeWPF/Views/AddPresetView.xaml @@ -8,7 +8,8 @@ xmlns:Properties="clr-namespace:HandBrakeWPF.Properties" xmlns:controls="clr-namespace:HandBrakeWPF.Controls"
xmlns:picture="clr-namespace:HandBrakeWPF.Converters.Picture"
Title="{Binding Title}"
- Width="350"
+ Width="450"
+ MaxHeight="800"
ResizeMode="NoResize"
SizeToContent="Height"
WindowStartupLocation="CenterScreen"
@@ -67,17 +68,11 @@ <!-- Description -->
- <TextBlock Grid.Row="2"
- Grid.Column="0" Margin="0,10,0,0"
- Text="{x:Static Properties:Resources.AddPresetView_Description}" />
- <TextBox Grid.Row="2"
- Grid.Column="1" Margin="0,10,0,0"
-
+ <TextBlock Grid.Row="2" Grid.Column="0" Margin="0,10,0,0" Text="{x:Static Properties:Resources.AddPresetView_Description}" />
+ <TextBox Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" MinHeight="75" TextWrapping="WrapWithOverflow" VerticalContentAlignment="Top"
Text="{Binding Preset.Description, UpdateSourceTrigger=PropertyChanged}" />
- <TextBlock Grid.Row="3"
- Grid.Column="0" Margin="0,10,0,0"
- Text="{x:Static Properties:Resources.AddPresetView_Category}" />
+ <TextBlock Grid.Row="3" Grid.Column="0" Margin="0,10,0,0" Text="{x:Static Properties:Resources.AddPresetView_Category}" />
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Vertical" Margin="0,10,0,0">
<ComboBox ItemsSource="{Binding PresetCategories}" SelectedItem="{Binding SelectedPresetCategory}" DisplayMemberPath="Category" />
diff --git a/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml b/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml index f0c011965..07186b94d 100644 --- a/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml +++ b/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml @@ -10,9 +10,9 @@ xmlns:controls="clr-namespace:HandBrakeWPF.Controls" xmlns:picture="clr-namespace:HandBrakeWPF.Converters.Picture" Title="{Binding Title}" - Width="750" + Width="850" Height="500" - MinWidth="750" + MinWidth="850" MinHeight="500" WindowStartupLocation="CenterScreen" TextOptions.TextFormattingMode="Display"> @@ -44,6 +44,13 @@ </Grid.RowDefinitions> <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_ManagePreset}" FontSize="28" VerticalAlignment="Center" FontFamily="Segoe UI Light" Margin="10,0,0,0" Grid.Row="0" /> + + <Button cal:Message.Attach="[Event Click] = [Action LaunchHelp]" Background="Transparent" BorderThickness="0" Grid.Row="0" HorizontalAlignment="Right" Margin="0,5,5,0" Padding="8,2"> + <Button.Content> + <Image Source="/Views/Images/question.png" Width="16" /> + </Button.Content> + </Button> + </Grid> <!-- Preset List --> @@ -128,7 +135,6 @@ <Trigger Property="HasItems" Value="True"> <Setter Property="Focusable" Value="false" /> </Trigger> - </Style.Triggers> </Style> </TreeView.ItemContainerStyle> @@ -154,114 +160,144 @@ </Grid> <!-- Control Panel --> - <Border BorderThickness="1,0,0,0" BorderBrush="LightGray" Grid.Column="1" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="5" - Visibility="{Binding IsPresetSelected, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" - IsEnabled="{Binding IsBuildIn, Converter={StaticResource booleanConverter}, ConverterParameter=true}"> - <Grid > + <Border BorderThickness="1,0,0,0" BorderBrush="LightGray" Grid.Column="1" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="5" > + + <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="*" /> - <RowDefinition Height="Auto" /> </Grid.RowDefinitions> - - <!-- Row 1 --> - <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_PresetInfo}" FontSize="16" Margin="10,0,0,15" Grid.Row="0" /> - - <!-- Row 2 --> - <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_RestrictedPreset}" HorizontalAlignment="Center" FontStyle="Italic" Grid.Row="1" - Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" /> - - <!-- Row 3 --> - <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="10,0,0,15" HorizontalAlignment="Stretch" > - - <StackPanel.Resources> - <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"> - <Setter Property="Padding" Value="8,2" /> - </Style> - </StackPanel.Resources> - - <Button Margin="0,0,0,0" AutomationProperties.Name="{x:Static Properties:Resources.PresetManagerView_Delete}" - cal:Message.Attach="[Event Click] = [Action DeletePreset]" - Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" > - <Button.Content> - <StackPanel Orientation="Horizontal"> - <Image Width="20" Height="20" VerticalAlignment="Center" Margin="0,0,5,0" - Source="{Binding Converter={StaticResource themeConverter}, ConverterParameter='Remove.png'}"> - </Image> - <TextBlock Text="{x:Static Properties:Resources.PresetManagerView_Delete}" VerticalAlignment="Center" /> - </StackPanel> - - </Button.Content> - </Button> - </StackPanel> - - <!-- Header --> - <Grid Grid.Row="3" Margin="10,0,10,0"> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="120" /> - <ColumnDefinition Width="*" /> - </Grid.ColumnDefinitions> + <!-- No Preset Selected --> + <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_NoPresetSelected}" HorizontalAlignment="Center" FontStyle="Italic" + Visibility="{Binding IsPresetSelected, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> + <!-- Main Content --> + <Grid Visibility="{Binding IsPresetSelected, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> + <RowDefinition Height="Auto" /> </Grid.RowDefinitions> - <!-- Name --> - <TextBlock Grid.Row="0" Grid.Column="0" Text="{x:Static Properties:Resources.AddPresetView_Name}" /> - <TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" Text="{Binding SelectedPreset.Name, UpdateSourceTrigger=PropertyChanged}" /> + <!-- Row 1 --> + <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_PresetInfo}" FontSize="16" Margin="10,0,0,15" Grid.Row="0" /> + + <!-- Row 2 --> + <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="10,5,0,15" HorizontalAlignment="Stretch" > + + <StackPanel.Resources> + <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"> + <Setter Property="Padding" Value="8,2" /> + </Style> + </StackPanel.Resources> + + <Button Content="Set Default" Margin="0,0,5,0" Visibility="{Binding SelectedPreset.IsDefault, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" + cal:Message.Attach="[Event Click] = [Action SetCurrentPresetAsDefault]" /> + + <Button Margin="0,0,0,0" AutomationProperties.Name="{x:Static Properties:Resources.PresetManagerView_Delete}" + cal:Message.Attach="[Event Click] = [Action DeletePreset]" + Visibility="{Binding SelectedPreset.IsDefault, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" > + <Button.Content> + <StackPanel Orientation="Horizontal"> + <Image Width="20" Height="20" VerticalAlignment="Center" Margin="0,0,5,0" + Source="{Binding Converter={StaticResource themeConverter}, ConverterParameter='Remove.png'}"> + </Image> + <TextBlock Text="{x:Static Properties:Resources.PresetManagerView_Delete}" VerticalAlignment="Center" /> + </StackPanel> + + </Button.Content> + </Button> + + </StackPanel> - <!-- Description --> - <TextBlock Grid.Row="2" Grid.Column="0" Margin="0,10,0,0" Text="{x:Static Properties:Resources.AddPresetView_Description}" VerticalAlignment="Top" /> - <TextBox Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" Text="{Binding SelectedPreset.Description, UpdateSourceTrigger=PropertyChanged}" Height="80" TextWrapping="WrapWithOverflow" VerticalContentAlignment="Top" + <!-- Row 3 --> + <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_RestrictedPreset}" HorizontalAlignment="Center" FontStyle="Italic" Grid.Row="2" + Margin="0,5,0,20" + Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" /> + + + <!-- Header --> + <Grid Grid.Row="3" Margin="10,0,10,0"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="120" /> + <ColumnDefinition Width="*" /> + </Grid.ColumnDefinitions> + + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="*" /> + </Grid.RowDefinitions> + + <!-- Name --> + <TextBlock Grid.Row="0" Grid.Column="0" Text="{x:Static Properties:Resources.AddPresetView_Name}" /> + <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1"> + <TextBlock HorizontalAlignment="Stretch" Text="{Binding SelectedPreset.Name, UpdateSourceTrigger=PropertyChanged}" TextTrimming="CharacterEllipsis" /> + <TextBlock HorizontalAlignment="Stretch" Text="{x:Static Properties:Resources.PresetManagerView_DefaultPreset}" FontWeight="Bold" Margin="15,0,0,0" Visibility="{Binding SelectedPreset.IsDefault, Converter={StaticResource boolToVisConverter}}" /> + </StackPanel> + + <!-- Description --> + <TextBlock Grid.Row="2" Grid.Column="0" Margin="0,10,0,0" Text="{x:Static Properties:Resources.AddPresetView_Description}" VerticalAlignment="Top" /> + <TextBox Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" Text="{Binding SelectedPreset.Description, UpdateSourceTrigger=PropertyChanged}" Height="80" TextWrapping="WrapWithOverflow" VerticalContentAlignment="Top" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> - <TextBlock Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" Text="{Binding SelectedPreset.Description, UpdateSourceTrigger=PropertyChanged}" TextWrapping="WrapWithOverflow" + <TextBlock Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" Text="{Binding SelectedPreset.Description, UpdateSourceTrigger=PropertyChanged}" TextWrapping="WrapWithOverflow" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" /> - <!-- Settings --> - <TextBlock Text="{x:Static Properties:Resources.PictureSettingsView_ResLimit}" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="0,15,0,5" + <!-- Category --> + <TextBlock Grid.Row="3" Grid.Column="0" Margin="0,10,0,0" Text="{x:Static Properties:Resources.AddPresetView_Category}" /> + <StackPanel Grid.Row="3" Grid.Column="1" Orientation="Vertical" Margin="0,10,0,0"> + + <ComboBox ItemsSource="{Binding UserPresetCategories}" SelectedItem="{Binding SelectedUserPresetCategory}" DisplayMemberPath="Category" Width="250" HorizontalAlignment="Left" + Visibility="{Binding SelectedPreset.IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"/> + <TextBlock Text="{Binding SelectedPreset.Category, UpdateSourceTrigger=PropertyChanged}" + Visibility="{Binding SelectedPreset.IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" /> + </StackPanel> + + <!-- Settings --> + <TextBlock Text="{x:Static Properties:Resources.PictureSettingsView_ResLimit}" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="0,15,0,5" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> - <ComboBox ItemsSource="{Binding ResolutionLimitModes, Converter={StaticResource resolutionLimitConverter}}" + <ComboBox ItemsSource="{Binding ResolutionLimitModes, Converter={StaticResource resolutionLimitConverter}}" SelectedItem="{Binding SelectedPictureSettingsResLimitMode, Converter={StaticResource resolutionLimitConverter}}" Width="150" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" Margin="0,15,0,5" AutomationProperties.Name="{x:Static Properties:Resources.PictureSettingsView_ResLimit}" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> - <!-- MAX Width and MAX Height --> - <StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"> - <controls:NumberBox Number="{Binding CustomWidth, Mode=TwoWay}" UpdateBindingOnTextChange="True" + <!-- MAX Width and MAX Height --> + <StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"> + <controls:NumberBox Number="{Binding CustomWidth, Mode=TwoWay}" UpdateBindingOnTextChange="True" Modulus="2" Minimum="0" Width="60" AutomationProperties.Name="{x:Static Properties:Resources.PictureSettingsView_MaxWidth}" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" /> - <TextBlock Text="x" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" VerticalAlignment="Center" Margin="10,0,10,0" /> - <controls:NumberBox Number="{Binding CustomHeight, Mode=TwoWay}" UpdateBindingOnTextChange="True" + <TextBlock Text="x" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" VerticalAlignment="Center" Margin="10,0,10,0" /> + <controls:NumberBox Number="{Binding CustomHeight, Mode=TwoWay}" UpdateBindingOnTextChange="True" Modulus="2" Minimum="0" Width="60" AutomationProperties.Name="{x:Static Properties:Resources.PictureSettingsView_MaxHeight}" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" /> - </StackPanel> + </StackPanel> - <TextBlock Text="Audio:" Grid.Row="6" VerticalAlignment="Center" Margin="0,15,0,0" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> - <Button Content="{x:Static Properties:Resources.AudioViewModel_ConfigureDefaults}" Grid.Row="6" Grid.Column="1" HorizontalAlignment="Left" Margin="0,15,0,0" Padding="8,2" + <TextBlock Text="Audio:" Grid.Row="6" VerticalAlignment="Center" Margin="0,15,0,0" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> + <Button Content="{x:Static Properties:Resources.AudioViewModel_ConfigureDefaults}" Grid.Row="6" Grid.Column="1" HorizontalAlignment="Left" Margin="0,15,0,0" Padding="8,2" cal:Message.Attach="[Event Click] = [Action EditAudioDefaults]" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> - <TextBlock Text="Subtitles:" Grid.Row="7" VerticalAlignment="Center" Margin="0,5,0,0" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> - <Button Content="{x:Static Properties:Resources.SubtitlesViewModel_ConfigureDefaults}" Grid.Row="7" Grid.Column="1" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="8,2" + <TextBlock Text="Subtitles:" Grid.Row="7" VerticalAlignment="Center" Margin="0,5,0,0" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> + <Button Content="{x:Static Properties:Resources.SubtitlesViewModel_ConfigureDefaults}" Grid.Row="7" Grid.Column="1" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="8,2" cal:Message.Attach="[Event Click] = [Action EditSubtitleDefaults]" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> - </Grid> + </Grid> + </Grid> </Grid> + + </Border> </Grid> diff --git a/win/CS/HandBrakeWPF/Views/Standalone/TextEntryView.xaml b/win/CS/HandBrakeWPF/Views/Standalone/TextEntryView.xaml new file mode 100644 index 000000000..4f6aa8805 --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/Standalone/TextEntryView.xaml @@ -0,0 +1,28 @@ +<Window x:Class="HandBrakeWPF.Views.Standalone.TextEntryView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + 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" + xmlns:Properties="clr-namespace:HandBrakeWPF.Properties" + mc:Ignorable="d" + Title="TextEntryView" Height="450" Width="800"> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="*" /> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + + + <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="10,10,0,0"> + <TextBlock Text="{x:Static Properties:Resources.TextEntryView_EnterName}" /> + <TextBox x:Name="entryBox" /> + </StackPanel> + + <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,10"> + + <Button Content="{x:Static Properties:Resources.Generic_Save}" Click="Save" IsDefault="True" /> + <Button Content="{x:Static Properties:Resources.Generic_Cancel}" Click="Cancel" IsCancel="False"/> + </StackPanel> + + </Grid> +</Window> diff --git a/win/CS/HandBrakeWPF/Views/Standalone/TextEntryView.xaml.cs b/win/CS/HandBrakeWPF/Views/Standalone/TextEntryView.xaml.cs new file mode 100644 index 000000000..84d31f517 --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/Standalone/TextEntryView.xaml.cs @@ -0,0 +1,40 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="TextEntryView.xaml.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Views.Standalone +{ + using System.Windows; + + public partial class TextEntryView : Window + { + public TextEntryView() + { + this.InitializeComponent(); + this.IsCancelled = false; + } + + public string EntryBoxContent + { + get + { + return this.entryBox.Text; + } + } + + public bool IsCancelled { get; private set; } + + public void Save(object sender, RoutedEventArgs e) + { + this.Close(); + } + + public void Cancel(object sender, RoutedEventArgs e) + { + this.IsCancelled = true; + this.Close(); + } + } +} |