diff options
author | sr55 <[email protected]> | 2012-05-27 17:50:01 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-05-27 17:50:01 +0000 |
commit | f5800c40e1c834fa5fc6de1432aea4cb86523950 (patch) | |
tree | 2c2d30a1d18d9d83f70878fecffca8dd9530db46 | |
parent | b225737b50c5cf584f9099c90dbcad939c2d6067 (diff) |
WinGui: Fix a bug in chapter duration calculation.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4708 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Parsing/Title.cs | 10 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 2 | ||||
-rw-r--r-- | win/CS/frmMain.cs | 4 |
3 files changed, 9 insertions, 7 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs index 4bb47f201..7bce41669 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs @@ -9,6 +9,7 @@ namespace HandBrake.ApplicationServices.Parsing using System.Collections.Generic;
using System.Globalization;
using System.IO;
+ using System.Linq;
using System.Text.RegularExpressions;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -244,12 +245,11 @@ namespace HandBrake.ApplicationServices.Parsing /// <returns>A Timespan</returns>
public TimeSpan CalculateDuration(int startPoint, int endPoint)
{
+ IEnumerable<Chapter> chapers =
+ this.Chapters.Where(c => c.ChapterNumber >= startPoint && c.ChapterNumber <= endPoint);
+
TimeSpan duration = TimeSpan.FromSeconds(0.0);
- if (endPoint <= this.Chapters.Count)
- {
- for (int i = startPoint; i <= endPoint; i++)
- duration += this.Chapters[i].Duration;
- }
+ duration = chapers.Aggregate(duration, (current, chapter) => current + chapter.Duration);
return duration;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index d8331354a..548523eee 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1354,7 +1354,7 @@ namespace HandBrakeWPF.ViewModels switch (this.SelectedPointToPoint)
{
case PointToPointMode.Chapters:
- return this.SelectedTitle.CalculateDuration(this.SelectedStartPoint - 1, this.SelectedEndPoint - 1).ToString();
+ return this.SelectedTitle.CalculateDuration(this.SelectedStartPoint, this.SelectedEndPoint).ToString();
case PointToPointMode.Seconds:
return TimeSpan.FromSeconds(startEndDuration).ToString();
case PointToPointMode.Frames:
diff --git a/win/CS/frmMain.cs b/win/CS/frmMain.cs index acb71fb40..1ebda69f1 100644 --- a/win/CS/frmMain.cs +++ b/win/CS/frmMain.cs @@ -1640,7 +1640,9 @@ namespace Handbrake }
// Update the Duration
- lbl_duration.Text = this.selectedTitle.CalculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex).ToString();
+ lbl_duration.Text =
+ this.selectedTitle.CalculateDuration(
+ drop_chapterStart.SelectedIndex + 1, drop_chapterFinish.SelectedIndex + 1).ToString();
// Run the Autonaming function
if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNaming))
|