-<ApplicationModel:CaliburnApplication x:Class="HandBrakeWPF.App"\r
+<Application x:Class="HandBrakeWPF.App"\r
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" \r
- xmlns:ApplicationModel="clr-namespace:Caliburn.PresentationFramework.ApplicationModel;assembly=Caliburn.PresentationFramework">\r
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:HandBrakeWPF.Services">\r
<Application.Resources>\r
- \r
+ <ResourceDictionary>\r
+ <ResourceDictionary.MergedDictionaries>\r
+ <ResourceDictionary>\r
+ <local:MefBootstrapper x:Key="bootstrapper" />\r
+ </ResourceDictionary>\r
+ </ResourceDictionary.MergedDictionaries>\r
+ </ResourceDictionary>\r
</Application.Resources>\r
-</ApplicationModel:CaliburnApplication>\r
+</Application>\r
\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
/// Interaction logic for App.xaml\r
/// </summary>\r
- public partial class App : CaliburnApplication\r
+ public partial class App \r
{\r
/*\r
* TODO:\r
* \r
*/\r
\r
-\r
/// <summary>\r
/// Initializes a new instance of the <see cref="App"/> class.\r
/// </summary>\r
public App()\r
{\r
}\r
-\r
- /// <summary>\r
- /// Create the Root View\r
- /// </summary>\r
- /// <returns>\r
- /// A MainViewMOdel\r
- /// </returns>\r
- protected override object CreateRootModel()\r
- {\r
- var binder = (DefaultBinder)Container.GetInstance<DefaultBinder>();\r
-\r
- binder.EnableBindingConventions();\r
- binder.EnableMessageConventions();\r
-\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="Caliburn.Core">\r
<HintPath>..\libraries\caliburn\Caliburn.Core.dll</HintPath>\r
</Reference>\r
- <Reference Include="Caliburn.ModelFramework">\r
- <HintPath>..\libraries\caliburn\Caliburn.ModelFramework.dll</HintPath>\r
+ <Reference Include="Caliburn.DynamicProxy">\r
+ <HintPath>..\libraries\caliburn\Caliburn.DynamicProxy.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Caliburn.FluentValidation">\r
+ <HintPath>..\libraries\caliburn\Caliburn.FluentValidation.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Caliburn.MEF">\r
+ <HintPath>..\libraries\caliburn\Caliburn.MEF.dll</HintPath>\r
</Reference>\r
<Reference Include="Caliburn.PresentationFramework">\r
<HintPath>..\libraries\caliburn\Caliburn.PresentationFramework.dll</HintPath>\r
</Reference>\r
- <Reference Include="Microsoft.Practices.ServiceLocation">\r
- <HintPath>..\libraries\caliburn\Microsoft.Practices.ServiceLocation.dll</HintPath>\r
+ <Reference Include="Caliburn.ShellFramework">\r
+ <HintPath>..\libraries\caliburn\Caliburn.ShellFramework.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Caliburn.Windsor">\r
+ <HintPath>..\libraries\caliburn\Caliburn.Windsor.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Castle.Core">\r
+ <HintPath>..\libraries\caliburn\Castle.Core.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Castle.Windsor">\r
+ <HintPath>..\libraries\caliburn\Castle.Windsor.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Common.Logging">\r
+ <HintPath>..\libraries\caliburn\Common.Logging.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="FluentValidation">\r
+ <HintPath>..\libraries\caliburn\FluentValidation.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Microsoft.Practices.Composite">\r
+ <HintPath>..\libraries\caliburn\Microsoft.Practices.Composite.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Microsoft.Practices.Composite.Presentation">\r
+ <HintPath>..\libraries\caliburn\Microsoft.Practices.Composite.Presentation.dll</HintPath>\r
</Reference>\r
<Reference Include="System" />\r
+ <Reference Include="System.ComponentModel.Composition" />\r
+ <Reference Include="System.CoreEx">\r
+ <HintPath>..\libraries\caliburn\System.CoreEx.dll</HintPath>\r
+ </Reference>\r
<Reference Include="System.Data" />\r
+ <Reference Include="System.Interactive">\r
+ <HintPath>..\libraries\caliburn\System.Interactive.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="System.Reactive">\r
+ <HintPath>..\libraries\caliburn\System.Reactive.dll</HintPath>\r
+ </Reference>\r
<Reference Include="System.Xml" />\r
<Reference Include="Microsoft.CSharp" />\r
<Reference Include="System.Core" />\r
<Generator>MSBuild:Compile</Generator>\r
<SubType>Designer</SubType>\r
</ApplicationDefinition>\r
- <Compile Include="Services\WindowManager.cs" />\r
+ <Compile Include="Services\MefBootstrapper.cs" />\r
<Compile Include="ViewModels\AboutViewModel.cs" />\r
<Compile Include="ViewModels\AddPresetViewModel.cs" />\r
+ <Compile Include="ViewModels\Interfaces\IMainViewModel.cs" />\r
<Compile Include="ViewModels\PreviewViewModel.cs" />\r
<Compile Include="ViewModels\QueueViewModel.cs" />\r
<Compile Include="ViewModels\OptionsViewModel.cs" />\r
--- /dev/null
+namespace HandBrakeWPF.Services \r
+{\r
+ using System.ComponentModel.Composition.Hosting;\r
+ using System.Linq;\r
+\r
+ using Caliburn.Core.InversionOfControl;\r
+ using Caliburn.MEF;\r
+ using Caliburn.PresentationFramework.ApplicationModel;\r
+\r
+ using HandBrakeWPF.ViewModels.Interfaces;\r
+\r
+ public class MefBootstrapper : Bootstrapper<IMainViewModel> \r
+ {\r
+ protected override IServiceLocator CreateContainer() \r
+ {\r
+ var container = new CompositionContainer(new AggregateCatalog(SelectAssemblies().Select(x => new AssemblyCatalog(x))));\r
+\r
+ return new MEFAdapter(container);\r
+ }\r
+ }\r
+}
\ No newline at end of file
+++ /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
+ using Caliburn.PresentationFramework.ApplicationModel;\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
+ public AboutViewModel(IWindowManager windowManager) : base(windowManager)\r
{\r
}\r
\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
- using Microsoft.Practices.ServiceLocation;\r
+ using Caliburn.PresentationFramework.ApplicationModel;\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
+ public AddPresetViewModel(IWindowManager windowManager) : base(windowManager)\r
{\r
}\r
}\r
--- /dev/null
+namespace HandBrakeWPF.ViewModels.Interfaces\r
+{\r
+ public interface IMainViewModel\r
+ {\r
+ /// <summary>\r
+ /// Shutdown the Application\r
+ /// </summary>\r
+ void ExitApplication();\r
+ }\r
+}
\ No newline at end of file
{\r
using System;\r
using System.Collections.ObjectModel;\r
+ using System.ComponentModel.Composition;\r
using System.Diagnostics;\r
using System.IO;\r
using System.Windows;\r
\r
+ using Caliburn.PresentationFramework.ApplicationModel;\r
+\r
using HandBrake.ApplicationServices.Model;\r
using HandBrake.ApplicationServices.Parsing;\r
using HandBrake.ApplicationServices.Services;\r
using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
- using Microsoft.Practices.ServiceLocation;\r
+ using HandBrakeWPF.ViewModels.Interfaces;\r
\r
/// <summary>\r
/// HandBrakes Main Window\r
/// </summary>\r
- public class MainViewModel : ViewModelBase\r
+ [Export(typeof(IMainViewModel))]\r
+ public class MainViewModel : ViewModelBase, IMainViewModel\r
{\r
#region Private Variables and Services\r
\r
\r
#region Properties\r
\r
- public MainViewModel(IServiceLocator locator)\r
- : base(locator)\r
+ [ImportingConstructor]\r
+ public MainViewModel(IWindowManager windowManager) : base(windowManager) \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
if (!object.Equals(this.windowName, value))\r
{\r
this.windowName = value;\r
- this.NotifyOfPropertyChange("TestProperty");\r
}\r
}\r
}\r
if (!object.Equals(this.sourceLabel, value))\r
{\r
this.sourceLabel = value;\r
- this.NotifyOfPropertyChange("SourceLabel");\r
}\r
}\r
}\r
if (!object.Equals(this.programStatusLabel, value))\r
{\r
this.programStatusLabel = value;\r
- this.NotifyOfPropertyChange("ProgramStatusLabel");\r
}\r
}\r
}\r
/// <summary>\r
/// Shutdown this View\r
/// </summary>\r
- public override void Shutdown()\r
+ public void Shutdown()\r
{\r
// Unsubscribe from Events.\r
this.scanService.ScanStared -= this.ScanStared;\r
this.queueProcessor.QueuePaused -= this.QueuePaused;\r
this.queueProcessor.EncodeService.EncodeStarted -= this.EncodeStarted;\r
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;\r
-\r
- // Shutdown Normally\r
- base.Shutdown();\r
}\r
\r
\r
\r
public void AboutApplication()\r
{\r
- this.ShowDialog<AboutViewModel>();\r
}\r
\r
/// <summary>\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
- using Microsoft.Practices.ServiceLocation;\r
+ using Caliburn.PresentationFramework.ApplicationModel;\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
+ public OptionsViewModel(IWindowManager windowManager) : base(windowManager)\r
{\r
}\r
}\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
- using Microsoft.Practices.ServiceLocation;\r
+ using Caliburn.PresentationFramework.ApplicationModel;\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
+ public PreviewViewModel(IWindowManager windowManager) : base(windowManager)\r
{\r
}\r
}\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
- using Microsoft.Practices.ServiceLocation;\r
+ using Caliburn.PresentationFramework.ApplicationModel;\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
+ public QueueViewModel(IWindowManager windowManager) : base(windowManager)\r
{\r
}\r
}\r
namespace HandBrakeWPF.ViewModels\r
{\r
using Caliburn.PresentationFramework.ApplicationModel;\r
-\r
- using Microsoft.Practices.ServiceLocation;\r
+ using Caliburn.PresentationFramework.Screens;\r
\r
/// <summary>\r
/// A Base Class for the View Models which contains reusable code.\r
/// </summary>\r
- public class ViewModelBase : MultiPresenterManager\r
+ public class ViewModelBase : Screen\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
+ public ViewModelBase(IWindowManager windowManager)\r
{\r
- this.ShutdownCurrent();\r
- this.Open(Locator.GetInstance<T>());\r
+ this.WindowManager = windowManager;\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
+ public IWindowManager WindowManager { get; private set; }\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" xmlns:PresentationFramework="clr-namespace:Caliburn.PresentationFramework;assembly=Caliburn.PresentationFramework" 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" xmlns:RoutedMessaging="clr-namespace:Caliburn.PresentationFramework.RoutedMessaging;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
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" PresentationFramework:Message.Attach="[Event Click] = [Action Close]"\r
+ <Button Content="OK" RoutedMessaging:Message.Attach="[Event Click] = [Action Close]"\r
HorizontalAlignment="Right" Padding="10,2" Margin="0,0,10,10" />\r
\r
</StackPanel>\r
<Window x:Class="HandBrakeWPF.Views.MainView"\r
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" \r
- xmlns:PresentationFramework="clr-namespace:Caliburn.PresentationFramework;assembly=Caliburn.PresentationFramework" \r
xmlns:Views="clr-namespace:HandBrakeWPF.Views"\r
xmlns:Data="clr-namespace:System.Windows.Data;assembly=PresentationFramework" \r
+ xmlns:RoutedMessaging="clr-namespace:Caliburn.PresentationFramework.RoutedMessaging;assembly=Caliburn.PresentationFramework" \r
Title="{Data:Binding Path=WindowTitle}" Height="655" Width="1015" FontSize="11">\r
\r
<Grid>\r
<Menu Height="23" VerticalAlignment="Top" HorizontalAlignment="Stretch">\r
<MenuItem Header="File">\r
<MenuItem Header="Cancel Scan" />\r
- <MenuItem Header="Exit" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Exit" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
</MenuItem>\r
\r
<MenuItem Header="Tools">\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 Header="Show Queue" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Activity Window" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
</MenuItem>\r
\r
<MenuItem Header="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
+ <MenuItem Header="Reset Built-in Presets" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Delete Built-in Presets" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
<Separator />\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 Header="Save As New Preset" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Import" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Export" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Set as Default" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
</MenuItem>\r
\r
<MenuItem Header="Help">\r
- <MenuItem Header="HandBrake User Guide" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="HandBrake User Guide" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
<Separator />\r
- <MenuItem Header="Check for Updates" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
+ <MenuItem Header="Check for Updates" RoutedMessaging:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
<Separator />\r
- <MenuItem Header="About..." PresentationFramework:Message.Attach="[Event Click] = [Action AboutApplication]" />\r
+ <MenuItem Header="About..." RoutedMessaging:Message.Attach="[Event Click] = [Action AboutApplication]" />\r
</MenuItem>\r
</Menu>\r
\r