]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fixes to chapters tab to correctly handle queue edit jobs. Fixes #870
authorsr55 <sr55.hb@outlook.com>
Sat, 26 Aug 2017 20:28:23 +0000 (21:28 +0100)
committersr55 <sr55.hb@outlook.com>
Sat, 26 Aug 2017 20:28:23 +0000 (21:28 +0100)
win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
win/CS/HandBrakeWPF/Views/ChaptersView.xaml

index fcd1f22d92147248c8fa9d473d68914ce46f25c7..0d1d3d1e1c90dec2fe8927de30a1d81bee79dec4 100644 (file)
@@ -92,6 +92,20 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+        public ObservableCollection<ChapterMarker> Chapters\r
+        {\r
+            get\r
+            {\r
+                return this.Task.ChapterNames;\r
+            }\r
+\r
+            set\r
+            {\r
+                this.Task.ChapterNames = value;\r
+                this.NotifyOfPropertyChange(() => this.Chapters);\r
+            }\r
+        }\r
+\r
         #endregion\r
 \r
         #region Properties\r
@@ -134,7 +148,7 @@ namespace HandBrakeWPF.ViewModels
             {\r
                 using (var csv = new StreamWriter(fileName))\r
                 {\r
-                    foreach (ChapterMarker row in this.Task.ChapterNames)\r
+                    foreach (ChapterMarker row in this.Chapters)\r
                     {\r
                         csv.Write("{0},{1}{2}", row.ChapterNumber, CsvHelper.Escape(row.ChapterName), Environment.NewLine);\r
                     }\r
@@ -218,7 +232,7 @@ namespace HandBrakeWPF.ViewModels
             }\r
 \r
             // Now iterate over each chatper we have, and set it's name\r
-            foreach (ChapterMarker item in this.Task.ChapterNames)\r
+            foreach (ChapterMarker item in this.Chapters)\r
             {\r
                 // If we don't have a chapter name for this chapter then \r
                 // fallback to the value that is already set for the chapter\r
@@ -252,7 +266,6 @@ namespace HandBrakeWPF.ViewModels
         public void SetSource(Source source, Title title, Preset preset, EncodeTask task)\r
         {\r
             this.Task = task;\r
-            this.NotifyOfPropertyChange(() => this.Task);\r
 \r
             if (preset != null)\r
             {\r
@@ -275,8 +288,8 @@ namespace HandBrakeWPF.ViewModels
         public void SetPreset(Preset preset, EncodeTask task)\r
         {\r
             this.Task = task;\r
-            this.Task.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers;\r
-            this.NotifyOfPropertyChange(() => this.Task);\r
+            this.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers;\r
+            this.NotifyOfPropertyChange(() => this.Chapters);\r
         }\r
 \r
         /// <summary>\r
@@ -289,8 +302,8 @@ namespace HandBrakeWPF.ViewModels
         {\r
             this.Task = task;\r
 \r
-            this.NotifyOfPropertyChange(() => this.Task.IncludeChapterMarkers);\r
-            this.NotifyOfPropertyChange(() => this.Task.ChapterNames);\r
+            this.NotifyOfPropertyChange(() => this.IncludeChapterMarkers);\r
+            this.NotifyOfPropertyChange(() => this.Chapters);\r
         }\r
 \r
         /// <summary>\r
@@ -314,7 +327,7 @@ namespace HandBrakeWPF.ViewModels
         {\r
             // Cache the chapters in this screen\r
             this.SourceChapterList = new ObservableCollection<Chapter>(sourceChapters);\r
-            this.Task.ChapterNames.Clear();\r
+            this.Chapters.Clear();\r
 \r
             // Then Add new Chapter Markers.\r
             int counter = 1;\r
@@ -323,7 +336,7 @@ namespace HandBrakeWPF.ViewModels
             {\r
                 string chapterName = string.IsNullOrEmpty(chapter.ChapterName) ? string.Format("Chapter {0}", counter) : chapter.ChapterName;\r
                 var marker = new ChapterMarker(chapter.ChapterNumber, chapterName, chapter.Duration);\r
-                this.Task.ChapterNames.Add(marker);\r
+                this.Chapters.Add(marker);\r
 \r
                 counter += 1;\r
             }\r
@@ -346,10 +359,10 @@ namespace HandBrakeWPF.ViewModels
             validationErrorMessage = null;\r
 \r
             // If the number of chapters don't match, prompt for confirmation\r
-            if (importedChapters.Count != this.Task.ChapterNames.Count)\r
+            if (importedChapters.Count != this.Chapters.Count)\r
             {\r
                 if (this.errorService.ShowMessageBox(\r
-                        string.Format(Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchMsg, this.Task.ChapterNames.Count, importedChapters.Count),\r
+                        string.Format(Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchMsg, this.Chapters.Count, importedChapters.Count),\r
                         Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchWarning,\r
                         MessageBoxButton.YesNo,\r
                         MessageBoxImage.Question) !=\r
@@ -364,7 +377,7 @@ namespace HandBrakeWPF.ViewModels
             //      (I chose 15sec based on empirical evidence from testing a few DVDs and comparing to chapter-marker files I downloaded)\r
             //      => This check will not be performed for the first and last chapter as they're very likely to differ significantly due to language and region\r
             //         differences (e.g. longer title sequences and different distributor credits)\r
-            var diffs = importedChapters.Zip(this.Task.ChapterNames, (import, source) => source.Duration - import.Value.Item2);\r
+            var diffs = importedChapters.Zip(this.Chapters, (import, source) => source.Duration - import.Value.Item2);\r
             if (diffs.Count(diff => Math.Abs(diff.TotalSeconds) > 15) > 2)\r
             {\r
                 if (this.errorService.ShowMessageBox(\r
index 6dfe534104dcf904caa7fa32bd4bf35c82398fb2..50e3698ac8cd4014f315549cda9cab62133a7442 100644 (file)
@@ -28,7 +28,7 @@
             <Button Content="{x:Static Properties:ResourcesUI.ChaptersView_Export}" Name="export" Grid.Column="3" Width="75" cal:Message.Attach="[Event Click] = [Action Export]" />\r
         </Grid>\r
 \r
-        <DataGrid Grid.Row="2" Margin="10" ItemsSource="{Binding Task.ChapterNames}" \r
+        <DataGrid Grid.Row="2" Margin="10" ItemsSource="{Binding Chapters}" \r
                   VerticalAlignment="Stretch"  AutoGenerateColumns="False"\r
                   CanUserSortColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False"\r
                   CanUserAddRows="False" CanUserDeleteRows="False">\r