summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-03-29 15:57:53 +0000
committersr55 <[email protected]>2015-03-29 15:57:53 +0000
commit168ce686fd837de7fbf20266df31af2ac00c8db1 (patch)
tree1feb3e16046babb4bee15b7554a04ca383e13206 /win/CS/HandBrakeWPF/ViewModels
parent476eb6ccaa4e655c43d85d8111f27451aa0a8f8f (diff)
WinGui: Add TrueHD, Flac and EAC3 Passthru, and EAC3 encoder options. Fixed No Audio Behaviour. Misc other experimental UX/UI code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7027 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs237
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs14
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioDefaultsViewModel.cs24
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IOverlayPanel.cs18
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs13
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs73
6 files changed, 379 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
new file mode 100644
index 000000000..18fee1926
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs
@@ -0,0 +1,237 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <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 Caliburn.Micro;
+
+ using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrake.ApplicationServices.Utilities;
+
+ using HandBrakeWPF.Commands;
+ using HandBrakeWPF.Model.Audio;
+ using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.Services.Presets.Model;
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// The Audio View Model
+ /// </summary>
+ public class AudioDefaultsViewModel : ViewModelBase, IAudioDefaultsViewModel
+ {
+ /// <summary>
+ /// The available languages.
+ /// </summary>
+ private BindingList<string> availableLanguages;
+
+ /// <summary>
+ /// The audio behaviours.
+ /// </summary>
+ private AudioBehaviours audioBehaviours;
+
+ #region Constructors and Destructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AudioDefaultsViewModel"/> class.
+ /// </summary>
+ /// <param name="windowManager">
+ /// The window manager.
+ /// </param>
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public AudioDefaultsViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
+ {
+ this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList();
+
+ this.AudioBehaviours = new AudioBehaviours();
+ this.SelectedAvailableToMove = new BindingList<string>();
+ this.SelectedLangaugesToMove = new BindingList<string>();
+ this.AvailableLanguages = new BindingList<string>();
+ this.SetupLanguages(null);
+ }
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets the audio behaviours.
+ /// </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 or sets AudioEncoders.
+ /// </summary>
+ public IEnumerable<AudioEncoder> AudioEncoders { get; set; }
+
+
+ /// <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
+
+ /// <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.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 = 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();
+ }
+
+ /// <summary>
+ /// The close.
+ /// </summary>
+ public void Close()
+ {
+ CloseOverlayPanelCommand command = new CloseOverlayPanelCommand();
+ command.Execute(null);
+ }
+
+ #endregion
+
+ #region Methods
+
+ /// <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;
+
+ foreach (string selectedItem in preset.AudioTrackBehaviours.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 699137169..a7c905f67 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
@@ -23,6 +23,7 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.ApplicationServices.Utilities;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.Commands;
using HandBrakeWPF.Model.Audio;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
@@ -272,6 +273,14 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Reload the audio tracks based on the defaults.
+ /// </summary>
+ public void ReloadDefaults()
+ {
+ this.SetupTracks();
+ }
+
+ /// <summary>
/// Trigger a Notify Property Changed on the Task to force various UI elements to update.
/// </summary>
public void RefreshTask()
@@ -300,6 +309,8 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void ShowAudioDefaults()
{
+ // OpenOverlayPanelCommand command = new OpenOverlayPanelCommand();
+ // command.Execute(new AudioDefaultsViewModel(this.WindowManager, this.UserSettingService));
this.ShowAudioDefaultsPanel = !this.ShowAudioDefaultsPanel;
}
@@ -507,6 +518,9 @@ namespace HandBrakeWPF.ViewModels
// Step 4, Handle the default selection behaviour.
switch (this.AudioBehaviours.SelectedBehaviour)
{
+ case AudioBehaviourModes.None:
+ this.Task.AudioTracks.Clear();
+ break;
case AudioBehaviourModes.FirstMatch: // Adding all remaining audio tracks
this.AddFirstForSelectedLanguages();
break;
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioDefaultsViewModel.cs
new file mode 100644
index 000000000..db2ce4d26
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioDefaultsViewModel.cs
@@ -0,0 +1,24 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IAudioDefaultsViewModel.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 IAudioViewModel type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ using HandBrakeWPF.Model.Audio;
+
+ /// <summary>
+ /// The Audio View Model Interface
+ /// </summary>
+ public interface IAudioDefaultsViewModel : IOverlayPanel
+ {
+ /// <summary>
+ /// Gets the audio behaviours.
+ /// </summary>
+ AudioBehaviours AudioBehaviours { get; }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IOverlayPanel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IOverlayPanel.cs
new file mode 100644
index 000000000..c713ce283
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IOverlayPanel.cs
@@ -0,0 +1,18 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IOverlayPanel.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 OverlayPanel interface.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ /// <summary>
+ /// The OverlayPanel interface.
+ /// </summary>
+ public interface IOverlayPanel
+ {
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs
index 6c537ef66..0b156109a 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs
@@ -17,6 +17,19 @@ namespace HandBrakeWPF.ViewModels.Interfaces
public interface IShellViewModel
{
/// <summary>
+ /// The show overlay.
+ /// </summary>
+ /// <param name="panel">
+ /// The panel.
+ /// </param>
+ void ShowOverlay(IOverlayPanel panel);
+
+ /// <summary>
+ /// The hide overlay.
+ /// </summary>
+ void HideOverlay();
+
+ /// <summary>
/// Change the page displayed on this window.
/// </summary>
/// <param name="window">
diff --git a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs
index c85c707bd..4d505b83d 100644
--- a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs
@@ -42,6 +42,10 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private bool showOptions;
+ private bool showOverlayPanel;
+
+ private bool isMainPanelEnabled;
+
#endregion
/// <summary>
@@ -55,6 +59,29 @@ namespace HandBrakeWPF.ViewModels
this.errorService = errorService;
this.showMainWindow = true;
this.showOptions = false;
+ this.IsMainPanelEnabled = true;
+ }
+
+ /// <summary>
+ /// The show overlay.
+ /// </summary>
+ /// <param name="panel">
+ /// The panel.
+ /// </param>
+ public void ShowOverlay(IOverlayPanel panel)
+ {
+ this.OverlayPanelViewModel = panel;
+ this.NotifyOfPropertyChange(() => this.OverlayPanelViewModel);
+ this.ShowOverlayPanel = true;
+ }
+
+ /// <summary>
+ /// The hide overlay.
+ /// </summary>
+ public void HideOverlay()
+ {
+ this.ShowOverlayPanel = false;
+ this.OverlayPanelViewModel = null;
}
/// <summary>
@@ -95,6 +122,11 @@ namespace HandBrakeWPF.ViewModels
public IOptionsViewModel OptionsViewModel { get; set; }
/// <summary>
+ /// Gets or sets the overlay panel view model.
+ /// </summary>
+ public IOverlayPanel OverlayPanelViewModel { get; set; }
+
+ /// <summary>
/// Gets or sets a value indicating whether ShowMainWindow.
/// </summary>
public bool ShowMainWindow
@@ -127,6 +159,47 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Gets or sets a value indicating whether is main panel enabled.
+ /// </summary>
+ public bool IsMainPanelEnabled
+ {
+ get
+ {
+ return this.isMainPanelEnabled;
+ }
+ set
+ {
+ if (value.Equals(this.isMainPanelEnabled))
+ {
+ return;
+ }
+ this.isMainPanelEnabled = value;
+ this.NotifyOfPropertyChange(() => this.IsMainPanelEnabled);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether show overlay panel.
+ /// </summary>
+ public bool ShowOverlayPanel
+ {
+ get
+ {
+ return this.showOverlayPanel;
+ }
+ set
+ {
+ if (value.Equals(this.showOverlayPanel))
+ {
+ return;
+ }
+ this.showOverlayPanel = value;
+ this.IsMainPanelEnabled = !value;
+ this.NotifyOfPropertyChange(() => this.ShowOverlayPanel);
+ }
+ }
+
+ /// <summary>
/// Gets WindowTitle.
/// </summary>
public string WindowTitle