diff options
-rw-r--r-- | win/CS/HandBrakeWPF/EventArgs/TabStatusEventArgs.cs | 20 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs | 83 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs | 18 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs | 111 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs | 7 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 94 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MetaDataViewModel.cs | 10 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs | 23 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs | 45 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs | 31 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs | 101 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/X264ViewModel.cs | 13 |
13 files changed, 551 insertions, 6 deletions
diff --git a/win/CS/HandBrakeWPF/EventArgs/TabStatusEventArgs.cs b/win/CS/HandBrakeWPF/EventArgs/TabStatusEventArgs.cs new file mode 100644 index 000000000..5c2fae966 --- /dev/null +++ b/win/CS/HandBrakeWPF/EventArgs/TabStatusEventArgs.cs @@ -0,0 +1,20 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="TabStatusEventArgs.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> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.EventArgs +{ + using System; + + public class TabStatusEventArgs : EventArgs + { + public TabStatusEventArgs(string tabKey) + { + this.TabKey = tabKey; + } + + public string TabKey { get; private set; } + } +} diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index b0db06436..7f2a7cbbd 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -170,6 +170,7 @@ <Compile Include="EventArgs\QueueCompletedEventArgs.cs" />
<Compile Include="EventArgs\QueueProgressEventArgs.cs" />
<Compile Include="EventArgs\SettingChangedEventArgs.cs" />
+ <Compile Include="EventArgs\TabStatusEventArgs.cs" />
<Compile Include="Exceptions\GeneralApplicationException.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Helpers\TreeViewHelper.cs" />
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index 83f509269..9d04261b0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -9,6 +9,7 @@ namespace HandBrakeWPF.ViewModels
{
+ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
@@ -20,6 +21,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Interop.Model.Encoding;
using HandBrake.ApplicationServices.Utilities;
+ using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Model.Audio;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Interfaces;
@@ -71,6 +73,8 @@ namespace HandBrakeWPF.ViewModels #endregion
+ public event EventHandler<TabStatusEventArgs> TabStatusChanged;
+
#region Properties
/// <summary>
@@ -266,6 +270,81 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.Task);
}
+ public bool MatchesPreset(Preset preset)
+ {
+ // Check the default behaviours still match the preset.
+ if (preset.AudioTrackBehaviours.SelectedBehaviour != this.AudioBehaviours.SelectedBehaviour)
+ {
+ return false;
+ }
+
+ if (preset.AudioTrackBehaviours.SelectedTrackDefaultBehaviour
+ != this.AudioBehaviours.SelectedTrackDefaultBehaviour)
+ {
+ return false;
+ }
+
+ foreach (var item in this.AudioBehaviours.SelectedLangauges)
+ {
+ if (!preset.AudioTrackBehaviours.SelectedLangauges.Contains(item))
+ {
+ return false;
+ }
+ }
+
+ if (preset.Task.AllowedPassthruOptions.AudioAllowMP3Pass != this.Task.AllowedPassthruOptions.AudioAllowMP3Pass)
+ {
+ return false;
+ }
+
+ if (preset.Task.AllowedPassthruOptions.AudioAllowAACPass != this.Task.AllowedPassthruOptions.AudioAllowAACPass)
+ {
+ return false;
+ }
+
+ if (preset.Task.AllowedPassthruOptions.AudioAllowAC3Pass != this.Task.AllowedPassthruOptions.AudioAllowAC3Pass)
+ {
+ return false;
+ }
+
+ if (preset.Task.AllowedPassthruOptions.AudioAllowEAC3Pass != this.Task.AllowedPassthruOptions.AudioAllowEAC3Pass)
+ {
+ return false;
+ }
+
+ if (preset.Task.AllowedPassthruOptions.AudioAllowDTSPass != this.Task.AllowedPassthruOptions.AudioAllowDTSPass)
+ {
+ return false;
+ }
+
+ if (preset.Task.AllowedPassthruOptions.AudioAllowDTSHDPass != this.Task.AllowedPassthruOptions.AudioAllowDTSHDPass)
+ {
+ return false;
+ }
+
+ if (preset.Task.AllowedPassthruOptions.AudioAllowTrueHDPass != this.Task.AllowedPassthruOptions.AudioAllowTrueHDPass)
+ {
+ return false;
+ }
+
+ if (preset.Task.AllowedPassthruOptions.AudioAllowFlacPass != this.Task.AllowedPassthruOptions.AudioAllowFlacPass)
+ {
+ return false;
+ }
+
+ if (preset.Task.AllowedPassthruOptions.AudioEncoderFallback != this.Task.AllowedPassthruOptions.AudioEncoderFallback)
+ {
+ return false;
+ }
+
+ if (preset.AudioTrackBehaviours.SelectedLangauges != this.AudioBehaviours.SelectedLangauges)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
/// <summary>
/// Set the Source Title
/// </summary>
@@ -326,6 +405,10 @@ namespace HandBrakeWPF.ViewModels #endregion
#region Methods
+ protected virtual void OnTabStatusChanged(TabStatusEventArgs e)
+ {
+ this.TabStatusChanged?.Invoke(this, e);
+ }
/// <summary>
/// Add the specified source track, or the first track in the SourceTracks collection if available.
diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs index 0d1d3d1e1..3939d786a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs @@ -19,6 +19,7 @@ namespace HandBrakeWPF.ViewModels using Caliburn.Micro;
+ using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
@@ -67,6 +68,8 @@ namespace HandBrakeWPF.ViewModels this.errorService = errorService;
}
+ public event EventHandler<TabStatusEventArgs> TabStatusChanged;
+
#endregion
#region Public Properties
@@ -306,6 +309,16 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.Chapters);
}
+ public bool MatchesPreset(Preset preset)
+ {
+ if (preset.Task.IncludeChapterMarkers != this.IncludeChapterMarkers)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
/// <summary>
/// Reset Chapter Names
/// </summary>
@@ -346,6 +359,11 @@ namespace HandBrakeWPF.ViewModels #region Private Methods
+ protected virtual void OnTabStatusChanged(TabStatusEventArgs e)
+ {
+ this.TabStatusChanged?.Invoke(this, e);
+ }
+
/// <summary>
/// Validates any imported chapter information against the currently detected chapter information in the
/// source media. If validation fails then an error message is returned via the out parameter <see cref="validationErrorMessage"/>
diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs index cd6b29d03..c1fff3015 100644 --- a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs @@ -9,6 +9,7 @@ namespace HandBrakeWPF.ViewModels
{
+ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
@@ -20,6 +21,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Interop.HbLib;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Model.Filters;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
@@ -58,6 +60,8 @@ namespace HandBrakeWPF.ViewModels #endregion
+ public event EventHandler<TabStatusEventArgs> TabStatusChanged;
+
#region Properties
/// <summary>
@@ -826,6 +830,106 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.SelectedRotation);
}
+ 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;
+ }
+
+ if (preset.Task.Deinterlace != this.SelectedDeInterlace)
+ {
+ return false;
+ }
+
+ if (preset.Task.Decomb != this.SelectedDecomb)
+ {
+ return false;
+ }
+
+ if (preset.Task.CombDetect != this.SelectedCombDetectPreset)
+ {
+ return false;
+ }
+
+ if (preset.Task.CustomDecomb != this.CustomDecomb)
+ {
+ return false;
+ }
+
+ if (preset.Task.CustomDeinterlace != this.CustomDeinterlace)
+ {
+ return false;
+ }
+
+ if (preset.Task.CustomCombDetect != this.CustomCombDetect)
+ {
+ return false;
+ }
+
+ if (preset.Task.Denoise != this.SelectedDenoise)
+ {
+ return false;
+ }
+
+ if (preset.Task.DenoisePreset != this.SelectedDenoisePreset)
+ {
+ return false;
+ }
+
+ if (preset.Task.DenoiseTune != this.SelectedDenoiseTune)
+ {
+ return false;
+ }
+
+ if (preset.Task.Sharpen != this.SelectedSharpen)
+ {
+ return false;
+ }
+
+ if (!Equals(preset.Task.SharpenPreset, this.SelectedSharpenPreset))
+ {
+ return false;
+ }
+
+ if (!Equals(preset.Task.SharpenTune, this.SelectedSharpenTune))
+ {
+ return false;
+ }
+
+ if (preset.Task.Deblock != this.DeblockValue)
+ {
+ return false;
+ }
+
+ if (preset.Task.Grayscale != this.Grayscale)
+ {
+ return false;
+ }
+
+ if (preset.Task.Rotation != this.SelectedRotation)
+ {
+ return false;
+ }
+
+ if (preset.Task.FlipVideo != this.FlipVideo)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
/// <summary>
/// Setup this window for a new source
/// </summary>
@@ -847,5 +951,12 @@ namespace HandBrakeWPF.ViewModels }
#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/ViewModels/Interfaces/ITabInterface.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs index 3e3ca0466..bdbeecf3a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITabInterface.cs @@ -9,6 +9,9 @@ namespace HandBrakeWPF.ViewModels.Interfaces
{
+ using System;
+
+ using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Services.Scan.Model;
@@ -19,6 +22,8 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// </summary>
public interface ITabInterface
{
+ event EventHandler<TabStatusEventArgs> TabStatusChanged;
+
/// <summary>
/// Setup the window after a scan.
/// </summary>
@@ -54,5 +59,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// The task.
/// </param>
void UpdateTask(EncodeTask task);
+
+ bool MatchesPreset(Preset preset);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index c8cf354ac..5d7d10027 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -96,8 +96,9 @@ namespace HandBrakeWPF.ViewModels private string alertWindowHeader;
private string alertWindowText;
private bool hasSource;
-
+ private bool isSettingPreset;
private IPresetObject selectedPresetCategory;
+ private bool isModifiedPreset;
#endregion
@@ -427,6 +428,20 @@ namespace HandBrakeWPF.ViewModels }
}
+ public bool IsModifiedPreset
+ {
+ get
+ {
+ return this.isModifiedPreset;
+ }
+ set
+ {
+ if (value == this.isModifiedPreset) return;
+ this.isModifiedPreset = value;
+ this.NotifyOfPropertyChange();
+ }
+ }
+
public void TrickPresetDisplayUpdate()
{
this.NotifyOfPropertyChange(() => this.SelectedPreset);
@@ -1235,6 +1250,16 @@ namespace HandBrakeWPF.ViewModels Thread clearLog = new Thread(() => GeneralUtilities.ClearLogFiles(30));
clearLog.Start();
}
+
+ this.PictureSettingsViewModel.TabStatusChanged += this.TabStatusChanged;
+ this.VideoViewModel.TabStatusChanged += this.TabStatusChanged;
+ this.FiltersViewModel.TabStatusChanged += this.TabStatusChanged;
+ this.AudioViewModel.TabStatusChanged += this.TabStatusChanged;
+ this.SubtitleViewModel.TabStatusChanged += this.TabStatusChanged;
+ this.ChaptersViewModel.TabStatusChanged += this.TabStatusChanged;
+ this.AdvancedViewModel.TabStatusChanged += this.TabStatusChanged;
+ this.MetaDataViewModel.TabStatusChanged += this.TabStatusChanged;
+ this.SummaryViewModel.TabStatusChanged += this.TabStatusChanged;
}
private void SummaryViewModel_OutputFormatChanged(object sender, OutputFormatChangedEventArgs e)
@@ -1270,6 +1295,17 @@ namespace HandBrakeWPF.ViewModels this.userSettingService.SettingChanged -= this.UserSettingServiceSettingChanged;
this.SummaryViewModel.OutputFormatChanged -= this.SummaryViewModel_OutputFormatChanged;
+
+ // Tab status events
+ this.PictureSettingsViewModel.TabStatusChanged -= this.TabStatusChanged;
+ this.VideoViewModel.TabStatusChanged -= this.TabStatusChanged;
+ this.FiltersViewModel.TabStatusChanged -= this.TabStatusChanged;
+ this.AudioViewModel.TabStatusChanged -= this.TabStatusChanged;
+ this.SubtitleViewModel.TabStatusChanged -= this.TabStatusChanged;
+ this.ChaptersViewModel.TabStatusChanged -= this.TabStatusChanged;
+ this.AdvancedViewModel.TabStatusChanged -= this.TabStatusChanged;
+ this.MetaDataViewModel.TabStatusChanged -= this.TabStatusChanged;
+ this.SummaryViewModel.TabStatusChanged -= this.TabStatusChanged;
}
#endregion
@@ -2053,6 +2089,7 @@ namespace HandBrakeWPF.ViewModels if (this.selectedPreset != null)
{
// Tab Settings
+ this.isSettingPreset = true;
this.PictureSettingsViewModel.SetPreset(this.selectedPreset, this.CurrentTask);
this.VideoViewModel.SetPreset(this.selectedPreset, this.CurrentTask);
this.FiltersViewModel.SetPreset(this.selectedPreset, this.CurrentTask);
@@ -2062,6 +2099,7 @@ namespace HandBrakeWPF.ViewModels this.AdvancedViewModel.SetPreset(this.selectedPreset, this.CurrentTask);
this.MetaDataViewModel.SetPreset(this.selectedPreset, this.CurrentTask);
this.SummaryViewModel.SetPreset(this.selectedPreset, this.CurrentTask);
+ this.isSettingPreset = false;
}
}
}
@@ -2175,6 +2213,7 @@ namespace HandBrakeWPF.ViewModels // Setup the Tabs
if (this.selectedTitle != null)
{
+ this.isSettingPreset = true;
this.PictureSettingsViewModel.SetSource(this.ScannedSource, this.SelectedTitle, this.selectedPreset, this.CurrentTask);
this.VideoViewModel.SetSource(this.ScannedSource, this.SelectedTitle, this.selectedPreset, this.CurrentTask);
this.FiltersViewModel.SetSource(this.ScannedSource, this.SelectedTitle, this.selectedPreset, this.CurrentTask);
@@ -2184,7 +2223,60 @@ namespace HandBrakeWPF.ViewModels this.AdvancedViewModel.SetSource(this.ScannedSource, this.SelectedTitle, this.selectedPreset, this.CurrentTask);
this.MetaDataViewModel.SetSource(this.ScannedSource, this.SelectedTitle, this.selectedPreset, this.CurrentTask);
this.SummaryViewModel.SetSource(this.ScannedSource, this.SelectedTitle, this.selectedPreset, this.CurrentTask);
+ this.isSettingPreset = false;
+ }
+ }
+
+ private void TabStatusChanged(object sender, TabStatusEventArgs e)
+ {
+ if (this.isSettingPreset)
+ {
+ return; // Don't process this when we are setting up.
}
+
+ bool matchesPreset = this.PictureSettingsViewModel.MatchesPreset(this.selectedPreset);
+
+ if (!this.VideoViewModel.MatchesPreset(this.selectedPreset))
+ {
+ matchesPreset = false;
+ }
+
+ if (!this.FiltersViewModel.MatchesPreset(this.selectedPreset))
+ {
+ matchesPreset = false;
+ }
+
+ if (!this.AudioViewModel.MatchesPreset(this.selectedPreset))
+ {
+ matchesPreset = false;
+ }
+
+ if (!this.SubtitleViewModel.MatchesPreset(this.selectedPreset))
+ {
+ matchesPreset = false;
+ }
+
+ if (!this.ChaptersViewModel.MatchesPreset(this.selectedPreset))
+ {
+ matchesPreset = false;
+ }
+
+ if (!this.AdvancedViewModel.MatchesPreset(this.selectedPreset))
+ {
+ matchesPreset = false;
+ }
+
+ if (!this.MetaDataViewModel.MatchesPreset(this.selectedPreset))
+ {
+ matchesPreset = false;
+ }
+
+ if (!this.SummaryViewModel.MatchesPreset(this.selectedPreset))
+ {
+ matchesPreset = false;
+ }
+
+ this.IsModifiedPreset = matchesPreset;
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/MetaDataViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MetaDataViewModel.cs index e0bd332d1..ec4fa6d78 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MetaDataViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MetaDataViewModel.cs @@ -9,8 +9,11 @@ namespace HandBrakeWPF.ViewModels { + using System; + using Caliburn.Micro; + using HandBrakeWPF.EventArgs; using HandBrakeWPF.Services.Encode.Model; using HandBrakeWPF.Services.Encode.Model.Models; using HandBrakeWPF.Services.Interfaces; @@ -40,6 +43,8 @@ namespace HandBrakeWPF.ViewModels this.Task = new EncodeTask(); } + public event EventHandler<TabStatusEventArgs> TabStatusChanged; + /// <summary> /// The Current Job /// </summary> @@ -122,5 +127,10 @@ namespace HandBrakeWPF.ViewModels { this.Task = encodeTask; } + + public bool MatchesPreset(Preset preset) + { + return true; + } } } diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index f4afb5109..8d2635485 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -17,6 +17,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Helpers;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Presets.Model;
@@ -134,6 +135,8 @@ namespace HandBrakeWPF.ViewModels #endregion
+ public event EventHandler<TabStatusEventArgs> TabStatusChanged;
+
#region Properties
/// <summary>
@@ -822,10 +825,30 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.Task);
}
+ public bool MatchesPreset(Preset preset)
+ {
+ if (preset.Task.Anamorphic != this.SelectedAnamorphicMode)
+ {
+ return false;
+ }
+
+ if (preset.Task.Modulus != this.SelectedModulus)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
#endregion
#region Methods
+ protected virtual void OnTabStatusChanged(TabStatusEventArgs e)
+ {
+ this.TabStatusChanged?.Invoke(this, e);
+ }
+
/// <summary>
/// The init.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index d747c6112..f1753aeed 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -9,8 +9,8 @@ namespace HandBrakeWPF.ViewModels
{
+ using System;
using System.Collections.Generic;
- using System.ComponentModel;
using System.IO;
using System.Linq;
@@ -18,11 +18,11 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Utilities;
+ using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Model.Subtitles;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Services.Scan.Model;
- using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using Microsoft.Win32;
@@ -69,6 +69,8 @@ namespace HandBrakeWPF.ViewModels #endregion
+ public event EventHandler<TabStatusEventArgs> TabStatusChanged;
+
#region Properties
/// <summary>
@@ -478,6 +480,40 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.Task);
}
+ public bool MatchesPreset(Preset preset)
+ {
+ // Check the default behaviours.
+ if (preset.SubtitleTrackBehaviours.AddClosedCaptions != this.SubtitleBehaviours.AddClosedCaptions)
+ {
+ return false;
+ }
+
+ if (preset.SubtitleTrackBehaviours.AddForeignAudioScanTrack != this.SubtitleBehaviours.AddForeignAudioScanTrack)
+ {
+ return false;
+ }
+
+ if (preset.SubtitleTrackBehaviours.SelectedBehaviour != this.SubtitleBehaviours.SelectedBehaviour)
+ {
+ return false;
+ }
+
+ if (preset.SubtitleTrackBehaviours.SelectedBurnInBehaviour != this.SubtitleBehaviours.SelectedBurnInBehaviour)
+ {
+ return false;
+ }
+
+ foreach (var item in this.SubtitleBehaviours.SelectedLangauges)
+ {
+ if (!preset.SubtitleTrackBehaviours.SelectedLangauges.Contains(item))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
/// <summary>
/// Setup this window for a new source
/// </summary>
@@ -512,6 +548,11 @@ namespace HandBrakeWPF.ViewModels #region Methods
+ protected virtual void OnTabStatusChanged(TabStatusEventArgs e)
+ {
+ this.TabStatusChanged?.Invoke(this, e);
+ }
+
/// <summary>
/// Add a subtitle track.
/// The Source track is set based on the following order. If null, it will skip to the next option.
diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs index a65fca5eb..5409e7502 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs @@ -55,6 +55,7 @@ namespace HandBrakeWPF.ViewModels this.userSettingService = userSettingService; } + public event EventHandler<TabStatusEventArgs> TabStatusChanged; public event EventHandler<OutputFormatChangedEventArgs> OutputFormatChanged; public Preset Preset @@ -309,6 +310,31 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.AlignAVStart); } + public bool MatchesPreset(Preset preset) + { + if (preset.Task.OutputFormat != this.SelectedOutputFormat) + { + return false; + } + + if (preset.Task.OptimizeMP4 != this.OptimizeMP4) + { + return false; + } + + if (preset.Task.AlignAVStart != this.AlignAVStart) + { + return false; + } + + if (preset.Task.IPod5GSupport != this.IPod5GSupport) + { + return false; + } + + return true; + } + public void UpdateDisplayedInfo() { if (this.CurrentTitle == null) @@ -377,6 +403,11 @@ namespace HandBrakeWPF.ViewModels #region Private Methods + protected virtual void OnTabStatusChanged(TabStatusEventArgs e) + { + this.TabStatusChanged?.Invoke(this, e); + } + private void UpdateSettings(Preset selectedPreset) { // Main Window Settings diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 2b84f506a..467d275c7 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -20,6 +20,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Interop;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets.Model;
@@ -77,9 +78,6 @@ namespace HandBrakeWPF.ViewModels /// <param name="userSettingService">
/// The user Setting Service.
/// </param>
- /// <param name="advancedEncoderOptionsCommand">
- /// The advanced Encoder Options Command.
- /// </param>
public VideoViewModel(IUserSettingService userSettingService)
{
this.Task = new EncodeTask { VideoEncoder = VideoEncoder.X264 };
@@ -99,6 +97,8 @@ namespace HandBrakeWPF.ViewModels #endregion
+ public event EventHandler<TabStatusEventArgs> TabStatusChanged;
+
#region Public Properties
/// <summary>
@@ -1004,6 +1004,96 @@ namespace HandBrakeWPF.ViewModels }
}
+ public bool MatchesPreset(Preset preset)
+ {
+ if (preset.Task.VideoEncoder != this.Task.VideoEncoder)
+ {
+ return false;
+ }
+
+ if (preset.Task.Framerate != this.Task.Framerate)
+ {
+ return false;
+ }
+
+ if (preset.Task.FramerateMode != this.Task.FramerateMode)
+ {
+ return false;
+ }
+
+ if (preset.Task.VideoEncodeRateType != this.Task.VideoEncodeRateType)
+ {
+ return false;
+ }
+
+ if (preset.Task.VideoEncodeRateType == VideoEncodeRateType.AverageBitrate)
+ {
+ if (preset.Task.VideoBitrate != this.Task.VideoBitrate)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (preset.Task.Quality != this.Task.Quality)
+ {
+ return false;
+ }
+ }
+
+ if (preset.Task.TwoPass != this.Task.TwoPass)
+ {
+ return false;
+ }
+
+ if (preset.Task.TurboFirstPass != this.Task.TurboFirstPass)
+ {
+ return false;
+ }
+
+ if (this.Task.VideoEncoder == VideoEncoder.X264 || this.Task.VideoEncoder == VideoEncoder.X264_10
+ || this.Task.VideoEncoder == VideoEncoder.X265 || this.Task.VideoEncoder == VideoEncoder.X265_10
+ || this.Task.VideoEncoder == VideoEncoder.X265_12 || this.Task.VideoEncoder == VideoEncoder.QuickSync
+ || this.Task.VideoEncoder == VideoEncoder.QuickSyncH265
+ || this.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b)
+ {
+ if (!Equals(preset.Task.VideoPreset, this.Task.VideoPreset))
+ {
+ return false;
+ }
+
+ foreach (VideoTune taskVideoTune in preset.Task.VideoTunes)
+ {
+ if (!this.Task.VideoTunes.Contains(taskVideoTune))
+ {
+ return false;
+ }
+ }
+
+ if (preset.Task.VideoTunes != this.Task.VideoTunes)
+ {
+ return false;
+ }
+
+ if (!Equals(preset.Task.VideoProfile, this.Task.VideoProfile))
+ {
+ return false;
+ }
+
+ if (!Equals(preset.Task.VideoLevel, this.Task.VideoLevel))
+ {
+ return false;
+ }
+ }
+
+ if (!Equals(preset.Task.ExtraAdvancedArguments, this.Task.ExtraAdvancedArguments))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
/// <summary>
/// Trigger a Notify Property Changed on the Task to force various UI elements to update.
/// </summary>
@@ -1027,6 +1117,11 @@ namespace HandBrakeWPF.ViewModels #endregion
+ protected virtual void OnTabStatusChanged(TabStatusEventArgs e)
+ {
+ this.TabStatusChanged?.Invoke(this, e);
+ }
+
/// <summary>
/// Set the bounds of the Constant Quality Slider
/// </summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/X264ViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/X264ViewModel.cs index 9a9e905e0..806b763be 100644 --- a/win/CS/HandBrakeWPF/ViewModels/X264ViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/X264ViewModel.cs @@ -16,6 +16,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrakeWPF.EventArgs;
using HandBrakeWPF.Helpers;
using HandBrakeWPF.Model;
using HandBrakeWPF.Services.Presets.Model;
@@ -190,6 +191,8 @@ namespace HandBrakeWPF.ViewModels #endregion
+ public event EventHandler<TabStatusEventArgs> TabStatusChanged;
+
#region Properties
/// <summary>
@@ -954,6 +957,11 @@ namespace HandBrakeWPF.ViewModels this.AdvancedOptionsString = task.AdvancedEncoderOptions;
}
+ public bool MatchesPreset(Preset preset)
+ {
+ return false;
+ }
+
/// <summary>
/// Setup this window for a new source
/// </summary>
@@ -981,6 +989,11 @@ namespace HandBrakeWPF.ViewModels #region Methods
+ protected virtual void OnTabStatusChanged(TabStatusEventArgs e)
+ {
+ this.TabStatusChanged?.Invoke(this, e);
+ }
+
/// <summary>
/// The set advanced to defaults.
/// </summary>
|