summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2021-01-13 18:22:36 +0000
committersr55 <[email protected]>2021-01-13 18:22:36 +0000
commitfe1893bce2bb9ad8d417ff2acf4ee383e05819df (patch)
tree41d0d207e6880ee60de601058e14f8a26b2752c1 /win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
parent2b2a8efa3cf966597afa1f7097dd0c374c3204fe (diff)
WinGui: Fixes #3347 where the preset menu list was slow to update.
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs60
1 files changed, 10 insertions, 50 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index f25e4559b..f6e6eb958 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -90,7 +90,6 @@ namespace HandBrakeWPF.ViewModels
private string alertWindowText;
private bool hasSource;
private bool isSettingPreset;
- private IPresetObject selectedPresetCategory;
private bool isModifiedPreset;
private bool updateAvailable;
@@ -270,43 +269,6 @@ namespace HandBrakeWPF.ViewModels
public IEnumerable<IPresetObject> PresetsCategories { get; set; }
- public IPresetObject SelectedPresetCategory
- {
- get
- {
- return this.selectedPresetCategory;
- }
- set
- {
- if (!object.Equals(this.selectedPresetCategory, value))
- {
- this.selectedPresetCategory = value;
- this.NotifyOfPropertyChange(() => this.SelectedPresetCategory);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
- }
- }
- }
-
- public IEnumerable<Preset> CategoryPresets
- {
- get
- {
- PresetDisplayCategory category = this.SelectedPresetCategory as PresetDisplayCategory;
- if (category != null && category.Presets != null)
- {
- if (!category.Presets.Contains(this.SelectedPreset))
- {
- this.SelectedPreset = category.Presets.FirstOrDefault();
- }
-
- return new BindingList<Preset>(category.Presets);
- }
-
- this.SelectedPreset = null;
- return new BindingList<Preset>();
- }
- }
-
public Preset SelectedPreset
{
get
@@ -1072,7 +1034,7 @@ namespace HandBrakeWPF.ViewModels
if (!this.PresetManagerViewModel.IsOpen)
{
this.PresetManagerViewModel.IsOpen = true;
- this.PresetManagerViewModel.SetupWindow();
+ this.PresetManagerViewModel.SetupWindow(PresetManageCallback);
this.windowManager.ShowWindow(this.PresetManagerViewModel);
}
else if (this.PresetManagerViewModel.IsOpen)
@@ -1082,6 +1044,12 @@ namespace HandBrakeWPF.ViewModels
}
}
+
+ private void PresetManageCallback()
+ {
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
+ }
+
public void LaunchHelp()
{
try
@@ -1638,7 +1606,6 @@ namespace HandBrakeWPF.ViewModels
this.windowManager.ShowDialog(presetViewModel);
this.NotifyOfPropertyChange(() => this.PresetsCategories);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
}
public void PresetUpdate()
@@ -1691,7 +1658,7 @@ namespace HandBrakeWPF.ViewModels
this.windowManager.ShowDialog(presetViewModel);
Preset preset = presetViewModel.Preset;
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
this.selectedPreset = preset; // Reselect the preset
this.NotifyOfPropertyChange(() => this.SelectedPreset);
}
@@ -1724,7 +1691,7 @@ namespace HandBrakeWPF.ViewModels
}
this.presetService.Remove(this.selectedPreset);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
this.SelectedPreset = this.presetService.DefaultPreset;
}
else
@@ -1753,7 +1720,7 @@ namespace HandBrakeWPF.ViewModels
if (dialogResult.HasValue && dialogResult.Value)
{
this.presetService.Import(dialog.FileName);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
+ this.NotifyOfPropertyChange(() => this.PresetsCategories);
}
}
@@ -1790,7 +1757,6 @@ namespace HandBrakeWPF.ViewModels
this.presetService.UpdateBuiltInPresets();
this.NotifyOfPropertyChange(() => this.PresetsCategories);
- this.NotifyOfPropertyChange(() => this.CategoryPresets);
this.SetDefaultPreset();
@@ -1817,11 +1783,6 @@ namespace HandBrakeWPF.ViewModels
return;
}
- if (this.SelectedPresetCategory == null || this.SelectedPresetCategory.Category != preset.Category)
- {
- this.SelectedPresetCategory = this.PresetsCategories.FirstOrDefault(c => c.Category == preset.Category);
- }
-
this.selectedPreset = preset;
this.NotifyOfPropertyChange(() => this.SelectedPreset);
@@ -2078,7 +2039,6 @@ namespace HandBrakeWPF.ViewModels
(PresetDisplayCategory)this.PresetsCategories.FirstOrDefault(
p => p.Category == this.presetService.DefaultPreset.Category);
- this.SelectedPresetCategory = category;
this.SelectedPreset = this.presetService.DefaultPreset;
}
}