From 6171d00692520927dc2fcc9bb43106bda15803b6 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 7 Oct 2012 19:04:49 +0000 Subject: [PATCH] WinGui: API Tidyup Part 1 of many git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5007 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Isolation/IsolatedEncodeService.cs | 10 ------ .../Parsing/Source.cs | 8 +++-- .../Parsing/Title.cs | 16 +++++----- .../Services/Base/EncodeBase.cs | 6 ++-- .../Services/Encode.cs | 32 +++---------------- .../Services/Interfaces/IEncode.cs | 7 ---- .../Services/LibEncode.cs | 20 +++--------- .../Services/ScanService.cs | 4 +-- 8 files changed, 28 insertions(+), 75 deletions(-) diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs index 6806e2844..3ddae9b1f 100644 --- a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs +++ b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs @@ -145,16 +145,6 @@ namespace HandBrake.ApplicationServices.Isolation ThreadPool.QueueUserWorkItem(delegate { this.Service.ProcessEncodeLogs(destination); }); } - /// - /// Attempt to Safely kill a DirectRun() CLI - /// NOTE: This will not work with a MinGW CLI - /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html - /// - public void SafelyStop() - { - ThreadPool.QueueUserWorkItem(delegate { this.Service.StopEncode(); }); - } - /// /// Start with a LibHb EncodeJob Object /// diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs index 7b63ec149..93aa13a0c 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Source.cs @@ -49,18 +49,20 @@ namespace HandBrake.ApplicationServices.Parsing /// /// The output. /// - /// + /// + /// The is Dvd Nav Disabled. + /// /// /// A DVD object which contains a list of title inforamtion /// - public static Source Parse(StreamReader output, IUserSettingService userSettingService) + public static Source Parse(StreamReader output, bool isDvdNavDisabled) { var thisDVD = new Source(); while (!output.EndOfStream) { if ((char) output.Peek() == '+') - thisDVD.Titles.AddRange(Title.ParseList(output.ReadToEnd(), userSettingService)); + thisDVD.Titles.AddRange(Title.ParseList(output.ReadToEnd(), isDvdNavDisabled)); else output.ReadLine(); } diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs index f19861cfd..04d00c1f2 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs @@ -123,13 +123,13 @@ namespace HandBrake.ApplicationServices.Parsing /// /// A StringReader of output data /// - /// - /// The user Setting Service. + /// + /// The is Dvd Nav Disabled. /// /// /// A Title Object /// - public static Title Parse(StringReader output, IUserSettingService userSettingService) + public static Title Parse(StringReader output, bool isDvdNavDisabled) { var thisTitle = new Title(); string nextLine = output.ReadLine(); @@ -172,7 +172,7 @@ namespace HandBrake.ApplicationServices.Parsing } // Multi-Angle Support if LibDvdNav is enabled - if (!userSettingService.GetUserSetting(ASUserSettingConstants.DisableLibDvdNav)) + if (!isDvdNavDisabled) { m = Regex.Match(nextLine, @" \+ angle\(s\) ([0-9])"); if (m.Success) @@ -229,13 +229,13 @@ namespace HandBrake.ApplicationServices.Parsing /// /// The Output /// - /// - /// The user Setting Service. + /// + /// The is Dvd Nav Disabled. /// /// /// A List of titles /// - public static Title[] ParseList(string output, IUserSettingService userSettingService) + public static Title[] ParseList(string output, bool isDvdNavDisabled) { var titles = new List(); var sr = new StringReader(output); @@ -246,7 +246,7 @@ namespace HandBrake.ApplicationServices.Parsing if (sr.Peek() == ' ') // If the character is a space, then chances are it's the combing detected line. sr.ReadLine(); // Skip over it else - titles.Add(Parse(sr, userSettingService)); + titles.Add(Parse(sr, isDvdNavDisabled)); } return titles.ToArray(); diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index ced71d4eb..6a9717ef8 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -147,7 +147,7 @@ namespace HandBrake.ApplicationServices.Services.Base /// <param name="e"> /// The EncodeProgressEventArgs. /// </param> - public void Invoke_encodeStatusChanged(EncodeProgressEventArgs e) + public void InvokeEncodeStatusChanged(EncodeProgressEventArgs e) { EncodeProgessStatus handler = this.EncodeStatusChanged; if (handler != null) @@ -162,7 +162,7 @@ namespace HandBrake.ApplicationServices.Services.Base /// <param name="e"> /// The EncodeCompletedEventArgs. /// </param> - public void Invoke_encodeCompleted(EncodeCompletedEventArgs e) + public void InvokeEncodeCompleted(EncodeCompletedEventArgs e) { EncodeCompletedStatus handler = this.EncodeCompleted; if (handler != null) @@ -177,7 +177,7 @@ namespace HandBrake.ApplicationServices.Services.Base /// <param name="e"> /// The EventArgs. /// </param> - public void Invoke_encodeStarted(EventArgs e) + public void InvokeEncodeStarted(EventArgs e) { EventHandler handler = this.EncodeStarted; if (handler != null) diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index 49ff66bd2..18457af85 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -195,12 +195,12 @@ namespace HandBrake.ApplicationServices.Services } // Fire the Encode Started Event - this.Invoke_encodeStarted(EventArgs.Empty); + this.InvokeEncodeStarted(EventArgs.Empty); } catch (Exception exc) { encodeQueueTask.Status = QueueItemStatus.Error; - this.Invoke_encodeCompleted( + this.InvokeEncodeCompleted( new EncodeCompletedEventArgs( false, null, "An Error occured when trying to encode this source. ")); throw; @@ -236,34 +236,12 @@ namespace HandBrake.ApplicationServices.Services // No need to report anything to the user. If it fails, it's probably already stopped. } - this.Invoke_encodeCompleted( + this.InvokeEncodeCompleted( exc == null ? new EncodeCompletedEventArgs(true, null, string.Empty) : new EncodeCompletedEventArgs(false, exc, "An Unknown Error has occured when trying to Stop this encode.")); } - /// <summary> - /// Attempt to Safely kill a DirectRun() CLI - /// NOTE: This will not work with a MinGW CLI - /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html - /// </summary> - public void SafelyStop() - { - if ((int)this.processHandle == 0) - return; - - // Allow the CLI to exit cleanly - Win32.SetForegroundWindow((int)this.processHandle); - SendKeys.Send("^C"); - SendKeys.Flush(); - - /*/if (HbProcess != null) - //{ - // HbProcess.StandardInput.AutoFlush = true; - // HbProcess.StandardInput.WriteLine("^c^z"); - //}*/ - } - /// <summary> /// Shutdown the service. /// </summary> @@ -314,7 +292,7 @@ namespace HandBrake.ApplicationServices.Services } this.currentTask.Status = QueueItemStatus.Completed; - this.Invoke_encodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty)); + this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty)); } /// <summary> @@ -399,7 +377,7 @@ namespace HandBrake.ApplicationServices.Services ElapsedTime = DateTime.Now - this.startTime, }; - this.Invoke_encodeStatusChanged(eventArgs); + this.InvokeEncodeStatusChanged(eventArgs); if (this.WindowsSeven.IsWindowsSeven) { diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs index eddc49d9b..915d66788 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs @@ -82,13 +82,6 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// </summary> void Stop(); - /// <summary> - /// Attempt to Safely kill a DirectRun() CLI - /// NOTE: This will not work with a MinGW CLI - /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html - /// </summary> - void SafelyStop(); - /// <summary> /// Copy the log file to the desired destinations /// </summary> diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index 5c3deb80f..eb0657cba 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -160,11 +160,11 @@ namespace HandBrake.ApplicationServices.Services } // Fire the Encode Started Event - this.Invoke_encodeStarted(EventArgs.Empty); + this.InvokeEncodeStarted(EventArgs.Empty); } catch (Exception exc) { - this.Invoke_encodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured.")); + this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured.")); } } @@ -195,22 +195,12 @@ namespace HandBrake.ApplicationServices.Services // Do Nothing. } - this.Invoke_encodeCompleted( + this.InvokeEncodeCompleted( exc == null ? new EncodeCompletedEventArgs(true, null, string.Empty) : new EncodeCompletedEventArgs(false, exc, "An Error has occured.")); } - /// <summary> - /// Attempt to Safely kill a DirectRun() CLI - /// NOTE: This will not work with a MinGW CLI - /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html - /// </summary> - public void SafelyStop() - { - throw new NotImplementedException("This Method is not used in the LibEncode service. You should use the Stop() method instead! "); - } - /// <summary> /// Shutdown the service. /// </summary> @@ -281,7 +271,7 @@ namespace HandBrake.ApplicationServices.Services ElapsedTime = DateTime.Now - this.startTime, }; - this.Invoke_encodeStatusChanged(args); + this.InvokeEncodeStatusChanged(args); if (this.WindowsSeven.IsWindowsSeven) { @@ -305,7 +295,7 @@ namespace HandBrake.ApplicationServices.Services { this.IsEncoding = false; - this.Invoke_encodeCompleted( + this.InvokeEncodeCompleted( e.Error ? new EncodeCompletedEventArgs(false, null, string.Empty) : new EncodeCompletedEventArgs(true, null, string.Empty)); diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs index 020aaf0ad..acfb4d6d6 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs @@ -186,7 +186,7 @@ namespace HandBrake.ApplicationServices.Services { StreamReader parseLog = new StreamReader(path); this.readData = new Parser(parseLog.BaseStream); - this.SouceData = Source.Parse(this.readData, this.userSettingService); + this.SouceData = Source.Parse(this.readData, this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav)); this.SouceData.ScanPath = path; if (this.ScanCompleted != null) @@ -301,7 +301,7 @@ namespace HandBrake.ApplicationServices.Services this.readData = new Parser(this.hbProc.StandardError.BaseStream); this.readData.OnScanProgress += this.OnScanProgress; - this.SouceData = Source.Parse(this.readData, this.userSettingService); + this.SouceData = Source.Parse(this.readData, this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav)); this.SouceData.ScanPath = (string)sourcePath; // Write the Buffer out to file. -- 2.40.0