summaryrefslogtreecommitdiffstats
path: root/win/C#/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'win/C#/HandBrakeWPF/ViewModels')
-rw-r--r--win/C#/HandBrakeWPF/ViewModels/AboutViewModel.cs7
-rw-r--r--win/C#/HandBrakeWPF/ViewModels/AddPresetViewModel.cs6
-rw-r--r--win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs22
-rw-r--r--win/C#/HandBrakeWPF/ViewModels/OptionsViewModel.cs6
-rw-r--r--win/C#/HandBrakeWPF/ViewModels/PreviewViewModel.cs6
-rw-r--r--win/C#/HandBrakeWPF/ViewModels/QueueViewModel.cs6
-rw-r--r--win/C#/HandBrakeWPF/ViewModels/ViewModelBase.cs25
7 files changed, 72 insertions, 6 deletions
diff --git a/win/C#/HandBrakeWPF/ViewModels/AboutViewModel.cs b/win/C#/HandBrakeWPF/ViewModels/AboutViewModel.cs
index 603bfb416..b2e83cd84 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;
+
/// <summary>
/// The About View Model
/// </summary>
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 bcd55fcfc..c744d0026 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;
+
/// <summary>
/// The Add Preset View Model
/// </summary>
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 0aaa4eb84..b39906df3 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;
+
/// <summary>
/// HandBrakes Main Window
/// </summary>
@@ -55,10 +57,10 @@ namespace HandBrakeWPF.ViewModels
#endregion
- /// <summary>
- /// Initializes a new instance of the <see cref="MainViewModel"/> class.
- /// </summary>
- 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
/// <summary>
/// Gets or sets TestProperty.
/// </summary>
@@ -185,6 +186,14 @@ namespace HandBrakeWPF.ViewModels
base.Shutdown();
}
+
+ #region Menu and Taskbar
+
+ public void AboutApplication()
+ {
+ this.ShowDialog<AboutViewModel>();
+ }
+
/// <summary>
/// Shutdown the Application
/// </summary>
@@ -193,6 +202,9 @@ namespace HandBrakeWPF.ViewModels
Application.Current.Shutdown();
}
+ #endregion
+
+
#region Event Handlers
/// <summary>
/// Handle the Scan Status Changed Event.
diff --git a/win/C#/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/C#/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index 62394c167..ab7749980 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;
+
/// <summary>
/// The Options View Model
/// </summary>
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 b70d2179f..2593fa51e 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;
+
/// <summary>
/// The About View Model
/// </summary>
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 bbe013d3a..5ebfd11f7 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;
+
/// <summary>
/// The Preview View Model
/// </summary>
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 829524606..c07593b7b 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;
+
/// <summary>
/// A Base Class for the View Models which contains reusable code.
/// </summary>
public class ViewModelBase : MultiPresenterManager
{
+ protected IServiceLocator Locator { get; private set; }
+
+ public ViewModelBase(IServiceLocator locator)
+ {
+ this.Locator = locator;
+ }
+
+ public void Show<T>() where T : IPresenter
+ {
+ this.ShutdownCurrent();
+ this.Open(Locator.GetInstance<T>());
+ }
+
+ public void ShowDialog<T>() where T : IPresenter
+ {
+ Locator.GetInstance<IWindowManager>().ShowDialog(Locator.GetInstance<T>());
+ }
+
+ public void Popup<T>() where T : IPresenter
+ {
+ Locator.GetInstance<IWindowManager>().Show(Locator.GetInstance<T>());
+ }
}
}