--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------
+// <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;
+ }
+ }
+}
{\r
#region Constructors and Destructors\r
\r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="FiltersViewModel"/> class.\r
- /// </summary>\r
- /// <param name="windowManager">\r
- /// The window manager.\r
- /// </param>\r
- /// <param name="userSettingService">\r
- /// The user Setting Service.\r
- /// </param>\r
public FiltersViewModel(IWindowManager windowManager, IUserSettingService userSettingService)\r
{\r
this.CurrentTask = new EncodeTask();\r
- this.DeblockValue = 4; // OFF\r
\r
this.SharpenFilter = new SharpenItem(this.CurrentTask, () => this.OnTabStatusChanged(null));\r
this.DenoiseFilter = new DenoiseItem(this.CurrentTask, () => this.OnTabStatusChanged(null));\r
this.DetelecineFilter = new DetelecineItem(this.CurrentTask, () => this.OnTabStatusChanged(null));\r
this.DeinterlaceFilter = new DeinterlaceFilterItem(this.CurrentTask, () => this.OnTabStatusChanged(null));\r
+ this.DeblockFilter = new DeblockFilter(this.CurrentTask, () => this.OnTabStatusChanged(null));\r
}\r
\r
#endregion\r
\r
#region Properties\r
\r
- /// <summary>\r
- /// Gets CurrentTask.\r
- /// </summary>\r
public EncodeTask CurrentTask { get; private set; }\r
\r
- /// <summary>\r
- /// Gets DeblockText.\r
- /// </summary>\r
- public string DeblockText\r
- {\r
- get\r
- {\r
- return this.DeblockValue == 4 ? "Off" : this.DeblockValue.ToString(CultureInfo.InvariantCulture);\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets or sets DeblockValue.\r
- /// </summary>\r
- public int DeblockValue\r
- {\r
- get\r
- {\r
- return this.CurrentTask.Deblock;\r
- }\r
-\r
- set\r
- {\r
- this.CurrentTask.Deblock = value;\r
- this.NotifyOfPropertyChange(() => this.DeblockValue);\r
- this.NotifyOfPropertyChange(() => this.DeblockText);\r
- this.OnTabStatusChanged(null);\r
- }\r
- }\r
-\r
- /// <summary>\r
- /// Gets or sets a value indicating whether Grayscale.\r
- /// </summary>\r
public bool Grayscale\r
{\r
get\r
}\r
}\r
\r
-\r
public DenoiseItem DenoiseFilter { get; set; }\r
\r
public SharpenItem SharpenFilter { get; set; }\r
\r
public DeinterlaceFilterItem DeinterlaceFilter { get; set; }\r
\r
- /// <summary>\r
- /// The rotation options.\r
- /// </summary>\r
+ public DeblockFilter DeblockFilter { get; set; }\r
+\r
+\r
+\r
public BindingList<int> RotationOptions => new BindingList<int> { 0, 90, 180, 270 };\r
\r
- /// <summary>\r
- /// Selected Rotation.\r
- /// </summary>\r
public int SelectedRotation\r
{\r
get\r
}\r
}\r
\r
- /// <summary>\r
- /// Flip the Video\r
- /// </summary>\r
public bool FlipVideo\r
{\r
get\r
}\r
}\r
\r
-\r
#endregion\r
\r
- #region Implemented Interfaces\r
-\r
- /// <summary>\r
- /// Setup this tab for the specified preset.\r
- /// </summary>\r
- /// <param name="preset">\r
- /// The preset.\r
- /// </param>\r
- /// <param name="task">\r
- /// The task.\r
- /// </param>\r
public void SetPreset(Preset preset, EncodeTask task)\r
{\r
this.CurrentTask = task;\r
if (preset != null)\r
{\r
// Properties\r
- \r
-\r
this.Grayscale = preset.Task.Grayscale;\r
- this.DeblockValue = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock;\r
- \r
+ \r
this.SharpenFilter.SetPreset(preset, task);\r
this.DenoiseFilter.SetPreset(preset, task);\r
this.DetelecineFilter.SetPreset(preset, task);\r
this.DeinterlaceFilter.SetPreset(preset, task);\r
+ this.DeblockFilter.SetPreset(preset, task);\r
\r
this.SelectedRotation = preset.Task.Rotation;\r
this.FlipVideo = preset.Task.FlipVideo;\r
{\r
// Default everything to off\r
this.Grayscale = false;\r
- this.DeblockValue = 0;\r
\r
this.SelectedRotation = 0;\r
this.FlipVideo = false;\r
}\r
}\r
\r
- /// <summary>\r
- /// Update all the UI controls based on the encode task passed in.\r
- /// </summary>\r
- /// <param name="task">\r
- /// The task.\r
- /// </param>\r
public void UpdateTask(EncodeTask task)\r
{\r
this.CurrentTask = task;\r
this.NotifyOfPropertyChange(() => this.Grayscale);\r
- this.NotifyOfPropertyChange(() => this.DeblockValue);\r
- \r
\r
this.NotifyOfPropertyChange(() => this.FlipVideo);\r
this.NotifyOfPropertyChange(() => this.SelectedRotation);\r
this.DenoiseFilter.UpdateTask(task);\r
this.DetelecineFilter.UpdateTask(task);\r
this.DeinterlaceFilter.UpdateTask(task);\r
+ this.DeblockFilter.UpdateTask(task);\r
}\r
\r
public bool MatchesPreset(Preset preset)\r
return false;\r
}\r
\r
- int presetDeblock = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock;\r
-\r
- if (presetDeblock != this.DeblockValue)\r
+ if (!this.DeblockFilter.MatchesPreset(preset))\r
{\r
return false;\r
}\r
return true;\r
}\r
\r
- /// <summary>\r
- /// Setup this window for a new source\r
- /// </summary>\r
- /// <param name="source">\r
- /// The source.\r
- /// </param>\r
- /// <param name="title">\r
- /// The title.\r
- /// </param>\r
- /// <param name="preset">\r
- /// The preset.\r
- /// </param>\r
- /// <param name="task">\r
- /// The task.\r
- /// </param>\r
public void SetSource(Source source, Title title, Preset preset, EncodeTask task)\r
{\r
this.CurrentTask = task;\r
this.DenoiseFilter.SetSource(source, title, preset, task);\r
this.DetelecineFilter.SetSource(source, title, preset, task);\r
this.DeinterlaceFilter.SetSource(source, title, preset, task);\r
+ this.DeblockFilter.SetSource(source, title, preset, task);\r
}\r
\r
- #endregion\r
-\r
- #region Private Methods\r
protected virtual void OnTabStatusChanged(TabStatusEventArgs e)\r
{\r
this.TabStatusChanged?.Invoke(this, e);\r
}\r
- #endregion\r
}\r
}
\ No newline at end of file