From daa18af4633c27170a8bd7f880d232ca3c688d9b Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 12 Apr 2015 15:03:25 +0000 Subject: WinGui: Misc IScan API tweaks. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7087 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Model/VideoScaler.cs | 3 -- .../Services/Encode/EncodeBase.cs | 8 ----- .../Services/Encode/LibEncode.cs | 2 +- .../Scan/EventArgs/ScanCompletedEventArgs.cs | 35 ++++++++++++---------- .../Services/Scan/Interfaces/IScan.cs | 7 +---- .../Services/Scan/LibScan.cs | 31 ++++++++++--------- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 17 +++++++++-- 7 files changed, 53 insertions(+), 50 deletions(-) diff --git a/win/CS/HandBrake.ApplicationServices/Model/VideoScaler.cs b/win/CS/HandBrake.ApplicationServices/Model/VideoScaler.cs index ded9f06bd..8fd6bcd07 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/VideoScaler.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/VideoScaler.cs @@ -19,9 +19,6 @@ namespace HandBrake.ApplicationServices.Model [Display(Name = "Lanczos (default)")] Lanczos = 0, - // [Display(Name = "Bicubic")] - // Bicubic, - [Display(Name = "Bicubic (OpenCL)")] BicubicCl, } diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs index 227a73f5e..9a2a7a848 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs @@ -174,14 +174,6 @@ namespace HandBrake.ApplicationServices.Services.Encode #region Methods - /// - /// A Stop Method to be implemeneted. - /// - public virtual void Stop() - { - // Do Nothing - } - /// /// Save a copy of the log to the users desired location or a default location /// if this feature is enabled in options. diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs index 3c92f9a6f..8aac4fcf0 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs @@ -147,7 +147,7 @@ namespace HandBrake.ApplicationServices.Services.Encode /// /// Kill the process /// - public override void Stop() + public void Stop() { try { diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs index 8e54cda12..41c44fb76 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/EventArgs/ScanCompletedEventArgs.cs @@ -10,12 +10,12 @@ namespace HandBrake.ApplicationServices.Services.Scan.EventArgs { using System; - using System.Runtime.Serialization; + + using HandBrake.ApplicationServices.Services.Scan.Model; /// /// Scan Progress Event Args /// - [DataContract] public class ScanCompletedEventArgs : EventArgs { /// @@ -30,36 +30,41 @@ namespace HandBrake.ApplicationServices.Services.Scan.EventArgs /// /// The error information. /// - public ScanCompletedEventArgs(bool cancelled, Exception exception, string errorInformation) + /// + /// The scanned Source. + /// + public ScanCompletedEventArgs(bool cancelled, Exception exception, string errorInformation, Source scannedSource) { this.Successful = !cancelled && exception == null && string.IsNullOrEmpty(errorInformation); this.Cancelled = cancelled; this.Exception = exception; this.ErrorInformation = errorInformation; + this.ScannedSource = scannedSource; } /// - /// Gets or sets a value indicating whether Successful. + /// Gets a value indicating whether Successful. + /// + public bool Successful { get; private set; } + + /// + /// Gets a value indicating whether Cancelled. /// - [DataMember] - public bool Successful { get; set; } + public bool Cancelled { get; private set; } /// - /// Gets or sets a value indicating whether Cancelled. + /// Gets the Exception. /// - [DataMember] - public bool Cancelled { get; set; } + public Exception Exception { get; private set; } /// - /// Gets or sets Exception. + /// Gets ErrorInformation. /// - [DataMember] - public Exception Exception { get; set; } + public string ErrorInformation { get; private set; } /// - /// Gets or sets ErrorInformation. + /// Gets the scanned source. /// - [DataMember] - public string ErrorInformation { get; set; } + public Source ScannedSource { get; private set; } } } diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs index 086a97487..0d4c6b3c2 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs @@ -64,11 +64,6 @@ namespace HandBrake.ApplicationServices.Services.Scan.Interfaces /// bool IsScanning { get; } - /// - /// Gets the Souce Data. - /// - Source SouceData { get; } - /// /// Gets ActivityLog. /// @@ -90,7 +85,7 @@ namespace HandBrake.ApplicationServices.Services.Scan.Interfaces /// /// The configuraiton. /// - void Scan(string sourcePath, int title, Action postAction, HBConfiguration configuration); + void Scan(string sourcePath, int title, Action postAction, HBConfiguration configuration); /// /// Get a Preview image for the current job and preview number. diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs index 524042606..a560493ab 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs @@ -86,7 +86,7 @@ namespace HandBrake.ApplicationServices.Services.Scan /// /// The post scan operation. /// - private Action postScanOperation; + private Action postScanOperation; #endregion @@ -97,6 +97,7 @@ namespace HandBrake.ApplicationServices.Services.Scan { this.logging = new StringBuilder(); this.header = GeneralUtilities.CreateLogHeader(); + this.IsScanning = false; } #region Events @@ -125,11 +126,6 @@ namespace HandBrake.ApplicationServices.Services.Scan /// public bool IsScanning { get; private set; } - /// - /// Gets the Souce Data. - /// - public Source SouceData { get; private set; } - /// /// Gets ActivityLog. /// @@ -165,7 +161,7 @@ namespace HandBrake.ApplicationServices.Services.Scan /// /// The configuraiton. /// - public void Scan(string sourcePath, int title, Action postAction, HBConfiguration configuraiton) + public void Scan(string sourcePath, int title, Action postAction, HBConfiguration configuraiton) { // Try to cleanup any previous scan instances. if (this.instance != null) @@ -326,7 +322,7 @@ namespace HandBrake.ApplicationServices.Services.Scan this.Stop(); if (this.ScanCompleted != null) - this.ScanCompleted(this, new ScanCompletedEventArgs(false, exc, "An Error has occured in ScanService.ScanSource()")); + this.ScanCompleted(this, new ScanCompletedEventArgs(false, exc, "An Error has occured in ScanService.ScanSource()", null)); } } @@ -370,20 +366,30 @@ namespace HandBrake.ApplicationServices.Services.Scan } // Process into internal structures. + Source sourceData = null; if (this.instance != null && this.instance.Titles != null) { - this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = path }; + sourceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = path }; } this.IsScanning = false; if (this.postScanOperation != null) { - this.postScanOperation(true); + try + { + this.postScanOperation(true, sourceData); + } + catch (Exception exc) + { + Debug.WriteLine(exc); + } + + this.postScanOperation = null; // Reset } else { - if (this.ScanCompleted != null) this.ScanCompleted(this, new ScanCompletedEventArgs(false, null, string.Empty)); + if (this.ScanCompleted != null) this.ScanCompleted(this, new ScanCompletedEventArgs(false, null, string.Empty, sourceData)); } } @@ -446,9 +452,6 @@ namespace HandBrake.ApplicationServices.Services.Scan /// /// The titles. /// - /// - /// The feature Title. - /// /// /// The convert titles. /// diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 2ba9744f6..71d8c6a73 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1811,13 +1811,16 @@ namespace HandBrakeWPF.ViewModels /// /// The successful. /// - private void QueueEditAction(bool successful) + /// + /// The scanned Source. + /// + private void QueueEditAction(bool successful, Source scannedSource) { /* TODO Fix this. */ Execute.OnUIThread(() => { // Copy all the Scan data into the UI - this.scanService.SouceData.CopyTo(this.ScannedSource); + scannedSource.CopyTo(this.ScannedSource); this.NotifyOfPropertyChange(() => this.ScannedSource); this.NotifyOfPropertyChange(() => this.ScannedSource.Titles); @@ -1990,7 +1993,15 @@ namespace HandBrakeWPF.ViewModels /// private void ScanCompleted(object sender, ScanCompletedEventArgs e) { - this.scanService.SouceData.CopyTo(this.ScannedSource); + if (e.ScannedSource != null) + { + e.ScannedSource.CopyTo(this.ScannedSource); + } + else + { + this.ScannedSource = null; + } + Execute.OnUIThread(() => { if (e.Successful) -- cgit v1.2.3