summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-06-08 02:13:59 +0000
committersr55 <[email protected]>2012-06-08 02:13:59 +0000
commita03739f0457ad9211744e540f33ab8a3c05598b9 (patch)
tree2f0dda9a6f9e9c48b2bb58d9cc6462c77bd55715 /win/CS/HandBrakeWPF/ViewModels
parent368023e13a633e9dc94f27696c84f3ce3ca24ed3 (diff)
WinGui: Added a Shell View which can host various windows. By default this will host the Main window. Changed the Options window to be a usercontrol so it can be hosted in this shell view, allowing for a chrome-esk style options within the main window without the need for a dialog window. The options window will need some design changes. (Coming soon)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4721 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs27
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs15
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs14
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs128
4 files changed, 180 insertions, 4 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs
new file mode 100644
index 000000000..4964e8b40
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs
@@ -0,0 +1,27 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IShellViewModel.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 Interface for the Shell View Model
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ using HandBrakeWPF.Model;
+
+ /// <summary>
+ /// The Interface for the Shell View Model
+ /// </summary>
+ public interface IShellViewModel
+ {
+ /// <summary>
+ /// Change the page displayed on this window.
+ /// </summary>
+ /// <param name="window">
+ /// The window.
+ /// </param>
+ void DisplayWindow(ShellWindow window);
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 061a1e148..d0a6450c8 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -32,7 +32,9 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Helpers;
+ using HandBrakeWPF.Model;
using HandBrakeWPF.ViewModels.Interfaces;
+ using HandBrakeWPF.Views;
using Ookii.Dialogs.Wpf;
@@ -74,6 +76,11 @@ namespace HandBrakeWPF.ViewModels
private readonly IErrorService errorService;
/// <summary>
+ /// The Shell View Model
+ /// </summary>
+ private readonly IShellViewModel shellViewModel;
+
+ /// <summary>
/// Backing field for the user setting service.
/// </summary>
private readonly IUserSettingService userSettingService;
@@ -157,14 +164,18 @@ namespace HandBrakeWPF.ViewModels
/// <param name="errorService">
/// The Error Service
/// </param>
+ /// <param name="shellViewModel">
+ /// The shell View Model.
+ /// </param>
[ImportingConstructor]
public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
- IErrorService errorService)
+ IErrorService errorService, IShellViewModel shellViewModel)
{
this.scanService = scanService;
this.encodeService = encodeService;
this.presetService = presetService;
this.errorService = errorService;
+ this.shellViewModel = shellViewModel;
this.userSettingService = userSettingService;
this.queueProcessor = IoC.Get<IQueueProcessor>(); // TODO Instance ID!
@@ -836,7 +847,7 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void OpenOptionsWindow()
{
- this.WindowManager.ShowWindow(IoC.Get<IOptionsViewModel>());
+ this.shellViewModel.DisplayWindow(ShellWindow.OptionsWindow);
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index 52ef447e0..706009107 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -26,6 +26,7 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
+ using HandBrakeWPF.Model;
using HandBrakeWPF.ViewModels.Interfaces;
using Ookii.Dialogs.Wpf;
@@ -44,6 +45,11 @@ namespace HandBrakeWPF.ViewModels
private readonly IUserSettingService userSettingService;
/// <summary>
+ /// The Shell View Model
+ /// </summary>
+ private readonly IShellViewModel shellViewModel;
+
+ /// <summary>
/// The add audio mode options.
/// </summary>
private BindingList<string> addAudioModeOptions = new BindingList<string>();
@@ -317,10 +323,14 @@ namespace HandBrakeWPF.ViewModels
/// <param name="userSettingService">
/// The user Setting Service.
/// </param>
- public OptionsViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
+ /// <param name="shellViewModel">
+ /// The shell View Model.
+ /// </param>
+ public OptionsViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IShellViewModel shellViewModel)
{
this.Title = "Options";
this.userSettingService = userSettingService;
+ this.shellViewModel = shellViewModel;
this.OnLoad();
}
@@ -1466,7 +1476,7 @@ namespace HandBrakeWPF.ViewModels
public void Close()
{
this.Save();
- this.TryClose();
+ this.shellViewModel.DisplayWindow(ShellWindow.MainWindow);
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs
new file mode 100644
index 000000000..349dc1200
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs
@@ -0,0 +1,128 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ShellViewModel.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 Shell View Model
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels
+{
+ using System.ComponentModel.Composition;
+
+ using HandBrakeWPF.Model;
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// The Shell View Model
+ /// </summary>
+ [Export(typeof(IShellViewModel))]
+ public class ShellViewModel : ViewModelBase, IShellViewModel
+ {
+ #region Constants and Fields
+
+ /// <summary>
+ /// The show main window.
+ /// </summary>
+ private bool showMainWindow;
+
+ /// <summary>
+ /// The show options.
+ /// </summary>
+ private bool showOptions;
+
+ #endregion
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ShellViewModel"/> class.
+ /// </summary>
+ public ShellViewModel()
+ {
+ this.showMainWindow = true;
+ this.showOptions = false;
+ }
+
+ /// <summary>
+ /// Change the page displayed on this window.
+ /// </summary>
+ /// <param name="window">
+ /// The window.
+ /// </param>
+ public void DisplayWindow(ShellWindow window)
+ {
+ if (window == ShellWindow.MainWindow)
+ {
+ this.ShowMainWindow = true;
+ this.ShowOptions = false;
+ }
+ else if (window == ShellWindow.OptionsWindow)
+ {
+ this.ShowOptions = true;
+ this.ShowMainWindow = false;
+ }
+ else
+ {
+ this.ShowMainWindow = true;
+ this.ShowOptions = false;
+ }
+ }
+
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets MainViewModel.
+ /// </summary>
+ public IMainViewModel MainViewModel { get; set; }
+
+ /// <summary>
+ /// Gets or sets OptionsViewModel.
+ /// </summary>
+ public IOptionsViewModel OptionsViewModel { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether ShowMainWindow.
+ /// </summary>
+ public bool ShowMainWindow
+ {
+ get
+ {
+ return this.showMainWindow;
+ }
+ set
+ {
+ this.showMainWindow = value;
+ this.NotifyOfPropertyChange(() => this.ShowMainWindow);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether ShowOptions.
+ /// </summary>
+ public bool ShowOptions
+ {
+ get
+ {
+ return this.showOptions;
+ }
+ set
+ {
+ this.showOptions = value;
+ this.NotifyOfPropertyChange(() => this.ShowOptions);
+ }
+ }
+
+ /// <summary>
+ /// Gets WindowTitle.
+ /// </summary>
+ public string WindowTitle
+ {
+ get
+ {
+ return "HandBrake";
+ }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file