summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj2
-rw-r--r--win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs5
-rw-r--r--win/C#/HandBrake.ApplicationServices/Parsing/Source.cs (renamed from win/C#/HandBrake.ApplicationServices/Parsing/DVD.cs)12
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs2
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/LibScan.cs4
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/ScanService.cs4
-rw-r--r--win/C#/HandBrakeWPF/HandBrakeWPF.csproj1
-rw-r--r--win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs239
-rw-r--r--win/C#/HandBrakeWPF/ViewModels/ViewModelBase.cs12
-rw-r--r--win/C#/HandBrakeWPF/Views/MainView.xaml29
-rw-r--r--win/C#/frmMain.cs2
11 files changed, 281 insertions, 31 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 57c3ca4ce..d45228ab2 100644
--- a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -114,7 +114,7 @@
<Compile Include="Model\Encoding\SubtitleType.cs" />
<Compile Include="Parsing\AudioTrack.cs" />
<Compile Include="Parsing\Chapter.cs" />
- <Compile Include="Parsing\DVD.cs" />
+ <Compile Include="Parsing\Source.cs" />
<Compile Include="Parsing\Parser.cs" />
<Compile Include="Parsing\Subtitle.cs" />
<Compile Include="Parsing\Title.cs" />
diff --git a/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs b/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs
index dfc0fbf08..a735902c1 100644
--- a/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs
+++ b/win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs
@@ -33,6 +33,11 @@ namespace HandBrake.ApplicationServices.Model
public int Title { get; set; }
/// <summary>
+ /// Gets or sets the Angle
+ /// </summary>
+ public int Angle { get; set; }
+
+ /// <summary>
/// Gets or sets PointToPointMode.
/// </summary>
public PointToPointMode PointToPointMode { get; set; }
diff --git a/win/C#/HandBrake.ApplicationServices/Parsing/DVD.cs b/win/C#/HandBrake.ApplicationServices/Parsing/Source.cs
index 40b1c4e5f..0ed9c0033 100644
--- a/win/C#/HandBrake.ApplicationServices/Parsing/DVD.cs
+++ b/win/C#/HandBrake.ApplicationServices/Parsing/Source.cs
@@ -1,4 +1,4 @@
-/* DVD.cs $ This file is part of the HandBrake source code.
+/* Source.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. */
@@ -10,13 +10,13 @@ namespace HandBrake.ApplicationServices.Parsing
/// <summary>
/// An object representing a scanned DVD
/// </summary>
- public class DVD
+ public class Source
{
/// <summary>
- /// Initializes a new instance of the <see cref="DVD"/> class.
+ /// Initializes a new instance of the <see cref="Source"/> class.
/// Default constructor for this object
/// </summary>
- public DVD()
+ public Source()
{
Titles = new List<Title>();
}
@@ -35,9 +35,9 @@ namespace HandBrake.ApplicationServices.Parsing
/// <returns>
/// A DVD object which contains a list of title inforamtion
/// </returns>
- public static DVD Parse(StreamReader output)
+ public static Source Parse(StreamReader output)
{
- var thisDVD = new DVD();
+ var thisDVD = new Source();
while (!output.EndOfStream)
{
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
index b05390301..6cbce5273 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
@@ -60,7 +60,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
/// <summary>
/// Gets the Souce Data.
/// </summary>
- DVD SouceData { get; }
+ Source SouceData { get; }
/// <summary>
/// Gets ActivityLog.
diff --git a/win/C#/HandBrake.ApplicationServices/Services/LibScan.cs b/win/C#/HandBrake.ApplicationServices/Services/LibScan.cs
index 50be6aa07..ea27ffdf0 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/LibScan.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/LibScan.cs
@@ -97,7 +97,7 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// Gets the Souce Data.
/// </summary>
- public DVD SouceData { get; private set; }
+ public Source SouceData { get; private set; }
/// <summary>
/// Gets ActivityLog.
@@ -179,7 +179,7 @@ namespace HandBrake.ApplicationServices.Services
/// </param>
private void InstanceScanCompleted(object sender, EventArgs e)
{
- this.SouceData = new DVD { Titles = ConvertTitles(this.instance.Titles) };
+ this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles) };
IsScanning = false;
diff --git a/win/C#/HandBrake.ApplicationServices/Services/ScanService.cs b/win/C#/HandBrake.ApplicationServices/Services/ScanService.cs
index 9b85740cd..2529f528b 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/ScanService.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/ScanService.cs
@@ -86,7 +86,7 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// Gets the Souce Data.
/// </summary>
- public DVD SouceData { get; private set; }
+ public Source SouceData { get; private set; }
/// <summary>
/// Gets ActivityLog.
@@ -227,7 +227,7 @@ namespace HandBrake.ApplicationServices.Services
this.readData = new Parser(this.hbProc.StandardError.BaseStream);
this.readData.OnScanProgress += this.OnScanProgress;
- this.SouceData = DVD.Parse(this.readData);
+ this.SouceData = Source.Parse(this.readData);
// Write the Buffer out to file.
using (StreamWriter scanLog = new StreamWriter(dvdInfoPath))
diff --git a/win/C#/HandBrakeWPF/HandBrakeWPF.csproj b/win/C#/HandBrakeWPF/HandBrakeWPF.csproj
index cd2eef097..512833dc5 100644
--- a/win/C#/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/C#/HandBrakeWPF/HandBrakeWPF.csproj
@@ -72,6 +72,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="ViewModels\MainViewModel.cs" />
+ <Compile Include="ViewModels\ViewModelBase.cs" />
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
diff --git a/win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs
index 8008064f3..4b2180dd3 100644
--- a/win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/C#/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -5,26 +5,74 @@
namespace HandBrakeWPF.ViewModels
{
- using Caliburn.Core;
+ using System;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Windows;
+
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
/// <summary>
/// HandBrakes Main Window
/// </summary>
- public class MainViewModel : PropertyChangedBase
+ public class MainViewModel : ViewModelBase
{
+ #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>
/// 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
+
+ /// <summary>
/// Initializes a new instance of the <see cref="MainViewModel"/> class.
/// </summary>
public MainViewModel()
{
+ // Setup Services
+ this.scanService = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();
+ this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);
+
+ // 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;
}
+ #region Properties
/// <summary>
/// Gets or sets TestProperty.
/// </summary>
@@ -44,5 +92,190 @@ namespace HandBrakeWPF.ViewModels
}
}
}
+
+ /// <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;
+ this.NotifyOfPropertyChange("SourceLabel");
+ }
+ }
+ }
+
+ /// <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;
+ this.NotifyOfPropertyChange("ProgramStatusLabel");
+ }
+ }
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Shutdown this View
+ /// </summary>
+ public override 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;
+
+ // Shutdown Normally
+ base.Shutdown();
+ }
+
+ /// <summary>
+ /// Shutdown the Application
+ /// </summary>
+ public void ExitApplication()
+ {
+ Application.Current.Shutdown();
+ }
+
+ #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/C#/HandBrakeWPF/ViewModels/ViewModelBase.cs b/win/C#/HandBrakeWPF/ViewModels/ViewModelBase.cs
new file mode 100644
index 000000000..829524606
--- /dev/null
+++ b/win/C#/HandBrakeWPF/ViewModels/ViewModelBase.cs
@@ -0,0 +1,12 @@
+namespace HandBrakeWPF.ViewModels
+{
+ using Caliburn.Core;
+ using Caliburn.PresentationFramework.ApplicationModel;
+
+ /// <summary>
+ /// A Base Class for the View Models which contains reusable code.
+ /// </summary>
+ public class ViewModelBase : MultiPresenterManager
+ {
+ }
+}
diff --git a/win/C#/HandBrakeWPF/Views/MainView.xaml b/win/C#/HandBrakeWPF/Views/MainView.xaml
index 493cb357a..86f807854 100644
--- a/win/C#/HandBrakeWPF/Views/MainView.xaml
+++ b/win/C#/HandBrakeWPF/Views/MainView.xaml
@@ -1,7 +1,6 @@
<Window x:Class="HandBrakeWPF.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="{Binding Path=WindowTitle}" Height="645" Width="1015" FontSize="11">
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:PresentationFramework="clr-namespace:Caliburn.PresentationFramework;assembly=Caliburn.PresentationFramework" Title="{Binding Path=WindowTitle}" Height="655" Width="1015" FontSize="11">
<Grid>
<Grid.RowDefinitions>
@@ -19,7 +18,7 @@
<Menu Height="23" Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<MenuItem Header="File">
<MenuItem Header="Cancel Scan" />
- <MenuItem Header="Exit" />
+ <MenuItem Header="Exit" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />
</MenuItem>
<MenuItem Header="Tools">
@@ -98,20 +97,20 @@
<StackPanel Grid.Row="2" Margin="10,5,10,5" MaxWidth="725" Width="725" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal">
<Label Content="Source" FontWeight="Bold" />
- <Label Content="Select 'Source' to continue" />
+ <Label Content="{Binding Path=SourceLabel}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Title" Margin="8,0,0,0" />
- <ComboBox Name="Titles" Margin="8,0,0,0" MinWidth="100" />
+ <ComboBox Name="Titles" Margin="8,0,0,0" MinWidth="100" SelectedItem="{Binding Path=CurrentTask.Title}" />
<Label Content="Angle" Margin="8,0,0,0" />
- <ComboBox Name="Angles" Margin="8,0,0,0" MinWidth="60"/>
+ <ComboBox Name="Angles" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.Angle}"/>
- <ComboBox Name="PointToPointMode" Margin="8,0,0,0" MinWidth="80" />
- <ComboBox Name="StartPoint" Margin="8,0,0,0" MinWidth="60" />
+ <ComboBox Name="PointToPointMode" Margin="8,0,0,0" MinWidth="80" SelectedItem="{Binding Path=CurrentTask.PointToPointMode}" />
+ <ComboBox Name="StartPoint" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.StartPoint}" />
<Label Content="through" Margin="8,0,0,0" />
- <ComboBox Name="EndPoint" Margin="8,0,0,0" MinWidth="60" />
+ <ComboBox Name="EndPoint" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.EndPoint}" />
<Label Content="Duration" Margin="8,0,0,0" />
<Label Content="--:--:--" Margin="8,0,0,0" />
</StackPanel>
@@ -122,7 +121,7 @@
<Label Content="Destination" FontWeight="Bold" />
<StackPanel Orientation="Horizontal">
<Label Content="File" Margin="8,0,0,0" />
- <TextBox Name="Destination" Margin="8,0,0,0" Width="600" />
+ <TextBox Name="Destination" Margin="8,0,0,0" Width="600" Text="{}" />
<Button Name="DestinationBrowser" Margin="8,0,0,0" Padding="8,0,8,0" Content="Browse" />
</StackPanel>
</StackPanel>
@@ -132,11 +131,11 @@
<Label Content="Output Settings (Preset: None)" FontWeight="Bold" />
<StackPanel Orientation="Horizontal">
<Label Content="Container" Margin="8,0,0,0" />
- <ComboBox Name="Container" Margin="8,0,0,0" MinWidth="100" />
+ <ComboBox Name="Container" Margin="8,0,0,0" MinWidth="100" SelectedItem="{Binding Path=CurrentTask.OutputFormat}" />
- <CheckBox Name="LargeFileMp4" Content="Large File Size" VerticalAlignment="Center" Margin="8,0,0,0" />
- <CheckBox Name="WebOptimized" Content="Web Optimized" VerticalAlignment="Center" Margin="8,0,0,0" />
- <CheckBox Name="iPod5G" Content="iPod 5G Support" VerticalAlignment="Center" Margin="8,0,0,0" />
+ <CheckBox Name="LargeFileMp4" Content="Large File Size" IsChecked="{Binding Path=CurrentTask.LargeFile}" VerticalAlignment="Center" Margin="8,0,0,0" />
+ <CheckBox Name="WebOptimized" Content="Web Optimized" IsChecked="{Binding Path=CurrentTask.OptimizeMP4}" VerticalAlignment="Center" Margin="8,0,0,0" />
+ <CheckBox Name="iPod5G" Content="iPod 5G Support" IsChecked="{Binding Path=CurrentTask.IPod5GSupport}" VerticalAlignment="Center" Margin="8,0,0,0" />
</StackPanel>
</StackPanel>
@@ -164,7 +163,7 @@
<!-- Status Bar -->
<StatusBar Grid.Row="6" Height="30" VerticalAlignment="Bottom">
- <Label Content="Ready" FontSize="11" />
+ <Label Content="{Binding Path=ProgramStatusLabel}" FontSize="10" VerticalAlignment="Center" />
</StatusBar>
</Grid>
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index b4feee8f2..f1462e83d 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -55,7 +55,7 @@ namespace Handbrake
private string dvdDrivePath;
private string dvdDriveLabel;
private Preset currentlySelectedPreset;
- private DVD currentSource;
+ private Source currentSource;
private IScan SourceScan;
private List<DriveInformation> drives;