summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
authorsr55 <[email protected]>2011-11-06 16:56:00 +0000
committersr55 <[email protected]>2011-11-06 16:56:00 +0000
commit7afefbc8814370a3c01805f693f7dfb15399453a (patch)
tree2e1140d62393623ec166553f054b016db6b76e80 /win/CS/HandBrakeWPF/ViewModels
parentd986524c71c2e41ce329e9dd5f6c78cb3d6e4de2 (diff)
WinGui: (WPF) Starting to wire up bits of the main window. (Source Scan)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4342 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs159
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs2
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs27
3 files changed, 178 insertions, 10 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 6e5153e85..2f3f3d270 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -13,7 +13,6 @@ namespace HandBrakeWPF.ViewModels
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using System.Diagnostics;
- using System.IO;
using System.Windows;
using Caliburn.Micro;
@@ -25,6 +24,8 @@ namespace HandBrakeWPF.ViewModels
using HandBrakeWPF.ViewModels.Interfaces;
+ using Ookii.Dialogs.Wpf;
+
/// <summary>
/// HandBrakes Main Window
/// </summary>
@@ -46,6 +47,11 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// The Encode Service
/// </summary>
+ private readonly IEncode encodeService;
+
+ /// <summary>
+ /// The Encode Service
+ /// </summary>
private readonly IQueueProcessor queueProcessor;
/// <summary>
@@ -68,6 +74,11 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private string programStatusLabel;
+ /// <summary>
+ /// Backing field for the scanned source.
+ /// </summary>
+ private Source scannedSource;
+
#endregion
/// <summary>
@@ -77,19 +88,32 @@ namespace HandBrakeWPF.ViewModels
/// <param name="windowManager">
/// The window manager.
/// </param>
- /// <param name="userSettingService">The User Setting Service</param>
+ /// <param name="userSettingService">
+ /// The User Setting Service
+ /// </param>
+ /// <param name="scanService">
+ /// The scan Service.
+ /// </param>
+ /// <param name="encodeService">
+ /// The encode Service.
+ /// </param>
+ /// <param name="presetService">
+ /// The preset Service.
+ /// </param>
[ImportingConstructor]
- public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
+ public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService)
: base(windowManager)
{
this.userSettingService = userSettingService;
- // 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();
+ this.scanService = scanService;
+ this.encodeService = encodeService;
+ this.presetService = presetService;
this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);
- this.presetService = new PresetService();
// Setup Properties
this.WindowTitle = "HandBrake WPF Test Application";
+ this.CurrentTask = new EncodeTask();
+ this.ScannedSource = new Source();
// Setup Events
this.scanService.ScanStared += this.ScanStared;
@@ -142,7 +166,18 @@ namespace HandBrakeWPF.ViewModels
/// Gets or sets the Last Scanned Source
/// This object contains information about the scanned source.
/// </summary>
- public Source ScannedSource { get; set; }
+ public Source ScannedSource
+ {
+ get
+ {
+ return this.scannedSource;
+ }
+ set
+ {
+ this.scannedSource = value;
+ this.NotifyOfPropertyChange("ScannedSource");
+ }
+ }
/// <summary>
/// Gets or sets the Source Label
@@ -160,6 +195,7 @@ namespace HandBrakeWPF.ViewModels
if (!object.Equals(this.sourceLabel, value))
{
this.sourceLabel = value;
+ this.NotifyOfPropertyChange("SourceLabel");
}
}
}
@@ -180,12 +216,22 @@ namespace HandBrakeWPF.ViewModels
if (!object.Equals(this.programStatusLabel, value))
{
this.programStatusLabel = value;
+ this.NotifyOfPropertyChange("ProgramStatusLabel");
}
}
}
#endregion
+ #region Load and Shutdown Handling
+ /// <summary>
+ /// Initialise this view model.
+ /// </summary>
+ public override void OnLoad()
+ {
+ // TODO
+ }
+
/// <summary>
/// Shutdown this View
/// </summary>
@@ -201,6 +247,7 @@ namespace HandBrakeWPF.ViewModels
this.queueProcessor.EncodeService.EncodeStarted -= this.EncodeStarted;
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
}
+ #endregion
#region Menu and Taskbar
@@ -228,7 +275,6 @@ namespace HandBrakeWPF.ViewModels
this.WindowManager.ShowWindow(new LogViewModel(this.WindowManager));
}
-
/// <summary>
/// Open the Queue Window.
/// </summary>
@@ -238,6 +284,74 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Launch the Help pages.
+ /// </summary>
+ public void LaunchHelp()
+ {
+ Process.Start("https://trac.handbrake.fr/wiki/HandBrakeGuide");
+ }
+
+ /// <summary>
+ /// Check for Updates.
+ /// </summary>
+ public void CheckForUpdates()
+ {
+ throw new NotImplementedException("Not Yet Implemented");
+ }
+
+ /// <summary>
+ /// Folder Scan
+ /// </summary>
+ public void FolderScan()
+ {
+ VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog { Description = "Please select a folder.", UseDescriptionForTitle = true };
+ dialog.ShowDialog();
+ this.StartScan(dialog.SelectedPath, 0);
+ }
+
+ /// <summary>
+ /// File Scan
+ /// </summary>
+ public void FileScan()
+ {
+ VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "All files (*.*)|*.*" };
+ dialog.ShowDialog();
+ this.StartScan(dialog.FileName, 0);
+ }
+
+ /// <summary>
+ /// Cancel a Scan
+ /// </summary>
+ public void CancelScan()
+ {
+ this.scanService.Stop();
+ }
+
+ /// <summary>
+ /// Start an Encode
+ /// </summary>
+ public void StartEncode()
+ {
+ throw new NotImplementedException("Not Yet Implemented");
+ }
+
+ /// <summary>
+ /// Pause an Encode
+ /// </summary>
+ public void PauseEncode()
+ {
+ throw new NotImplementedException("Not Yet Implemented");
+ }
+
+ /// <summary>
+ /// Stop an Encode.
+ /// </summary>
+ public void StopEncode()
+ {
+ throw new NotImplementedException("Not Yet Implemented");
+ }
+
+ /// <summary>
/// Shutdown the Application
/// </summary>
public void ExitApplication()
@@ -247,6 +361,27 @@ namespace HandBrakeWPF.ViewModels
#endregion
+ #region Private Worker Methods
+
+ /// <summary>
+ /// Start a Scan
+ /// </summary>
+ /// <param name="filename">
+ /// The filename.
+ /// </param>
+ /// <param name="title">
+ /// The title.
+ /// </param>
+ public void StartScan(string filename, int title)
+ {
+ // TODO
+ // 1. Disable GUI.
+ this.scanService.Scan(filename, title, this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount));
+ }
+
+ #endregion
+
+
#region Event Handlers
/// <summary>
/// Handle the Scan Status Changed Event.
@@ -275,8 +410,14 @@ namespace HandBrakeWPF.ViewModels
{
if (e.Successful)
{
- this.ScannedSource = this.scanService.SouceData;
+ this.scanService.SouceData.CopyTo(this.ScannedSource);
+ this.NotifyOfPropertyChange("ScannedSource");
+ this.NotifyOfPropertyChange("ScannedSource.Titles");
}
+
+ this.SourceLabel = "Scan Completed";
+
+ // TODO Re-enable GUI.
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index 35207e3b8..463e747ab 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -1225,7 +1225,7 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// Load User Settings
/// </summary>
- public void Load()
+ public override void OnLoad()
{
// #############################
// General
diff --git a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs
index eea335d84..f9781800c 100644
--- a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs
@@ -19,6 +19,11 @@ namespace HandBrakeWPF.ViewModels
public class ViewModelBase : Screen, IViewModelBase
{
/// <summary>
+ /// Backing Field to prevent the Load method being called more than once.
+ /// </summary>
+ private bool hasLoaded;
+
+ /// <summary>
/// Initializes a new instance of the <see cref="ViewModelBase"/> class.
/// </summary>
/// <param name="windowManager">
@@ -33,5 +38,27 @@ namespace HandBrakeWPF.ViewModels
/// Gets WindowManager.
/// </summary>
public IWindowManager WindowManager { get; private set; }
+
+ /// <summary>
+ /// Perform any Initialisation for this ViewModelBase.
+ /// </summary>
+ public void Load()
+ {
+ if (!hasLoaded)
+ {
+ hasLoaded = true;
+
+ // Initialise the ViewModels OnLoad method if it exists.
+ this.OnLoad();
+ }
+ }
+
+ /// <summary>
+ /// Load Method for the ViewModel
+ /// </summary>
+ public virtual void OnLoad()
+ {
+ // Impliment in the ViewModel to perform viewmodel specific code.
+ }
}
}