diff options
Diffstat (limited to 'win/CS')
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModelItems/Filters/DetelecineItem.cs | 138 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs | 86 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/FiltersView.xaml | 8 |
4 files changed, 155 insertions, 78 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index fb40aa871..2a5c2d21c 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -273,6 +273,7 @@ <Compile Include="Utilities\Win32.cs" />
<Compile Include="Utilities\Win7.cs" />
<Compile Include="ViewModelItems\Filters\DenoiseItem.cs" />
+ <Compile Include="ViewModelItems\Filters\DetelecineItem.cs" />
<Compile Include="ViewModelItems\Filters\SharpenItem.cs" />
<Compile Include="ViewModels\Interfaces\IManagePresetViewModel.cs" />
<Compile Include="ViewModels\Interfaces\ISummaryViewModel.cs" />
diff --git a/win/CS/HandBrakeWPF/ViewModelItems/Filters/DetelecineItem.cs b/win/CS/HandBrakeWPF/ViewModelItems/Filters/DetelecineItem.cs new file mode 100644 index 000000000..0b98b9d7e --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModelItems/Filters/DetelecineItem.cs @@ -0,0 +1,138 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="DetelecineItem.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 DetelecineItem type. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModelItems.Filters +{ + using System.Collections.Generic; + + using Caliburn.Micro; + + using HandBrake.Interop.Interop.Model.Encoding; + + using HandBrakeWPF.Services.Encode.Model; + using HandBrakeWPF.Services.Presets.Model; + using HandBrakeWPF.Services.Scan.Model; + using HandBrakeWPF.Utilities; + + using Action = System.Action; + + public class DetelecineItem : PropertyChangedBase + { + private readonly Action triggerTabChanged; + + public DetelecineItem(EncodeTask currentTask, Action triggerTabChanged) + { + this.triggerTabChanged = triggerTabChanged; + this.CurrentTask = currentTask; + } + + public EncodeTask CurrentTask { get; private set; } + + public Detelecine SelectedDetelecine + { + get + { + return this.CurrentTask.Detelecine; + } + + set + { + this.CurrentTask.Detelecine = value; + this.NotifyOfPropertyChange(() => this.SelectedDetelecine); + + // Show / Hide the Custom Control + if (value != Detelecine.Custom) this.CustomDetelecine = string.Empty; + this.NotifyOfPropertyChange(() => this.ShowDetelecineCustom); + this.triggerTabChanged(); + } + } + + /// <summary> + /// Gets or sets a value indicating whether ShowDetelecineCustom. + /// </summary> + public bool ShowDetelecineCustom => this.CurrentTask.Detelecine == Detelecine.Custom; + + /// <summary> + /// Gets DetelecineOptions. + /// </summary> + public IEnumerable<Detelecine> DetelecineOptions + { + get + { + return EnumHelper<Detelecine>.GetEnumList(); + } + } + + /// <summary> + /// Gets or sets CustomDetelecine. + /// </summary> + public string CustomDetelecine + { + get + { + return this.CurrentTask.CustomDetelecine; + } + + set + { + this.CurrentTask.CustomDetelecine = value; + this.NotifyOfPropertyChange(() => this.CustomDetelecine); + this.triggerTabChanged(); + } + } + + public void SetPreset(Preset preset, EncodeTask task) + { + this.CurrentTask = task; + + if (preset == null) + { + this.SelectedDetelecine = Detelecine.Off; + return; + } + + this.SelectedDetelecine = preset.Task.Detelecine; + this.CustomDetelecine = preset.Task.CustomDetelecine; + } + + /// <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.SelectedDetelecine); + this.NotifyOfPropertyChange(() => this.CustomDetelecine); + this.NotifyOfPropertyChange(() => this.ShowDetelecineCustom); + } + + public bool MatchesPreset(Preset preset) + { + if (preset.Task.Detelecine != this.SelectedDetelecine) + { + return false; + } + + if (preset.Task.CustomDetelecine != this.CustomDetelecine) + { + 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 9e9271a48..171d29a29 100644 --- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs @@ -60,6 +60,7 @@ namespace HandBrakeWPF.ViewModels 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));
}
#endregion
@@ -74,24 +75,6 @@ namespace HandBrakeWPF.ViewModels public EncodeTask CurrentTask { get; private set; }
/// <summary>
- /// Gets or sets CustomDetelecine.
- /// </summary>
- public string CustomDetelecine
- {
- get
- {
- return this.CurrentTask.CustomDetelecine;
- }
-
- set
- {
- this.CurrentTask.CustomDetelecine = value;
- this.NotifyOfPropertyChange(() => this.CustomDetelecine);
- this.OnTabStatusChanged(null);
- }
- }
-
- /// <summary>
/// Gets DeblockText.
/// </summary>
public string DeblockText
@@ -122,17 +105,6 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
- /// Gets DetelecineOptions.
- /// </summary>
- public IEnumerable<Detelecine> DetelecineOptions
- {
- get
- {
- return EnumHelper<Detelecine>.GetEnumList();
- }
- }
-
- /// <summary>
/// Gets or sets a value indicating whether Grayscale.
/// </summary>
public bool Grayscale
@@ -306,33 +278,7 @@ namespace HandBrakeWPF.ViewModels #endregion
- /// <summary>
- /// Gets or sets SelectedDetelecine.
- /// </summary>
- public Detelecine SelectedDetelecine
- {
- get
- {
- return this.CurrentTask.Detelecine;
- }
-
- set
- {
- this.CurrentTask.Detelecine = value;
- this.NotifyOfPropertyChange(() => this.SelectedDetelecine);
-
- // Show / Hide the Custom Control
- if (value != Detelecine.Custom) this.CustomDetelecine = string.Empty;
- this.NotifyOfPropertyChange(() => this.ShowDetelecineCustom);
- this.OnTabStatusChanged(null);
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether ShowDetelecineCustom.
- /// </summary>
- public bool ShowDetelecineCustom => this.CurrentTask.Detelecine == Detelecine.Custom;
-
+ public DetelecineItem DetelecineFilter { get; set; }
public DenoiseItem DenoiseFilter { get; set; }
@@ -415,8 +361,6 @@ namespace HandBrakeWPF.ViewModels if (preset != null)
{
// Properties
- this.SelectedDetelecine = preset.Task.Detelecine;
-
this.SelectedDeinterlaceFilter = preset.Task.DeinterlaceFilter;
this.SelectedDeInterlacePreset = preset.Task.DeinterlacePreset;
@@ -427,11 +371,11 @@ namespace HandBrakeWPF.ViewModels this.SharpenFilter.SetPreset(preset, task);
this.DenoiseFilter.SetPreset(preset, task);
+ this.DetelecineFilter.SetPreset(preset, task);
// Custom Values
this.CustomDeinterlaceSettings = preset.Task.CustomDeinterlaceSettings;
this.CustomCombDetect = preset.Task.CustomCombDetect;
- this.CustomDetelecine = preset.Task.CustomDetelecine;
this.SelectedRotation = preset.Task.Rotation;
this.FlipVideo = preset.Task.FlipVideo;
@@ -440,7 +384,6 @@ namespace HandBrakeWPF.ViewModels {
// Default everything to off
this.SelectedDeinterlaceFilter = DeinterlaceFilter.Off;
- this.SelectedDetelecine = Detelecine.Off;
this.Grayscale = false;
this.DeblockValue = 0;
@@ -460,7 +403,6 @@ namespace HandBrakeWPF.ViewModels this.CurrentTask = task;
this.NotifyOfPropertyChange(() => this.SelectedDeinterlaceFilter);
this.NotifyOfPropertyChange(() => this.SelectedDeInterlacePreset);
- this.NotifyOfPropertyChange(() => this.SelectedDetelecine);
this.NotifyOfPropertyChange(() => this.Grayscale);
this.NotifyOfPropertyChange(() => this.DeblockValue);
this.NotifyOfPropertyChange(() => this.SelectedCombDetectPreset);
@@ -469,29 +411,19 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.SelectedRotation);
this.NotifyOfPropertyChange(() => this.CustomDeinterlaceSettings);
- this.NotifyOfPropertyChange(() => this.CustomDetelecine);
this.NotifyOfPropertyChange(() => this.CustomCombDetect);
this.NotifyOfPropertyChange(() => this.ShowCustomDeinterlace);
this.NotifyOfPropertyChange(() => this.ShowCombDetectCustom);
- this.NotifyOfPropertyChange(() => this.ShowDetelecineCustom);
this.SharpenFilter.UpdateTask(task);
this.DenoiseFilter.UpdateTask(task);
+ this.DetelecineFilter.UpdateTask(task);
}
public bool MatchesPreset(Preset preset)
{
- if (preset.Task.Detelecine != this.SelectedDetelecine)
- {
- return false;
- }
-
- if (preset.Task.CustomDetelecine != this.CustomDetelecine)
- {
- return false;
- }
-
+
if (preset.Task.DeinterlaceFilter != this.SelectedDeinterlaceFilter)
{
return false;
@@ -526,7 +458,12 @@ namespace HandBrakeWPF.ViewModels {
return false;
}
-
+
+ if (!this.DetelecineFilter.MatchesPreset(preset))
+ {
+ return false;
+ }
+
int presetDeblock = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock;
if (presetDeblock != this.DeblockValue)
@@ -572,6 +509,7 @@ namespace HandBrakeWPF.ViewModels this.CurrentTask = task;
this.SharpenFilter.SetSource(source, title, preset, task);
this.DenoiseFilter.SetSource(source, title, preset, task);
+ this.DetelecineFilter.SetSource(source, title, preset, task);
}
#endregion
diff --git a/win/CS/HandBrakeWPF/Views/FiltersView.xaml b/win/CS/HandBrakeWPF/Views/FiltersView.xaml index f360a0503..8379c6eb6 100644 --- a/win/CS/HandBrakeWPF/Views/FiltersView.xaml +++ b/win/CS/HandBrakeWPF/Views/FiltersView.xaml @@ -51,12 +51,12 @@ <!-- Detelecine -->
<TextBlock Text="{x:Static Properties:Resources.FiltersView_Detelecine}" Grid.Row="0" Grid.Column="0" Margin="0,0,0,10" />
- <ComboBox Width="120" Grid.Row="0" ItemsSource="{Binding DetelecineOptions, Converter={StaticResource boolComboConverter}}"
- SelectedItem="{Binding SelectedDetelecine, Converter={StaticResource boolComboConverter}}" Grid.Column="1" Margin="0,0,0,10"
+ <ComboBox Width="120" Grid.Row="0" ItemsSource="{Binding DetelecineFilter.DetelecineOptions, Converter={StaticResource boolComboConverter}}"
+ SelectedItem="{Binding DetelecineFilter.SelectedDetelecine, Converter={StaticResource boolComboConverter}}" Grid.Column="1" Margin="0,0,0,10"
ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Detelecine}"
HorizontalAlignment="Left" AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_Detelecine}" />
- <TextBox Width="120" Grid.Row="0" Grid.Column="2" Margin="0,0,0,10" Text="{Binding CustomDetelecine, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left"
- Visibility="{Binding ShowDetelecineCustom, Converter={StaticResource boolToVisConverter}}"/>
+ <TextBox Width="120" Grid.Row="0" Grid.Column="2" Margin="0,0,0,10" Text="{Binding DetelecineFilter.CustomDetelecine, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left"
+ Visibility="{Binding DetelecineFilter.ShowDetelecineCustom, Converter={StaticResource boolToVisConverter}}"/>
<!-- Interlace Detection -->
<TextBlock Text="{x:Static Properties:Resources.FiltersView_InterlaceDetection}" VerticalAlignment="Center" Margin="0,0,5,0" Grid.Row="1" />
|