summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-04-25 15:28:54 +0100
committersr55 <[email protected]>2019-04-25 15:28:54 +0100
commit0937a200e89bda04cbd6b7b231462be8b4701155 (patch)
tree54ae6a8dc217c7f181532e5b8ea9caca82460a5b /win/CS
parent3c5adac3feef83d30cba159e97715a3df726c0b0 (diff)
WinGui: Refactor Filters View Model - (Deblock)
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj1
-rw-r--r--win/CS/HandBrakeWPF/ViewModelItems/Filters/DeblockFilter.cs90
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs113
-rw-r--r--win/CS/HandBrakeWPF/Views/FiltersView.xaml4
4 files changed, 103 insertions, 105 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index e85382f0e..9caf1ab38 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -272,6 +272,7 @@
<Compile Include="Utilities\UwpDetect.cs" />
<Compile Include="Utilities\Win32.cs" />
<Compile Include="Utilities\Win7.cs" />
+ <Compile Include="ViewModelItems\Filters\DeblockFilter.cs" />
<Compile Include="ViewModelItems\Filters\DeinterlaceFilterItem.cs" />
<Compile Include="ViewModelItems\Filters\DenoiseItem.cs" />
<Compile Include="ViewModelItems\Filters\DetelecineItem.cs" />
diff --git a/win/CS/HandBrakeWPF/ViewModelItems/Filters/DeblockFilter.cs b/win/CS/HandBrakeWPF/ViewModelItems/Filters/DeblockFilter.cs
new file mode 100644
index 000000000..09b785e3b
--- /dev/null
+++ b/win/CS/HandBrakeWPF/ViewModelItems/Filters/DeblockFilter.cs
@@ -0,0 +1,90 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="DeblockFilter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the DeblockFilter type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModelItems.Filters
+{
+ using System.Globalization;
+
+ using Caliburn.Micro;
+
+ using HandBrakeWPF.Services.Encode.Model;
+ using HandBrakeWPF.Services.Presets.Model;
+ using HandBrakeWPF.Services.Scan.Model;
+
+ using Action = System.Action;
+
+ public class DeblockFilter : PropertyChangedBase
+ {
+ private readonly Action triggerTabChanged;
+
+ public DeblockFilter(EncodeTask currentTask, Action triggerTabChanged)
+ {
+ this.triggerTabChanged = triggerTabChanged;
+ this.CurrentTask = currentTask;
+ this.DeblockValue = 4; // OFF
+ }
+
+ public EncodeTask CurrentTask { get; private set; }
+
+ public string DeblockText =>
+ this.DeblockValue == 4 ? "Off" : this.DeblockValue.ToString(CultureInfo.InvariantCulture);
+
+ public int DeblockValue
+ {
+ get
+ {
+ return this.CurrentTask.Deblock;
+ }
+
+ set
+ {
+ this.CurrentTask.Deblock = value;
+ this.NotifyOfPropertyChange(() => this.DeblockValue);
+ this.NotifyOfPropertyChange(() => this.DeblockText);
+ this.triggerTabChanged();
+ }
+ }
+
+ public void SetPreset(Preset preset, EncodeTask task)
+ {
+ this.CurrentTask = task;
+
+ if (preset == null)
+ {
+ this.DeblockValue = 4; // OFF
+ return;
+ }
+
+ this.DeblockValue = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock;
+ }
+
+ public void UpdateTask(EncodeTask task)
+ {
+ this.CurrentTask = task;
+ this.NotifyOfPropertyChange(() => this.DeblockValue);
+ }
+
+ public bool MatchesPreset(Preset preset)
+ {
+ int presetDeblock = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock;
+
+ if (presetDeblock != this.DeblockValue)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public void SetSource(Source source, Title title, Preset preset, EncodeTask task)
+ {
+ this.CurrentTask = task;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
index 50d4a2d1f..4ee14632a 100644
--- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs
@@ -41,24 +41,15 @@ namespace HandBrakeWPF.ViewModels
{
#region Constructors and Destructors
- /// <summary>
- /// Initializes a new instance of the <see cref="FiltersViewModel"/> class.
- /// </summary>
- /// <param name="windowManager">
- /// The window manager.
- /// </param>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
public FiltersViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
{
this.CurrentTask = new EncodeTask();
- this.DeblockValue = 4; // OFF
this.SharpenFilter = new SharpenItem(this.CurrentTask, () => this.OnTabStatusChanged(null));
this.DenoiseFilter = new DenoiseItem(this.CurrentTask, () => this.OnTabStatusChanged(null));
this.DetelecineFilter = new DetelecineItem(this.CurrentTask, () => this.OnTabStatusChanged(null));
this.DeinterlaceFilter = new DeinterlaceFilterItem(this.CurrentTask, () => this.OnTabStatusChanged(null));
+ this.DeblockFilter = new DeblockFilter(this.CurrentTask, () => this.OnTabStatusChanged(null));
}
#endregion
@@ -67,44 +58,8 @@ namespace HandBrakeWPF.ViewModels
#region Properties
- /// <summary>
- /// Gets CurrentTask.
- /// </summary>
public EncodeTask CurrentTask { get; private set; }
- /// <summary>
- /// Gets DeblockText.
- /// </summary>
- public string DeblockText
- {
- get
- {
- return this.DeblockValue == 4 ? "Off" : this.DeblockValue.ToString(CultureInfo.InvariantCulture);
- }
- }
-
- /// <summary>
- /// Gets or sets DeblockValue.
- /// </summary>
- public int DeblockValue
- {
- get
- {
- return this.CurrentTask.Deblock;
- }
-
- set
- {
- this.CurrentTask.Deblock = value;
- this.NotifyOfPropertyChange(() => this.DeblockValue);
- this.NotifyOfPropertyChange(() => this.DeblockText);
- this.OnTabStatusChanged(null);
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether Grayscale.
- /// </summary>
public bool Grayscale
{
get
@@ -120,7 +75,6 @@ namespace HandBrakeWPF.ViewModels
}
}
-
public DenoiseItem DenoiseFilter { get; set; }
public SharpenItem SharpenFilter { get; set; }
@@ -129,14 +83,12 @@ namespace HandBrakeWPF.ViewModels
public DeinterlaceFilterItem DeinterlaceFilter { get; set; }
- /// <summary>
- /// The rotation options.
- /// </summary>
+ public DeblockFilter DeblockFilter { get; set; }
+
+
+
public BindingList<int> RotationOptions => new BindingList<int> { 0, 90, 180, 270 };
- /// <summary>
- /// Selected Rotation.
- /// </summary>
public int SelectedRotation
{
get
@@ -152,9 +104,6 @@ namespace HandBrakeWPF.ViewModels
}
}
- /// <summary>
- /// Flip the Video
- /// </summary>
public bool FlipVideo
{
get
@@ -170,20 +119,8 @@ namespace HandBrakeWPF.ViewModels
}
}
-
#endregion
- #region Implemented Interfaces
-
- /// <summary>
- /// Setup this tab for the specified preset.
- /// </summary>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <param name="task">
- /// The task.
- /// </param>
public void SetPreset(Preset preset, EncodeTask task)
{
this.CurrentTask = task;
@@ -191,15 +128,13 @@ namespace HandBrakeWPF.ViewModels
if (preset != null)
{
// Properties
-
-
this.Grayscale = preset.Task.Grayscale;
- this.DeblockValue = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock;
-
+
this.SharpenFilter.SetPreset(preset, task);
this.DenoiseFilter.SetPreset(preset, task);
this.DetelecineFilter.SetPreset(preset, task);
this.DeinterlaceFilter.SetPreset(preset, task);
+ this.DeblockFilter.SetPreset(preset, task);
this.SelectedRotation = preset.Task.Rotation;
this.FlipVideo = preset.Task.FlipVideo;
@@ -208,25 +143,16 @@ namespace HandBrakeWPF.ViewModels
{
// Default everything to off
this.Grayscale = false;
- this.DeblockValue = 0;
this.SelectedRotation = 0;
this.FlipVideo = false;
}
}
- /// <summary>
- /// Update all the UI controls based on the encode task passed in.
- /// </summary>
- /// <param name="task">
- /// The task.
- /// </param>
public void UpdateTask(EncodeTask task)
{
this.CurrentTask = task;
this.NotifyOfPropertyChange(() => this.Grayscale);
- this.NotifyOfPropertyChange(() => this.DeblockValue);
-
this.NotifyOfPropertyChange(() => this.FlipVideo);
this.NotifyOfPropertyChange(() => this.SelectedRotation);
@@ -235,6 +161,7 @@ namespace HandBrakeWPF.ViewModels
this.DenoiseFilter.UpdateTask(task);
this.DetelecineFilter.UpdateTask(task);
this.DeinterlaceFilter.UpdateTask(task);
+ this.DeblockFilter.UpdateTask(task);
}
public bool MatchesPreset(Preset preset)
@@ -259,9 +186,7 @@ namespace HandBrakeWPF.ViewModels
return false;
}
- int presetDeblock = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock;
-
- if (presetDeblock != this.DeblockValue)
+ if (!this.DeblockFilter.MatchesPreset(preset))
{
return false;
}
@@ -284,21 +209,6 @@ namespace HandBrakeWPF.ViewModels
return true;
}
- /// <summary>
- /// Setup this window for a new source
- /// </summary>
- /// <param name="source">
- /// The source.
- /// </param>
- /// <param name="title">
- /// The title.
- /// </param>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <param name="task">
- /// The task.
- /// </param>
public void SetSource(Source source, Title title, Preset preset, EncodeTask task)
{
this.CurrentTask = task;
@@ -306,15 +216,12 @@ namespace HandBrakeWPF.ViewModels
this.DenoiseFilter.SetSource(source, title, preset, task);
this.DetelecineFilter.SetSource(source, title, preset, task);
this.DeinterlaceFilter.SetSource(source, title, preset, task);
+ this.DeblockFilter.SetSource(source, title, preset, task);
}
- #endregion
-
- #region Private Methods
protected virtual void OnTabStatusChanged(TabStatusEventArgs e)
{
this.TabStatusChanged?.Invoke(this, e);
}
- #endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Views/FiltersView.xaml b/win/CS/HandBrakeWPF/Views/FiltersView.xaml
index a311900eb..2030c5fae 100644
--- a/win/CS/HandBrakeWPF/Views/FiltersView.xaml
+++ b/win/CS/HandBrakeWPF/Views/FiltersView.xaml
@@ -172,10 +172,10 @@
<!-- Deblock -->
<TextBlock Text="{x:Static Properties:Resources.FiltersView_Deblock}" Grid.Row="5" Grid.Column="0" Margin="0,0,0,10"/>
- <Slider Width="120" Value="{Binding DeblockValue}" TickPlacement="BottomRight" Minimum="4" Maximum="15" Grid.Row="5" Grid.Column="1" Margin="0,0,0,10"
+ <Slider Width="120" Value="{Binding DeblockFilter.DeblockValue}" TickPlacement="BottomRight" Minimum="4" Maximum="15" Grid.Row="5" Grid.Column="1" Margin="0,0,0,10"
HorizontalAlignment="Left" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Deblock}"
AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_Deblock}" />
- <TextBlock Text="{Binding DeblockText}" Grid.Row="5" Grid.Column="2" Margin="0,0,0,10"/>
+ <TextBlock Text="{Binding DeblockFilter.DeblockText}" Grid.Row="5" Grid.Column="2" Margin="0,0,0,10"/>
<CheckBox Content="{x:Static Properties:Resources.FiltersView_Grayscale}" IsChecked="{Binding Grayscale}" Grid.Row="6" Grid.Column="1" Margin="0,0,0,10"
ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Grayscale}" />