From a03739f0457ad9211744e540f33ab8a3c05598b9 Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 8 Jun 2012 02:13:59 +0000 Subject: 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 --- win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 10 ++ win/CS/HandBrakeWPF/Model/ShellWindow.cs | 20 ++++ win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs | 3 +- .../ViewModels/Interfaces/IShellViewModel.cs | 27 +++++ win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 15 ++- win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 14 ++- win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs | 128 +++++++++++++++++++++ win/CS/HandBrakeWPF/Views/MainView.xaml | 15 +-- win/CS/HandBrakeWPF/Views/MainView.xaml.cs | 4 +- win/CS/HandBrakeWPF/Views/OptionsView.xaml | 34 +++--- win/CS/HandBrakeWPF/Views/OptionsView.xaml.cs | 3 +- win/CS/HandBrakeWPF/Views/ShellView.xaml | 25 ++++ win/CS/HandBrakeWPF/Views/ShellView.xaml.cs | 27 +++++ 13 files changed, 291 insertions(+), 34 deletions(-) create mode 100644 win/CS/HandBrakeWPF/Model/ShellWindow.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs create mode 100644 win/CS/HandBrakeWPF/Views/ShellView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/ShellView.xaml.cs (limited to 'win') diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 57a135d79..bb6511e7f 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -121,7 +121,13 @@ + + + ShellView.xaml + + + TitleSpecificView.xaml @@ -270,6 +276,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/win/CS/HandBrakeWPF/Model/ShellWindow.cs b/win/CS/HandBrakeWPF/Model/ShellWindow.cs new file mode 100644 index 000000000..05ca1995e --- /dev/null +++ b/win/CS/HandBrakeWPF/Model/ShellWindow.cs @@ -0,0 +1,20 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Window that the shell view can display +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Model +{ + /// + /// The Window that the shell view can display + /// + public enum ShellWindow + { + MainWindow, + OptionsWindow + } +} diff --git a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs index a348c2c95..2b694252b 100644 --- a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs +++ b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs @@ -31,7 +31,7 @@ namespace HandBrakeWPF.Startup /// /// The Castle Bootstrapper /// - public class CastleBootstrapper : Bootstrapper + public class CastleBootstrapper : Bootstrapper { /// /// The Windsor Container @@ -55,6 +55,7 @@ namespace HandBrakeWPF.Startup this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); + this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Transient)); this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); 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 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Interface for the Shell View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + using HandBrakeWPF.Model; + + /// + /// The Interface for the Shell View Model + /// + public interface IShellViewModel + { + /// + /// Change the page displayed on this window. + /// + /// + /// The window. + /// + 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; @@ -73,6 +75,11 @@ namespace HandBrakeWPF.ViewModels /// private readonly IErrorService errorService; + /// + /// The Shell View Model + /// + private readonly IShellViewModel shellViewModel; + /// /// Backing field for the user setting service. /// @@ -157,14 +164,18 @@ namespace HandBrakeWPF.ViewModels /// /// The Error Service /// + /// + /// The shell View Model. + /// [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(); // TODO Instance ID! @@ -836,7 +847,7 @@ namespace HandBrakeWPF.ViewModels /// public void OpenOptionsWindow() { - this.WindowManager.ShowWindow(IoC.Get()); + this.shellViewModel.DisplayWindow(ShellWindow.OptionsWindow); } /// 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; @@ -43,6 +44,11 @@ namespace HandBrakeWPF.ViewModels /// private readonly IUserSettingService userSettingService; + /// + /// The Shell View Model + /// + private readonly IShellViewModel shellViewModel; + /// /// The add audio mode options. /// @@ -317,10 +323,14 @@ namespace HandBrakeWPF.ViewModels /// /// The user Setting Service. /// - public OptionsViewModel(IWindowManager windowManager, IUserSettingService userSettingService) + /// + /// The shell View Model. + /// + 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); } /// 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 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Shell View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System.ComponentModel.Composition; + + using HandBrakeWPF.Model; + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The Shell View Model + /// + [Export(typeof(IShellViewModel))] + public class ShellViewModel : ViewModelBase, IShellViewModel + { + #region Constants and Fields + + /// + /// The show main window. + /// + private bool showMainWindow; + + /// + /// The show options. + /// + private bool showOptions; + + #endregion + + /// + /// Initializes a new instance of the class. + /// + public ShellViewModel() + { + this.showMainWindow = true; + this.showOptions = false; + } + + /// + /// Change the page displayed on this window. + /// + /// + /// The window. + /// + 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 + + /// + /// Gets or sets MainViewModel. + /// + public IMainViewModel MainViewModel { get; set; } + + /// + /// Gets or sets OptionsViewModel. + /// + public IOptionsViewModel OptionsViewModel { get; set; } + + /// + /// Gets or sets a value indicating whether ShowMainWindow. + /// + public bool ShowMainWindow + { + get + { + return this.showMainWindow; + } + set + { + this.showMainWindow = value; + this.NotifyOfPropertyChange(() => this.ShowMainWindow); + } + } + + /// + /// Gets or sets a value indicating whether ShowOptions. + /// + public bool ShowOptions + { + get + { + return this.showOptions; + } + set + { + this.showOptions = value; + this.NotifyOfPropertyChange(() => this.ShowOptions); + } + } + + /// + /// Gets WindowTitle. + /// + public string WindowTitle + { + get + { + return "HandBrake"; + } + } + + #endregion + } +} \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 938e31719..29565cf1c 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -1,23 +1,16 @@ - @@ -34,7 +27,7 @@ - + - + @@ -628,4 +621,4 @@ - + diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs index 165e74923..2845ff0f2 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs @@ -9,12 +9,12 @@ namespace HandBrakeWPF.Views { - using System.Windows; + using System.Windows.Controls; /// /// Interaction logic for MainView.xaml /// - public partial class MainView : Window + public partial class MainView : UserControl { /// /// Initializes a new instance of the class. diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index e79fd91a7..80a97754f 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -1,9 +1,9 @@ - + xmlns:Helpers="clr-namespace:HandBrakeWPF.Helpers" > - + - - - - + + + + + + + + + - + @@ -35,7 +40,7 @@ - + @@ -367,12 +372,11 @@ - -