summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs59
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs230
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs177
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioDefaultsViewModel.cs19
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IPopupWindowViewModel.cs22
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesDefaultsViewModel.cs41
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/PopupWindowViewModel.cs112
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SubtitlesDefaultsViewModel.cs249
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs172
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs1
10 files changed, 749 insertions, 333 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
index 2d8a7bd68..6bc8b2998 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
@@ -12,7 +12,8 @@ namespace HandBrakeWPF.ViewModels
using System.Collections.Generic;
using System.Windows;
- using HandBrake.ApplicationServices.Utilities;
+ using Caliburn.Micro;
+
using HandBrake.ApplicationServices.Interop.Model.Encoding;
using HandBrakeWPF.Model.Audio;
@@ -45,6 +46,11 @@ namespace HandBrakeWPF.ViewModels
private readonly IErrorService errorService;
/// <summary>
+ /// The window manager.
+ /// </summary>
+ private readonly IWindowManager windowManager;
+
+ /// <summary>
/// Backing fields for Selected Picture settings mode.
/// </summary>
private PresetPictureSettingsMode selectedPictureSettingMode;
@@ -59,6 +65,9 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private Title selectedTitle;
+ private IAudioDefaultsViewModel audioDefaultsViewModel;
+ private ISubtitlesDefaultsViewModel subtitlesDefaultsViewModel;
+
/// <summary>
/// Initializes a new instance of the <see cref="AddPresetViewModel"/> class.
/// </summary>
@@ -68,10 +77,14 @@ namespace HandBrakeWPF.ViewModels
/// <param name="errorService">
/// The Error Service
/// </param>
- public AddPresetViewModel(IPresetService presetService, IErrorService errorService)
+ /// <param name="windowManager">
+ /// The window Manager.
+ /// </param>
+ public AddPresetViewModel(IPresetService presetService, IErrorService errorService, IWindowManager windowManager)
{
this.presetService = presetService;
this.errorService = errorService;
+ this.windowManager = windowManager;
this.Title = "Add Preset";
this.Preset = new Preset { IsBuildIn = false, IsDefault = false, Category = PresetService.UserPresetCatgoryName};
this.PictureSettingsModes = EnumHelper<PresetPictureSettingsMode>.GetEnumList();
@@ -146,9 +159,16 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public void Setup(EncodeTask task, Title title, AudioBehaviours audioBehaviours, SubtitleBehaviours subtitleBehaviours)
{
+ this.audioDefaultsViewModel = new AudioDefaultsViewModel();
+ this.audioDefaultsViewModel.SetupLanguages(audioBehaviours);
+
+ this.subtitlesDefaultsViewModel = new SubtitlesDefaultsViewModel();
+ this.subtitlesDefaultsViewModel.SetupLanguages(subtitleBehaviours);
+
this.Preset.Task = new EncodeTask(task);
- this.Preset.AudioTrackBehaviours = audioBehaviours.Clone();
+ this.Preset.AudioTrackBehaviours = audioBehaviours;
this.Preset.SubtitleTrackBehaviours = subtitleBehaviours.Clone();
+
this.selectedTitle = title;
switch (task.Anamorphic)
@@ -236,6 +256,39 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// The edit audio defaults.
+ /// </summary>
+ public void EditAudioDefaults()
+ {
+ IPopupWindowViewModel popup = new PopupWindowViewModel(this.audioDefaultsViewModel, ResourcesUI.Preset_AudioDefaults_Title, ResourcesUI.Preset_AudioDefaults_SubText);
+ if (this.windowManager.ShowDialog(popup) == true)
+ {
+ this.Preset.AudioTrackBehaviours = this.audioDefaultsViewModel.AudioBehaviours.Clone();
+ }
+ else
+ {
+ // Handle other case(s)
+ }
+ }
+
+ /// <summary>
+ /// The edit subtitle defaults.
+ /// </summary>
+ public void EditSubtitleDefaults()
+ {
+ IPopupWindowViewModel popup = new PopupWindowViewModel(this.subtitlesDefaultsViewModel, ResourcesUI.Preset_SubtitleDefaults_Title, ResourcesUI.Preset_SubtitleDefaults_SubText);
+
+ if (this.windowManager.ShowDialog(popup) == true)
+ {
+ this.Preset.SubtitleTrackBehaviours = this.subtitlesDefaultsViewModel.SubtitleBehaviours.Clone();
+ }
+ else
+ {
+ // Handle other case(s)
+ }
+ }
+
+ /// <summary>
/// Cancel adding a preset
/// </summary>
public void Cancel()
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
new file mode 100644
index 000000000..f61aa4010
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
@@ -0,0 +1,230 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AudioDefaultsViewModel.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>
+// <summary>
+// The Audio Defaults View Model
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels
+{
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Linq;
+
+ using HandBrake.ApplicationServices.Utilities;
+
+ using HandBrakeWPF.Model.Audio;
+ using HandBrakeWPF.Services.Presets.Model;
+ using HandBrakeWPF.Utilities;
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// The Audio View Model
+ /// </summary>
+ public class AudioDefaultsViewModel : ViewModelBase, IAudioDefaultsViewModel
+ {
+ private BindingList<string> availableLanguages;
+ private AudioBehaviours audioBehaviours;
+
+ #region Constructors and Destructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AudioDefaultsViewModel"/> class.
+ /// </summary>
+ public AudioDefaultsViewModel()
+ {
+ this.AudioBehaviours = new AudioBehaviours();
+ this.SelectedAvailableToMove = new BindingList<string>();
+ this.SelectedLangaugesToMove = new BindingList<string>();
+ this.AvailableLanguages = new BindingList<string>();
+ this.SetupLanguages((Preset)null);
+ }
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets the audio behaviours.
+ /// </summary>
+ public AudioBehaviours AudioBehaviours
+ {
+ get
+ {
+ return this.audioBehaviours;
+ }
+
+ private set
+ {
+ if (Equals(value, this.audioBehaviours))
+ {
+ return;
+ }
+ this.audioBehaviours = value;
+ this.NotifyOfPropertyChange(() => this.AudioBehaviours);
+ }
+ }
+
+ /// <summary>
+ /// Gets the audio behaviour modes.
+ /// </summary>
+ public BindingList<AudioBehaviourModes> AudioBehaviourModeList
+ {
+ get
+ {
+ return new BindingList<AudioBehaviourModes>(EnumHelper<AudioBehaviourModes>.GetEnumList().ToList());
+ }
+ }
+
+ /// <summary>
+ /// Gets the audio track default behaviour mode list.
+ /// </summary>
+ public BindingList<AudioTrackDefaultsMode> AudioTrackDefaultBehaviourModeList
+ {
+ get
+ {
+ return new BindingList<AudioTrackDefaultsMode>(EnumHelper<AudioTrackDefaultsMode>.GetEnumList().ToList());
+ }
+ }
+
+ /// <summary>
+ /// Gets AvailableLanguages.
+ /// </summary>
+ public BindingList<string> AvailableLanguages
+ {
+ get
+ {
+ return this.availableLanguages;
+ }
+
+ private set
+ {
+ this.availableLanguages = value;
+ this.NotifyOfPropertyChange("AvailableLanguages");
+ }
+ }
+
+ /// <summary>
+ /// Gets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedAvailableToMove { get; private set; }
+
+ /// <summary>
+ /// Gets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedLangaugesToMove { get; private set; }
+
+ #endregion
+
+ #region Public Methods
+
+ /// <summary>
+ /// Audio List Move Left
+ /// </summary>
+ public void LanguageMoveRight()
+ {
+ if (this.SelectedAvailableToMove.Count > 0)
+ {
+ List<string> copiedList = this.SelectedAvailableToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.AvailableLanguages.Remove(item);
+ this.AudioBehaviours.SelectedLangauges.Add(item);
+ }
+
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+ }
+ }
+
+ /// <summary>
+ /// Audio List Move Right
+ /// </summary>
+ public void LanguageMoveLeft()
+ {
+ if (this.SelectedLangaugesToMove.Count > 0)
+ {
+ List<string> copiedList = this.SelectedLangaugesToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.AudioBehaviours.SelectedLangauges.Remove(item);
+ this.AvailableLanguages.Add(item);
+ }
+ }
+
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+ }
+
+ /// <summary>
+ /// Audio List Clear all selected languages
+ /// </summary>
+ public void LanguageClearAll()
+ {
+ foreach (string item in this.AudioBehaviours.SelectedLangauges)
+ {
+ this.AvailableLanguages.Add(item);
+ }
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+
+ this.AudioBehaviours.SelectedLangauges.Clear();
+ }
+
+ #endregion
+
+ #region Methods
+
+ /// <summary>
+ /// The setup languages.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ public void SetupLanguages(Preset preset)
+ {
+ if (preset != null)
+ {
+ this.SetupLanguages(preset.AudioTrackBehaviours.Clone());
+ }
+ }
+
+ /// <summary>
+ /// The setup languages.
+ /// </summary>
+ /// <param name="behaviours">
+ /// The behaviours.
+ /// </param>
+ public void SetupLanguages(AudioBehaviours behaviours)
+ {
+ // Step 1, Set the behaviour mode
+ this.AudioBehaviours.SelectedBehaviour = AudioBehaviourModes.None;
+ this.AudioBehaviours.SelectedLangauges.Clear();
+
+ // Step 2, Get all the languages
+ IDictionary<string, string> langList = LanguageUtilities.MapLanguages();
+ langList = (from entry in langList orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
+
+ // Step 3, Setup Available Languages
+ this.AvailableLanguages.Clear();
+ foreach (string item in langList.Keys)
+ {
+ this.AvailableLanguages.Add(item);
+ }
+
+ // Step 4, Set the Selected Languages
+ if (behaviours != null)
+ {
+ this.AudioBehaviours.SelectedBehaviour = behaviours.SelectedBehaviour;
+ this.AudioBehaviours.SelectedTrackDefaultBehaviour = behaviours.SelectedTrackDefaultBehaviour;
+
+ foreach (string selectedItem in behaviours.SelectedLangauges)
+ {
+ this.AvailableLanguages.Remove(selectedItem);
+ this.AudioBehaviours.SelectedLangauges.Add(selectedItem);
+ }
+ }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
index 05a904d5f..9e86506fa 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
@@ -54,16 +54,6 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private bool showAudioDefaultsPanel;
- /// <summary>
- /// The available languages.
- /// </summary>
- private BindingList<string> availableLanguages;
-
- /// <summary>
- /// The audio behaviours.
- /// </summary>
- private AudioBehaviours audioBehaviours;
-
#region Constructors and Destructors
/// <summary>
@@ -77,6 +67,7 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public AudioViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
+ this.AudioDefaultsViewModel = new AudioDefaultsViewModel();
this.Task = new EncodeTask();
this.SampleRates = new ObservableCollection<string> { "Auto" };
@@ -88,12 +79,6 @@ namespace HandBrakeWPF.ViewModels
this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList();
this.AudioMixdowns = EnumHelper<Mixdown>.GetEnumList();
this.SourceTracks = new List<Audio>();
-
- this.AudioBehaviours = new AudioBehaviours();
- this.SelectedAvailableToMove = new BindingList<string>();
- this.SelectedLangaugesToMove = new BindingList<string>();
- this.AvailableLanguages = new BindingList<string>();
- this.SetupLanguages(null);
}
#endregion
@@ -101,46 +86,9 @@ namespace HandBrakeWPF.ViewModels
#region Properties
/// <summary>
- /// Gets or sets the audio behaviours.
+ /// Gets or sets the audio defaults view model.
/// </summary>
- public AudioBehaviours AudioBehaviours
- {
- get
- {
- return this.audioBehaviours;
- }
- set
- {
- if (Equals(value, this.audioBehaviours))
- {
- return;
- }
- this.audioBehaviours = value;
- this.NotifyOfPropertyChange(() => this.AudioBehaviours);
- }
- }
-
- /// <summary>
- /// Gets the audio behaviour modes.
- /// </summary>
- public BindingList<AudioBehaviourModes> AudioBehaviourModeList
- {
- get
- {
- return new BindingList<AudioBehaviourModes>(EnumHelper<AudioBehaviourModes>.GetEnumList().ToList());
- }
- }
-
- /// <summary>
- /// Gets the audio track default behaviour mode list.
- /// </summary>
- public BindingList<AudioTrackDefaultsMode> AudioTrackDefaultBehaviourModeList
- {
- get
- {
- return new BindingList<AudioTrackDefaultsMode>(EnumHelper<AudioTrackDefaultsMode>.GetEnumList().ToList());
- }
- }
+ public IAudioDefaultsViewModel AudioDefaultsViewModel { get; set; }
/// <summary>
/// Gets or sets AudioBitrates.
@@ -228,32 +176,16 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Gets or sets AvailableLanguages.
+ /// Gets the default audio behaviours.
/// </summary>
- public BindingList<string> AvailableLanguages
+ public AudioBehaviours AudioBehaviours
{
get
{
- return this.availableLanguages;
- }
-
- set
- {
- this.availableLanguages = value;
- this.NotifyOfPropertyChange("AvailableLanguages");
+ return this.AudioDefaultsViewModel.AudioBehaviours;
}
}
- /// <summary>
- /// Gets or sets SelectedLangauges.
- /// </summary>
- public BindingList<string> SelectedAvailableToMove { get; set; }
-
- /// <summary>
- /// Gets or sets SelectedLangauges.
- /// </summary>
- public BindingList<string> SelectedLangaugesToMove { get; set; }
-
#endregion
#region Public Methods
@@ -336,56 +268,6 @@ namespace HandBrakeWPF.ViewModels
this.ShowAudioDefaultsPanel = !this.ShowAudioDefaultsPanel;
}
- /// <summary>
- /// Audio List Move Left
- /// </summary>
- public void LanguageMoveRight()
- {
- if (this.SelectedAvailableToMove.Count > 0)
- {
- List<string> copiedList = this.SelectedAvailableToMove.ToList();
- foreach (string item in copiedList)
- {
- this.AvailableLanguages.Remove(item);
- this.AudioBehaviours.SelectedLangauges.Add(item);
- }
-
- this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
- }
- }
-
- /// <summary>
- /// Audio List Move Right
- /// </summary>
- public void LanguageMoveLeft()
- {
- if (this.SelectedLangaugesToMove.Count > 0)
- {
- List<string> copiedList = this.SelectedLangaugesToMove.ToList();
- foreach (string item in copiedList)
- {
- this.AudioBehaviours.SelectedLangauges.Remove(item);
- this.AvailableLanguages.Add(item);
- }
- }
-
- this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
- }
-
- /// <summary>
- /// Audio List Clear all selected languages
- /// </summary>
- public void LanguageClearAll()
- {
- foreach (string item in this.AudioBehaviours.SelectedLangauges)
- {
- this.AvailableLanguages.Add(item);
- }
- this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
-
- this.AudioBehaviours.SelectedLangauges.Clear();
- }
-
#endregion
#region Implemented Interfaces
@@ -405,7 +287,7 @@ namespace HandBrakeWPF.ViewModels
this.currentPreset = preset;
// Audio Behaviours
- this.SetupLanguages(preset);
+ this.AudioDefaultsViewModel.SetupLanguages(preset);
if (preset != null && preset.Task != null)
{
@@ -495,7 +377,7 @@ namespace HandBrakeWPF.ViewModels
return;
}
- switch (this.AudioBehaviours.SelectedTrackDefaultBehaviour)
+ switch (this.AudioDefaultsViewModel.AudioBehaviours.SelectedTrackDefaultBehaviour)
{
case AudioTrackDefaultsMode.None:
this.Task.AudioTracks.Add(new AudioTrack { ScannedTrack = track });
@@ -563,7 +445,7 @@ namespace HandBrakeWPF.ViewModels
}
// Step 4, Handle the default selection behaviour.
- switch (this.AudioBehaviours.SelectedBehaviour)
+ switch (this.AudioDefaultsViewModel.AudioBehaviours.SelectedBehaviour)
{
case AudioBehaviourModes.None:
this.Task.AudioTracks.Clear();
@@ -635,9 +517,9 @@ namespace HandBrakeWPF.ViewModels
// The first track in the selected languages list is considered the preferred language.
// So, try match tracks on this.
IEnumerable<Audio> preferredAudioTracks = new List<Audio>();
- if (this.AudioBehaviours.SelectedLangauges.Count > 0)
+ if (this.AudioDefaultsViewModel.AudioBehaviours.SelectedLangauges.Count > 0)
{
- string langName = this.AudioBehaviours.SelectedLangauges.FirstOrDefault(w => !w.Equals(Constants.Any));
+ string langName = this.AudioDefaultsViewModel.AudioBehaviours.SelectedLangauges.FirstOrDefault(w => !w.Equals(Constants.Any));
if (!string.IsNullOrEmpty(langName))
{
preferredAudioTracks = this.SourceTracks.Where(item => item.Language.Contains(langName));
@@ -660,7 +542,7 @@ namespace HandBrakeWPF.ViewModels
{
List<Audio> trackList = new List<Audio>();
- List<string> isoCodes = LanguageUtilities.GetLanguageCodes(this.AudioBehaviours.SelectedLangauges.ToArray());
+ List<string> isoCodes = LanguageUtilities.GetLanguageCodes(this.AudioDefaultsViewModel.AudioBehaviours.SelectedLangauges.ToArray());
if (includeAny)
{
@@ -675,42 +557,7 @@ namespace HandBrakeWPF.ViewModels
return trackList;
}
- /// <summary>
- /// The setup languages.
- /// </summary>
- /// <param name="preset">
- /// The preset.
- /// </param>
- private void SetupLanguages(Preset preset)
- {
- // Step 1, Set the behaviour mode
- this.AudioBehaviours.SelectedBehaviour = AudioBehaviourModes.None;
- this.AudioBehaviours.SelectedLangauges.Clear();
-
- // Step 2, Get all the languages
- IDictionary<string, string> langList = LanguageUtilities.MapLanguages();
- langList = (from entry in langList orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
-
- // Step 3, Setup Available Languages
- this.AvailableLanguages.Clear();
- foreach (string item in langList.Keys)
- {
- this.AvailableLanguages.Add(item);
- }
- // Step 4, Set the Selected Languages
- if (preset != null && preset.AudioTrackBehaviours != null)
- {
- this.AudioBehaviours.SelectedBehaviour = preset.AudioTrackBehaviours.SelectedBehaviour;
- this.AudioBehaviours.SelectedTrackDefaultBehaviour = preset.AudioTrackBehaviours.SelectedTrackDefaultBehaviour;
-
- foreach (string selectedItem in preset.AudioTrackBehaviours.SelectedLangauges)
- {
- this.AvailableLanguages.Remove(selectedItem);
- this.AudioBehaviours.SelectedLangauges.Add(selectedItem);
- }
- }
- }
#endregion
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioDefaultsViewModel.cs
index db2ce4d26..d6859e38e 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioDefaultsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioDefaultsViewModel.cs
@@ -10,15 +10,32 @@
namespace HandBrakeWPF.ViewModels.Interfaces
{
using HandBrakeWPF.Model.Audio;
+ using HandBrakeWPF.Services.Presets.Model;
/// <summary>
/// The Audio View Model Interface
/// </summary>
- public interface IAudioDefaultsViewModel : IOverlayPanel
+ public interface IAudioDefaultsViewModel : IOverlayPanel, IViewModelBase
{
/// <summary>
/// Gets the audio behaviours.
/// </summary>
AudioBehaviours AudioBehaviours { get; }
+
+ /// <summary>
+ /// The setup languages.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ void SetupLanguages(Preset preset);
+
+ /// <summary>
+ /// The setup languages.
+ /// </summary>
+ /// <param name="behaviours">
+ /// The behaviours.
+ /// </param>
+ void SetupLanguages(AudioBehaviours behaviours);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPopupWindowViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPopupWindowViewModel.cs
new file mode 100644
index 000000000..f4b432e4f
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPopupWindowViewModel.cs
@@ -0,0 +1,22 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IPopupWindowViewModel.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>
+// <summary>
+// The PopupWindowViewModel interface.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ /// <summary>
+ /// The PopupWindowViewModel interface.
+ /// </summary>
+ public interface IPopupWindowViewModel
+ {
+ /// <summary>
+ /// Gets the content view model.
+ /// </summary>
+ IViewModelBase ContentViewModel { get; }
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesDefaultsViewModel.cs
new file mode 100644
index 000000000..ed4521897
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesDefaultsViewModel.cs
@@ -0,0 +1,41 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ISubtitlesDefaultsViewModel.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>
+// <summary>
+// Defines the ISubtitlesDefaultsViewMode type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ using HandBrakeWPF.Model.Subtitles;
+ using HandBrakeWPF.Services.Presets.Model;
+
+ /// <summary>
+ /// The Subtiles View Model Interface
+ /// </summary>
+ public interface ISubtitlesDefaultsViewModel : IViewModelBase
+ {
+ /// <summary>
+ /// Gets the subtitle behaviours.
+ /// </summary>
+ SubtitleBehaviours SubtitleBehaviours { get; }
+
+ /// <summary>
+ /// The setup languages.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ void SetupLanguages(Preset preset);
+
+ /// <summary>
+ /// The setup languages.
+ /// </summary>
+ /// <param name="behaviours">
+ /// The behaviours.
+ /// </param>
+ void SetupLanguages(SubtitleBehaviours behaviours);
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PopupWindowViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PopupWindowViewModel.cs
new file mode 100644
index 000000000..1bca58f43
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/PopupWindowViewModel.cs
@@ -0,0 +1,112 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="PopupWindowViewModel.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>
+// <summary>
+// Defines the PopupWindowViewModel type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels
+{
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// The popup window view model.
+ /// </summary>
+ public class PopupWindowViewModel : ViewModelBase, IPopupWindowViewModel
+ {
+ private string windowTitle;
+ private string subText;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PopupWindowViewModel"/> class.
+ /// </summary>
+ /// <param name="contentViewModel">
+ /// The content View Model.
+ /// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
+ /// <param name="subText">
+ /// The sub Text.
+ /// </param>
+ public PopupWindowViewModel(IViewModelBase contentViewModel, string title, string subText)
+ {
+ this.ContentViewModel = contentViewModel;
+ this.WindowTitle = title;
+ this.Title = title;
+ this.SubText = subText;
+ }
+
+ /// <summary>
+ /// Gets or sets the content view model.
+ /// </summary>
+ public IViewModelBase ContentViewModel { get; set; }
+
+ /// <summary>
+ /// Gets or sets the title.
+ /// </summary>
+ public string WindowTitle
+ {
+ get
+ {
+ return this.windowTitle;
+ }
+ set
+ {
+ if (value == this.windowTitle)
+ {
+ return;
+ }
+ this.windowTitle = value;
+ this.NotifyOfPropertyChange(() => this.Title);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the sub text.
+ /// </summary>
+ public string SubText
+ {
+ get
+ {
+ return this.subText;
+ }
+ set
+ {
+ if (value == this.subText)
+ {
+ return;
+ }
+ this.subText = value;
+
+ this.SubTextVisible = !string.IsNullOrEmpty(value);
+
+ this.NotifyOfPropertyChange(() => this.SubText);
+ this.NotifyOfPropertyChange(() => this.SubTextVisible);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether sub text visible.
+ /// </summary>
+ public bool SubTextVisible { get; set; }
+
+ /// <summary>
+ /// The save.
+ /// </summary>
+ public void Save()
+ {
+ this.TryClose(true);
+ }
+
+ /// <summary>
+ /// The cancel.
+ /// </summary>
+ public void Cancel()
+ {
+ this.TryClose(false);
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesDefaultsViewModel.cs
new file mode 100644
index 000000000..0334d2d1a
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesDefaultsViewModel.cs
@@ -0,0 +1,249 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="SubtitlesDefaultsViewModel.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>
+// <summary>
+// The Subtitles Defaults View Model
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels
+{
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Linq;
+
+ using HandBrake.ApplicationServices.Utilities;
+
+ using HandBrakeWPF.Model.Subtitles;
+ using HandBrakeWPF.Services.Presets.Model;
+ using HandBrakeWPF.Utilities;
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// The Subtitles View Model
+ /// </summary>
+ public class SubtitlesDefaultsViewModel : ViewModelBase, ISubtitlesDefaultsViewModel
+ {
+ #region Constants and Fields
+
+ private SubtitleBehaviours subtitleBehaviours;
+ private BindingList<string> availableLanguages;
+
+ #endregion
+
+ #region Constructors and Destructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SubtitlesDefaultsViewModel"/> class.
+ /// </summary>
+ public SubtitlesDefaultsViewModel()
+ {
+ this.Langauges = LanguageUtilities.MapLanguages().Keys;
+ this.CharacterCodes = CharCodesUtilities.GetCharacterCodes();
+ this.SubtitleBehaviours = new SubtitleBehaviours();
+ this.SelectedAvailableToMove = new BindingList<string>();
+ this.SelectedLangaugesToMove = new BindingList<string>();
+ this.availableLanguages = new BindingList<string>();
+ this.SetupLanguages((Preset)null);
+ }
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets CharacterCodes.
+ /// </summary>
+ public IEnumerable<string> CharacterCodes { get; private set; }
+
+ /// <summary>
+ /// Gets Langauges.
+ /// </summary>
+ public IEnumerable<string> Langauges { get; private set; }
+
+ /// <summary>
+ /// Gets or sets the subtitle behaviours.
+ /// </summary>
+ public SubtitleBehaviours SubtitleBehaviours
+ {
+ get
+ {
+ return this.subtitleBehaviours;
+ }
+ set
+ {
+ if (Equals(value, this.subtitleBehaviours))
+ {
+ return;
+ }
+ this.subtitleBehaviours = value;
+ this.NotifyOfPropertyChange(() => this.SubtitleBehaviours);
+ }
+ }
+
+ /// <summary>
+ /// Gets the sbutitle behaviour modes.
+ /// </summary>
+ public BindingList<SubtitleBehaviourModes> SubtitleBehaviourModeList
+ {
+ get
+ {
+ return new BindingList<SubtitleBehaviourModes>(EnumHelper<SubtitleBehaviourModes>.GetEnumList().ToList());
+ }
+ }
+
+ /// <summary>
+ /// Gets the subtitle burn in behaviour mode list.
+ /// </summary>
+ public BindingList<SubtitleBurnInBehaviourModes> SubtitleBurnInBehaviourModeList
+ {
+ get
+ {
+ return new BindingList<SubtitleBurnInBehaviourModes>(EnumHelper<SubtitleBurnInBehaviourModes>.GetEnumList().ToList());
+ }
+ }
+
+ /// <summary>
+ /// Gets AvailableLanguages.
+ /// </summary>
+ public BindingList<string> AvailableLanguages
+ {
+ get
+ {
+ return this.availableLanguages;
+ }
+
+ private set
+ {
+ this.availableLanguages = value;
+ this.NotifyOfPropertyChange("AvailableLanguages");
+ }
+ }
+
+ /// <summary>
+ /// Gets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedAvailableToMove { get; private set; }
+
+ /// <summary>
+ /// Gets SelectedLangauges.
+ /// </summary>
+ public BindingList<string> SelectedLangaugesToMove { get; private set; }
+
+ #endregion
+
+ #region Public Methods
+
+ /// <summary>
+ /// Audio List Move Left
+ /// </summary>
+ public void LanguageMoveRight()
+ {
+ if (this.SelectedAvailableToMove.Count > 0)
+ {
+ List<string> copiedList = SelectedAvailableToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.AvailableLanguages.Remove(item);
+ this.SubtitleBehaviours.SelectedLangauges.Add(item);
+ }
+
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+ }
+ }
+
+ /// <summary>
+ /// Audio List Move Right
+ /// </summary>
+ public void LanguageMoveLeft()
+ {
+ if (this.SelectedLangaugesToMove.Count > 0)
+ {
+ List<string> copiedList = SelectedLangaugesToMove.ToList();
+ foreach (string item in copiedList)
+ {
+ this.SubtitleBehaviours.SelectedLangauges.Remove(item);
+ this.AvailableLanguages.Add(item);
+ }
+ }
+
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+ }
+
+ /// <summary>
+ /// Language List Clear all selected languages
+ /// </summary>
+ public void LanguageClearAll()
+ {
+ foreach (string item in this.SubtitleBehaviours.SelectedLangauges)
+ {
+ this.AvailableLanguages.Add(item);
+ }
+ this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
+
+ this.SubtitleBehaviours.SelectedLangauges.Clear();
+ }
+
+ #endregion
+
+ #region Methods
+
+ /// <summary>
+ /// The setup languages.
+ /// </summary>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ public void SetupLanguages(Preset preset)
+ {
+ if (preset != null)
+ {
+ this.SetupLanguages(preset.SubtitleTrackBehaviours);
+ }
+ }
+
+ /// <summary>
+ /// The setup languages.
+ /// </summary>
+ /// <param name="behaviours">
+ /// The behaviours.
+ /// </param>
+ public void SetupLanguages(SubtitleBehaviours behaviours)
+ {
+ // Step 1, Set the behaviour mode
+ this.SubtitleBehaviours.SelectedBehaviour = SubtitleBehaviourModes.None;
+ this.SubtitleBehaviours.SelectedBurnInBehaviour = SubtitleBurnInBehaviourModes.None;
+ this.SubtitleBehaviours.AddClosedCaptions = false;
+ this.SubtitleBehaviours.AddForeignAudioScanTrack = false;
+ this.SubtitleBehaviours.SelectedLangauges.Clear();
+
+ // Step 2, Get all the languages
+ IDictionary<string, string> langList = LanguageUtilities.MapLanguages();
+ langList = (from entry in langList orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
+
+ // Step 3, Setup Available Languages
+ this.AvailableLanguages.Clear();
+ foreach (string item in langList.Keys)
+ {
+ this.AvailableLanguages.Add(item);
+ }
+
+ // Step 4, Set the Selected Languages
+ if (behaviours != null)
+ {
+ this.SubtitleBehaviours.SelectedBehaviour = behaviours.SelectedBehaviour;
+ this.SubtitleBehaviours.SelectedBurnInBehaviour = behaviours.SelectedBurnInBehaviour;
+ this.SubtitleBehaviours.AddClosedCaptions = behaviours.AddClosedCaptions;
+ this.SubtitleBehaviours.AddForeignAudioScanTrack = behaviours.AddForeignAudioScanTrack;
+
+ foreach (string selectedItem in behaviours.SelectedLangauges)
+ {
+ this.AvailableLanguages.Remove(selectedItem);
+ this.SubtitleBehaviours.SelectedLangauges.Add(selectedItem);
+ }
+ }
+ }
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
index 73df64ddd..d27b8dc26 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
@@ -57,11 +57,6 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private SubtitleBehaviours subtitleBehaviours;
- /// <summary>
- /// The available languages.
- /// </summary>
- private BindingList<string> availableLanguages;
-
#endregion
#region Constructors and Destructors
@@ -71,6 +66,7 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public SubtitlesViewModel()
{
+ this.SubtitleDefaultsViewModel = new SubtitlesDefaultsViewModel();
this.Task = new EncodeTask();
this.Langauges = LanguageUtilities.MapLanguages().Keys;
@@ -78,12 +74,6 @@ namespace HandBrakeWPF.ViewModels
this.ForeignAudioSearchTrack = new Subtitle { SubtitleType = SubtitleType.ForeignAudioSearch, Language = "Foreign Audio Search (Bitmap)" };
this.SourceTracks = new List<Subtitle> { this.ForeignAudioSearchTrack };
-
- this.SubtitleBehaviours = new SubtitleBehaviours();
- this.SelectedAvailableToMove = new BindingList<string>();
- this.SelectedLangaugesToMove = new BindingList<string>();
- this.availableLanguages = new BindingList<string>();
- this.SetupLanguages(null);
}
#endregion
@@ -91,6 +81,11 @@ namespace HandBrakeWPF.ViewModels
#region Properties
/// <summary>
+ /// Gets or sets the audio defaults view model.
+ /// </summary>
+ public ISubtitlesDefaultsViewModel SubtitleDefaultsViewModel { get; set; }
+
+ /// <summary>
/// Gets or sets CharacterCodes.
/// </summary>
public IEnumerable<string> CharacterCodes { get; set; }
@@ -167,74 +162,16 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Gets or sets the subtitle behaviours.
+ /// Gets the default audio behaviours.
/// </summary>
public SubtitleBehaviours SubtitleBehaviours
{
get
{
- return this.subtitleBehaviours;
- }
- set
- {
- if (Equals(value, this.subtitleBehaviours))
- {
- return;
- }
- this.subtitleBehaviours = value;
- this.NotifyOfPropertyChange(() => this.SubtitleBehaviours);
+ return this.SubtitleDefaultsViewModel.SubtitleBehaviours;
}
}
- /// <summary>
- /// Gets the sbutitle behaviour modes.
- /// </summary>
- public BindingList<SubtitleBehaviourModes> SubtitleBehaviourModeList
- {
- get
- {
- return new BindingList<SubtitleBehaviourModes>(EnumHelper<SubtitleBehaviourModes>.GetEnumList().ToList());
- }
- }
-
- /// <summary>
- /// Gets the subtitle burn in behaviour mode list.
- /// </summary>
- public BindingList<SubtitleBurnInBehaviourModes> SubtitleBurnInBehaviourModeList
- {
- get
- {
- return new BindingList<SubtitleBurnInBehaviourModes>(EnumHelper<SubtitleBurnInBehaviourModes>.GetEnumList().ToList());
- }
- }
-
- /// <summary>
- /// Gets or sets AvailableLanguages.
- /// </summary>
- public BindingList<string> AvailableLanguages
- {
- get
- {
- return this.availableLanguages;
- }
-
- set
- {
- this.availableLanguages = value;
- this.NotifyOfPropertyChange("AvailableLanguages");
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedLangauges.
- /// </summary>
- public BindingList<string> SelectedAvailableToMove { get; set; }
-
- /// <summary>
- /// Gets or sets SelectedLangauges.
- /// </summary>
- public BindingList<string> SelectedLangaugesToMove { get; set; }
-
#endregion
#region Public Methods
@@ -514,56 +451,6 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Audio List Move Left
- /// </summary>
- public void LanguageMoveRight()
- {
- if (this.SelectedAvailableToMove.Count > 0)
- {
- List<string> copiedList = SelectedAvailableToMove.ToList();
- foreach (string item in copiedList)
- {
- this.AvailableLanguages.Remove(item);
- this.SubtitleBehaviours.SelectedLangauges.Add(item);
- }
-
- this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
- }
- }
-
- /// <summary>
- /// Audio List Move Right
- /// </summary>
- public void LanguageMoveLeft()
- {
- if (this.SelectedLangaugesToMove.Count > 0)
- {
- List<string> copiedList = SelectedLangaugesToMove.ToList();
- foreach (string item in copiedList)
- {
- this.SubtitleBehaviours.SelectedLangauges.Remove(item);
- this.AvailableLanguages.Add(item);
- }
- }
-
- this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
- }
-
- /// <summary>
- /// Language List Clear all selected languages
- /// </summary>
- public void LanguageClearAll()
- {
- foreach (string item in this.SubtitleBehaviours.SelectedLangauges)
- {
- this.AvailableLanguages.Add(item);
- }
- this.AvailableLanguages = new BindingList<string>(this.AvailableLanguages.OrderBy(o => o).ToList());
-
- this.SubtitleBehaviours.SelectedLangauges.Clear();
- }
-
- /// <summary>
/// Reload the audio tracks based on the defaults.
/// </summary>
public void ReloadDefaults()
@@ -590,7 +477,7 @@ namespace HandBrakeWPF.ViewModels
this.Task = task;
this.NotifyOfPropertyChange(() => this.Task);
- this.SetupLanguages(preset);
+ this.SubtitleDefaultsViewModel.SetupLanguages(preset);
this.AutomaticSubtitleSelection();
}
@@ -747,47 +634,6 @@ namespace HandBrakeWPF.ViewModels
: this.SourceTracks.Where(subtitle => !this.Task.SubtitleTracks.Any(track => Equals(track.SourceTrack, subtitle))).ToList();
}
- /// <summary>
- /// The setup languages.
- /// </summary>
- /// <param name="preset">
- /// The preset.
- /// </param>
- private void SetupLanguages(Preset preset)
- {
- // Step 1, Set the behaviour mode
- this.SubtitleBehaviours.SelectedBehaviour = SubtitleBehaviourModes.None;
- this.SubtitleBehaviours.SelectedBurnInBehaviour = SubtitleBurnInBehaviourModes.None;
- this.SubtitleBehaviours.AddClosedCaptions = false;
- this.SubtitleBehaviours.AddForeignAudioScanTrack = false;
- this.SubtitleBehaviours.SelectedLangauges.Clear();
-
- // Step 2, Get all the languages
- IDictionary<string, string> langList = LanguageUtilities.MapLanguages();
- langList = (from entry in langList orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
-
- // Step 3, Setup Available Languages
- this.AvailableLanguages.Clear();
- foreach (string item in langList.Keys)
- {
- this.AvailableLanguages.Add(item);
- }
-
- // Step 4, Set the Selected Languages
- if (preset != null && preset.SubtitleTrackBehaviours != null)
- {
- this.SubtitleBehaviours.SelectedBehaviour = preset.SubtitleTrackBehaviours.SelectedBehaviour;
- this.SubtitleBehaviours.SelectedBurnInBehaviour = preset.SubtitleTrackBehaviours.SelectedBurnInBehaviour;
- this.SubtitleBehaviours.AddClosedCaptions = preset.SubtitleTrackBehaviours.AddClosedCaptions;
- this.SubtitleBehaviours.AddForeignAudioScanTrack = preset.SubtitleTrackBehaviours.AddForeignAudioScanTrack;
-
- foreach (string selectedItem in preset.SubtitleTrackBehaviours.SelectedLangauges)
- {
- this.AvailableLanguages.Remove(selectedItem);
- this.SubtitleBehaviours.SelectedLangauges.Add(selectedItem);
- }
- }
- }
#endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs
index 835add7fd..db40c7c66 100644
--- a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs
@@ -11,7 +11,6 @@ namespace HandBrakeWPF.ViewModels
{
using Caliburn.Micro;
- using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.ViewModels.Interfaces;
/// <summary>