<Compile Include="Model\Encoding\SubtitleType.cs" />\r
<Compile Include="Parsing\AudioTrack.cs" />\r
<Compile Include="Parsing\Chapter.cs" />\r
- <Compile Include="Parsing\DVD.cs" />\r
+ <Compile Include="Parsing\Source.cs" />\r
<Compile Include="Parsing\Parser.cs" />\r
<Compile Include="Parsing\Subtitle.cs" />\r
<Compile Include="Parsing\Title.cs" />\r
/// </summary>\r
public int Title { get; set; }\r
\r
+ /// <summary>\r
+ /// Gets or sets the Angle\r
+ /// </summary>\r
+ public int Angle { get; set; }\r
+\r
/// <summary>\r
/// Gets or sets PointToPointMode.\r
/// </summary>\r
-/* DVD.cs $ This file is part of the HandBrake source code.\r
+/* Source.cs $ This file is part of the HandBrake source code.\r
Homepage: <http://handbrake.fr>.\r
It may be used under the terms of the GNU General Public License. */\r
\r
/// <summary>\r
/// An object representing a scanned DVD\r
/// </summary>\r
- public class DVD\r
+ public class Source\r
{\r
/// <summary>\r
- /// Initializes a new instance of the <see cref="DVD"/> class. \r
+ /// Initializes a new instance of the <see cref="Source"/> class. \r
/// Default constructor for this object\r
/// </summary>\r
- public DVD()\r
+ public Source()\r
{\r
Titles = new List<Title>();\r
}\r
/// <returns>\r
/// A DVD object which contains a list of title inforamtion\r
/// </returns>\r
- public static DVD Parse(StreamReader output)\r
+ public static Source Parse(StreamReader output)\r
{\r
- var thisDVD = new DVD();\r
+ var thisDVD = new Source();\r
\r
while (!output.EndOfStream)\r
{\r
/// <summary>\r
/// Gets the Souce Data.\r
/// </summary>\r
- DVD SouceData { get; }\r
+ Source SouceData { get; }\r
\r
/// <summary>\r
/// Gets ActivityLog.\r
/// <summary>\r
/// Gets the Souce Data.\r
/// </summary>\r
- public DVD SouceData { get; private set; }\r
+ public Source SouceData { get; private set; }\r
\r
/// <summary>\r
/// Gets ActivityLog.\r
/// </param>\r
private void InstanceScanCompleted(object sender, EventArgs e)\r
{\r
- this.SouceData = new DVD { Titles = ConvertTitles(this.instance.Titles) };\r
+ this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles) };\r
\r
IsScanning = false;\r
\r
/// <summary>\r
/// Gets the Souce Data.\r
/// </summary>\r
- public DVD SouceData { get; private set; }\r
+ public Source SouceData { get; private set; }\r
\r
/// <summary>\r
/// Gets ActivityLog.\r
\r
this.readData = new Parser(this.hbProc.StandardError.BaseStream);\r
this.readData.OnScanProgress += this.OnScanProgress;\r
- this.SouceData = DVD.Parse(this.readData);\r
+ this.SouceData = Source.Parse(this.readData);\r
\r
// Write the Buffer out to file.\r
using (StreamWriter scanLog = new StreamWriter(dvdInfoPath))\r
<SubType>Code</SubType>\r
</Compile>\r
<Compile Include="ViewModels\MainViewModel.cs" />\r
+ <Compile Include="ViewModels\ViewModelBase.cs" />\r
<Compile Include="Views\MainView.xaml.cs">\r
<DependentUpon>MainView.xaml</DependentUpon>\r
</Compile>\r
\r
namespace HandBrakeWPF.ViewModels\r
{\r
- using Caliburn.Core;\r
+ using System;\r
+ using System.Diagnostics;\r
+ using System.IO;\r
+ using System.Windows;\r
+\r
+ using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Parsing;\r
+ using HandBrake.ApplicationServices.Services;\r
+ using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
/// <summary>\r
/// HandBrakes Main Window\r
/// </summary>\r
- public class MainViewModel : PropertyChangedBase\r
+ public class MainViewModel : ViewModelBase\r
{\r
+ #region Private Variables and Services\r
+\r
+ /// <summary>\r
+ /// The Source Scan Service.\r
+ /// </summary>\r
+ private readonly IScan scanService;\r
+\r
+ /// <summary>\r
+ /// The Encode Service\r
+ /// </summary>\r
+ private readonly IQueueProcessor queueProcessor;\r
+\r
/// <summary>\r
/// HandBrakes Main Window Title\r
/// </summary>\r
private string windowName;\r
\r
+ /// <summary>\r
+ /// The Source Label\r
+ /// </summary>\r
+ private string sourceLabel;\r
+\r
+ /// <summary>\r
+ /// The Toolbar Status Label\r
+ /// </summary>\r
+ private string programStatusLabel;\r
+\r
+ #endregion\r
+\r
/// <summary>\r
/// Initializes a new instance of the <see cref="MainViewModel"/> class.\r
/// </summary>\r
public MainViewModel()\r
{\r
+ // Setup Services\r
+ this.scanService = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();\r
+ this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);\r
+\r
+ // Setup Properties\r
this.WindowTitle = "HandBrake WPF Test Application";\r
+\r
+ // Setup Events\r
+ this.scanService.ScanStared += this.ScanStared;\r
+ this.scanService.ScanCompleted += this.ScanCompleted;\r
+ this.scanService.ScanStatusChanged += this.ScanStatusChanged;\r
+\r
+ this.queueProcessor.QueueCompleted += this.QueueCompleted;\r
+ this.queueProcessor.QueuePaused += this.QueuePaused;\r
+ this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;\r
+ this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;\r
}\r
\r
+ #region Properties\r
/// <summary>\r
/// Gets or sets TestProperty.\r
/// </summary>\r
}\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// Gets or sets The Current Encode Task that the user is building\r
+ /// </summary>\r
+ public EncodeTask CurrentTask { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the Last Scanned Source\r
+ /// This object contains information about the scanned source.\r
+ /// </summary>\r
+ public Source ScannedSource { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the Source Label\r
+ /// This indicates the status of scans.\r
+ /// </summary>\r
+ public string SourceLabel\r
+ {\r
+ get\r
+ {\r
+ return string.IsNullOrEmpty(this.sourceLabel) ? "Select 'Source' to continue" : this.sourceLabel;\r
+ }\r
+\r
+ set\r
+ {\r
+ if (!object.Equals(this.sourceLabel, value))\r
+ {\r
+ this.sourceLabel = value;\r
+ this.NotifyOfPropertyChange("SourceLabel");\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the Program Status Toolbar Label\r
+ /// This indicates the status of HandBrake\r
+ /// </summary>\r
+ public string ProgramStatusLabel\r
+ {\r
+ get\r
+ {\r
+ return string.IsNullOrEmpty(this.programStatusLabel) ? "Ready" : this.sourceLabel;\r
+ }\r
+\r
+ set\r
+ {\r
+ if (!object.Equals(this.programStatusLabel, value))\r
+ {\r
+ this.programStatusLabel = value;\r
+ this.NotifyOfPropertyChange("ProgramStatusLabel");\r
+ }\r
+ }\r
+ }\r
+\r
+ #endregion\r
+\r
+ /// <summary>\r
+ /// Shutdown this View\r
+ /// </summary>\r
+ public override void Shutdown()\r
+ {\r
+ // Unsubscribe from Events.\r
+ this.scanService.ScanStared -= this.ScanStared;\r
+ this.scanService.ScanCompleted -= this.ScanCompleted;\r
+ this.scanService.ScanStatusChanged -= this.ScanStatusChanged;\r
+\r
+ this.queueProcessor.QueueCompleted -= this.QueueCompleted;\r
+ this.queueProcessor.QueuePaused -= this.QueuePaused;\r
+ this.queueProcessor.EncodeService.EncodeStarted -= this.EncodeStarted;\r
+ this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;\r
+\r
+ // Shutdown Normally\r
+ base.Shutdown();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Shutdown the Application\r
+ /// </summary>\r
+ public void ExitApplication()\r
+ {\r
+ Application.Current.Shutdown();\r
+ }\r
+\r
+ #region Event Handlers\r
+ /// <summary>\r
+ /// Handle the Scan Status Changed Event.\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The Sender\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The EventArgs\r
+ /// </param>\r
+ private void ScanStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.ScanProgressEventArgs e)\r
+ {\r
+ this.SourceLabel = "Scanning Title " + e.CurrentTitle + " of " + e.Titles;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Handle the Scan Completed Event\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The Sender\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The EventArgs\r
+ /// </param>\r
+ private void ScanCompleted(object sender, HandBrake.ApplicationServices.EventArgs.ScanCompletedEventArgs e)\r
+ {\r
+ if (e.Successful)\r
+ {\r
+ this.ScannedSource = this.scanService.SouceData;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Handle the Scan Started Event\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The Sender\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The EventArgs\r
+ /// </param>\r
+ private void ScanStared(object sender, EventArgs e)\r
+ {\r
+ // TODO - Disable relevant parts of the UI.\r
+ }\r
+\r
+ /// <summary>\r
+ /// The Encode Status has changed Handler\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The Sender\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The Encode Progress Event Args\r
+ /// </param>\r
+ private void EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs e)\r
+ {\r
+ //\r
+ }\r
+\r
+ /// <summary>\r
+ /// Encode Started Handler\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The Sender\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The EventArgs\r
+ /// </param>\r
+ private void EncodeStarted(object sender, EventArgs e)\r
+ {\r
+ // TODO Handle Updating the UI\r
+ }\r
+\r
+ /// <summary>\r
+ /// The Queue has been paused handler\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The Sender\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The EventArgs\r
+ /// </param>\r
+ private void QueuePaused(object sender, EventArgs e)\r
+ {\r
+ // TODO Handle Updating the UI\r
+ }\r
+\r
+ /// <summary>\r
+ /// The Queue has completed handler\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The Sender\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The EventArgs\r
+ /// </param>\r
+ private void QueueCompleted(object sender, EventArgs e)\r
+ {\r
+ // TODO Handle Updating the UI\r
+ }\r
+ #endregion\r
}\r
-}\r
+}
\ No newline at end of file
--- /dev/null
+namespace HandBrakeWPF.ViewModels\r
+{\r
+ using Caliburn.Core;\r
+ using Caliburn.PresentationFramework.ApplicationModel;\r
+\r
+ /// <summary>\r
+ /// A Base Class for the View Models which contains reusable code.\r
+ /// </summary>\r
+ public class ViewModelBase : MultiPresenterManager\r
+ {\r
+ }\r
+}\r
<Window x:Class="HandBrakeWPF.Views.MainView"\r
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r
- Title="{Binding Path=WindowTitle}" Height="645" Width="1015" FontSize="11">\r
+ 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">\r
\r
<Grid>\r
<Grid.RowDefinitions>\r
<Menu Height="23" Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Stretch">\r
<MenuItem Header="File">\r
<MenuItem Header="Cancel Scan" />\r
- <MenuItem Header="Exit" />\r
+ <MenuItem Header="Exit" PresentationFramework:Message.Attach="[Event Click] = [Action ExitApplication]" />\r
</MenuItem>\r
\r
<MenuItem Header="Tools">\r
<StackPanel Grid.Row="2" Margin="10,5,10,5" MaxWidth="725" Width="725" HorizontalAlignment="Left">\r
<StackPanel Orientation="Horizontal">\r
<Label Content="Source" FontWeight="Bold" />\r
- <Label Content="Select 'Source' to continue" />\r
+ <Label Content="{Binding Path=SourceLabel}" />\r
</StackPanel>\r
\r
<StackPanel Orientation="Horizontal">\r
<Label Content="Title" Margin="8,0,0,0" />\r
- <ComboBox Name="Titles" Margin="8,0,0,0" MinWidth="100" />\r
+ <ComboBox Name="Titles" Margin="8,0,0,0" MinWidth="100" SelectedItem="{Binding Path=CurrentTask.Title}" />\r
\r
<Label Content="Angle" Margin="8,0,0,0" />\r
- <ComboBox Name="Angles" Margin="8,0,0,0" MinWidth="60"/>\r
+ <ComboBox Name="Angles" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.Angle}"/>\r
\r
- <ComboBox Name="PointToPointMode" Margin="8,0,0,0" MinWidth="80" />\r
- <ComboBox Name="StartPoint" Margin="8,0,0,0" MinWidth="60" />\r
+ <ComboBox Name="PointToPointMode" Margin="8,0,0,0" MinWidth="80" SelectedItem="{Binding Path=CurrentTask.PointToPointMode}" />\r
+ <ComboBox Name="StartPoint" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.StartPoint}" />\r
<Label Content="through" Margin="8,0,0,0" />\r
- <ComboBox Name="EndPoint" Margin="8,0,0,0" MinWidth="60" />\r
+ <ComboBox Name="EndPoint" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.EndPoint}" />\r
<Label Content="Duration" Margin="8,0,0,0" />\r
<Label Content="--:--:--" Margin="8,0,0,0" />\r
</StackPanel>\r
<Label Content="Destination" FontWeight="Bold" />\r
<StackPanel Orientation="Horizontal">\r
<Label Content="File" Margin="8,0,0,0" />\r
- <TextBox Name="Destination" Margin="8,0,0,0" Width="600" />\r
+ <TextBox Name="Destination" Margin="8,0,0,0" Width="600" Text="{}" />\r
<Button Name="DestinationBrowser" Margin="8,0,0,0" Padding="8,0,8,0" Content="Browse" />\r
</StackPanel>\r
</StackPanel>\r
<Label Content="Output Settings (Preset: None)" FontWeight="Bold" />\r
<StackPanel Orientation="Horizontal">\r
<Label Content="Container" Margin="8,0,0,0" />\r
- <ComboBox Name="Container" Margin="8,0,0,0" MinWidth="100" />\r
+ <ComboBox Name="Container" Margin="8,0,0,0" MinWidth="100" SelectedItem="{Binding Path=CurrentTask.OutputFormat}" />\r
\r
- <CheckBox Name="LargeFileMp4" Content="Large File Size" VerticalAlignment="Center" Margin="8,0,0,0" />\r
- <CheckBox Name="WebOptimized" Content="Web Optimized" VerticalAlignment="Center" Margin="8,0,0,0" />\r
- <CheckBox Name="iPod5G" Content="iPod 5G Support" VerticalAlignment="Center" Margin="8,0,0,0" />\r
+ <CheckBox Name="LargeFileMp4" Content="Large File Size" IsChecked="{Binding Path=CurrentTask.LargeFile}" VerticalAlignment="Center" Margin="8,0,0,0" />\r
+ <CheckBox Name="WebOptimized" Content="Web Optimized" IsChecked="{Binding Path=CurrentTask.OptimizeMP4}" VerticalAlignment="Center" Margin="8,0,0,0" />\r
+ <CheckBox Name="iPod5G" Content="iPod 5G Support" IsChecked="{Binding Path=CurrentTask.IPod5GSupport}" VerticalAlignment="Center" Margin="8,0,0,0" />\r
</StackPanel>\r
</StackPanel>\r
\r
\r
<!-- Status Bar -->\r
<StatusBar Grid.Row="6" Height="30" VerticalAlignment="Bottom">\r
- <Label Content="Ready" FontSize="11" />\r
+ <Label Content="{Binding Path=ProgramStatusLabel}" FontSize="10" VerticalAlignment="Center" />\r
</StatusBar>\r
\r
</Grid>\r
private string dvdDrivePath;\r
private string dvdDriveLabel;\r
private Preset currentlySelectedPreset;\r
- private DVD currentSource;\r
+ private Source currentSource;\r
\r
private IScan SourceScan;\r
private List<DriveInformation> drives;\r