summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueManager.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs10
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/ScanService.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs155
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs4
5 files changed, 114 insertions, 62 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueManager.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueManager.cs
index e86b5fe7c..0ae6bf518 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueManager.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IQueueManager.cs
@@ -131,5 +131,10 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
/// True if sucessful
/// </returns>
bool WriteBatchScriptToFile(string path);
+
+ /// <summary>
+ /// Temp workaround until this can be fixed properly.
+ /// </summary>
+ void ResetInstanceId();
}
} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
index 452f47365..abe684a17 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
@@ -54,7 +54,7 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// HandBrakes Queue file with a place holder for an extra string.
/// </summary>
- private readonly string queueFile;
+ private string queueFile;
#endregion
@@ -408,6 +408,14 @@ namespace HandBrake.ApplicationServices.Services
return false;
}
+ /// <summary>
+ /// Temp workaround until this can be fixed properly.
+ /// </summary>
+ public void ResetInstanceId()
+ {
+ this.queueFile = string.Format("hb_queue_recovery{0}.xml", GeneralUtilities.GetInstanceCount);
+ }
+
#endregion
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
index fc8bb3f63..742a46b08 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
@@ -25,7 +25,7 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// Scan a Source
/// </summary>
- public class ScanService : IScan
+ public class ScanService : IScan
{
#region Private Variables
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
index 34a078a7c..773de5bfc 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
@@ -12,6 +12,7 @@ namespace HandBrake.ApplicationServices.Utilities
using System;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Globalization;
using System.IO;
using System.Text;
using System.Windows.Forms;
@@ -27,15 +28,54 @@ namespace HandBrake.ApplicationServices.Utilities
/// </summary>
public class GeneralUtilities
{
+ #region Constants and Fields
+
+ /// <summary>
+ /// The Default Log Directory
+ /// </summary>
+ private static readonly string LogDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
+ "\\HandBrake\\logs";
+
/// <summary>
/// The User Setting Service
/// </summary>
private static readonly IUserSettingService UserSettingService = IoC.Get<IUserSettingService>();
/// <summary>
- /// The Default Log Directory
+ /// The Instance ID
+ /// </summary>
+ private static int instanceId = 0;
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets the number of HandBrake instances running.
/// </summary>
- private static readonly string LogDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
+ public static string GetInstanceCount
+ {
+ get
+ {
+ return instanceId == 0 ? string.Empty : instanceId.ToString(CultureInfo.InvariantCulture);
+ }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether HandBrake is running in multi instance mode
+ /// </summary>
+ /// <returns>True if the UI has another instance running</returns>
+ public static bool IsMultiInstance
+ {
+ get
+ {
+ return Process.GetProcessesByName("HandBrake").Length > 1 ? true : false;
+ }
+ }
+
+ #endregion
+
+ #region Public Methods
/// <summary>
/// Clear all the log files older than 30 Days
@@ -48,7 +88,7 @@ namespace HandBrake.ApplicationServices.Utilities
if (Directory.Exists(LogDir))
{
// Get all the log files
- DirectoryInfo info = new DirectoryInfo(LogDir);
+ var info = new DirectoryInfo(LogDir);
FileInfo[] logFiles = info.GetFiles("*.txt");
// Delete Them
@@ -70,25 +110,65 @@ namespace HandBrake.ApplicationServices.Utilities
}
/// <summary>
+ /// Add the CLI Query to the Log File.
+ /// </summary>
+ /// <returns>
+ /// The create cli log header.
+ /// </returns>
+ public static StringBuilder CreateCliLogHeader()
+ {
+ var logHeader = new StringBuilder();
+
+ logHeader.AppendLine(
+ String.Format(
+ "HandBrake {0} {1}",
+ UserSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion),
+ UserSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild)));
+ logHeader.AppendLine(String.Format("OS: {0}", Environment.OSVersion));
+ logHeader.AppendLine(String.Format("CPU: {0}", SystemInfo.GetCpuCount));
+ logHeader.Append(String.Format("Ram: {0} MB, ", SystemInfo.TotalPhysicalMemory));
+ logHeader.AppendLine(
+ String.Format(
+ "Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));
+ logHeader.AppendLine(String.Format("Temp Dir: {0}", Path.GetTempPath()));
+ logHeader.AppendLine(String.Format("Install Dir: {0}", Application.StartupPath));
+ logHeader.AppendLine(String.Format("Data Dir: {0}\n", Application.UserAppDataPath));
+
+ logHeader.AppendLine("-------------------------------------------");
+
+ return logHeader;
+ }
+
+ /// <summary>
+ /// Get the Process ID of HandBrakeCLI for the current instance.
+ /// </summary>
+ /// <returns>A list of processes</returns>
+ public static Process[] GetCliProcess()
+ {
+ return Process.GetProcessesByName("HandBrakeCLI");
+ }
+
+ /// <summary>
/// Get a list of available DVD drives which are ready and contain DVD content.
/// </summary>
/// <returns>A List of Drives with their details</returns>
public static List<DriveInformation> GetDrives()
{
- List<DriveInformation> drives = new List<DriveInformation>();
+ var drives = new List<DriveInformation>();
DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();
int id = 0;
foreach (DriveInfo curDrive in theCollectionOfDrives)
{
if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady)
{
- if (Directory.Exists(curDrive.RootDirectory + "VIDEO_TS") || Directory.Exists(curDrive.RootDirectory + "BDMV"))
+ if (Directory.Exists(curDrive.RootDirectory + "VIDEO_TS") ||
+ Directory.Exists(curDrive.RootDirectory + "BDMV"))
{
drives.Add(
new DriveInformation
{
- Id = id,
- VolumeLabel = curDrive.VolumeLabel,
+ Id = id,
+ VolumeLabel = curDrive.VolumeLabel,
RootDirectory = curDrive.RootDirectory.ToString()
});
id++;
@@ -100,42 +180,11 @@ namespace HandBrake.ApplicationServices.Utilities
}
/// <summary>
- /// Get the Process ID of HandBrakeCLI for the current instance.
- /// </summary>
- /// <returns>A list of processes</returns>
- public static Process[] GetCliProcess()
- {
- return Process.GetProcessesByName("HandBrakeCLI");
- }
-
- /// <summary>
- /// Add the CLI Query to the Log File.
- /// </summary>
- /// <returns>
- /// The create cli log header.
- /// </returns>
- public static StringBuilder CreateCliLogHeader()
- {
- StringBuilder logHeader = new StringBuilder();
-
- logHeader.AppendLine(String.Format("HandBrake {0} {1}", UserSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion), UserSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild)));
- logHeader.AppendLine(String.Format("OS: {0}", Environment.OSVersion));
- logHeader.AppendLine(String.Format("CPU: {0}", SystemInfo.GetCpuCount));
- logHeader.Append(String.Format("Ram: {0} MB, ", SystemInfo.TotalPhysicalMemory));
- logHeader.AppendLine(String.Format("Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));
- logHeader.AppendLine(String.Format("Temp Dir: {0}", Path.GetTempPath()));
- logHeader.AppendLine(String.Format("Install Dir: {0}", Application.StartupPath));
- logHeader.AppendLine(String.Format("Data Dir: {0}\n", Application.UserAppDataPath));
-
- logHeader.AppendLine("-------------------------------------------");
-
- return logHeader;
- }
-
- /// <summary>
/// Return the standard log format line of text for a given log message
/// </summary>
- /// <param name="message">The Log Message</param>
+ /// <param name="message">
+ /// The Log Message
+ /// </param>
/// <returns>
/// A Log Message in the format: "[hh:mm:ss] message"
/// </returns>
@@ -145,26 +194,12 @@ namespace HandBrake.ApplicationServices.Utilities
}
/// <summary>
- /// Gets a value indicating whether HandBrake is running in multi instance mode
+ /// Set the Instance ID
/// </summary>
- /// <returns>True if the UI has another instance running</returns>
- public static bool IsMultiInstance
+ public static void SetInstanceId()
{
- get
- {
- return Process.GetProcessesByName("HandBrake").Length > 1 ? true : false;
- }
- }
-
- /// <summary>
- /// Gets the number of HandBrake instances running.
- /// </summary>
- public static string GetInstanceCount
- {
- get
- {
- return Process.GetProcessesByName("HandBrake").Length == 0 ? string.Empty : Process.GetProcessesByName("HandBrake").Length.ToString();
- }
+ instanceId = Process.GetProcessesByName("HandBrake").Length;
}
+ #endregion
}
-}
+} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 44dc15eff..d63915624 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -181,6 +181,9 @@ namespace HandBrakeWPF.ViewModels
public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService)
{
+ GeneralUtilities.SetInstanceId();
+
+
this.scanService = scanService;
this.encodeService = encodeService;
this.presetService = presetService;
@@ -189,6 +192,7 @@ namespace HandBrakeWPF.ViewModels
this.updateService = updateService;
this.userSettingService = userSettingService;
this.queueProcessor = IoC.Get<IQueueProcessor>();
+ queueProcessor.QueueManager.ResetInstanceId();
// Setup Properties
this.WindowTitle = "HandBrake";