diff options
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/AboutViewModel.cs | 20 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs | 19 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs | 10 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 308 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 19 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs | 19 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 19 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs | 18 |
8 files changed, 432 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AboutViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AboutViewModel.cs new file mode 100644 index 000000000..aeb0ee822 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/AboutViewModel.cs @@ -0,0 +1,20 @@ +/* AboutViewModel.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrakeWPF.ViewModels
+{
+ using Caliburn.PresentationFramework.ApplicationModel;
+
+ /// <summary>
+ /// The About View Model
+ /// </summary>
+ public class AboutViewModel : ViewModelBase
+ {
+ public AboutViewModel(IWindowManager windowManager) : base(windowManager)
+ {
+ }
+
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs new file mode 100644 index 000000000..6a44bb1a5 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs @@ -0,0 +1,19 @@ +/* AddPresetViewModel.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrakeWPF.ViewModels
+{
+ using Caliburn.PresentationFramework.ApplicationModel;
+
+ /// <summary>
+ /// The Add Preset View Model
+ /// </summary>
+ public class AddPresetViewModel : ViewModelBase
+ {
+ public AddPresetViewModel(IWindowManager windowManager) : base(windowManager)
+ {
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs new file mode 100644 index 000000000..31ce54db0 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs @@ -0,0 +1,10 @@ +namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ public interface IMainViewModel
+ {
+ /// <summary>
+ /// Shutdown the Application
+ /// </summary>
+ void ExitApplication();
+ }
+}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs new file mode 100644 index 000000000..dc8a62a48 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -0,0 +1,308 @@ +/* MainViewModel.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrakeWPF.ViewModels
+{
+ using System;
+ using System.Collections.ObjectModel;
+ using System.ComponentModel.Composition;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Windows;
+
+ using Caliburn.PresentationFramework.ApplicationModel;
+
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// HandBrakes Main Window
+ /// </summary>
+ [Export(typeof(IMainViewModel))]
+ public class MainViewModel : ViewModelBase, IMainViewModel
+ {
+ #region Private Variables and Services
+
+ /// <summary>
+ /// The Source Scan Service.
+ /// </summary>
+ private readonly IScan scanService;
+
+ /// <summary>
+ /// The Encode Service
+ /// </summary>
+ private readonly IQueueProcessor queueProcessor;
+
+ /// <summary>
+ /// The preset service
+ /// </summary>
+ private readonly IPresetService presetService;
+
+ /// <summary>
+ /// HandBrakes Main Window Title
+ /// </summary>
+ private string windowName;
+
+ /// <summary>
+ /// The Source Label
+ /// </summary>
+ private string sourceLabel;
+
+ /// <summary>
+ /// The Toolbar Status Label
+ /// </summary>
+ private string programStatusLabel;
+
+ #endregion
+
+ #region Properties
+
+ [ImportingConstructor]
+ public MainViewModel(IWindowManager windowManager) : base(windowManager)
+ {
+ // 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.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);
+ this.presetService = new PresetService();
+
+ // Setup Properties
+ this.WindowTitle = "HandBrake WPF Test Application";
+
+ // Setup Events
+ this.scanService.ScanStared += this.ScanStared;
+ this.scanService.ScanCompleted += this.ScanCompleted;
+ this.scanService.ScanStatusChanged += this.ScanStatusChanged;
+
+ this.queueProcessor.QueueCompleted += this.QueueCompleted;
+ this.queueProcessor.QueuePaused += this.QueuePaused;
+ this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
+ this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
+ }
+
+ /// <summary>
+ /// Gets or sets TestProperty.
+ /// </summary>
+ public string WindowTitle
+ {
+ get
+ {
+ return this.windowName;
+ }
+
+ set
+ {
+ if (!object.Equals(this.windowName, value))
+ {
+ this.windowName = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets a list of presets
+ /// </summary>
+ public ObservableCollection<Preset> Presets
+ {
+ get
+ {
+ return this.presetService.Presets;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets The Current Encode Task that the user is building
+ /// </summary>
+ public EncodeTask CurrentTask { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Last Scanned Source
+ /// This object contains information about the scanned source.
+ /// </summary>
+ public Source ScannedSource { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Source Label
+ /// This indicates the status of scans.
+ /// </summary>
+ public string SourceLabel
+ {
+ get
+ {
+ return string.IsNullOrEmpty(this.sourceLabel) ? "Select 'Source' to continue" : this.sourceLabel;
+ }
+
+ set
+ {
+ if (!object.Equals(this.sourceLabel, value))
+ {
+ this.sourceLabel = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the Program Status Toolbar Label
+ /// This indicates the status of HandBrake
+ /// </summary>
+ public string ProgramStatusLabel
+ {
+ get
+ {
+ return string.IsNullOrEmpty(this.programStatusLabel) ? "Ready" : this.sourceLabel;
+ }
+
+ set
+ {
+ if (!object.Equals(this.programStatusLabel, value))
+ {
+ this.programStatusLabel = value;
+ }
+ }
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Shutdown this View
+ /// </summary>
+ public void Shutdown()
+ {
+ // Unsubscribe from Events.
+ this.scanService.ScanStared -= this.ScanStared;
+ this.scanService.ScanCompleted -= this.ScanCompleted;
+ this.scanService.ScanStatusChanged -= this.ScanStatusChanged;
+
+ this.queueProcessor.QueueCompleted -= this.QueueCompleted;
+ this.queueProcessor.QueuePaused -= this.QueuePaused;
+ this.queueProcessor.EncodeService.EncodeStarted -= this.EncodeStarted;
+ this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
+ }
+
+
+ #region Menu and Taskbar
+
+ public void AboutApplication()
+ {
+ }
+
+ /// <summary>
+ /// Shutdown the Application
+ /// </summary>
+ public void ExitApplication()
+ {
+ Application.Current.Shutdown();
+ }
+
+ #endregion
+
+
+ #region Event Handlers
+ /// <summary>
+ /// Handle the Scan Status Changed Event.
+ /// </summary>
+ /// <param name="sender">
+ /// The Sender
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs
+ /// </param>
+ private void ScanStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.ScanProgressEventArgs e)
+ {
+ this.SourceLabel = "Scanning Title " + e.CurrentTitle + " of " + e.Titles;
+ }
+
+ /// <summary>
+ /// Handle the Scan Completed Event
+ /// </summary>
+ /// <param name="sender">
+ /// The Sender
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs
+ /// </param>
+ private void ScanCompleted(object sender, HandBrake.ApplicationServices.EventArgs.ScanCompletedEventArgs e)
+ {
+ if (e.Successful)
+ {
+ this.ScannedSource = this.scanService.SouceData;
+ }
+ }
+
+ /// <summary>
+ /// Handle the Scan Started Event
+ /// </summary>
+ /// <param name="sender">
+ /// The Sender
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs
+ /// </param>
+ private void ScanStared(object sender, EventArgs e)
+ {
+ // TODO - Disable relevant parts of the UI.
+ }
+
+ /// <summary>
+ /// The Encode Status has changed Handler
+ /// </summary>
+ /// <param name="sender">
+ /// The Sender
+ /// </param>
+ /// <param name="e">
+ /// The Encode Progress Event Args
+ /// </param>
+ private void EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs e)
+ {
+ //
+ }
+
+ /// <summary>
+ /// Encode Started Handler
+ /// </summary>
+ /// <param name="sender">
+ /// The Sender
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs
+ /// </param>
+ private void EncodeStarted(object sender, EventArgs e)
+ {
+ // TODO Handle Updating the UI
+ }
+
+ /// <summary>
+ /// The Queue has been paused handler
+ /// </summary>
+ /// <param name="sender">
+ /// The Sender
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs
+ /// </param>
+ private void QueuePaused(object sender, EventArgs e)
+ {
+ // TODO Handle Updating the UI
+ }
+
+ /// <summary>
+ /// The Queue has completed handler
+ /// </summary>
+ /// <param name="sender">
+ /// The Sender
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs
+ /// </param>
+ private void QueueCompleted(object sender, EventArgs e)
+ {
+ // TODO Handle Updating the UI
+ }
+ #endregion
+ }
+}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs new file mode 100644 index 000000000..6d634bbbb --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -0,0 +1,19 @@ +/* OptionsViewModel.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrakeWPF.ViewModels
+{
+ using Caliburn.PresentationFramework.ApplicationModel;
+
+ /// <summary>
+ /// The Options View Model
+ /// </summary>
+ public class OptionsViewModel : ViewModelBase
+ {
+ public OptionsViewModel(IWindowManager windowManager) : base(windowManager)
+ {
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs new file mode 100644 index 000000000..b41fd69f5 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs @@ -0,0 +1,19 @@ +/* PreviewViewModel.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrakeWPF.ViewModels
+{
+ using Caliburn.PresentationFramework.ApplicationModel;
+
+ /// <summary>
+ /// The About View Model
+ /// </summary>
+ public class PreviewViewModel : ViewModelBase
+ {
+ public PreviewViewModel(IWindowManager windowManager) : base(windowManager)
+ {
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs new file mode 100644 index 000000000..07f3f486f --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -0,0 +1,19 @@ +/* QueueViewModel.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrakeWPF.ViewModels
+{
+ using Caliburn.PresentationFramework.ApplicationModel;
+
+ /// <summary>
+ /// The Preview View Model
+ /// </summary>
+ public class QueueViewModel : ViewModelBase
+ {
+ public QueueViewModel(IWindowManager windowManager) : base(windowManager)
+ {
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs new file mode 100644 index 000000000..b946d7c7e --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs @@ -0,0 +1,18 @@ +namespace HandBrakeWPF.ViewModels
+{
+ using Caliburn.PresentationFramework.ApplicationModel;
+ using Caliburn.PresentationFramework.Screens;
+
+ /// <summary>
+ /// A Base Class for the View Models which contains reusable code.
+ /// </summary>
+ public class ViewModelBase : Screen
+ {
+ public ViewModelBase(IWindowManager windowManager)
+ {
+ this.WindowManager = windowManager;
+ }
+
+ public IWindowManager WindowManager { get; private set; }
+ }
+}
|