diff options
author | sr55 <[email protected]> | 2015-01-31 15:19:14 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-01-31 15:19:14 +0000 |
commit | 6d57e42b6b2cc38cf256f2970b23b94121e49479 (patch) | |
tree | 6841b6c50f50b6ac34bfa9dba954f959f030b480 /win/CS | |
parent | a4416e99f06e31e1da8767d071e882f32c5a4e67 (diff) |
WinGui: Remove a bunch of CLI handling code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6840 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS')
27 files changed, 63 insertions, 2880 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 63844f7ab..e3436d19f 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -159,7 +159,6 @@ </Compile>
<Compile Include="ServicesWindsorInstaller.cs" />
<Compile Include="Services\Encode\EncodeBase.cs" />
- <Compile Include="Services\Encode\EncodeService.cs" />
<Compile Include="Services\Encode\Interfaces\IEncode.cs" />
<Compile Include="Services\Interfaces\IQueueProcessor.cs" />
<Compile Include="Services\Scan\Interfaces\IScan.cs" />
@@ -169,7 +168,6 @@ <Compile Include="Utilities\CharCodesUtilities.cs" />
<Compile Include="Utilities\GeneralUtilities.cs" />
<Compile Include="Utilities\LanguageUtilities.cs" />
- <Compile Include="Utilities\QueryGeneratorUtility.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs index 5a1c69c72..0fa7c2474 100644 --- a/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs +++ b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs @@ -4,7 +4,7 @@ // </copyright>
// <summary>
// Background Service Connector.
-// HandBrake has the ability to connect to a service app that will control HandBrakeCLI or Libhb.
+// HandBrake has the ability to connect to a service app that will control Libhb.
// This acts as process isolation.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
@@ -16,14 +16,13 @@ namespace HandBrake.ApplicationServices.Isolation using System.ServiceModel;
using System.Threading;
- using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Services.Encode.EventArgs;
using HandBrake.ApplicationServices.Services.Interfaces;
/// <summary>
/// Background Service Connector.
- /// HandBrake has the ability to connect to a service app that will control HandBrakeCLI or Libhb.
+ /// HandBrake has the ability to connect to a service app that will control Libhb.
/// This acts as process isolation.
/// </summary>
public class BackgroundServiceConnector : IHbServiceCallback, IDisposable
@@ -83,9 +82,9 @@ namespace HandBrake.ApplicationServices.Isolation ProcessStartInfo processStartInfo = new ProcessStartInfo(
"HandBrake.Server.exe", port)
{
- UseShellExecute = false,
- CreateNoWindow = true,
- RedirectStandardOutput = true,
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ RedirectStandardOutput = true,
};
backgroundProcess = new Process { StartInfo = processStartInfo };
@@ -101,8 +100,8 @@ namespace HandBrake.ApplicationServices.Isolation try
{
pipeFactory = new DuplexChannelFactory<IServerService>(
- new InstanceContext(this),
- new NetTcpBinding(),
+ new InstanceContext(this),
+ new NetTcpBinding(),
new EndpointAddress(string.Format("net.tcp://127.0.0.1:{0}/IHbService", port)));
// Connect and Subscribe to the Server
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs index 8737ba64f..9c5c9f7bd 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs @@ -10,7 +10,6 @@ namespace HandBrake.ApplicationServices.Services.Encode
{
using System;
- using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
@@ -21,7 +20,6 @@ namespace HandBrake.ApplicationServices.Services.Encode using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.EventArgs;
using HandBrake.ApplicationServices.Services.Encode.Interfaces;
- using HandBrake.ApplicationServices.Services.Encode.Model;
using HandBrake.ApplicationServices.Utilities;
/// <summary>
@@ -59,19 +57,19 @@ namespace HandBrake.ApplicationServices.Services.Encode public EncodeBase()
{
this.logBuffer = new StringBuilder();
- this.header = GeneralUtilities.CreateCliLogHeader();
+ this.header = GeneralUtilities.CreateLogHeader();
this.LogIndex = 0;
}
#region Events
/// <summary>
- /// Fires when a new CLI QueueTask starts
+ /// Fires when a new QueueTask starts
/// </summary>
public event EventHandler EncodeStarted;
/// <summary>
- /// Fires when a CLI QueueTask finishes.
+ /// Fires when a QueueTask finishes.
/// </summary>
public event EncodeCompletedStatus EncodeCompleted;
@@ -83,6 +81,7 @@ namespace HandBrake.ApplicationServices.Services.Encode #endregion
#region Properties
+
/// <summary>
/// Gets or sets a value indicating whether IsEncoding.
/// </summary>
@@ -236,7 +235,7 @@ namespace HandBrake.ApplicationServices.Services.Encode }
/// <summary>
- /// Pase the CLI status output (from standard output)
+ /// Pase the status output (from standard output)
/// </summary>
/// <param name="encodeStatus">
/// The encode Status.
@@ -252,7 +251,7 @@ namespace HandBrake.ApplicationServices.Services.Encode try
{
Match m = Regex.Match(
- encodeStatus,
+ encodeStatus,
@"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?");
if (m.Success)
@@ -278,16 +277,16 @@ namespace HandBrake.ApplicationServices.Services.Encode EncodeProgressEventArgs eventArgs = new EncodeProgressEventArgs
{
- AverageFrameRate = avgFps,
- CurrentFrameRate = currentFps,
+ AverageFrameRate = avgFps,
+ CurrentFrameRate = currentFps,
EstimatedTimeLeft =
Converters.EncodeToTimespan(
- remaining),
- PercentComplete = percent,
- Task = currentTask,
- TaskCount = totalTasks,
+ remaining),
+ PercentComplete = percent,
+ Task = currentTask,
+ TaskCount = totalTasks,
ElapsedTime =
- DateTime.Now - startTime,
+ DateTime.Now - startTime,
};
return eventArgs;
@@ -319,14 +318,8 @@ namespace HandBrake.ApplicationServices.Services.Encode try
{
- string query = QueryGeneratorUtility.GenerateQuery(new EncodeTask(encodeQueueTask.Task), encodeQueueTask.Configuration);
this.logBuffer = new StringBuilder();
- if (!isLibhb)
- {
- this.logBuffer.AppendLine(String.Format("CLI Query: {0}", query));
- }
-
this.logBuffer.AppendLine();
// Clear the current Encode Logs)
@@ -344,10 +337,6 @@ namespace HandBrake.ApplicationServices.Services.Encode {
this.fileWriter = new StreamWriter(logFile) { AutoFlush = true };
this.fileWriter.WriteLine(this.header);
- if (!isLibhb)
- {
- this.fileWriter.WriteLine("CLI Query: {0}", query);
- }
this.fileWriter.WriteLine();
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs deleted file mode 100644 index 1aaa0d301..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs +++ /dev/null @@ -1,332 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="EncodeService.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Class which handles the CLI
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Services.Encode
-{
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Windows.Forms;
-
- using HandBrake.ApplicationServices.Exceptions;
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.EventArgs;
- using HandBrake.ApplicationServices.Services.Encode.Interfaces;
- using HandBrake.ApplicationServices.Services.Encode.Model;
- using HandBrake.ApplicationServices.Utilities;
-
- /// <summary>
- /// Class which handles the CLI
- /// </summary>
- public class EncodeService : EncodeBase, IEncode
- {
- #region Private Variables
-
- /// <summary>
- /// Gets the Process ID
- /// </summary>
- private int processId;
-
- /// <summary>
- /// The Start time of the current Encode;
- /// </summary>
- private DateTime startTime;
-
- /// <summary>
- /// The Current Task
- /// </summary>
- private QueueTask currentTask;
-
- /// <summary>
- /// The init shutdown.
- /// </summary>
- private bool initShutdown;
-
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets or sets The HB Process
- /// </summary>
- protected Process HbProcess { get; set; }
-
- /// <summary>
- /// Gets a value indicating whether can pause.
- /// </summary>
- public bool CanPause
- {
- get
- {
- return false;
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether is pasued.
- /// </summary>
- public bool IsPasued { get; private set; }
-
- #endregion
-
- #region Public Methods
-
- /// <summary>
- /// Execute a HandBrakeCLI process.
- /// This should only be called from the UI thread.
- /// </summary>
- /// <param name="encodeQueueTask">
- /// The encodeQueueTask.
- /// </param>
- public void Start(QueueTask encodeQueueTask)
- {
- try
- {
- if (this.IsEncoding)
- {
- throw new GeneralApplicationException("HandBrake is already encodeing.", "Please try again in a minute", null);
- }
-
- this.IsEncoding = true;
- this.currentTask = encodeQueueTask;
-
- try
- {
- this.SetupLogging(this.currentTask, false);
- }
- catch (Exception)
- {
- this.IsEncoding = false;
- throw;
- }
-
- // Make sure the path exists, attempt to create it if it doesn't
- this.VerifyEncodeDestinationPath(this.currentTask);
-
- string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
-
- // TODO tidy this code up, it's kinda messy.
- string query = this.currentTask.Task.IsPreviewEncode
- ? QueryGeneratorUtility.GeneratePreviewQuery(
- new EncodeTask(this.currentTask.Task),
- encodeQueueTask.Configuration,
- this.currentTask.Task.PreviewEncodeDuration.HasValue ? this.currentTask.Task.PreviewEncodeDuration.Value : 0,
- this.currentTask.Task.PreviewEncodeStartAt.HasValue ? this.currentTask.Task.PreviewEncodeStartAt.Value : 0)
- : QueryGeneratorUtility.GenerateQuery(new EncodeTask(this.currentTask.Task), encodeQueueTask.Configuration);
-
- ProcessStartInfo cliStart = new ProcessStartInfo(handbrakeCLIPath, query)
- {
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- };
-
- this.HbProcess = new Process { StartInfo = cliStart };
-
- this.HbProcess.Start();
-
- this.startTime = DateTime.Now;
-
- this.HbProcess.ErrorDataReceived += this.HbProcErrorDataReceived;
- this.HbProcess.BeginErrorReadLine();
-
- this.HbProcess.OutputDataReceived += this.HbProcess_OutputDataReceived;
- this.HbProcess.BeginOutputReadLine();
-
- this.processId = this.HbProcess.Id;
-
- // Set the process Priority
- if (this.processId != -1)
- {
- this.HbProcess.EnableRaisingEvents = true;
- this.HbProcess.Exited += this.HbProcessExited;
- }
-
- // Set the Process Priority
- switch (encodeQueueTask.Configuration.ProcessPriority)
- {
- case "Realtime":
- this.HbProcess.PriorityClass = ProcessPriorityClass.RealTime;
- break;
- case "High":
- this.HbProcess.PriorityClass = ProcessPriorityClass.High;
- break;
- case "Above Normal":
- this.HbProcess.PriorityClass = ProcessPriorityClass.AboveNormal;
- break;
- case "Normal":
- this.HbProcess.PriorityClass = ProcessPriorityClass.Normal;
- break;
- case "Low":
- this.HbProcess.PriorityClass = ProcessPriorityClass.Idle;
- break;
- default:
- this.HbProcess.PriorityClass = ProcessPriorityClass.BelowNormal;
- break;
- }
-
- // Fire the Encode Started Event
- this.InvokeEncodeStarted(System.EventArgs.Empty);
- }
- catch (Exception exc)
- {
- encodeQueueTask.Status = QueueItemStatus.Error;
- this.IsEncoding = false;
- this.InvokeEncodeCompleted(
- new EncodeCompletedEventArgs(
- false, exc, "An Error occured when trying to encode this source. ", this.currentTask.Task.Destination));
- throw;
- }
- }
-
- /// <summary>
- /// The pause.
- /// </summary>
- /// <exception cref="NotImplementedException">
- /// This feature is not available for CLI based encoding.
- /// </exception>
- public void Pause()
- {
- throw new NotImplementedException("This feature is not available for CLI based encoding.");
- }
-
- /// <summary>
- /// The resume.
- /// </summary>
- /// <exception cref="NotImplementedException">
- /// This feature is not available for CLI based encoding.
- /// </exception>
- public void Resume()
- {
- throw new NotImplementedException("This feature is not available for CLI based encoding.");
- }
-
- /// <summary>
- /// Kill the CLI process
- /// </summary>
- public override void Stop()
- {
- try
- {
- if (this.HbProcess != null && !this.HbProcess.HasExited)
- {
- this.HbProcess.Kill();
- }
- }
- catch (Exception)
- {
- // No need to report anything to the user. If it fails, it's probably already stopped.
- }
- }
-
- /// <summary>
- /// Shutdown the service.
- /// </summary>
- public void Shutdown()
- {
- // Nothing to do.
- }
-
- #endregion
-
- #region Private Helper Methods
-
- /// <summary>
- /// The HandBrakeCLI process has exited.
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The EventArgs.
- /// </param>
- private void HbProcessExited(object sender, System.EventArgs e)
- {
- this.HbProcess.WaitForExit();
-
- try
- {
- this.HbProcess.CancelErrorRead();
- this.HbProcess.CancelOutputRead();
- this.ShutdownFileWriter();
- }
- catch (Exception)
- {
- // This exception doesn't warrent user interaction, but it should be logged (TODO)
- }
-
- this.currentTask.Status = QueueItemStatus.Completed;
- this.IsEncoding = false;
- this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Task.Destination));
- }
-
- /// <summary>
- /// Recieve the Standard Error information and process it
- /// </summary>
- /// <param name="sender">
- /// The Sender Object
- /// </param>
- /// <param name="e">
- /// DataReceived EventArgs
- /// </param>
- /// <remarks>
- /// Worker Thread.
- /// </remarks>
- private void HbProcErrorDataReceived(object sender, DataReceivedEventArgs e)
- {
- if (!String.IsNullOrEmpty(e.Data))
- {
- if (this.initShutdown && this.LogBuffer.Length < 25000000)
- {
- this.initShutdown = false; // Reset this flag.
- }
-
- if (this.LogBuffer.Length > 25000000 && !this.initShutdown) // Approx 23.8MB and make sure it's only printed once
- {
- this.ProcessLogMessage("ERROR: Initiating automatic shutdown of encode process. The size of the log file indicates that there is an error! ");
- this.initShutdown = true;
- this.Stop();
- }
-
- this.ProcessLogMessage(e.Data);
- }
- }
-
- /// <summary>
- /// The hb process output data received.
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The e.
- /// </param>
- private void HbProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
- {
- if (!String.IsNullOrEmpty(e.Data) && this.IsEncoding)
- {
- EncodeProgressEventArgs eventArgs = this.ReadEncodeStatus(e.Data, this.startTime);
- if (eventArgs != null)
- {
- if (!this.IsEncoding)
- {
- // We can get events out of order since the CLI progress is monitored on a background thread.
- // So make sure we don't send a status update after an encode complete event.
- return;
- }
-
- this.InvokeEncodeStatusChanged(eventArgs);
- }
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs index 90c42149b..aa53ed180 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Interfaces/IEncode.cs @@ -42,12 +42,12 @@ namespace HandBrake.ApplicationServices.Services.Encode.Interfaces public interface IEncode
{
/// <summary>
- /// Fires when a new CLI Job starts
+ /// Fires when a new Job starts
/// </summary>
event EventHandler EncodeStarted;
/// <summary>
- /// Fires when a CLI job finishes.
+ /// Fires when a job finishes.
/// </summary>
event EncodeCompletedStatus EncodeCompleted;
@@ -100,7 +100,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Interfaces void Resume();
/// <summary>
- /// Kill the CLI process
+ /// Kill the process
/// </summary>
void Stop();
@@ -114,10 +114,5 @@ namespace HandBrake.ApplicationServices.Services.Encode.Interfaces /// The configuration.
/// </param>
void ProcessLogs(string destination, HBConfiguration configuration);
-
- /// <summary>
- /// Shutdown the service.
- /// </summary>
- void Shutdown();
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs index 208f8d307..82bb4b1a7 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs @@ -174,31 +174,26 @@ namespace HandBrake.ApplicationServices.Services.Encode }
/// <summary>
- /// Kill the CLI process
+ /// Kill the process
/// </summary>
public override void Stop()
{
try
{
this.IsEncoding = false;
- this.instance.StopEncode();
- ServiceLogMessage("Encode Stopped");
+ if (instance != null)
+ {
+ this.instance.StopEncode();
+ ServiceLogMessage("Encode Stopped");
+ }
}
- catch (Exception)
+ catch (Exception exc)
{
- // Do Nothing.
+ Debug.WriteLine(exc);
}
}
/// <summary>
- /// Shutdown the service.
- /// </summary>
- public void Shutdown()
- {
- // Nothing to do for this implementation.
- }
-
- /// <summary>
/// The scan completed.
/// </summary>
/// <param name="job">
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs index 721959a90..bc9304f8e 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs @@ -39,13 +39,6 @@ namespace HandBrake.ApplicationServices.Services.Scan /// </summary>
public class LibScan : IScan
{
- /*
- * TODO
- * 1. Expose the Previews code.
- * 2. Cleanup old instances.
- *
- */
-
#region Private Variables
/// <summary>
@@ -101,7 +94,7 @@ namespace HandBrake.ApplicationServices.Services.Scan public LibScan()
{
this.logging = new StringBuilder();
- this.header = GeneralUtilities.CreateCliLogHeader();
+ this.header = GeneralUtilities.CreateLogHeader();
}
#region Events
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs index aa9b55a13..7a790f7f9 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs @@ -108,12 +108,12 @@ namespace HandBrake.ApplicationServices.Utilities }
/// <summary>
- /// Add the CLI Query to the Log File.
+ /// Generate the header for the log file.
/// </summary>
/// <returns>
- /// The create cli log header.
+ /// The generatedlog header.
/// </returns>
- public static StringBuilder CreateCliLogHeader()
+ public static StringBuilder CreateLogHeader()
{
var logHeader = new StringBuilder();
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs deleted file mode 100644 index 47c29db0a..000000000 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ /dev/null @@ -1,1059 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="QueryGeneratorUtility.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Generate a CLI Query for HandBrakeCLI
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Globalization;
- using System.IO;
- using System.Linq;
-
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model.Models;
- using HandBrake.Interop.Model.Encoding;
-
- /// <summary>
- /// Generate a CLI Query for HandBrakeCLI
- /// </summary>
- public class QueryGeneratorUtility
- {
- /// <summary>
- /// Generate a CLI Query for an EncodeTask Model object
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- /// <returns>
- /// A Cli Query
- /// </returns>
- public static string GenerateQuery(EncodeTask task, HBConfiguration configuration)
- {
- if (string.IsNullOrEmpty(task.Source))
- {
- return "No source selected";
- }
-
- string query = string.Empty;
- query += SourceQuery(task, null, -1, configuration.PreviewScanCount);
- query += DestinationQuery(task);
- query += GenerateTabbedComponentsQuery(task, true, configuration.Verbosity, configuration.IsDvdNavDisabled, configuration.DisableQuickSyncDecoding, configuration.EnableDxva, configuration.ScalingMode == VideoScaler.BicubicCl);
-
- return query;
- }
-
- /// <summary>
- /// Generate a Query for a Preview Encode
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </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, HBConfiguration configuration, int duration, int startAtPreview)
- {
- string query = string.Empty;
- query += SourceQuery(task, duration, startAtPreview, configuration.PreviewScanCount);
- query += DestinationQuery(task);
- query += GenerateTabbedComponentsQuery(task, true, configuration.Verbosity, configuration.IsDvdNavDisabled, configuration.DisableQuickSyncDecoding, false, false);
-
- return query;
- }
-
- #region Individual Query Sections
-
- /// <summary>
- /// Generate a Query from an Encode Task Object.
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
- /// <param name="enableFilters">
- /// The enableFilters.
- /// </param>
- /// <param name="verbosity">
- /// The verbosity.
- /// </param>
- /// <param name="disableLibDvdNav">
- /// The disable Lib Dvd Nav.
- /// </param>
- /// <param name="disableQsvDecode">
- /// The disable Qsv Decode.
- /// </param>
- /// <param name="enableHwd">
- /// The enable Hwd.
- /// </param>
- /// <param name="enableOpenCL">
- /// The enable Open CL.
- /// </param>
- /// <returns>
- /// The CLI query for the Tabbed section of the main window UI
- /// </returns>
- private static string GenerateTabbedComponentsQuery(EncodeTask task, bool enableFilters, int verbosity, bool disableLibDvdNav, bool disableQsvDecode, bool enableHwd, bool enableOpenCL)
- {
- string query = string.Empty;
-
- // Output Settings
- query += OutputSettingsQuery(task);
-
- // Filters Panel
- if (enableFilters)
- query += FiltersQuery(task);
-
- // Picture Settings
- query += PictureSettingsQuery(task);
-
- // Video Settings
- query += VideoSettingsQuery(task);
-
- // Audio Settings
- query += AudioSettingsQuery(task);
-
- // Subtitles Panel
- query += SubtitlesQuery(task);
-
- // Chapter Markers
- query += ChapterMarkersQuery(task);
-
- // Advanced Panel
- query += AdvancedQuery(task);
-
- // Extra Settings
- query += ExtraSettings(verbosity, disableLibDvdNav, disableQsvDecode, enableHwd, enableOpenCL, task.VideoEncoder == VideoEncoder.QuickSync);
-
- return query;
- }
-
- /// <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>
- /// <param name="previewScanCount">
- /// The preview Scan Count.
- /// </param>
- /// <returns>
- /// A Cli Query as a string
- /// </returns>
- private static string SourceQuery(EncodeTask task, int? duration, int preview, int previewScanCount)
- {
- string query = string.Empty;
-
- query += task.Source.EndsWith("\\")
- ? string.Format(" -i \"{0}\\\\\"", task.Source.TrimEnd('\\'))
- : string.Format(" -i \"{0}\"", task.Source);
-
- query += string.Format(" -t {0}", task.Title);
- query += string.Format(" --angle {0}", task.Angle);
-
- // Decide what part of the video we want to encode.
- switch (task.PointToPointMode)
- {
- case PointToPointMode.Chapters: // Chapters
-
- if (task.StartPoint == task.EndPoint)
- query += string.Format(" -c {0}", task.StartPoint);
- else
- query += string.Format(" -c {0}-{1}", task.StartPoint, task.EndPoint);
- break;
- case PointToPointMode.Seconds: // Seconds
- int calculatedDuration = task.EndPoint - task.StartPoint;
- query += string.Format(" --start-at duration:{0} --stop-at duration:{1}", task.StartPoint, calculatedDuration);
- break;
- case PointToPointMode.Frames: // Frames
- calculatedDuration = task.EndPoint - task.StartPoint;
- query += string.Format(" --start-at frame:{0} --stop-at frame:{1}", task.StartPoint, calculatedDuration);
- break;
- case PointToPointMode.Preview: // Preview
- query += " --previews " + previewScanCount + " ";
- query += " --start-at-preview " + preview;
- query += " --stop-at duration:" + duration + " ";
- 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)
- {
- return string.Format(" -o \"{0}\" ", task.Destination);
- }
-
- /// <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;
-
- query += string.Format(" -f {0} ", EnumHelper<Enum>.GetDescription(task.OutputFormat).ToLower());
-
- // These are output settings features
- if (task.IPod5GSupport)
- query += " -I ";
-
- if (task.OptimizeMP4)
- query += " -O ";
-
- return query;
- }
-
- /// <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;
-
- if (task.Anamorphic != Anamorphic.Strict)
- {
- if (task.Width.HasValue && task.Width != 0) query += string.Format(" -w {0}", task.Width);
-
- if (task.Height.HasValue && task.Height != 0) query += string.Format(" -l {0}", task.Height);
- }
-
- query += string.Format(
- " --crop {0}:{1}:{2}:{3}",
- task.Cropping.Top,
- task.Cropping.Bottom,
- task.Cropping.Left,
- task.Cropping.Right);
-
- switch (task.Anamorphic)
- {
- case Anamorphic.Strict:
- query += " --strict-anamorphic ";
- break;
- case Anamorphic.Loose:
- query += " --loose-anamorphic ";
- break;
- case Anamorphic.Custom:
- query += " --custom-anamorphic ";
-
- if (task.DisplayWidth.HasValue)
- query += " --display-width " + task.DisplayWidth + " ";
-
- if (task.KeepDisplayAspect)
- query += " --keep-display-aspect ";
-
- if (!task.KeepDisplayAspect)
- query += string.Format(" --pixel-aspect {0}:{1}", task.PixelAspectX, task.PixelAspectY);
- break;
- }
-
- if (task.Modulus.HasValue)
- {
- query += " --modulus " + task.Modulus;
- }
-
- 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
- {
- case Detelecine.Off:
- query += string.Empty;
- break;
- case Detelecine.Default:
- query += " --detelecine";
- break;
- case Detelecine.Custom:
- query += string.Format(" --detelecine=\"{0}\"", task.CustomDetelecine);
- break;
- default:
- query += string.Empty;
- break;
- }
-
- switch (task.Decomb) // Decomb
- {
- case Decomb.Off:
- query += string.Empty;
- break;
- case Decomb.Default:
- query += " --decomb";
- break;
- case Decomb.Custom:
- query += string.Format(" --decomb=\"{0}\"", task.CustomDecomb);
- break;
- case Decomb.Fast:
- query += " --decomb=\"fast\"";
- break;
- case Decomb.Bob:
- query += " --decomb=\"bob\"";
- break;
- default:
- query += string.Empty;
- break;
- }
-
- switch (task.Deinterlace) // DeInterlace
- {
- case Deinterlace.Fast:
- query += " --deinterlace=\"fast\"";
- break;
- case Deinterlace.Slow:
- query += " --deinterlace=\"slow\"";
- break;
- case Deinterlace.Slower:
- query += " --deinterlace=\"slower\"";
- break;
- case Deinterlace.Custom:
- query += string.Format(" --deinterlace=\"{0}\"", task.CustomDeinterlace);
- break;
-
- case Deinterlace.Bob:
- query += " --deinterlace=\"bob\"";
- break;
- default:
- query += string.Empty;
- break;
- }
-
- if (task.Denoise == Denoise.hqdn3d)
- {
- switch (task.DenoisePreset) // Denoise
- {
- case DenoisePreset.Weak:
- query += " --denoise=\"weak\"";
- break;
- case DenoisePreset.Medium:
- query += " --denoise=\"medium\"";
- break;
- case DenoisePreset.Strong:
- query += " --denoise=\"strong\"";
- break;
- case DenoisePreset.Custom:
- query += string.Format(" --denoise=\"{0}\"", task.CustomDenoise);
- break;
- }
- }
-
- // NL Means
- if (task.Denoise == Denoise.NLMeans)
- {
- switch (task.DenoisePreset) // Denoise
- {
- case DenoisePreset.Light:
- query += " --nlmeans=\"light\"";
- break;
- case DenoisePreset.Ultralight:
- query += " --nlmeans=\"ultralight\"";
- break;
- case DenoisePreset.Medium:
- query += " --nlmeans=\"medium\"";
- break;
- case DenoisePreset.Strong:
- query += " --nlmeans=\"strong\"";
- break;
- default:
- query += string.Empty;
- break;
- }
-
- switch (task.DenoiseTune)
- {
- case DenoiseTune.Animation:
- query += " --nlmeans-tune=\"animation\"";
- break;
- case DenoiseTune.Film:
- query += " --nlmeans-tune=\"film\"";
- break;
- case DenoiseTune.Grain:
- query += " --nlmeans-tune=\"grain\"";
- break;
- case DenoiseTune.HighMotion:
- query += " --nlmeans-tune=\"highmotion\"";
- break;
- default:
- query += string.Empty;
- break;
- }
- }
-
- if (task.Deblock > 4)
- query += string.Format(" --deblock={0}", task.Deblock);
-
- if (task.Grayscale)
- query += " -g ";
-
- return query;
- }
-
- /// <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;
-
- switch (task.VideoEncoder)
- {
- case VideoEncoder.FFMpeg:
- query += " -e ffmpeg4";
- break;
- case VideoEncoder.FFMpeg2:
- query += " -e ffmpeg2";
- break;
- case VideoEncoder.X264:
- query += " -e x264";
- break;
- case VideoEncoder.QuickSync:
- query += " -e qsv_h264";
- break;
- case VideoEncoder.Theora:
- query += " -e theora";
- break;
- case VideoEncoder.VP8:
- query += " -e VP8";
- break;
- default:
- query += " -e x264";
- break;
- case VideoEncoder.X265:
- query += " -e x265";
- break;
- }
-
- switch (task.VideoEncodeRateType)
- {
- case VideoEncodeRateType.AverageBitrate:
- if (task.VideoBitrate.HasValue)
- query += string.Format(" -b {0}", task.VideoBitrate.Value);
- break;
- case VideoEncodeRateType.ConstantQuality:
- query += string.Format(" -q {0}", task.Quality.Value.ToString(CultureInfo.InvariantCulture));
- break;
- }
-
- if (task.TwoPass)
- query += " -2 ";
-
- if (task.TurboFirstPass && task.VideoEncoder == VideoEncoder.X264)
- query += " -T ";
-
- if (task.Framerate.HasValue)
- query += string.Format(" -r {0}", task.Framerate.Value.ToString(CultureInfo.InvariantCulture));
-
- switch (task.FramerateMode)
- {
- case FramerateMode.CFR:
- query += " --cfr";
- break;
- case FramerateMode.VFR:
- query += " --vfr";
- break;
- case FramerateMode.PFR:
- query += " --pfr";
- break;
- default:
- query += " --vfr";
- break;
- }
-
- 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;
-
- ObservableCollection<AudioTrack> audioTracks = task.AudioTracks;
-
- List<int> tracks = new List<int>();
- List<AudioEncoder> codecs = new List<AudioEncoder>();
- List<Mixdown> mixdowns = new List<Mixdown>();
- List<double> samplerates = new List<double>();
- List<int> bitrates = new List<int>();
- List<double> drcs = new List<double>();
- List<double> gains = new List<double>();
- List<string> trackNames = new List<string>();
-
- // No Audio
- if (audioTracks.Count == 0)
- query += " -a none ";
-
- // Gather information about each audio track and store them in the declared lists.
- foreach (AudioTrack track in audioTracks)
- {
- if (track.Track == null)
- {
- continue;
- }
-
- tracks.Add(track.Track.Value);
-
- // Audio Codec (-E)
- codecs.Add(track.Encoder);
-
- // Audio Mixdown (-6)
- mixdowns.Add(track.IsPassthru ? Mixdown.None : track.MixDown);
-
- // Sample Rate (-R)
- samplerates.Add(track.IsPassthru ? 0 : track.SampleRate);
-
- // Audio Bitrate (-B)
- bitrates.Add(track.IsPassthru ? 0 : track.Bitrate);
-
- // DRC (-D)
- drcs.Add(track.IsPassthru ? 0 : track.DRC);
-
- // Gain (--gain)
- gains.Add(track.IsPassthru ? 0 : track.Gain);
-
- // Audio Track Name (--aname)
- trackNames.Add(track.TrackName);
- }
-
- // Audio Track (-a)
- string audioItems = string.Empty;
- bool firstLoop = true;
-
- foreach (int item in tracks)
- {
- if (firstLoop)
- {
- audioItems = item.ToString();
- firstLoop = false;
- }
- else
- audioItems += "," + item;
- }
- if (audioItems.Trim() != String.Empty)
- query += " -a " + audioItems;
- firstLoop = true;
- audioItems = string.Empty; // Reset for another pass.
-
- // Audio Codec (-E)
- foreach (AudioEncoder item in codecs)
- {
- if (firstLoop)
- {
- audioItems = Converters.GetCliAudioEncoder(item);
- firstLoop = false;
- }
- else
- audioItems += "," + Converters.GetCliAudioEncoder(item);
- }
- if (audioItems.Trim() != String.Empty)
- query += " -E " + audioItems;
- firstLoop = true;
- audioItems = string.Empty; // Reset for another pass.
-
- // Audio Mixdown (-6)
- foreach (Mixdown item in mixdowns)
- {
- if (firstLoop)
- {
- audioItems = Converters.GetCliMixDown(item);
- firstLoop = false;
- }
- else
- audioItems += "," + Converters.GetCliMixDown(item);
- }
- if (audioItems.Trim() != String.Empty)
- query += " -6 " + audioItems;
- firstLoop = true;
- audioItems = string.Empty; // Reset for another pass.
-
- // Sample Rate (-R)
- foreach (double item in samplerates)
- {
- string add = (item == 0.0) ? "Auto" : item.ToString(new CultureInfo("en-US"));
- if (firstLoop)
- {
- audioItems = add;
- firstLoop = false;
- }
- else
- audioItems += "," + add;
- }
- if (audioItems.Trim() != String.Empty)
- query += " -R " + audioItems;
- firstLoop = true;
- audioItems = string.Empty; // Reset for another pass.
-
- // Audio Bitrate (-B)
- foreach (int item in bitrates)
- {
- if (firstLoop)
- {
- audioItems = item.ToString();
- firstLoop = false;
- }
- else
- audioItems += "," + item;
- }
- if (audioItems.Trim() != String.Empty)
- query += " -B " + audioItems;
- firstLoop = true;
- audioItems = string.Empty; // Reset for another pass.
-
- // DRC (-D)
- foreach (var itm in drcs)
- {
- string item = itm.ToString(new CultureInfo("en-US"));
- if (firstLoop)
- {
- audioItems = item;
- firstLoop = false;
- }
- else
- audioItems += "," + item;
- }
- if (audioItems.Trim() != String.Empty)
- query += " -D " + audioItems;
-
- audioItems = string.Empty; // Reset for another pass.
- firstLoop = true;
-
- // Gain (--gain)
- foreach (var itm in gains)
- {
- string item = itm.ToString(new CultureInfo("en-US"));
- if (firstLoop)
- {
- audioItems = item;
- firstLoop = false;
- }
- else
- audioItems += "," + item;
- }
- if (audioItems.Trim() != String.Empty)
- query += " --gain " + audioItems;
-
- audioItems = string.Empty; // Reset for another pass.
- firstLoop = true;
-
- // Audio Track Names (--aname)
- bool foundTrackName = false;
- foreach (string trackName in trackNames)
- {
- if (!string.IsNullOrEmpty(trackName))
- {
- foundTrackName = true;
- }
-
- string fixedTrackName = trackName != null ? trackName.Replace(",", "\\,") : string.Empty;
-
- if (firstLoop)
- {
- audioItems = string.IsNullOrEmpty(fixedTrackName) ? string.Empty : string.Format("{0}", fixedTrackName.Trim());
- firstLoop = false;
- }
- else
- audioItems += "," + (string.IsNullOrEmpty(fixedTrackName) ? string.Empty : string.Format("{0}", fixedTrackName.Trim()));
- }
- if (foundTrackName)
- query += string.Format(" --aname=\"{0}\"", audioItems);
-
- // Passthru Settings
- if (task.AllowedPassthruOptions != null)
- {
- string fallbackEncoders = string.Empty;
-
- if (task.AllowedPassthruOptions.AudioAllowAACPass != null && task.AllowedPassthruOptions.AudioAllowAACPass.Value)
- {
- fallbackEncoders += "aac";
- }
-
- if (task.AllowedPassthruOptions.AudioAllowAC3Pass != null && task.AllowedPassthruOptions.AudioAllowAC3Pass.Value)
- {
- fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "ac3" : ",ac3";
- }
-
- if (task.AllowedPassthruOptions.AudioAllowDTSHDPass != null && task.AllowedPassthruOptions.AudioAllowDTSHDPass.Value)
- {
- fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "dtshd" : ",dtshd";
- }
-
- if (task.AllowedPassthruOptions.AudioAllowDTSPass != null && task.AllowedPassthruOptions.AudioAllowDTSPass.Value)
- {
- fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "dts" : ",dts";
- }
-
- if (task.AllowedPassthruOptions.AudioAllowMP3Pass != null && task.AllowedPassthruOptions.AudioAllowMP3Pass.Value)
- {
- fallbackEncoders += string.IsNullOrEmpty(fallbackEncoders) ? "mp3" : ",mp3";
- }
-
- if (!string.IsNullOrEmpty(fallbackEncoders))
- {
- // Special Case, The CLI alredy defaults to ALL, so if all area selected, then don't need to set copy mask
- if (fallbackEncoders != "aac,ac3,dtshd,dts,mp3")
- {
- query += string.Format(" --audio-copy-mask {0}", fallbackEncoders);
- }
- }
- else
- {
- query += string.Format(" --audio-copy-mask none");
- }
-
- query += string.Format(" --audio-fallback {0}", Converters.GetCliAudioEncoder(task.AllowedPassthruOptions.AudioEncoderFallback));
- }
-
- 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)
- {
- 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? srtBurnTrack = null;
- 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.Replace("\\", "\\\\").Replace(",", "\\,");
- srtFile += srtFile == string.Empty ? itemToAdd : "," + itemToAdd;
-
- itemToAdd = item.SrtOffset.ToString();
- srtOffset += srtOffset == string.Empty ? itemToAdd : "," + itemToAdd;
- if (item.Burned)
- srtBurnTrack = srtCount;
- }
- else // We have Bitmap or CC
- {
- subCount++;
-
- // Find --subtitle <string>
- if (item.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch)
- 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-burned=" + 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;
- if (srtBurnTrack.HasValue)
- query += " --srt-burn=" + srtBurnTrack.Value;
- }
- }
-
- 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;
-
- // Attach Source name and dvd title to the start of the chapters.csv filename.
- // This is for the queue. It allows different chapter name files for each title.
- string destName = Path.GetFileNameWithoutExtension(task.Destination);
- string sourceTitle = task.Title.ToString();
-
- if (task.IncludeChapterMarkers && destName != null)
- {
- if (destName.Trim() != String.Empty)
- {
- string path = sourceTitle != "Automatic"
- ? Path.Combine(Path.GetTempPath(), destName + "-" + sourceTitle + "-chapters.csv")
- : Path.Combine(Path.GetTempPath(), destName + "-chapters.csv");
-
- if (ChapterCsvSave(task.ChapterNames, path) == false)
- query += " -m ";
- else
- query += " --markers=" + "\"" + path + "\"";
- }
- else
- query += " -m";
- }
-
- return query;
- }
-
- /// <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)
- {
- string query = string.Empty;
-
- if (task.VideoEncoder == VideoEncoder.X264 || task.VideoEncoder == VideoEncoder.X265 || task.VideoEncoder == VideoEncoder.QuickSync)
- {
- if (!task.ShowAdvancedTab)
- {
- query += string.Format(" --encoder-preset={0} ", task.VideoPreset.ShortName);
-
- string tuneQuery = task.VideoTunes.Aggregate(string.Empty, (current, tune) => string.IsNullOrEmpty(current) ? tune.ShortName : string.Format(",{0}", tune.ShortName));
- if (!string.IsNullOrEmpty(tuneQuery))
- {
- query += string.Format(" --encoder-tune=\"{0}\" ", tuneQuery);
- }
-
- query += string.Format(" --encoder-profile={0} ", task.VideoProfile.ShortName);
-
- query += string.Format(" --encoder-level=\"{0}\" ", task.VideoLevel.ShortName);
-
- if (!string.IsNullOrEmpty(task.ExtraAdvancedArguments))
- {
- query += string.Format(" -x {0}", task.ExtraAdvancedArguments);
- }
- }
- }
- else if (!task.ShowAdvancedTab && !string.IsNullOrEmpty(task.ExtraAdvancedArguments))
- {
- query += string.Format(" -x {0}", task.ExtraAdvancedArguments);
- }
-
-
- // options that apply to all encoders
- if (task.ShowAdvancedTab && !string.IsNullOrEmpty(task.AdvancedEncoderOptions))
- {
- query += string.Format(" -x {0}", task.AdvancedEncoderOptions);
- }
-
- return query;
- }
-
- /// <summary>
- /// Generate the Command Line Arguments for any additional advanced options.
- /// </summary>
- /// <param name="verbosity">
- /// The verbosity.
- /// </param>
- /// <param name="disableLibdvdNav">
- /// The disable Libdvd Nav.
- /// </param>
- /// <param name="disableQsvDecode">
- /// The disable Qsv Decode.
- /// </param>
- /// <param name="enableHwd">
- /// The enable Hwd.
- /// </param>
- /// <param name="enableOpenCL">
- /// The enable Open CL.
- /// </param>
- /// <param name="isQsv">
- /// The is Qsv.
- /// </param>
- /// <returns>
- /// A Cli Query as a string
- /// </returns>
- private static string ExtraSettings(int verbosity, bool disableLibdvdNav, bool disableQsvDecode, bool enableHwd, bool enableOpenCL, bool isQsv)
- {
- string query = string.Empty;
-
- // Verbosity Level
- query += string.Format(" --verbose={0}", verbosity);
-
- // LibDVDNav
- if (disableLibdvdNav)
- query += " --no-dvdnav";
-
- if (disableQsvDecode)
- query += " --disable-qsv-decoding";
-
- if (enableOpenCL && !isQsv)
- query += " -P ";
-
- if (enableHwd && !isQsv)
- {
- query += " -U ";
- }
-
- return query;
- }
-
- #endregion
-
- #region Helpers
-
- /// <summary>
- /// Create a CSV file with the data from the Main Window Chapters tab
- /// </summary>
- /// <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(IEnumerable<ChapterMarker> chapters, string filePathName)
- {
- string csv = string.Empty;
- int counter = 1;
-
- foreach (ChapterMarker name in chapters)
- {
- csv += counter + "," + name.ChapterName.Replace(",", "\\,") + Environment.NewLine;
- counter++;
- }
-
- StreamWriter file = new StreamWriter(filePathName);
- file.Write(csv);
- file.Close();
- file.Dispose();
- return true;
- }
- #endregion
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/App.xaml.cs b/win/CS/HandBrakeWPF/App.xaml.cs index ce13693ab..e0bfd1bbf 100644 --- a/win/CS/HandBrakeWPF/App.xaml.cs +++ b/win/CS/HandBrakeWPF/App.xaml.cs @@ -53,12 +53,6 @@ namespace HandBrakeWPF return;
}
- if (e.Args.Any(f => f.Equals("--instant")))
- {
- AppArguments.IsInstantHandBrake = true;
- MessageBox.Show("Instant HandBrake is just a prototype for toying with ideas. It may or may not work, or even be included in future builds.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
- }
-
if (e.Args.Any(f => f.Equals("--reset")))
{
HandBrakeApp.ResetToDefaults();
@@ -66,11 +60,6 @@ namespace HandBrakeWPF return;
}
- if (e.Args.Any(f => f.Equals("--enable-libhb")))
- {
- AppArguments.UseLibHb = true;
- }
-
base.OnStartup(e);
// If we have a file dropped on the icon, try scanning it.
diff --git a/win/CS/HandBrakeWPF/AppArguments.cs b/win/CS/HandBrakeWPF/AppArguments.cs index ecd47fb35..c673a8fa1 100644 --- a/win/CS/HandBrakeWPF/AppArguments.cs +++ b/win/CS/HandBrakeWPF/AppArguments.cs @@ -14,14 +14,5 @@ namespace HandBrakeWPF /// </summary>
public class AppArguments
{
- /// <summary>
- /// Gets or sets a value indicating whether is instant hand brake.
- /// </summary>
- public static bool IsInstantHandBrake { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether enable lib hb.
- /// </summary>
- public static bool UseLibHb { get; set; }
}
}
diff --git a/win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs b/win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs index b27355df9..6cced25d4 100644 --- a/win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs +++ b/win/CS/HandBrakeWPF/Commands/ProcessShortcutCommand.cs @@ -96,11 +96,6 @@ namespace HandBrakeWPF.Commands mainViewModel.FolderScan();
}
- if (gesture.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift) && gesture.Key == Key.D)
- {
- mainViewModel.ShowCliQuery();
- }
-
if (gesture.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift) && gesture.Key == Key.G)
{
GC.Collect();
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 3b84e37a6..13ba9c645 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -236,17 +236,12 @@ <Compile Include="Services\UpdateService.cs" />
<Compile Include="Services\PrePostActionService.cs" />
<Compile Include="ViewModels\AdvancedViewModel.cs" />
- <Compile Include="ViewModels\InstantViewModel.cs" />
- <Compile Include="ViewModels\Interfaces\IInstantViewModel.cs" />
<Compile Include="ViewModels\Interfaces\IX264ViewModel.cs" />
<Compile Include="ViewModels\Interfaces\IQueueSelectionViewModel.cs" />
<Compile Include="ViewModels\QueueSelectionViewModel.cs" />
<Compile Include="Views\AdvancedView.xaml.cs">
<DependentUpon>AdvancedView.xaml</DependentUpon>
</Compile>
- <Compile Include="Views\InstantView.xaml.cs">
- <DependentUpon>InstantView.xaml</DependentUpon>
- </Compile>
<Compile Include="Views\QueueSelectionView.xaml.cs">
<DependentUpon>QueueSelectionView.xaml</DependentUpon>
</Compile>
@@ -422,10 +417,6 @@ <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Page Include="Views\InstantView.xaml">
- <SubType>Designer</SubType>
- <Generator>MSBuild:Compile</Generator>
- </Page>
<Page Include="Views\QueueSelectionView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
diff --git a/win/CS/HandBrakeWPF/Installer/Installer64.nsi b/win/CS/HandBrakeWPF/Installer/Installer64.nsi index c7052b05a..d81314a2e 100644 --- a/win/CS/HandBrakeWPF/Installer/Installer64.nsi +++ b/win/CS/HandBrakeWPF/Installer/Installer64.nsi @@ -132,7 +132,6 @@ Section "Handbrake" SEC01 ; Install Files
File "Handbrake.exe"
- File "HandBrakeCLI.exe"
CreateDirectory "$SMPROGRAMS\Handbrake"
CreateShortCut "$SMPROGRAMS\Handbrake\Handbrake.lnk" "$INSTDIR\Handbrake.exe"
CreateShortCut "$DESKTOP\Handbrake.lnk" "$INSTDIR\Handbrake.exe"
diff --git a/win/CS/HandBrakeWPF/Model/ShellWindow.cs b/win/CS/HandBrakeWPF/Model/ShellWindow.cs index bbb71625e..923b79cb5 100644 --- a/win/CS/HandBrakeWPF/Model/ShellWindow.cs +++ b/win/CS/HandBrakeWPF/Model/ShellWindow.cs @@ -16,6 +16,5 @@ namespace HandBrakeWPF.Model {
MainWindow,
OptionsWindow,
- InstantMainWindow
}
}
diff --git a/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs b/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs index bfcf24fc4..b63b74078 100644 --- a/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs +++ b/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs @@ -48,38 +48,30 @@ namespace HandBrakeWPF.Services /// </param>
public EncodeServiceWrapper(IUserSettingService userSettingService)
{
- var useLibHb = true;
var useProcessIsolation =
userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation);
var port = userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);
- if (useLibHb)
+ try
{
- try
+ if (useProcessIsolation)
{
- if (useProcessIsolation)
- {
- this.encodeService = new IsolatedEncodeService(port);
- }
- else
- {
- this.encodeService = new LibEncode();
- }
+ this.encodeService = new IsolatedEncodeService(port);
}
- catch (Exception exc)
+ else
{
- // Try to recover from errors.
- throw new GeneralApplicationException(
- "Unable to initialise LibHB or Background worker service",
- "Falling back to using HandBrakeCLI.exe. Setting has been reset",
- exc);
+ this.encodeService = new LibEncode();
}
}
- else
+ catch (Exception exc)
{
- this.encodeService = new EncodeService();
+ // Try to recover from errors.
+ throw new GeneralApplicationException(
+ "Unable to initialise LibHB or Background worker service",
+ "HandBrake will not be able to operate correctly.",
+ exc);
}
-
+
this.encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;
this.encodeService.EncodeStarted += this.EncodeServiceEncodeStarted;
this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged;
@@ -188,7 +180,7 @@ namespace HandBrakeWPF.Services /// </summary>
public void Shutdown()
{
- this.encodeService.Shutdown();
+ this.encodeService.Stop();
this.encodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted;
this.encodeService.EncodeStarted -= this.EncodeServiceEncodeStarted;
this.encodeService.EncodeStatusChanged -= this.EncodeServiceEncodeStatusChanged;
diff --git a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs index a812e4f08..10da855fa 100644 --- a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs +++ b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs @@ -86,7 +86,6 @@ namespace HandBrakeWPF.Startup this.windsorContainer.Register(Component.For<ICountdownAlertViewModel>().ImplementedBy<CountdownAlertViewModel>().LifeStyle.Is(LifestyleType.Singleton));
// Experimental Services and Windows.
- this.windsorContainer.Register(Component.For<IInstantViewModel>().ImplementedBy<InstantViewModel>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<IStaticPreviewViewModel>().ImplementedBy<StaticPreviewViewModel>().LifeStyle.Is(LifestyleType.Singleton));
// Tab Components
diff --git a/win/CS/HandBrakeWPF/ViewModels/InstantViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/InstantViewModel.cs deleted file mode 100644 index 003e2e2f1..000000000 --- a/win/CS/HandBrakeWPF/ViewModels/InstantViewModel.cs +++ /dev/null @@ -1,1017 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="InstantViewModel.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The instant view model.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.ViewModels
-{
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Globalization;
- using System.IO;
- using System.Linq;
- using System.Threading;
- using System.Windows;
-
- using Caliburn.Micro;
-
- using HandBrake.ApplicationServices.EventArgs;
- using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Encode.EventArgs;
- using HandBrake.ApplicationServices.Services.Encode.Interfaces;
- using HandBrake.ApplicationServices.Services.Interfaces;
- using HandBrake.ApplicationServices.Services.Scan.EventArgs;
- using HandBrake.ApplicationServices.Services.Scan.Interfaces;
- using HandBrake.ApplicationServices.Services.Scan.Model;
- using HandBrake.ApplicationServices.Utilities;
-
- using HandBrakeWPF.Commands;
- using HandBrakeWPF.Factories;
- using HandBrakeWPF.Model;
- using HandBrakeWPF.Services.Interfaces;
- using HandBrakeWPF.Services.Presets.Interfaces;
- using HandBrakeWPF.Services.Presets.Model;
- using HandBrakeWPF.Utilities;
- using HandBrakeWPF.ViewModels.Interfaces;
- using HandBrakeWPF.Views;
-
- using Microsoft.Win32;
-
- using Ookii.Dialogs.Wpf;
-
- /// <summary>
- /// The instant view model.
- /// </summary>
- public class InstantViewModel : ViewModelBase, IInstantViewModel
- {
- #region Constants and Fields
-
- /// <summary>
- /// The encode service.
- /// </summary>
- private readonly IEncodeServiceWrapper encodeService;
-
- /// <summary>
- /// The error service.
- /// </summary>
- private readonly IErrorService errorService;
-
- /// <summary>
- /// The preset service.
- /// </summary>
- private readonly IPresetService presetService;
-
- /// <summary>
- /// The queue processor.
- /// </summary>
- private readonly IQueueProcessor queueProcessor;
-
- /// <summary>
- /// The scan service.
- /// </summary>
- private readonly IScan scanService;
-
- /// <summary>
- /// The shell view model.
- /// </summary>
- private readonly IShellViewModel shellViewModel;
-
- /// <summary>
- /// The update service.
- /// </summary>
- private readonly IUpdateService updateService;
-
- /// <summary>
- /// The user setting service.
- /// </summary>
- private readonly IUserSettingService userSettingService;
-
- /// <summary>
- /// Windows 7 API Pack wrapper
- /// </summary>
- private readonly Win7 windowsSeven = new Win7();
-
- /// <summary>
- /// The is encoding.
- /// </summary>
- private bool isEncoding;
-
- /// <summary>
- /// The last percentage complete value.
- /// </summary>
- private int lastEncodePercentage;
-
- /// <summary>
- /// The ordered by duration.
- /// </summary>
- private bool orderedByDuration;
-
- /// <summary>
- /// The ordered by title.
- /// </summary>
- private bool orderedByTitle;
-
- /// <summary>
- /// The output directory.
- /// </summary>
- private string outputDirectory;
-
- /// <summary>
- /// The program status label.
- /// </summary>
- private string programStatusLabel;
-
- /// <summary>
- /// The scanned source.
- /// </summary>
- private Source scannedSource;
-
- /// <summary>
- /// The selected preset.
- /// </summary>
- private Preset selectedPreset;
-
- /// <summary>
- /// The show status window.
- /// </summary>
- private bool showStatusWindow;
-
- /// <summary>
- /// The source label.
- /// </summary>
- private string sourceLabel;
-
- /// <summary>
- /// The status label.
- /// </summary>
- private string statusLabel;
-
- #endregion
-
- #region Constructors and Destructors
-
- /// <summary>
- /// Initializes a new instance of the <see cref="InstantViewModel"/> class.
- /// </summary>
- /// <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>
- /// <param name="errorService">
- /// The error service.
- /// </param>
- /// <param name="shellViewModel">
- /// The shell view model.
- /// </param>
- /// <param name="updateService">
- /// The update service.
- /// </param>
- /// <param name="notificationService">
- /// The notification service.
- /// </param>
- /// <param name="whenDoneService">
- /// The when done service.
- /// </param>
- public InstantViewModel(
- IUserSettingService userSettingService,
- IScan scanService,
- IEncodeServiceWrapper encodeService,
- IPresetService presetService,
- IErrorService errorService,
- IShellViewModel shellViewModel,
- IUpdateService updateService,
- INotificationService notificationService,
- IPrePostActionService whenDoneService)
- {
- this.userSettingService = userSettingService;
- this.scanService = scanService;
- this.encodeService = encodeService;
- this.presetService = presetService;
- this.errorService = errorService;
- this.shellViewModel = shellViewModel;
- this.updateService = updateService;
-
- this.queueProcessor = IoC.Get<IQueueProcessor>();
-
- // Setup Properties
- this.TitleList = new BindingList<SelectionTitle>();
- this.ScannedSource = new Source();
-
- // Setup Events
- this.scanService.ScanStared += this.ScanStared;
- this.scanService.ScanCompleted += this.ScanCompleted;
- this.scanService.ScanStatusChanged += this.ScanStatusChanged;
- this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
- this.queueProcessor.QueueCompleted += this.QueueCompleted;
- this.queueProcessor.QueueChanged += this.QueueChanged;
- this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
-
- this.Presets = this.presetService.Presets;
- this.CancelScanCommand = new CancelScanCommand(this.scanService);
- }
-
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets or sets the cancel scan command.
- /// </summary>
- public CancelScanCommand CancelScanCommand { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether IsEncoding.
- /// </summary>
- public bool IsEncoding
- {
- get
- {
- return this.isEncoding;
- }
-
- set
- {
- this.isEncoding = value;
- this.NotifyOfPropertyChange(() => this.IsEncoding);
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether ordered by duration.
- /// </summary>
- public bool OrderedByDuration
- {
- get
- {
- return this.orderedByDuration;
- }
-
- set
- {
- this.orderedByDuration = value;
- this.NotifyOfPropertyChange(() => this.OrderedByDuration);
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether ordered by title.
- /// </summary>
- public bool OrderedByTitle
- {
- get
- {
- return this.orderedByTitle;
- }
-
- set
- {
- this.orderedByTitle = value;
- this.NotifyOfPropertyChange(() => this.OrderedByTitle);
- }
- }
-
- /// <summary>
- /// Gets or sets the output directory.
- /// </summary>
- public string OutputDirectory
- {
- get
- {
- return this.outputDirectory;
- }
- set
- {
- this.outputDirectory = value;
- this.NotifyOfPropertyChange(() => this.OutputDirectory);
- }
- }
-
- /// <summary>
- /// Gets or sets Presets.
- /// </summary>
- public IEnumerable<Preset> Presets { get; set; }
-
- /// <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.programStatusLabel;
- }
-
- set
- {
- if (!Equals(this.programStatusLabel, value))
- {
- this.programStatusLabel = value;
- this.NotifyOfPropertyChange(() => this.ProgramStatusLabel);
- }
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating progress percentage.
- /// </summary>
- public int ProgressPercentage { get; set; }
-
- /// <summary>
- /// Gets or sets the Last Scanned Source
- /// This object contains information about the scanned source.
- /// </summary>
- public Source ScannedSource
- {
- get
- {
- return this.scannedSource;
- }
-
- set
- {
- this.scannedSource = value;
-
- this.NotifyOfPropertyChange("ScannedSource");
- }
- }
-
- /// <summary>
- /// Gets or sets SelectedPreset.
- /// </summary>
- public Preset SelectedPreset
- {
- get
- {
- return this.selectedPreset;
- }
- set
- {
- this.selectedPreset = value;
- this.NotifyOfPropertyChange(() => this.SelectedPreset);
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether ShowStatusWindow.
- /// </summary>
- public bool ShowStatusWindow
- {
- get
- {
- return this.showStatusWindow;
- }
-
- set
- {
- this.showStatusWindow = value;
- this.NotifyOfPropertyChange(() => this.ShowStatusWindow);
- }
- }
-
- /// <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 (!Equals(this.sourceLabel, value))
- {
- this.sourceLabel = value;
- this.NotifyOfPropertyChange("SourceLabel");
- }
- }
- }
-
- /// <summary>
- /// Gets SourceName.
- /// </summary>
- public string SourceName
- {
- get
- {
- // Sanity Check
- if (this.ScannedSource == null || this.ScannedSource.ScanPath == null)
- {
- return string.Empty;
- }
-
- // The title that is selected has a source name. This means it's part of a batch scan.
- // if (selectedTitle != null && !string.IsNullOrEmpty(selectedTitle.SourceName))
- // {
- // return Path.GetFileNameWithoutExtension(selectedTitle.SourceName);
- // }
-
- // Check if we have a Folder, if so, check if it's a DVD / Bluray drive and get the label.
- if (this.ScannedSource.ScanPath.EndsWith("\\"))
- {
- foreach (DriveInformation item in GeneralUtilities.GetDrives())
- {
- if (item.RootDirectory.Contains(this.ScannedSource.ScanPath))
- {
- return item.VolumeLabel;
- }
- }
- }
-
- if (Path.GetFileNameWithoutExtension(this.ScannedSource.ScanPath) != "VIDEO_TS")
- {
- return Path.GetFileNameWithoutExtension(this.ScannedSource.ScanPath);
- }
-
- return Path.GetFileNameWithoutExtension(Path.GetDirectoryName(this.ScannedSource.ScanPath));
- }
- }
-
- /// <summary>
- /// Gets or sets the Program Status Toolbar Label
- /// This indicates the status of HandBrake
- /// </summary>
- public string StatusLabel
- {
- get
- {
- return string.IsNullOrEmpty(this.statusLabel) ? "Ready" : this.statusLabel;
- }
-
- set
- {
- if (!Equals(this.statusLabel, value))
- {
- this.statusLabel = value;
- this.NotifyOfPropertyChange(() => this.StatusLabel);
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the selected titles.
- /// </summary>
- public BindingList<SelectionTitle> TitleList { get; set; }
-
- #endregion
-
- #region Public Methods
-
- /// <summary>
- /// The Destination Path
- /// </summary>
- public void BrowseDestination()
- {
- var saveFileDialog = new SaveFileDialog
- {
- Filter = "mp4|*.mp4;*.m4v|mkv|*.mkv",
- CheckPathExists = true,
- AddExtension = true,
- DefaultExt = ".mp4",
- OverwritePrompt = true,
- };
-
- saveFileDialog.ShowDialog();
- this.OutputDirectory = Path.GetDirectoryName(saveFileDialog.FileName);
- }
-
- /// <summary>
- /// Cancel a Scan
- /// </summary>
- public void CancelScan()
- {
- this.scanService.Stop();
- }
-
- /// <summary>
- /// File Scan
- /// </summary>
- public void FileScan()
- {
- var dialog = new OpenFileDialog() { Filter = "All files (*.*)|*.*" };
- dialog.ShowDialog();
- this.StartScan(dialog.FileName, 0);
- }
-
- /// <summary>
- /// Support dropping a file onto the main window to scan.
- /// </summary>
- /// <param name="e">
- /// The DragEventArgs.
- /// </param>
- public void FilesDroppedOnWindow(DragEventArgs e)
- {
- if (e.Data.GetDataPresent(DataFormats.FileDrop))
- {
- var fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[];
- if (fileNames != null && fileNames.Any() &&
- (File.Exists(fileNames[0]) || Directory.Exists(fileNames[0])))
- {
- this.StartScan(fileNames[0], 0);
- }
- }
-
- e.Handled = true;
- }
-
- /// <summary>
- /// Folder Scan
- /// </summary>
- public void FolderScan()
- {
- var dialog = new VistaFolderBrowserDialog
- {
- Description = "Please select a folder.",
- UseDescriptionForTitle = true
- };
- dialog.ShowDialog();
- this.StartScan(dialog.SelectedPath, 0);
- }
-
- /// <summary>
- /// Launch the Help pages.
- /// </summary>
- public void LaunchHelp()
- {
- Process.Start("https://trac.handbrake.fr/wiki/HandBrakeGuide");
- }
-
- /// <summary>
- /// The on load.
- /// </summary>
- public override void OnLoad()
- {
- // Perform an update check if required
- // this.updateService.PerformStartupUpdateCheck(this.HandleUpdateCheckResults);
-
- // Setup the presets.
- this.presetService.Load();
- if (this.presetService.CheckIfPresetsAreOutOfDate())
- {
- if (!this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PresetNotification))
- {
- this.errorService.ShowMessageBox(
- "HandBrake has determined your built-in presets are out of date... These presets will now be updated." +
- Environment.NewLine +
- "Your custom presets have not been updated so you may have to re-create these by deleting and re-adding them.",
- "Preset Update",
- MessageBoxButton.OK,
- MessageBoxImage.Information);
- }
- }
-
- this.SelectedPreset = this.presetService.DefaultPreset;
-
- // Log Cleaning
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ClearOldLogs))
- {
- var clearLog = new Thread(() => GeneralUtilities.ClearLogFiles(30));
- clearLog.Start();
- }
- base.OnLoad();
- }
-
- /// <summary>
- /// Open the About Window
- /// </summary>
- public void OpenAboutApplication()
- {
- var command = new OpenOptionsScreenCommand();
- command.Execute(OptionsTab.About);
- }
-
- /// <summary>
- /// Open the Log Window
- /// </summary>
- public void OpenLogWindow()
- {
- Window window =
- Application.Current.Windows.Cast<Window>().FirstOrDefault(x => x.GetType() == typeof(LogView));
-
- if (window != null)
- {
- var logvm = (ILogViewModel)window.DataContext;
- logvm.SelectedTab = this.IsEncoding ? 0 : 1;
- window.Activate();
- }
- else
- {
- var logvm = IoC.Get<ILogViewModel>();
- logvm.SelectedTab = this.IsEncoding ? 0 : 1;
- this.WindowManager.ShowWindow(logvm);
- }
- }
-
- /// <summary>
- /// Open the Options Window
- /// </summary>
- public void OpenOptionsWindow()
- {
- this.shellViewModel.DisplayWindow(ShellWindow.OptionsWindow);
- }
-
- /// <summary>
- /// The order by duration.
- /// </summary>
- public void OrderByDuration()
- {
- this.TitleList =
- new BindingList<SelectionTitle>(this.TitleList.OrderByDescending(o => o.Title.Duration).ToList());
- this.NotifyOfPropertyChange(() => this.TitleList);
- this.OrderedByTitle = false;
- this.OrderedByDuration = true;
- }
-
- /// <summary>
- /// The order by title.
- /// </summary>
- public void OrderByTitle()
- {
- this.TitleList = new BindingList<SelectionTitle>(this.TitleList.OrderBy(o => o.Title.TitleNumber).ToList());
- this.NotifyOfPropertyChange(() => this.TitleList);
- this.OrderedByTitle = true;
- this.OrderedByDuration = false;
- }
-
- /// <summary>
- /// Pause an Encode
- /// </summary>
- public void PauseEncode()
- {
- this.queueProcessor.Pause();
- }
-
- /// <summary>
- /// The select all.
- /// </summary>
- public void SelectAll()
- {
- foreach (SelectionTitle item in this.TitleList)
- {
- item.IsSelected = true;
- }
- }
-
- /// <summary>
- /// The setup.
- /// </summary>
- /// <param name="scannedSource">
- /// The scanned source.
- /// </param>
- public void Setup(Source scannedSource)
- {
- this.TitleList.Clear();
-
- if (scannedSource != null)
- {
- IEnumerable<Title> titles = this.orderedByTitle
- ? scannedSource.Titles
- : scannedSource.Titles.OrderByDescending(o => o.Duration).ToList();
-
- foreach (Title item in titles)
- {
- var title = new SelectionTitle(item, item.SourceName) { IsSelected = true };
- this.TitleList.Add(title);
- }
- }
- }
-
- /// <summary>
- /// Shutdown this View
- /// </summary>
- public void Shutdown()
- {
- // Shutdown Service
- this.encodeService.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.QueueChanged -= this.QueueChanged;
- this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
- this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
- }
-
- /// <summary>
- /// Start an Encode
- /// </summary>
- public void StartEncode()
- {
- // if (this.queueProcessor.IsProcessing)
- // {
- // this.errorService.ShowMessageBox("HandBrake is already encoding.", Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- // return;
- // }
-
- //// Check if we already have jobs, and if we do, just start the queue.
- // if (this.queueProcessor.Count != 0)
- // {
- // this.queueProcessor.Start();
- // return;
- // }
-
- //// Otherwise, perform Santiy Checking then add to the queue and start if everything is ok.
- // if (this.SelectedTitle == null)
- // {
- // this.errorService.ShowMessageBox("You must first scan a source.", Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- // return;
- // }
-
- // if (string.IsNullOrEmpty(this.Destination))
- // {
- // this.errorService.ShowMessageBox("The Destination field was empty.", Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- // return;
- // }
-
- // if (File.Exists(this.Destination))
- // {
- // MessageBoxResult result = this.errorService.ShowMessageBox("The current file already exists, do you wish to overwrite it?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question);
- // if (result == MessageBoxResult.No)
- // {
- // return;
- // }
- // }
-
- //// Create the Queue Task and Start Processing
- // QueueTask task = new QueueTask
- // {
- // Task = new EncodeTask(this.CurrentTask),
- // CustomQuery = false
- // };
- // this.queueProcessor.Add(task);
- // this.queueProcessor.Start();
- // this.IsEncoding = true;
- }
-
- /// <summary>
- /// Start a Scan
- /// </summary>
- /// <param name="filename">
- /// The filename.
- /// </param>
- /// <param name="title">
- /// The title.
- /// </param>
- public void StartScan(string filename, int title)
- {
- if (!string.IsNullOrEmpty(filename))
- {
- this.scanService.Scan(
- filename,
- title,
- null,
- HBConfigurationFactory.Create());
- }
- }
-
- /// <summary>
- /// Stop an Encode.
- /// </summary>
- public void StopEncode()
- {
- this.queueProcessor.Pause();
- this.encodeService.Stop();
- }
-
- /// <summary>
- /// The select all.
- /// </summary>
- public void UnSelectAll()
- {
- foreach (SelectionTitle item in this.TitleList)
- {
- item.IsSelected = false;
- }
- }
-
- #endregion
-
- #region Methods
-
- /// <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, EncodeProgressEventArgs e)
- {
- int percent;
- int.TryParse(Math.Round(e.PercentComplete).ToString(CultureInfo.InvariantCulture), out percent);
-
- Execute.OnUIThread(
- () =>
- {
- if (this.queueProcessor.EncodeService.IsEncoding)
- {
- string josPending = string.Empty;
- if (!AppArguments.IsInstantHandBrake)
- {
- josPending = ", Pending Jobs {5}";
- }
-
- this.ProgramStatusLabel =
- string.Format(
- "{0:00.00}%, FPS: {1:000.0}, Avg FPS: {2:000.0}, Time Remaining: {3}, Elapsed: {4:hh\\:mm\\:ss}" +
- josPending,
- e.PercentComplete,
- e.CurrentFrameRate,
- e.AverageFrameRate,
- e.EstimatedTimeLeft,
- e.ElapsedTime,
- this.queueProcessor.Count);
-
- if (this.lastEncodePercentage != percent && this.windowsSeven.IsWindowsSeven)
- {
- this.windowsSeven.SetTaskBarProgress(percent);
- }
-
- this.lastEncodePercentage = percent;
- this.ProgressPercentage = percent;
- this.NotifyOfPropertyChange(() => this.ProgressPercentage);
- }
- else
- {
- this.ProgramStatusLabel = "Queue Finished";
- this.IsEncoding = false;
-
- if (this.windowsSeven.IsWindowsSeven)
- {
- this.windowsSeven.SetTaskBarProgressToNoProgress();
- }
- }
- });
- }
-
- /// <summary>
- /// The queue changed.
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The EventArgs.
- /// </param>
- private void QueueChanged(object sender, EventArgs e)
- {
- Execute.OnUIThread(
- () => { this.ProgramStatusLabel = string.Format("{0} Encodes Pending", this.queueProcessor.Count); });
- }
-
- /// <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)
- {
- this.IsEncoding = false;
-
- Execute.OnUIThread(
- () =>
- {
- this.ProgramStatusLabel = "Queue Finished";
- this.IsEncoding = false;
-
- if (this.windowsSeven.IsWindowsSeven)
- {
- this.windowsSeven.SetTaskBarProgressToNoProgress();
- }
- });
- }
-
- /// <summary>
- /// Handle the Queue Starting Event
- /// </summary>
- /// <param name="sender">
- /// The sender.
- /// </param>
- /// <param name="e">
- /// The e.
- /// </param>
- private void QueueProcessorJobProcessingStarted(object sender, QueueProgressEventArgs e)
- {
- Execute.OnUIThread(
- () =>
- {
- this.ProgramStatusLabel = "Preparing to encode ...";
- this.IsEncoding = true;
- });
- }
-
- /// <summary>
- /// Handle the Scan Completed Event
- /// </summary>
- /// <param name="sender">
- /// The Sender
- /// </param>
- /// <param name="e">
- /// The EventArgs
- /// </param>
- private void ScanCompleted(object sender, ScanCompletedEventArgs e)
- {
- this.scanService.SouceData.CopyTo(this.ScannedSource);
- this.NotifyOfPropertyChange(() => this.ScannedSource);
-
- Execute.OnUIThread(
- () =>
- {
- if (this.scannedSource != null)
- {
- this.Setup(this.scannedSource);
- }
-
- if (e.Successful)
- {
- this.NotifyOfPropertyChange(() => this.ScannedSource);
- this.NotifyOfPropertyChange(() => this.ScannedSource.Titles);
- }
-
- this.ShowStatusWindow = false;
- if (e.Successful)
- {
- this.SourceLabel = this.SourceName;
- this.StatusLabel = "Scan Completed";
- }
- else if (e.Cancelled)
- {
- this.SourceLabel = "Scan Cancelled.";
- this.StatusLabel = "Scan Cancelled.";
- }
- else if (e.Exception == null && e.ErrorInformation != null)
- {
- this.SourceLabel = "Scan failed: " + e.ErrorInformation;
- this.StatusLabel = "Scan failed: " + e.ErrorInformation;
- }
- else
- {
- this.SourceLabel = "Scan Failed... See Activity Log for details.";
- this.StatusLabel = "Scan Failed... See Activity Log for details.";
- }
- });
- }
-
- /// <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)
- {
- Execute.OnUIThread(
- () =>
- {
- this.StatusLabel = "Scanning source, please wait...";
- this.ShowStatusWindow = true;
- });
- }
-
- /// <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, ScanProgressEventArgs e)
- {
- this.SourceLabel = string.Format("Scanning Title {0} of {1} ({2}%)", e.CurrentTitle, e.Titles, e.Percentage);
- this.StatusLabel = string.Format("Scanning Title {0} of {1} ({2}%)", e.CurrentTitle, e.Titles, e.Percentage);
- }
-
- #endregion
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IInstantViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IInstantViewModel.cs deleted file mode 100644 index 5481865b8..000000000 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IInstantViewModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="IInstantViewModel.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the IInstantViewModel type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.ViewModels.Interfaces
-{
- /// <summary>
- /// The InstantViewModel interface.
- /// </summary>
- public interface IInstantViewModel
- {
- }
-}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs index a580eb86c..8e66c661e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs @@ -94,11 +94,6 @@ namespace HandBrakeWPF.ViewModels.Interfaces void Shutdown();
/// <summary>
- /// The show cli query.
- /// </summary>
- void ShowCliQuery();
-
- /// <summary>
/// The files dropped on window.
/// </summary>
/// <param name="e">
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 6eff64259..18f994026 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1064,10 +1064,7 @@ namespace HandBrakeWPF.ViewModels Resources.Notice, MessageBoxButton.OK, MessageBoxImage.Information);
// Queue Recovery
- if (!AppArguments.IsInstantHandBrake)
- {
- QueueRecoveryHelper.RecoverQueue(this.queueProcessor, this.errorService);
- }
+ QueueRecoveryHelper.RecoverQueue(this.queueProcessor, this.errorService);
this.SelectedPreset = this.presetService.DefaultPreset;
@@ -1085,7 +1082,7 @@ namespace HandBrakeWPF.ViewModels public void Shutdown()
{
// Shutdown Service
- this.encodeService.Shutdown();
+ this.encodeService.Stop();
// Unsubscribe from Events.
this.scanService.ScanStared -= this.ScanStared;
@@ -1455,18 +1452,6 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
- /// DEBUG: Show CLI Query for settings+6
- /// </summary>
- public void ShowCliQuery()
- {
- this.errorService.ShowMessageBox(
- QueryGeneratorUtility.GenerateQuery(this.CurrentTask, HBConfigurationFactory.Create()),
- "CLI Query",
- MessageBoxButton.OK,
- MessageBoxImage.Information);
- }
-
- /// <summary>
/// The select source window.
/// </summary>
public void SelectSourceWindow()
@@ -2065,14 +2050,8 @@ namespace HandBrakeWPF.ViewModels {
if (this.queueProcessor.EncodeService.IsEncoding)
{
- string josPending = string.Empty;
- if (!AppArguments.IsInstantHandBrake)
- {
- josPending = Resources.Main_JobsPending_addon;
- }
-
this.ProgramStatusLabel =
- string.Format("{0:00.00}%, FPS: {1:000.0}, Avg FPS: {2:000.0}, Time Remaining: {3}, Elapsed: {4:hh\\:mm\\:ss}" + josPending,
+ string.Format("{0:00.00}%, FPS: {1:000.0}, Avg FPS: {2:000.0}, Time Remaining: {3}, Elapsed: {4:hh\\:mm\\:ss}" + Resources.Main_JobsPending_addon,
e.PercentComplete,
e.CurrentFrameRate,
e.AverageFrameRate,
diff --git a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs index 10c82f1a4..e297db422 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs @@ -9,8 +9,6 @@ namespace HandBrakeWPF.ViewModels
{
- using System.IO;
- using System.Linq;
using System.Windows;
using Caliburn.Micro;
@@ -44,11 +42,6 @@ namespace HandBrakeWPF.ViewModels /// </summary>
private bool showOptions;
- /// <summary>
- /// The show instant.
- /// </summary>
- private bool showInstant;
-
#endregion
/// <summary>
@@ -60,19 +53,8 @@ namespace HandBrakeWPF.ViewModels public ShellViewModel(IErrorService errorService)
{
this.errorService = errorService;
-
- if (!AppArguments.IsInstantHandBrake)
- {
- this.showMainWindow = true;
- this.showOptions = false;
- this.showInstant = false;
- }
- else
- {
- this.showMainWindow = false;
- this.showOptions = false;
- this.showInstant = true;
- }
+ this.showMainWindow = true;
+ this.showOptions = false;
}
/// <summary>
@@ -87,25 +69,16 @@ namespace HandBrakeWPF.ViewModels {
this.ShowMainWindow = true;
this.ShowOptions = false;
- this.ShowInstant = false;
}
else if (window == ShellWindow.OptionsWindow)
{
this.ShowOptions = true;
this.ShowMainWindow = false;
- this.ShowInstant = false;
- }
- else if (window == ShellWindow.InstantMainWindow)
- {
- this.ShowInstant = true;
- this.ShowOptions = false;
- this.ShowMainWindow = false;
}
else
{
this.ShowMainWindow = true;
this.ShowOptions = false;
- this.ShowInstant = false;
}
}
@@ -122,11 +95,6 @@ namespace HandBrakeWPF.ViewModels public IOptionsViewModel OptionsViewModel { get; set; }
/// <summary>
- /// Gets or sets the instant view model.
- /// </summary>
- public IInstantViewModel InstantViewModel { get; set; }
-
- /// <summary>
/// Gets or sets a value indicating whether ShowMainWindow.
/// </summary>
public bool ShowMainWindow
@@ -159,29 +127,13 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
- /// Gets or sets a value indicating whether ShowInstant.
- /// </summary>
- public bool ShowInstant
- {
- get
- {
- return this.showInstant;
- }
- set
- {
- this.showInstant = value;
- this.NotifyOfPropertyChange(() => this.ShowInstant);
- }
- }
-
- /// <summary>
/// Gets WindowTitle.
/// </summary>
public string WindowTitle
{
get
{
- return AppArguments.IsInstantHandBrake ? "Instant HandBrake" : "HandBrake";
+ return "HandBrake";
}
}
diff --git a/win/CS/HandBrakeWPF/Views/InstantView.xaml b/win/CS/HandBrakeWPF/Views/InstantView.xaml deleted file mode 100644 index bb9bc1971..000000000 --- a/win/CS/HandBrakeWPF/Views/InstantView.xaml +++ /dev/null @@ -1,202 +0,0 @@ -<UserControl x:Class="HandBrakeWPF.Views.InstantView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:cal="http://www.caliburnproject.org"
- xmlns:controls="clr-namespace:HandBrakeWPF.Controls"
- xmlns:converters="clr-namespace:HandBrakeWPF.Converters"
- xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
- mc:Ignorable="d"
- cal:Message.Attach="[Event Loaded] = [Action Load]"
- >
-
- <i:Interaction.Triggers>
- <i:EventTrigger EventName="Drop">
- <cal:ActionMessage MethodName="FilesDroppedOnWindow">
- <cal:Parameter Value="$eventArgs" />
- </cal:ActionMessage>
- </i:EventTrigger>
- </i:Interaction.Triggers>
-
- <UserControl.Resources>
- <converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
- </UserControl.Resources>
-
- <!-- Window Body -->
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="*" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
-
-
- <!-- Source -->
- <StackPanel Orientation="Vertical" Grid.Row="0">
- <!-- Source -->
- <StackPanel Margin="10,5,5,5"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- >
- <StackPanel Orientation="Horizontal">
- <Label Content="Source" FontWeight="Bold" />
- </StackPanel>
-
- <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="8,10,0,10">
-
- <TextBlock Text="Drag and Drop a file - OR - Open a " />
- <Button cal:Message.Attach="[Event Click] = [Action FileScan]" Padding="8,2">
- File
- </Button>
- <TextBlock Text="- OR -" FontWeight="Bold" Margin="10,0,10,0" />
- <Button cal:Message.Attach="[Event Click] = [Action FolderScan]" Padding="8,2">
- Folder
- </Button>
-
- </StackPanel>
-
- <ListBox Grid.Row="2"
- Margin="10,10,10,10"
- MinHeight="150" MaxHeight="150"
- VerticalAlignment="Stretch"
- Background="LightGray"
- ItemsSource="{Binding TitleList}"
- SelectionMode="Single">
- <ListBox.ItemContainerStyle>
- <Style TargetType="ListBoxItem">
- <Setter Property="HorizontalContentAlignment" Value="Stretch" />
- <Setter Property="Background" Value="WhiteSmoke" />
- <Setter Property="Margin" Value="0,0,0,1" />
- </Style>
- </ListBox.ItemContainerStyle>
-
- <ListBox.ContextMenu>
- <ContextMenu>
- <MenuItem Header="Select All" cal:Message.Attach="[Event Click] = [Action SelectAll]" />
- <MenuItem Header="Deselect All" cal:Message.Attach="[Event Click] = [Action UnSelectAll]" />
- <Separator />
- <MenuItem Header="Order by Title" IsChecked="{Binding OrderedByTitle}" cal:Message.Attach="[Event Click] = [Action OrderByTitle]" />
- <MenuItem Header="Order by Duration" IsChecked="{Binding OrderedByDuration}" cal:Message.Attach="[Event Click] = [Action OrderByDuration]" />
- </ContextMenu>
- </ListBox.ContextMenu>
-
- <ListBox.ItemTemplate>
- <DataTemplate>
- <Grid HorizontalAlignment="Stretch" MinHeight="28">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="Auto" />
- </Grid.ColumnDefinitions>
-
- <CheckBox IsChecked="{Binding IsSelected}" Grid.RowSpan="2" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" />
-
- <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Margin="10,0,0,0" >
- <TextBlock Text="Title:" Margin="0,0,5,0" FontWeight="Bold" />
- <TextBlock Text="{Binding Title}" Margin="5,0,5,0" />
- </StackPanel>
-
- <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" Margin="10,0,0,0" >
- <TextBlock Text="Source:" Margin="0,0,5,0" FontWeight="Bold" />
- <TextBlock Text="{Binding SourceName}" Margin="5,0,5,0" />
- </StackPanel>
- </Grid>
-
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- </StackPanel>
- </StackPanel>
-
-
- <!-- Destination -->
- <StackPanel Grid.Row="1"
- Margin="10,5,5,5"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- >
- <Label Content="Destination" FontWeight="Bold" />
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="Auto" />
- </Grid.ColumnDefinitions>
- <Label Margin="8,0,0,0" Content="File" />
- <TextBox Name="Destination"
- Grid.Column="1"
- Margin="8,0,0,0"
- Text="{Binding OutputDirectory,
- UpdateSourceTrigger=PropertyChanged}"
- />
- <Button Name="DestinationBrowser"
- Grid.Column="2"
- Margin="8,0,5,0"
- Padding="8,2"
- Content="Browse"
- cal:Message.Attach="[Event Click] = [Action BrowseDestination]"
- />
- </Grid>
- </StackPanel>
-
- <!-- Opitons -->
- <StackPanel Grid.Row="2"
- Margin="10,5,5,5"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- >
- <Label Content="Options" FontWeight="Bold" />
-
- <StackPanel Orientation="Horizontal" Margin="8,0,0,0">
- <TextBlock Text="Preset:" Margin="0,0,5,0" />
- <ComboBox ItemsSource="{Binding Presets}" SelectedItem="{Binding SelectedPreset}" MinWidth="150" />
- </StackPanel>
-
- </StackPanel>
-
-
- <!-- Buttons and Queueing -->
- <Grid Grid.Row="3" Margin="10,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <Label Content="Start" FontWeight="Bold" Grid.Row="0" />
- <Button Content="Start Encoding" cal:Message.Attach="[Event Click] = [Action StartEncode]" FontWeight="Bold" Grid.Row="1" Padding="8,2" HorizontalAlignment="Center"
- Visibility="{Binding IsEncoding, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
- <Button Content="Stop Encoding" cal:Message.Attach="[Event Click] = [Action StopEncode]" FontWeight="Bold" Grid.Row="1" Padding="8,2" HorizontalAlignment="Center"
- Visibility="{Binding IsEncoding, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
- </Grid>
-
-
- <!-- StatusPanel -->
- <controls:StatusPanel x:Name="loadingPanel"
- Grid.Row="3"
- Grid.RowSpan="2"
- Height="70"
- VerticalAlignment="Bottom"
- Panel.ZIndex="10"
- IsLoading="{Binding ShowStatusWindow}"
- Message="{Binding StatusLabel}"
- SubMessage="Please Wait ..."
- />
-
- <!-- Status Bar -->
- <StatusBar Grid.Row="4" Grid.ColumnSpan="2" MinHeight="32" >
-
- <ProgressBar Value="{Binding ProgressPercentage}" Visibility="{Binding IsEncoding, Converter={StaticResource boolToVisConverter}}"
- Width="100" Height="18" VerticalAlignment="Center"/>
- <Label VerticalAlignment="Center"
- Content="{Binding Path=ProgramStatusLabel}" />
-
- </StatusBar>
-
- </Grid>
-</UserControl>
diff --git a/win/CS/HandBrakeWPF/Views/InstantView.xaml.cs b/win/CS/HandBrakeWPF/Views/InstantView.xaml.cs deleted file mode 100644 index 8ca18aa87..000000000 --- a/win/CS/HandBrakeWPF/Views/InstantView.xaml.cs +++ /dev/null @@ -1,27 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="InstantView.xaml.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Interaction logic for InstantMainView.xaml
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Views
-{
- using System.Windows.Controls;
-
- /// <summary>
- /// Interaction logic for InstantMainView.xaml
- /// </summary>
- public partial class InstantView : UserControl
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="InstantView"/> class.
- /// </summary>
- public InstantView()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/win/CS/HandBrakeWPF/Views/ShellView.xaml b/win/CS/HandBrakeWPF/Views/ShellView.xaml index ab82b298a..9f735ec61 100644 --- a/win/CS/HandBrakeWPF/Views/ShellView.xaml +++ b/win/CS/HandBrakeWPF/Views/ShellView.xaml @@ -35,7 +35,5 @@ <ContentControl x:Name="MainViewModel" Visibility="{Binding ShowMainWindow, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
<ContentControl x:Name="OptionsViewModel" Visibility="{Binding ShowOptions, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
- <views:InstantView DataContext="{Binding InstantViewModel}"
- Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ShowInstant, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
</Grid>
</Window>
diff --git a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs index 03059a2a8..e38e37c46 100644 --- a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs @@ -4,12 +4,14 @@ // </copyright>
// <summary>
// Interaction logic for ShellView.xaml
-// </summary>
+// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Views
{
using System;
+ using System.ComponentModel;
+ using System.Drawing;
using System.IO;
using System.Windows;
using System.Windows.Forms;
@@ -18,9 +20,6 @@ namespace HandBrakeWPF.Views using Caliburn.Micro;
- using HandBrake.ApplicationServices.Services.Interfaces;
- using HandBrake.ApplicationServices.Utilities;
-
using HandBrakeWPF.Commands;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Utilities;
@@ -36,7 +35,7 @@ namespace HandBrakeWPF.Views /// <summary>
/// The my notify icon.
/// </summary>
- private readonly System.Windows.Forms.NotifyIcon notifyIcon;
+ private readonly NotifyIcon notifyIcon;
/// <summary>
/// Initializes a new instance of the <see cref="ShellView"/> class.
@@ -50,14 +49,14 @@ namespace HandBrakeWPF.Views if (minimiseToTray)
{
- this.notifyIcon = new System.Windows.Forms.NotifyIcon();
+ this.notifyIcon = new NotifyIcon();
this.notifyIcon.ContextMenu = new ContextMenu(new[] { new MenuItem("Restore", NotifyIconClick) });
StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri("pack://application:,,,/handbrakepineapple.ico"));
if (streamResourceInfo != null)
{
Stream iconStream = streamResourceInfo.Stream;
- this.notifyIcon.Icon = new System.Drawing.Icon(iconStream);
+ this.notifyIcon.Icon = new Icon(iconStream);
}
this.notifyIcon.DoubleClick += this.NotifyIconClick;
this.StateChanged += this.ShellViewStateChanged;
@@ -70,7 +69,6 @@ namespace HandBrakeWPF.Views // Add to Queue (Ctrl+A)
// Scan a File (Ctrl+F)
// Scan a Folder (Ctrl+R)
- // Show CLI Query (Ctrl+Shift+D)
this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.S, ModifierKeys.Control)), new KeyGesture(Key.S, ModifierKeys.Control)));
this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.K, ModifierKeys.Control)), new KeyGesture(Key.K, ModifierKeys.Control)));
@@ -80,7 +78,6 @@ namespace HandBrakeWPF.Views this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.F, ModifierKeys.Control)), new KeyGesture(Key.F, ModifierKeys.Control)));
this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Control)), new KeyGesture(Key.O, ModifierKeys.Control)));
this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.R, ModifierKeys.Control)), new KeyGesture(Key.R, ModifierKeys.Control)));
- this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift)));
this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)));
// Enable Windows 7 Taskbar progress indication.
@@ -88,14 +85,6 @@ namespace HandBrakeWPF.Views {
this.TaskbarItemInfo = Win7.WindowsTaskbar;
}
-
- // Window Sizing
- if (AppArguments.IsInstantHandBrake)
- {
- this.SizeToContent = SizeToContent.WidthAndHeight;
- this.MinHeight = 380;
- this.MinWidth = 600;
- }
}
/// <summary>
@@ -129,6 +118,7 @@ namespace HandBrakeWPF.Views {
this.ShowInTaskbar = false;
notifyIcon.Visible = true;
+
// notifyIcon.ShowBalloonTip(5000, "HandBrake", "Application Minimised", ToolTipIcon.Info);
}
else if (this.WindowState == WindowState.Normal)
@@ -145,7 +135,7 @@ namespace HandBrakeWPF.Views /// <param name="e">
/// The CancelEventArgs.
/// </param>
- protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
+ protected override void OnClosing(CancelEventArgs e)
{
IShellViewModel shellViewModel = this.DataContext as IShellViewModel;
diff --git a/win/CS/build.xml b/win/CS/build.xml index f030e843e..595e24866 100644 --- a/win/CS/build.xml +++ b/win/CS/build.xml @@ -8,7 +8,7 @@ Usage:
msbuild build.xml /p:Platform=x86 /t:Nightly
msbuild build.xml /p:Platform=x86 /t:Release
- Reuqires: HandBrakeCli.exe to be in the release folder.
+ Reuqires: libhb.dll to be in the release folder.
-->
<Project DefaultTargets="Nightly" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|