diff options
-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))
|