diff options
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r-- | win/CS/HandBrakeWPF/UserSettingConstants.cs | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 103 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml | 9 |
4 files changed, 100 insertions, 17 deletions
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index 41997ffb9..575a65678 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -34,7 +34,6 @@ namespace HandBrakeWPF public const string NativeLanguage = "NativeLanguage";
public const string DubMode = "DubMode";
public const string CliExeHash = "CliExeHash";
- public const string PreviewScanCount = "previewScanCount";
public const string ClearOldLogs = "clearOldLogs";
public const string AutoNameTitleCase = "AutoNameTitleCase";
public const string AutoNameRemoveUnderscore = "AutoNameRemoveUnderscore";
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 2f3f3d270..206eeba0c 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -13,14 +13,18 @@ namespace HandBrakeWPF.ViewModels using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using System.Diagnostics;
+ using System.IO;
using System.Windows;
using Caliburn.Micro;
+ using HandBrake.ApplicationServices;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -79,6 +83,11 @@ namespace HandBrakeWPF.ViewModels /// </summary>
private Source scannedSource;
+ /// <summary>
+ /// Backing field for the selected title.
+ /// </summary>
+ private Title selectedTitle;
+
#endregion
/// <summary>
@@ -180,6 +189,27 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Gets or sets SelectedTitle.
+ /// </summary>
+ public Title SelectedTitle
+ {
+ get
+ {
+ return this.selectedTitle;
+ }
+ set
+ {
+ if (!object.Equals(this.selectedTitle, value))
+ {
+ this.selectedTitle = value;
+ // Use the Path on the Title, or the Source Scan path if one doesn't exist.
+ this.CurrentTask.Source = !string.IsNullOrEmpty(this.selectedTitle.SourceName) ? this.selectedTitle.SourceName : this.ScannedSource.ScanPath;
+ this.CurrentTask.Title = value.TitleNumber;
+ }
+ }
+ }
+
+ /// <summary>
/// Gets or sets the Source Label
/// This indicates the status of scans.
/// </summary>
@@ -332,7 +362,37 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void StartEncode()
{
- throw new NotImplementedException("Not Yet Implemented");
+ // Santiy Checking.
+ if (this.ScannedSource == null || this.CurrentTask == null)
+ {
+ throw new GeneralApplicationException("You must first scan a source.", string.Empty, null);
+ }
+
+ if (string.IsNullOrEmpty(this.CurrentTask.Destination))
+ {
+ throw new GeneralApplicationException("The Destination field was empty.", "You must first set a destination for the encoded file.", null);
+ }
+
+ if (this.queueProcessor.IsProcessing)
+ {
+ throw new GeneralApplicationException("HandBrake is already encoding.", string.Empty, null);
+ }
+
+ if (File.Exists(this.CurrentTask.Destination))
+ {
+ // TODO: File Overwrite warning.
+ }
+
+ // Create the Queue Task and Start Processing
+ QueueTask task = new QueueTask(null)
+ {
+ Destination = this.CurrentTask.Destination,
+ Task = this.CurrentTask,
+ Query = QueryGeneratorUtility.GenerateQuery(this.CurrentTask),
+ CustomQuery = false
+ };
+ this.queueProcessor.QueueManager.Add(task);
+ this.queueProcessor.Start();
}
/// <summary>
@@ -340,7 +400,7 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void PauseEncode()
{
- throw new NotImplementedException("Not Yet Implemented");
+ this.queueProcessor.Pause();
}
/// <summary>
@@ -348,7 +408,7 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void StopEncode()
{
- throw new NotImplementedException("Not Yet Implemented");
+ this.encodeService.Stop();
}
/// <summary>
@@ -361,6 +421,22 @@ namespace HandBrakeWPF.ViewModels #endregion
+ #region Main Window
+
+ /// <summary>
+ /// The Destination Path
+ /// </summary>
+ public void BrowseDestination()
+ {
+ VistaSaveFileDialog dialog = new VistaSaveFileDialog { Filter = "MP4 File (*.mp4)|Mkv File(*.mkv)" };
+ dialog.ShowDialog();
+ dialog.AddExtension = true;
+ this.CurrentTask.Destination = dialog.FileName;
+ this.NotifyOfPropertyChange("CurrentTask");
+ }
+
+ #endregion
+
#region Private Worker Methods
/// <summary>
@@ -376,12 +452,11 @@ namespace HandBrakeWPF.ViewModels {
// TODO
// 1. Disable GUI.
- this.scanService.Scan(filename, title, this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount));
+ this.scanService.Scan(filename, title, this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount));
}
#endregion
-
#region Event Handlers
/// <summary>
/// Handle the Scan Status Changed Event.
@@ -410,13 +485,13 @@ namespace HandBrakeWPF.ViewModels {
if (e.Successful)
{
- this.scanService.SouceData.CopyTo(this.ScannedSource);
- this.NotifyOfPropertyChange("ScannedSource");
- this.NotifyOfPropertyChange("ScannedSource.Titles");
+ this.scanService.SouceData.CopyTo(this.ScannedSource);
+ this.NotifyOfPropertyChange("ScannedSource");
+ this.NotifyOfPropertyChange("ScannedSource.Titles");
}
this.SourceLabel = "Scan Completed";
-
+
// TODO Re-enable GUI.
}
@@ -445,7 +520,15 @@ namespace HandBrakeWPF.ViewModels /// </param>
private void EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs e)
{
- //
+ ProgramStatusLabel =
+ string.Format(
+ "{0:00.00}%, FPS: {1:000.0}, Avg FPS: {2:000.0}, Time Remaining: {3}, Elapsed: {4:hh\\:mm\\:ss}, Pending Jobs {5}",
+ e.PercentComplete,
+ e.CurrentFrameRate,
+ e.AverageFrameRate,
+ e.EstimatedTimeLeft,
+ e.ElapsedTime,
+ this.queueProcessor.QueueManager.Count);
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 463e747ab..eedd247ce 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -1400,7 +1400,7 @@ namespace HandBrakeWPF.ViewModels this.PreviewPicturesToScan.Add(20);
this.PreviewPicturesToScan.Add(25);
this.PreviewPicturesToScan.Add(30);
- this.selectedPreviewCount = this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount);
+ this.selectedPreviewCount = this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount);
// x264 step
this.ConstantQualityGranularity.Add("1.0");
@@ -1632,7 +1632,7 @@ namespace HandBrakeWPF.ViewModels userSettingService.SetUserSetting(UserSettingConstants.PromptOnUnmatchingQueries, this.PromptOnDifferentQuery);
userSettingService.SetUserSetting(UserSettingConstants.PresetNotification, this.DisablePresetUpdateCheckNotification);
userSettingService.SetUserSetting(ASUserSettingConstants.ShowCLI, this.ShowCliWindow);
- userSettingService.SetUserSetting(UserSettingConstants.PreviewScanCount, this.SelectedPreviewCount);
+ userSettingService.SetUserSetting(ASUserSettingConstants.PreviewScanCount, this.SelectedPreviewCount);
userSettingService.SetUserSetting(ASUserSettingConstants.X264Step, double.Parse(this.SelectedGranulairty));
int value;
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 5273a008a..f85b7a1a5 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -60,12 +60,13 @@ <Separator />
- <Button Name="Start">
+ <Button Name="Start" Micro:Message.Attach="[Event Click] = [Action StartEncode]">
<StackPanel Orientation="Horizontal">
<Image Source="Images/Play.png" Height="32" Width="32" />
<Label Content="Start" Margin="8,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</Button>
+
<Button Name="AddToQueue">
<StackPanel Orientation="Horizontal">
<Image Source="Images/AddToQueue.png" Height="32" Width="32" />
@@ -111,7 +112,7 @@ <StackPanel Orientation="Horizontal">
<Label Content="Title" Margin="8,0,0,0" />
- <ComboBox Name="Titles" Margin="8,0,0,0" MinWidth="100" ItemsSource="{Binding ScannedSource.Titles}" SelectedItem="{Binding Path=CurrentTask.Title}" />
+ <ComboBox Name="Titles" Margin="8,0,0,0" MinWidth="100" ItemsSource="{Binding ScannedSource.Titles}" SelectedItem="{Binding Path=SelectedTitle}" />
<Label Content="Angle" Margin="8,0,0,0" />
<ComboBox Name="Angles" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.Angle}"/>
@@ -130,8 +131,8 @@ <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" Text="{}" />
- <Button Name="DestinationBrowser" Margin="8,0,0,0" Padding="8,0,8,0" Content="Browse" />
+ <TextBox Name="Destination" Margin="8,0,0,0" Width="600" Text="{Binding CurrentTask.Destination}" />
+ <Button Name="DestinationBrowser" Margin="8,0,0,0" Padding="8,0,8,0" Content="Browse" Micro:Message.Attach="[Event Click] = [Action BrowseDestination]" />
</StackPanel>
</StackPanel>
|