\r
namespace HandBrakeWPF\r
{\r
+ using Caliburn.PresentationFramework;\r
using Caliburn.PresentationFramework.ApplicationModel;\r
\r
+ using HandBrakeWPF.Services;\r
using HandBrakeWPF.ViewModels;\r
\r
/// <summary>\r
/// </returns>\r
protected override object CreateRootModel()\r
{\r
- var binder = (DefaultBinder)Container.GetInstance<IBinder>();\r
+ var binder = (DefaultBinder)Container.GetInstance<DefaultBinder>();\r
\r
binder.EnableBindingConventions();\r
binder.EnableMessageConventions();\r
\r
- return new MainViewModel();\r
+ return Container.GetInstance<MainViewModel>();\r
+ }\r
+\r
+\r
+ protected override void ConfigurePresentationFramework(PresentationFrameworkModule module)\r
+ {\r
+ module.UsingWindowManager<WindowManager>();\r
}\r
}\r
}\r
<Reference Include="WindowsBase" />\r
<Reference Include="PresentationCore" />\r
<Reference Include="PresentationFramework" />\r
+ <Reference Include="WPFToolkit.Extended">\r
+ <HintPath>..\libraries\WPFToolkit.Extended.dll</HintPath>\r
+ </Reference>\r
</ItemGroup>\r
<ItemGroup>\r
<ApplicationDefinition Include="App.xaml">\r
<Generator>MSBuild:Compile</Generator>\r
<SubType>Designer</SubType>\r
</ApplicationDefinition>\r
+ <Compile Include="Services\WindowManager.cs" />\r
<Compile Include="ViewModels\AboutViewModel.cs" />\r
<Compile Include="ViewModels\AddPresetViewModel.cs" />\r
<Compile Include="ViewModels\PreviewViewModel.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Folder Include="Model\" />\r
- <Folder Include="Services\" />\r
</ItemGroup>\r
<ItemGroup>\r
<Resource Include="Views\Images\ActivityWindow.png" />\r
--- /dev/null
+namespace HandBrakeWPF.Services\r
+{\r
+ using System;\r
+ using System.Windows;\r
+\r
+ using Caliburn.PresentationFramework.ApplicationModel;\r
+\r
+ public class WindowManager : DefaultWindowManager, IWindowManager\r
+ {\r
+\r
+ public WindowManager(IViewStrategy viewStrategy, IBinder binder)\r
+\r
+ : base(viewStrategy, binder)\r
+ {\r
+ }\r
+\r
+ //Display a view in a dialog (modal) window \r
+ public new bool? ShowDialog(object rootModel, object context, Action<ISubordinate, Action> handleShutdownModel)\r
+ {\r
+ var window = base.CreateWindow(rootModel, true, context, handleShutdownModel);\r
+ window.WindowStartupLocation = WindowStartupLocation.CenterScreen;\r
+ window.WindowStyle = WindowStyle.ToolWindow;\r
+ window.ResizeMode = ResizeMode.NoResize;\r
+ window.Title = ((IPresenter)rootModel).DisplayName;\r
+ return window.ShowDialog();\r
+ }\r
+\r
+ //Display a view in a popup (non-modal) window \r
+ public new void Show(object rootModel, object context, Action<ISubordinate, Action> handleShutdownModel)\r
+ {\r
+ var window = base.CreateWindow(rootModel, false, context, handleShutdownModel);\r
+ window.WindowStartupLocation = WindowStartupLocation.CenterScreen;\r
+ window.Title = ((IPresenter)rootModel).DisplayName;\r
+ window.ResizeMode = ResizeMode.NoResize;\r
+ window.Show();\r
+ }\r
+\r
+ }\r
+\r
+}\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
+ using Microsoft.Practices.ServiceLocation;\r
+\r
/// <summary>\r
/// The About View Model\r
/// </summary>\r
public class AboutViewModel : ViewModelBase\r
{\r
+ public AboutViewModel(IServiceLocator locator)\r
+ : base(locator)\r
+ {\r
+ }\r
+\r
}\r
}\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
+ using Microsoft.Practices.ServiceLocation;\r
+\r
/// <summary>\r
/// The Add Preset View Model\r
/// </summary>\r
public class AddPresetViewModel : ViewModelBase\r
{\r
+ public AddPresetViewModel(IServiceLocator locator)\r
+ : base(locator)\r
+ {\r
+ }\r
}\r
}\r
using HandBrake.ApplicationServices.Services;\r
using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
+ using Microsoft.Practices.ServiceLocation;\r
+\r
/// <summary>\r
/// HandBrakes Main Window\r
/// </summary>\r
\r
#endregion\r
\r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="MainViewModel"/> class.\r
- /// </summary>\r
- public MainViewModel()\r
+ #region Properties\r
+\r
+ public MainViewModel(IServiceLocator locator)\r
+ : base(locator)\r
{\r
// Setup Services (TODO - Bring Castle back into the project to wire these up for us)\r
this.scanService = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();\r
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;\r
}\r
\r
- #region Properties\r
/// <summary>\r
/// Gets or sets TestProperty.\r
/// </summary>\r
base.Shutdown();\r
}\r
\r
+\r
+ #region Menu and Taskbar\r
+ \r
+ public void AboutApplication()\r
+ {\r
+ this.ShowDialog<AboutViewModel>();\r
+ }\r
+ \r
/// <summary>\r
/// Shutdown the Application\r
/// </summary>\r
Application.Current.Shutdown();\r
}\r
\r
+ #endregion\r
+\r
+\r
#region Event Handlers\r
/// <summary>\r
/// Handle the Scan Status Changed Event.\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
+ using Microsoft.Practices.ServiceLocation;\r
+\r
/// <summary>\r
/// The Options View Model\r
/// </summary>\r
public class OptionsViewModel : ViewModelBase\r
{\r
+ public OptionsViewModel(IServiceLocator locator)\r
+ : base(locator)\r
+ {\r
+ }\r
}\r
}\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
+ using Microsoft.Practices.ServiceLocation;\r
+\r
/// <summary>\r
/// The About View Model\r
/// </summary>\r
public class PreviewViewModel : ViewModelBase\r
{\r
+ public PreviewViewModel(IServiceLocator locator)\r
+ : base(locator)\r
+ {\r
+ }\r
}\r
}\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
+ using Microsoft.Practices.ServiceLocation;\r
+\r
/// <summary>\r
/// The Preview View Model\r
/// </summary>\r
public class QueueViewModel : ViewModelBase\r
{\r
+ public QueueViewModel(IServiceLocator locator)\r
+ : base(locator)\r
+ {\r
+ }\r
}\r
}\r
namespace HandBrakeWPF.ViewModels\r
{\r
- using Caliburn.Core;\r
using Caliburn.PresentationFramework.ApplicationModel;\r
\r
+ using Microsoft.Practices.ServiceLocation;\r
+\r
/// <summary>\r
/// A Base Class for the View Models which contains reusable code.\r
/// </summary>\r
public class ViewModelBase : MultiPresenterManager\r
{\r
+ protected IServiceLocator Locator { get; private set; }\r
+\r
+ public ViewModelBase(IServiceLocator locator)\r
+ {\r
+ this.Locator = locator;\r
+ }\r
+\r
+ public void Show<T>() where T : IPresenter\r
+ {\r
+ this.ShutdownCurrent();\r
+ this.Open(Locator.GetInstance<T>());\r
+ }\r
+\r
+ public void ShowDialog<T>() where T : IPresenter\r
+ {\r
+ Locator.GetInstance<IWindowManager>().ShowDialog(Locator.GetInstance<T>());\r
+ }\r
+ \r
+ public void Popup<T>() where T : IPresenter\r
+ {\r
+ Locator.GetInstance<IWindowManager>().Show(Locator.GetInstance<T>());\r
+ }\r
}\r
}\r
<Window x:Class="HandBrakeWPF.Views.AboutView"\r
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r
- Title="AboutView" Height="268" Width="511">\r
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:PresentationFramework="clr-namespace:Caliburn.PresentationFramework;assembly=Caliburn.PresentationFramework" Title="AboutView" Height="268" Width="511">\r
\r
<StackPanel Orientation="Horizontal">\r
<Image Source="Images/logo64.png" Width="64" Height="64" SnapsToDevicePixels="True" Margin="10,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top" />\r
<Label Content="Copyright 2003-2011 HandBrake Team" />\r
\r
<Label Content="License:" />\r
- <TextBox IsEnabled="False" Width="380" Height="100" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Margin="10,0,10,10">\r
+ <TextBox Width="380" Height="100" IsReadOnly="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Margin="10,0,10,10">\r
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r
\r
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
\r
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
</TextBox>\r
- \r
- <Button Content="OK" HorizontalAlignment="Right" Padding="10,2" Margin="0,0,10,10"></Button>\r
+\r
+ <Button Content="OK" PresentationFramework:Message.Attach="[Event Click] = [Action Close]"\r
+ HorizontalAlignment="Right" Padding="10,2" Margin="0,0,10,10" />\r
\r
</StackPanel>\r
\r
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" \r
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" \r
- mc:Ignorable="d" \r
- d:DesignHeight="300" d:DesignWidth="300">\r
- <Grid Background="Beige">\r
+ xmlns:Controls="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"\r
+ >\r
+ \r
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">\r
+\r
+ <!-- Size Panel-->\r
+ <StackPanel Name="SizePanel" Orientation="Vertical" >\r
+ <Label Content="Size" FontWeight="Bold" />\r
+\r
+ <!-- Row 1-->\r
+ <StackPanel Orientation="Horizontal" Margin="5,0,5,0">\r
+ <Label Content="Source" Grid.Row="0" Grid.Column="0" />\r
+ <Label Content="---" Name="sourceResolution" Grid.Row="0" Grid.Column="1" />\r
+ </StackPanel>\r
+\r
+ <!-- Row 2-->\r
+ <StackPanel Orientation="Horizontal" Margin="5,0,5,0">\r
+ <Label Content="Width:" Grid.Row="1" Grid.Column="0" />\r
+ <Controls:NumericUpDown Name="width" Minimum="0" Grid.Row="1" Grid.Column="1" Width="45" />\r
+ <Label Content="Height:" Grid.Row="1" Grid.Column="2" />\r
+ <Controls:NumericUpDown Name="height" Minimum="0" Grid.Row="1" Grid.Column="3" Width="45" />\r
+ <CheckBox Content="Keep Aspect Ratio" VerticalAlignment="Center" Margin="5,0,0,0" />\r
+ </StackPanel>\r
+\r
+ <!-- Row 3-->\r
+ <Grid Margin="5,15,5,0">\r
+ <Grid.RowDefinitions>\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ </Grid.RowDefinitions>\r
+\r
+ <Grid.ColumnDefinitions>\r
+ <ColumnDefinition Width="Auto" />\r
+ <ColumnDefinition Width="Auto" />\r
+ </Grid.ColumnDefinitions>\r
+\r
+ <Label Content="Anamorphic:" Grid.Row="0" Grid.Column="0" />\r
+ <Label Content="Modulus:" Grid.Row="1" Grid.Column="0" />\r
+ <Label Content="Display Width:" Grid.Row="2" Grid.Column="0" />\r
+ <Label Content="PAR Width:" Grid.Row="3" Grid.Column="0" />\r
+ <Label Content="PAR Height:" Grid.Row="4" Grid.Column="0" />\r
+ <Label Content="Display Size:" Grid.Row="5" Grid.Column="0" />\r
+\r
+ <ComboBox Width="110" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+ <ComboBox Width="110" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+ <Controls:NumericUpDown Width="45" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+ <Controls:NumericUpDown Width="45" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+ <Controls:NumericUpDown Width="45" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+ <Label Content="---" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+ </Grid>\r
+ </StackPanel>\r
+\r
+\r
+ <StackPanel Name="CropPanel" Margin="50,0,0,0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">\r
+ <Label Content="Cropping" FontWeight="Bold" />\r
+ <RadioButton Content="Automatic" Margin="10,0,0,0"/>\r
+ <RadioButton Content="Custom" Margin="10,0,0,0" />\r
\r
- </Grid>\r
+ <Grid Margin="0,10,0,0">\r
+ <Grid.RowDefinitions>\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ </Grid.RowDefinitions>\r
+\r
+ <Grid.ColumnDefinitions>\r
+ <ColumnDefinition Width="Auto" />\r
+ <ColumnDefinition Width="Auto" />\r
+ <ColumnDefinition Width="Auto" />\r
+ <ColumnDefinition Width="Auto" />\r
+ <ColumnDefinition Width="Auto" />\r
+ </Grid.ColumnDefinitions>\r
+\r
+ <Label Content="Top" Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" />\r
+ <Label Content="Bottom" Grid.Row="4" Grid.Column="2" VerticalAlignment="Center" />\r
+ <Label Content="Left" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" />\r
+ <Label Content="Right" Grid.Row="2" Grid.Column="4" HorizontalAlignment="Center" />\r
+\r
+ <Controls:NumericUpDown Width="45" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+ <Controls:NumericUpDown Width="45" Grid.Row="3" Grid.Column="2" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+ <Controls:NumericUpDown Width="45" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+ <Controls:NumericUpDown Width="45" Grid.Row="2" Grid.Column="3" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
+\r
+ </Grid>\r
+ \r
+ \r
+ </StackPanel>\r
+\r
+\r
+ </StackPanel>\r
</UserControl>\r
</MenuItem>\r
\r
<MenuItem Header="Tools">\r
- <MenuItem Header="Show Queue" />\r
- <MenuItem Header="Activity Window" />\r
+ <MenuItem Header="Show Queue" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Activity Window" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
</MenuItem>\r
\r
<MenuItem Header="Presets">\r
- <MenuItem Header="Reset Built-in Presets" />\r
- <MenuItem Header="Delete Built-in Presets" />\r
+ <MenuItem Header="Reset Built-in Presets" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Delete Built-in Presets" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
<Separator />\r
- <MenuItem Header="Save As New Preset" />\r
- <MenuItem Header="Import" />\r
- <MenuItem Header="Export" />\r
- <MenuItem Header="Set as Default" />\r
+ <MenuItem Header="Save As New Preset" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Import" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Export" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Set as Default" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
</MenuItem>\r
\r
<MenuItem Header="Help">\r
- <MenuItem Header="HandBrake User Guide" />\r
+ <MenuItem Header="HandBrake User Guide" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
<Separator />\r
- <MenuItem Header="Check for Updates" />\r
+ <MenuItem Header="Check for Updates" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
<Separator />\r
- <MenuItem Header="About..." />\r
+ <MenuItem Header="About..." PresentationFramework:Message.Attach="[Event Click] = [Action AboutApplication]" />\r
</MenuItem>\r
</Menu>\r
\r
<!-- Tab Control -->\r
<TabControl HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="725" Height="330" Margin="10,10,10,10" Name="tabControl" >\r
<TabItem Header="Picture" Name="pictureTab">\r
- <Views:PictureSettingsView></Views:PictureSettingsView>\r
+ <Views:PictureSettingsView x:Name="pictureSettingsView"></Views:PictureSettingsView>\r
</TabItem>\r
<TabItem Header="Video Filters" Name="filtersTab">\r
<Views:FiltersView></Views:FiltersView>\r