summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj3
-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
-rw-r--r--win/CS/HandBrakeWPF/Views/MainView.xaml17
5 files changed, 193 insertions, 15 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index 48710e7df..6cdf5c969 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -48,6 +48,9 @@
<Reference Include="Common.Logging">
<HintPath>..\libraries\caliburn\Common.Logging.dll</HintPath>
</Reference>
+ <Reference Include="EagleBoost.Wpf.Presentation">
+ <HintPath>..\libraries\EagleBoost.Wpf.Presentation.dll</HintPath>
+ </Reference>
<Reference Include="Ookii.Dialogs.Wpf">
<HintPath>..\libraries\OokiiDialogs\Ookii.Dialogs.Wpf.dll</HintPath>
</Reference>
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.
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml
index 1994f7434..5273a008a 100644
--- a/win/CS/HandBrakeWPF/Views/MainView.xaml
+++ b/win/CS/HandBrakeWPF/Views/MainView.xaml
@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Data="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" xmlns:Controls="clr-namespace:HandBrakeWPF.Views.Controls"
- Title="{Data:Binding Path=WindowTitle}" Height="655" Width="1015" FontSize="11">
+ Title="{Data:Binding Path=WindowTitle}" Height="655" Width="1015" FontSize="11" Background="#FFF0F0F0">
<Window.Resources>
<Style TargetType="Button">
@@ -21,7 +21,8 @@
<!-- Main Menu -->
<Menu Height="23" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<MenuItem Header="File">
- <MenuItem Header="Cancel Scan" />
+ <MenuItem Header="Cancel Scan" Micro:Message.Attach="[Event Click] = [Action CancelScan]" />
+ <Separator />
<MenuItem Header="Exit" Micro:Message.Attach="[Event Click] = [Action ExitApplication]" />
</MenuItem>
@@ -33,9 +34,9 @@
</MenuItem>
<MenuItem Header="Help">
- <MenuItem Header="HandBrake User Guide" Micro:Message.Attach="[Event Click] = [Action ExitApplication]" />
+ <MenuItem Header="HandBrake User Guide" Micro:Message.Attach="[Event Click] = [Action LaunchHelp]" />
<Separator />
- <MenuItem Header="Check for Updates" Micro:Message.Attach="[Event Click] = [Action ExitApplication]" />
+ <MenuItem Header="Check for Updates" Micro:Message.Attach="[Event Click] = [Action CheckForUpdates]" />
<Separator />
<MenuItem Header="About..." Micro:Message.Attach="[Event Click] = [Action OpenAboutApplication]" />
</MenuItem>
@@ -49,6 +50,12 @@
<Image Source="Images/Movies.png" Height="32" Width="32" />
<Label Content="Source" Margin="8,0,0,0" VerticalAlignment="Center" />
</StackPanel>
+ <Button.ContextMenu>
+ <ContextMenu >
+ <MenuItem Header="Open Folder" Micro:Message.Attach="[Event Click] = [Action FolderScan]"/>
+ <MenuItem Header="Open File" Micro:Message.Attach="[Event Click] = [Action FileScan]"/>
+ </ContextMenu>
+ </Button.ContextMenu>
</Button>
<Separator />
@@ -104,7 +111,7 @@
<StackPanel Orientation="Horizontal">
<Label Content="Title" Margin="8,0,0,0" />
- <ComboBox Name="Titles" Margin="8,0,0,0" MinWidth="100" SelectedItem="{Binding Path=CurrentTask.Title}" />
+ <ComboBox Name="Titles" Margin="8,0,0,0" MinWidth="100" ItemsSource="{Binding ScannedSource.Titles}" SelectedItem="{Binding Path=CurrentTask.Title}" />
<Label Content="Angle" Margin="8,0,0,0" />
<ComboBox Name="Angles" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.Angle}"/>