From 76d7ab1861dbc85eb3e8ad35d365a35b4b681a96 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 2 Mar 2013 19:38:24 +0000 Subject: WinGui: Update the scan parser to handle the new scan progress meter. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5283 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../EventArgs/ScanProgressEventArgs.cs | 6 ++++++ win/CS/HandBrake.ApplicationServices/Parsing/Parser.cs | 13 +++++++------ .../HandBrake.ApplicationServices/Services/ScanService.cs | 6 ++++-- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-) (limited to 'win/CS') diff --git a/win/CS/HandBrake.ApplicationServices/EventArgs/ScanProgressEventArgs.cs b/win/CS/HandBrake.ApplicationServices/EventArgs/ScanProgressEventArgs.cs index fd0d01fe3..ff84bd7d5 100644 --- a/win/CS/HandBrake.ApplicationServices/EventArgs/ScanProgressEventArgs.cs +++ b/win/CS/HandBrake.ApplicationServices/EventArgs/ScanProgressEventArgs.cs @@ -29,5 +29,11 @@ namespace HandBrake.ApplicationServices.EventArgs /// [DataMember] public int Titles { get; set; } + + /// + /// Gets or sets the percentage. + /// + [DataMember] + public decimal Percentage { get; set; } } } diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Parser.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Parser.cs index f17a6a51b..82b339278 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Parser.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Parser.cs @@ -28,7 +28,8 @@ namespace HandBrake.ApplicationServices.Parsing /// The object who's raising the event /// The title number currently being processed /// The total number of titiles to be processed - public delegate void ScanProgressEventHandler(object sender, int currentTitle, int titleCount); + /// Percentage complete. + public delegate void ScanProgressEventHandler(object sender, int currentTitle, int titleCount, decimal percentage); /// /// A delegate to handle encode progress updates // EXPERIMENTAL @@ -97,18 +98,18 @@ namespace HandBrake.ApplicationServices.Parsing { string tmp = base.ReadLine(); - buffer.Append(tmp + Environment.NewLine); - Match m = null; - if (tmp.Contains("Scanning title")) - m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)"); + if (tmp != null && tmp.Contains("Scanning title")) + m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)([a-z0-9 ,]*), ([0-9.]*)"); + else if (!string.IsNullOrEmpty(tmp)) + buffer.Append(tmp + Environment.NewLine); if (OnReadLine != null) OnReadLine(this, tmp); if (m != null) if (m.Success && OnScanProgress != null) - OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)); + OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), decimal.Parse(m.Groups[4].Value)); return tmp; } diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs index cc99b916b..40329f14d 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs @@ -370,12 +370,14 @@ namespace HandBrake.ApplicationServices.Services /// the sender /// the current title being scanned /// the total number of titles - private void OnScanProgress(object sender, int currentTitle, int titleCount) + /// The Percentage + private void OnScanProgress(object sender, int currentTitle, int titleCount, decimal percentage) { ScanProgressEventArgs eventArgs = new ScanProgressEventArgs { CurrentTitle = currentTitle, - Titles = titleCount + Titles = titleCount, + Percentage = percentage }; if (this.ScanStatusChanged != null) diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 3ae4f9d58..c837627c4 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1703,8 +1703,8 @@ namespace HandBrakeWPF.ViewModels /// private void ScanStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.ScanProgressEventArgs e) { - this.SourceLabel = "Scanning Title " + e.CurrentTitle + " of " + e.Titles; - this.StatusLabel = "Scanning Title " + e.CurrentTitle + " of " + e.Titles; + 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); } /// -- cgit v1.2.3