summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/Functions/QueryGenerator.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Parsing/Source.cs7
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/LibScan.cs14
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/ScanService.cs1
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs324
-rw-r--r--win/CS/HandBrakeWPF/UserSettingConstants.cs1
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs103
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs4
-rw-r--r--win/CS/HandBrakeWPF/Views/MainView.xaml9
-rw-r--r--win/CS/UserSettingConstants.cs1
-rw-r--r--win/CS/frmMain.cs2
-rw-r--r--win/CS/frmOptions.cs4
-rw-r--r--win/CS/frmPreview.cs3
14 files changed, 415 insertions, 65 deletions
diff --git a/win/CS/Functions/QueryGenerator.cs b/win/CS/Functions/QueryGenerator.cs
index 7bf0dd01b..af51a442d 100644
--- a/win/CS/Functions/QueryGenerator.cs
+++ b/win/CS/Functions/QueryGenerator.cs
@@ -192,7 +192,7 @@ namespace Handbrake.Functions
query += string.Format(" --start-at frame:{0} --stop-at frame:{1}", mainWindow.drop_chapterStart.Text, calculatedDuration);
break;
case 3: // Preview
- query += " --previews " + UserSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount) + " ";
+ query += " --previews " + UserSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount) + " ";
query += " --start-at-preview " + preview;
query += " --stop-at duration:" + duration + " ";
break;
diff --git a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs
index a7510b5fb..0600de5d0 100644
--- a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs
+++ b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs
@@ -114,5 +114,10 @@ namespace HandBrake.ApplicationServices
/// Min Title Scan Duration
/// </summary>
public const string MinScanDuration = "MinTitleScanDuration";
+
+ /// <summary>
+ /// Preview Scan Count
+ /// </summary>
+ public const string PreviewScanCount = "previewScanCount";
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs
index a79da7040..696063f0f 100644
--- a/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs
+++ b/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs
@@ -22,6 +22,12 @@ namespace HandBrake.ApplicationServices.Parsing
}
/// <summary>
+ /// Gets or sets ScanPath.
+ /// The Path used by the Scan Service.
+ /// </summary>
+ public string ScanPath { get; set; }
+
+ /// <summary>
/// Gets or sets Titles. A list of titles from the source
/// </summary>
public List<Title> Titles { get; set; }
@@ -59,6 +65,7 @@ namespace HandBrake.ApplicationServices.Parsing
public void CopyTo(Source source)
{
source.Titles = this.Titles;
+ source.ScanPath = this.ScanPath;
}
}
} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
index 1dab6aa6c..033f16018 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
@@ -50,6 +50,11 @@ namespace HandBrake.ApplicationServices.Services
/// </summary>
private readonly StringBuilder logging;
+ /// <summary>
+ /// The Current source scan path.
+ /// </summary>
+ private string currentSourceScanPath;
+
#endregion
/// <summary>
@@ -168,14 +173,17 @@ namespace HandBrake.ApplicationServices.Services
{
this.logging.Clear();
+ string source = sourcePath.ToString().EndsWith("\\") ? sourcePath.ToString() : "\"" + sourcePath + "\"";
+ currentSourceScanPath = source;
+
IsScanning = true;
if (this.ScanStared != null)
this.ScanStared(this, new EventArgs());
if (title != 0)
- instance.StartScan(sourcePath.ToString(), previewCount, title);
+ instance.StartScan(source, previewCount, title);
else
- instance.StartScan(sourcePath.ToString(), previewCount);
+ instance.StartScan(source, previewCount);
}
catch (Exception exc)
{
@@ -200,7 +208,7 @@ namespace HandBrake.ApplicationServices.Services
/// </param>
private void InstanceScanCompleted(object sender, EventArgs e)
{
- this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles) };
+ this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = currentSourceScanPath};
IsScanning = false;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
index 3b2543264..781aa40ec 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
@@ -231,6 +231,7 @@ namespace HandBrake.ApplicationServices.Services
this.readData = new Parser(this.hbProc.StandardError.BaseStream);
this.readData.OnScanProgress += this.OnScanProgress;
this.SouceData = Source.Parse(this.readData);
+ this.SouceData.ScanPath = source;
// Write the Buffer out to file.
using (StreamWriter scanLog = new StreamWriter(dvdInfoPath))
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
index 07da56ec0..36e7f0525 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
@@ -13,39 +13,78 @@ namespace HandBrake.ApplicationServices.Utilities
using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
- /*
- * TODO:
- * 1. Handle Subittles
- * 2. Wireupt he Generate Query Methods.
- * 3. Handle Settings Better.
- * 4. Test and bug fix.
- */
-
/// <summary>
/// Generate a CLI Query for HandBrakeCLI
/// </summary>
public class QueryGeneratorUtility
{
- public static string GenerateQuery()
+ /// <summary>
+ /// Backing field for the user settings service.
+ /// </summary>
+ private static readonly IUserSettingService UserSettingService = ServiceManager.UserSettingService;
+
+ /// <summary>
+ /// Generate a CLI Query for an EncodeTask Model object
+ /// </summary>
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query
+ /// </returns>
+ public static string GenerateQuery(EncodeTask task)
{
- throw new NotImplementedException("This class hasn't been finished yet.");
string query = string.Empty;
- return query;
+ query += SourceQuery(task, null, null);
+ query += DestinationQuery(task);
+ query += GenerateTabbedComponentsQuery(task, true);
+ return query;
}
- public static string GeneratePreviewQuery()
+ /// <summary>
+ /// Generate a Query for a Preview Encode
+ /// </summary>
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ /// <param name="duration">
+ /// The duration.
+ /// </param>
+ /// <param name="startAtPreview">
+ /// The start At Preview.
+ /// </param>
+ /// <returns>
+ /// A Cli query suitable for generating a preview video.
+ /// </returns>
+ public static string GeneratePreviewQuery(EncodeTask task, int duration, string startAtPreview)
{
- throw new NotImplementedException("This class hasn't been finished yet.");
string query = string.Empty;
+ query += SourceQuery(task, duration, startAtPreview);
+ query += DestinationQuery(task);
+ query += GenerateTabbedComponentsQuery(task, true);
+
return query;
}
#region Individual Query Sections
- private static string GenerateTabbedComponentsQuery(EncodeTask task, bool filters, int width, int height, int verbose, bool noDvdNav, double x264Step)
+ /// <summary>
+ /// Generate a Query from an Encode Task Object.
+ /// </summary>
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ /// <param name="enableFilters">
+ /// The enableFilters.
+ /// </param>
+ /// <returns>
+ /// The CLI query for the Tabbed section of the main window UI
+ /// </returns>
+ private static string GenerateTabbedComponentsQuery(EncodeTask task, bool enableFilters)
{
string query = string.Empty;
@@ -53,14 +92,14 @@ namespace HandBrake.ApplicationServices.Utilities
query += OutputSettingsQuery(task);
// Filters Panel
- if (filters)
+ if (enableFilters)
query += FiltersQuery(task);
// Picture Settings
- query += PictureSettingsQuery(task, width, height);
+ query += PictureSettingsQuery(task);
// Video Settings
- query += VideoSettingsQuery(task, x264Step);
+ query += VideoSettingsQuery(task);
// Audio Settings
query += AudioSettingsQuery(task);
@@ -71,16 +110,31 @@ namespace HandBrake.ApplicationServices.Utilities
// Chapter Markers
query += ChapterMarkersQuery(task);
- // X264 Panel
- query += X264Query(task);
+ // Advanced Panel
+ query += AdvancedQuery(task);
// Extra Settings
- query += ExtraSettings(verbose.ToString(), noDvdNav);
+ query += ExtraSettings();
return query;
}
- private static string SourceQuery(EncodeTask task, int mode, int duration, string preview, string previewTotal)
+ /// <summary>
+ /// Generate the Command Line Arguments for the Source
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <param name="duration">
+ /// The duration.
+ /// </param>
+ /// <param name="preview">
+ /// The preview.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
+ private static string SourceQuery(EncodeTask task, int? duration, string preview)
{
string query = string.Empty;
@@ -107,17 +161,24 @@ namespace HandBrake.ApplicationServices.Utilities
query += string.Format(" --start-at frame:{0} --stop-at frame:{1}", task.StartPoint, calculatedDuration);
break;
case PointToPointMode.Preview: // Preview
- query += " --previews " + previewTotal + " ";
+ query += " --previews " + UserSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount) + " ";
query += " --start-at-preview " + preview;
query += " --stop-at duration:" + duration + " ";
break;
- default:
- break;
}
return query;
}
+ /// <summary>
+ /// Generate the Command Line Arguments for the Destination File
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
private static string DestinationQuery(EncodeTask task)
{
string query = string.Empty;
@@ -130,6 +191,15 @@ namespace HandBrake.ApplicationServices.Utilities
return query;
}
+ /// <summary>
+ /// Generate the Command Line Arguments for the Output Settings
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
private static string OutputSettingsQuery(EncodeTask task)
{
string query = string.Empty;
@@ -149,7 +219,16 @@ namespace HandBrake.ApplicationServices.Utilities
return query;
}
- private static string PictureSettingsQuery(EncodeTask task, int width, int height)
+ /// <summary>
+ /// Generate the Command Line Arguments for the Picture Settings tab
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
+ private static string PictureSettingsQuery(EncodeTask task)
{
string query = string.Empty;
@@ -162,7 +241,10 @@ namespace HandBrake.ApplicationServices.Utilities
else if (task.Height.HasValue) query += string.Format(" -h {0}", task.Height);
}
- query += string.Format(" --crop {0}:{1}:{2}:{3}", task.Cropping.Top, task.Cropping.Bottom, task.Cropping.Left, task.Cropping.Right);
+ if (task.HasCropping)
+ {
+ query += string.Format(" --crop {0}:{1}:{2}:{3}", task.Cropping.Top, task.Cropping.Bottom, task.Cropping.Left, task.Cropping.Right);
+ }
switch (task.Anamorphic)
{
@@ -190,9 +272,17 @@ namespace HandBrake.ApplicationServices.Utilities
return query;
}
+ /// <summary>
+ /// Generate the Command Line Arguments for the Filters Tab
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
private static string FiltersQuery(EncodeTask task)
{
-
string query = string.Empty;
switch (task.Detelecine) // DeTelecine
@@ -274,7 +364,16 @@ namespace HandBrake.ApplicationServices.Utilities
return query;
}
- private static string VideoSettingsQuery(EncodeTask task, double x264CqStep)
+ /// <summary>
+ /// Generate the Command Line Arguments for the Video Settings Tab
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
+ private static string VideoSettingsQuery(EncodeTask task)
{
string query = string.Empty;
@@ -294,6 +393,8 @@ namespace HandBrake.ApplicationServices.Utilities
break;
}
+ double x264CqStep = UserSettingService.GetUserSetting<double>(ASUserSettingConstants.X264Step);
+
switch (task.VideoEncodeRateType)
{
case VideoEncodeRateType.AverageBitrate:
@@ -319,7 +420,6 @@ namespace HandBrake.ApplicationServices.Utilities
break;
}
break;
-
}
if (task.TwoPass)
@@ -350,6 +450,15 @@ namespace HandBrake.ApplicationServices.Utilities
return query;
}
+ /// <summary>
+ /// Generate the Command Line Arguments for the Audio Settings Tab
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
private static string AudioSettingsQuery(EncodeTask task)
{
string query = string.Empty;
@@ -494,12 +603,127 @@ namespace HandBrake.ApplicationServices.Utilities
return query;
}
+ /// <summary>
+ /// Generate the Command Line Arguments for the Subtitles Tab
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
private static string SubtitlesQuery(EncodeTask task)
{
- // TODO
- return string.Empty;
+ string query = string.Empty;
+ if (task.SubtitleTracks.Count != 0)
+ {
+ // BitMap and CC's
+ string subtitleTracks = String.Empty;
+ string subtitleForced = String.Empty;
+ string subtitleBurn = String.Empty;
+ string subtitleDefault = String.Empty;
+
+ // SRT
+ string srtFile = String.Empty;
+ string srtCodeset = String.Empty;
+ string srtOffset = String.Empty;
+ string srtLang = String.Empty;
+ string srtDefault = String.Empty;
+ int srtCount = 0;
+ int subCount = 0;
+
+ // Languages
+ IDictionary<string, string> langMap = LanguageUtilities.MapLanguages();
+
+ foreach (SubtitleTrack item in task.SubtitleTracks)
+ {
+ string itemToAdd;
+
+ if (item.IsSrtSubtitle) // We have an SRT file
+ {
+ srtCount++; // SRT track id.
+
+ srtLang += srtLang == string.Empty ? langMap[item.SrtLang] : "," + langMap[item.SrtLang];
+ srtCodeset += srtCodeset == string.Empty ? item.SrtCharCode : "," + item.SrtCharCode;
+
+ if (item.Default)
+ srtDefault = srtCount.ToString();
+
+ itemToAdd = item.SrtPath;
+ srtFile += srtFile == string.Empty ? itemToAdd : "," + itemToAdd;
+
+ itemToAdd = item.SrtOffset.ToString();
+ srtOffset += srtOffset == string.Empty ? itemToAdd : "," + itemToAdd;
+ }
+ else // We have Bitmap or CC
+ {
+ subCount++;
+
+ // Find --subtitle <string>
+ if (item.Track.Contains("Foreign Audio Search"))
+ itemToAdd = "scan";
+ else
+ {
+ string[] tempSub = item.Track.Split(' ');
+ itemToAdd = tempSub[0];
+ }
+
+ subtitleTracks += subtitleTracks == string.Empty ? itemToAdd : "," + itemToAdd;
+
+ // Find --subtitle-forced
+ if (item.Forced)
+ subtitleForced += subtitleForced == string.Empty ? subCount.ToString() : "," + subCount;
+
+ // Find --subtitle-burn
+ if (item.Burned)
+ subtitleBurn = subCount.ToString();
+
+ // Find --subtitle-default
+ if (item.Default)
+ subtitleDefault = subCount.ToString();
+ }
+ }
+
+ // Build The CLI Subtitles Query
+ if (subtitleTracks != string.Empty)
+ {
+ query += " --subtitle " + subtitleTracks;
+
+ if (subtitleForced != string.Empty)
+ query += " --subtitle-forced=" + subtitleForced;
+ if (subtitleBurn != string.Empty)
+ query += " --subtitle-burn=" + subtitleBurn;
+ if (subtitleDefault != string.Empty)
+ query += " --subtitle-default=" + subtitleDefault;
+ }
+
+ if (srtFile != string.Empty) // SRTs
+ {
+ query += " --srt-file " + "\"" + srtFile + "\"";
+
+ if (srtCodeset != string.Empty)
+ query += " --srt-codeset " + srtCodeset;
+ if (srtOffset != string.Empty)
+ query += " --srt-offset " + srtOffset;
+ if (srtLang != string.Empty)
+ query += " --srt-lang " + srtLang;
+ if (srtDefault != string.Empty)
+ query += " --srt-default=" + srtDefault;
+ }
+ }
+
+ return query;
}
+ /// <summary>
+ /// Generate the Command Line Arguments for the Chapter markers tab
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
private static string ChapterMarkersQuery(EncodeTask task)
{
string query = string.Empty;
@@ -529,20 +753,45 @@ namespace HandBrake.ApplicationServices.Utilities
return query;
}
- private static string X264Query(EncodeTask task)
+ /// <summary>
+ /// Generate the Command Line Arguments for the Advanced Encoder Options
+ /// </summary>
+ /// <param name="task">
+ /// The encode task.
+ /// </param>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
+ private static string AdvancedQuery(EncodeTask task)
{
+ if (task.VideoEncoder == VideoEncoder.X264)
+ {
+ return string.Format(
+ " --x264-preset={0} --x264-tune={1} --x264-profile={2}",
+ task.x264Preset.ToString().ToLower().Replace(" ", string.Empty),
+ task.X264Tune.ToString().ToLower().Replace(" ", string.Empty),
+ task.x264Profile.ToString().ToLower().Replace(" ", string.Empty));
+ }
+
return string.IsNullOrEmpty(task.AdvancedEncoderOptions) ? string.Empty : string.Format(" -x {0}", task.AdvancedEncoderOptions);
}
- private static string ExtraSettings(string verboseLevel, bool disableLibDvdNav)
+ /// <summary>
+ /// Generate the Command Line Arguments for any additional advanced options.
+ /// </summary>
+ /// <returns>
+ /// A Cli Query as a string
+ /// </returns>
+ private static string ExtraSettings()
{
string query = string.Empty;
// Verbosity Level
- query += string.Format(" --verbose= {0}", string.IsNullOrEmpty(verboseLevel) ? "1" : verboseLevel);
+ int verbosity = UserSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity);
+ query += string.Format(" --verbose= {0}", verbosity);
// LibDVDNav
- if (disableLibDvdNav)
+ if (UserSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav))
query += " --no-dvdnav";
return query;
@@ -558,7 +807,7 @@ namespace HandBrake.ApplicationServices.Utilities
/// <param name="chapters">The List of chapters</param>
/// <param name="filePathName">Path to save the csv file</param>
/// <returns>True if successful </returns>
- private static bool ChapterCsvSave(List<string> chapters, string filePathName)
+ private static bool ChapterCsvSave(IEnumerable<string> chapters, string filePathName)
{
string csv = string.Empty;
int counter = 0;
@@ -566,10 +815,9 @@ namespace HandBrake.ApplicationServices.Utilities
foreach (string name in chapters)
{
csv += counter + "," + name.Replace(",", "\\,") + Environment.NewLine;
- counter ++;
+ counter++;
}
-
StreamWriter file = new StreamWriter(filePathName);
file.Write(csv);
file.Close();
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>
diff --git a/win/CS/UserSettingConstants.cs b/win/CS/UserSettingConstants.cs
index 9754bbdc2..d4fdf12a0 100644
--- a/win/CS/UserSettingConstants.cs
+++ b/win/CS/UserSettingConstants.cs
@@ -30,7 +30,6 @@ namespace Handbrake
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/frmMain.cs b/win/CS/frmMain.cs
index 4f2e70c2b..6e8f97fcc 100644
--- a/win/CS/frmMain.cs
+++ b/win/CS/frmMain.cs
@@ -2111,7 +2111,7 @@ namespace Handbrake
// Start the Scan
try
{
- SourceScan.Scan(sourcePath, title, this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount));
+ SourceScan.Scan(sourcePath, title, this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount));
}
catch (Exception exc)
{
diff --git a/win/CS/frmOptions.cs b/win/CS/frmOptions.cs
index 3fc663473..972ded0ee 100644
--- a/win/CS/frmOptions.cs
+++ b/win/CS/frmOptions.cs
@@ -226,7 +226,7 @@ namespace Handbrake
check_showCliForInGUIEncode.Checked = userSettingService.GetUserSetting<bool>(ASUserSettingConstants.ShowCLI);
// Set the preview count
- drop_previewScanCount.SelectedItem = this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount).ToString();
+ drop_previewScanCount.SelectedItem = this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount).ToString();
// x264 step
string step = userSettingService.GetUserSetting<double>(ASUserSettingConstants.X264Step).ToString(CultureInfo.InvariantCulture);
@@ -690,7 +690,7 @@ namespace Handbrake
private void drop_previewScanCount_SelectedIndexChanged(object sender, EventArgs e)
{
- userSettingService.SetUserSetting(UserSettingConstants.PreviewScanCount, int.Parse(drop_previewScanCount.SelectedItem.ToString()));
+ userSettingService.SetUserSetting(ASUserSettingConstants.PreviewScanCount, int.Parse(drop_previewScanCount.SelectedItem.ToString()));
}
private void x264step_SelectedIndexChanged(object sender, EventArgs e)
diff --git a/win/CS/frmPreview.cs b/win/CS/frmPreview.cs
index a9cf946ab..4251923f3 100644
--- a/win/CS/frmPreview.cs
+++ b/win/CS/frmPreview.cs
@@ -15,7 +15,6 @@ namespace Handbrake
using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Model.General;
using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -76,7 +75,7 @@ namespace Handbrake
endPoint.SelectedIndex = 1;
startPoint.Items.Clear();
- for (int i = 1; i <= UserSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount); i++)
+ for (int i = 1; i <= UserSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount); i++)
{
startPoint.Items.Add(i.ToString());
}