From: sr55 Date: Sat, 26 Feb 2011 16:24:38 +0000 (+0000) Subject: WinGui: X-Git-Url: http://git.osdn.jp/view?p=handbrake-jp%2Fhandbrake-jp-git.git;a=commitdiff_plain;h=e83c570f4856660bbb120998546333aa4308a43f WinGui: - Started designing the Picture Settings Panel - Added a WindowManager. git-svn-id: svn://localhost/HandBrake/trunk@3810 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/win/C#/HandBrakeWPF/App.xaml.cs b/win/C#/HandBrakeWPF/App.xaml.cs index ae8d6a35..c0ed622a 100644 --- a/win/C#/HandBrakeWPF/App.xaml.cs +++ b/win/C#/HandBrakeWPF/App.xaml.cs @@ -5,8 +5,10 @@ namespace HandBrakeWPF { + using Caliburn.PresentationFramework; using Caliburn.PresentationFramework.ApplicationModel; + using HandBrakeWPF.Services; using HandBrakeWPF.ViewModels; /// @@ -37,12 +39,18 @@ namespace HandBrakeWPF /// protected override object CreateRootModel() { - var binder = (DefaultBinder)Container.GetInstance(); + var binder = (DefaultBinder)Container.GetInstance(); binder.EnableBindingConventions(); binder.EnableMessageConventions(); - return new MainViewModel(); + return Container.GetInstance(); + } + + + protected override void ConfigurePresentationFramework(PresentationFrameworkModule module) + { + module.UsingWindowManager(); } } } diff --git a/win/C#/HandBrakeWPF/HandBrakeWPF.csproj b/win/C#/HandBrakeWPF/HandBrakeWPF.csproj index efcf37bb..031f56ba 100644 --- a/win/C#/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/C#/HandBrakeWPF/HandBrakeWPF.csproj @@ -61,12 +61,16 @@ + + ..\libraries\WPFToolkit.Extended.dll + MSBuild:Compile Designer + @@ -205,7 +209,6 @@ - diff --git a/win/C#/HandBrakeWPF/Services/WindowManager.cs b/win/C#/HandBrakeWPF/Services/WindowManager.cs new file mode 100644 index 00000000..903597bd --- /dev/null +++ b/win/C#/HandBrakeWPF/Services/WindowManager.cs @@ -0,0 +1,40 @@ +namespace HandBrakeWPF.Services +{ + using System; + using System.Windows; + + using Caliburn.PresentationFramework.ApplicationModel; + + public class WindowManager : DefaultWindowManager, IWindowManager + { + + public WindowManager(IViewStrategy viewStrategy, IBinder binder) + + : base(viewStrategy, binder) + { + } + + //Display a view in a dialog (modal) window + public new bool? ShowDialog(object rootModel, object context, Action handleShutdownModel) + { + var window = base.CreateWindow(rootModel, true, context, handleShutdownModel); + window.WindowStartupLocation = WindowStartupLocation.CenterScreen; + window.WindowStyle = WindowStyle.ToolWindow; + window.ResizeMode = ResizeMode.NoResize; + window.Title = ((IPresenter)rootModel).DisplayName; + return window.ShowDialog(); + } + + //Display a view in a popup (non-modal) window + public new void Show(object rootModel, object context, Action handleShutdownModel) + { + var window = base.CreateWindow(rootModel, false, context, handleShutdownModel); + window.WindowStartupLocation = WindowStartupLocation.CenterScreen; + window.Title = ((IPresenter)rootModel).DisplayName; + window.ResizeMode = ResizeMode.NoResize; + window.Show(); + } + + } + +} diff --git a/win/C#/HandBrakeWPF/ViewModels/AboutViewModel.cs b/win/C#/HandBrakeWPF/ViewModels/AboutViewModel.cs index 603bfb41..b2e83cd8 100644 --- a/win/C#/HandBrakeWPF/ViewModels/AboutViewModel.cs +++ b/win/C#/HandBrakeWPF/ViewModels/AboutViewModel.cs @@ -5,10 +5,17 @@ namespace HandBrakeWPF.ViewModels { + using Microsoft.Practices.ServiceLocation; + /// /// The About View Model /// public class AboutViewModel : ViewModelBase { + public AboutViewModel(IServiceLocator locator) + : base(locator) + { + } + } } diff --git a/win/C#/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/C#/HandBrakeWPF/ViewModels/AddPresetViewModel.cs index bcd55fcf..c744d002 100644 --- a/win/C#/HandBrakeWPF/ViewModels/AddPresetViewModel.cs +++ b/win/C#/HandBrakeWPF/ViewModels/AddPresetViewModel.cs @@ -5,10 +5,16 @@ namespace HandBrakeWPF.ViewModels { + using Microsoft.Practices.ServiceLocation; + /// /// The Add Preset View Model /// public class AddPresetViewModel : ViewModelBase { + public AddPresetViewModel(IServiceLocator locator) + : base(locator) + { + } } } diff --git a/win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs index 0aaa4eb8..b39906df 100644 --- a/win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -16,6 +16,8 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Services; using HandBrake.ApplicationServices.Services.Interfaces; + using Microsoft.Practices.ServiceLocation; + /// /// HandBrakes Main Window /// @@ -55,10 +57,10 @@ namespace HandBrakeWPF.ViewModels #endregion - /// - /// Initializes a new instance of the class. - /// - public MainViewModel() + #region Properties + + public MainViewModel(IServiceLocator locator) + : base(locator) { // Setup Services (TODO - Bring Castle back into the project to wire these up for us) this.scanService = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService(); @@ -79,7 +81,6 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged; } - #region Properties /// /// Gets or sets TestProperty. /// @@ -185,6 +186,14 @@ namespace HandBrakeWPF.ViewModels base.Shutdown(); } + + #region Menu and Taskbar + + public void AboutApplication() + { + this.ShowDialog(); + } + /// /// Shutdown the Application /// @@ -193,6 +202,9 @@ namespace HandBrakeWPF.ViewModels Application.Current.Shutdown(); } + #endregion + + #region Event Handlers /// /// Handle the Scan Status Changed Event. diff --git a/win/C#/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/C#/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 62394c16..ab774998 100644 --- a/win/C#/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/C#/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -5,10 +5,16 @@ namespace HandBrakeWPF.ViewModels { + using Microsoft.Practices.ServiceLocation; + /// /// The Options View Model /// public class OptionsViewModel : ViewModelBase { + public OptionsViewModel(IServiceLocator locator) + : base(locator) + { + } } } diff --git a/win/C#/HandBrakeWPF/ViewModels/PreviewViewModel.cs b/win/C#/HandBrakeWPF/ViewModels/PreviewViewModel.cs index b70d2179..2593fa51 100644 --- a/win/C#/HandBrakeWPF/ViewModels/PreviewViewModel.cs +++ b/win/C#/HandBrakeWPF/ViewModels/PreviewViewModel.cs @@ -5,10 +5,16 @@ namespace HandBrakeWPF.ViewModels { + using Microsoft.Practices.ServiceLocation; + /// /// The About View Model /// public class PreviewViewModel : ViewModelBase { + public PreviewViewModel(IServiceLocator locator) + : base(locator) + { + } } } diff --git a/win/C#/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/C#/HandBrakeWPF/ViewModels/QueueViewModel.cs index bbe013d3..5ebfd11f 100644 --- a/win/C#/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/C#/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -5,10 +5,16 @@ namespace HandBrakeWPF.ViewModels { + using Microsoft.Practices.ServiceLocation; + /// /// The Preview View Model /// public class QueueViewModel : ViewModelBase { + public QueueViewModel(IServiceLocator locator) + : base(locator) + { + } } } diff --git a/win/C#/HandBrakeWPF/ViewModels/ViewModelBase.cs b/win/C#/HandBrakeWPF/ViewModels/ViewModelBase.cs index 82952460..c07593b7 100644 --- a/win/C#/HandBrakeWPF/ViewModels/ViewModelBase.cs +++ b/win/C#/HandBrakeWPF/ViewModels/ViewModelBase.cs @@ -1,12 +1,35 @@ namespace HandBrakeWPF.ViewModels { - using Caliburn.Core; using Caliburn.PresentationFramework.ApplicationModel; + using Microsoft.Practices.ServiceLocation; + /// /// A Base Class for the View Models which contains reusable code. /// public class ViewModelBase : MultiPresenterManager { + protected IServiceLocator Locator { get; private set; } + + public ViewModelBase(IServiceLocator locator) + { + this.Locator = locator; + } + + public void Show() where T : IPresenter + { + this.ShutdownCurrent(); + this.Open(Locator.GetInstance()); + } + + public void ShowDialog() where T : IPresenter + { + Locator.GetInstance().ShowDialog(Locator.GetInstance()); + } + + public void Popup() where T : IPresenter + { + Locator.GetInstance().Show(Locator.GetInstance()); + } } } diff --git a/win/C#/HandBrakeWPF/Views/AboutView.xaml b/win/C#/HandBrakeWPF/Views/AboutView.xaml index 155a5f07..030623f9 100644 --- a/win/C#/HandBrakeWPF/Views/AboutView.xaml +++ b/win/C#/HandBrakeWPF/Views/AboutView.xaml @@ -1,7 +1,6 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:PresentationFramework="clr-namespace:Caliburn.PresentationFramework;assembly=Caliburn.PresentationFramework" Title="AboutView" Height="268" Width="511"> @@ -11,15 +10,16 @@