summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs40
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs38
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs68
3 files changed, 146 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
index 741f31876..1c0f9de67 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
@@ -172,6 +172,9 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// Initializes a new instance of the <see cref="AdvancedViewModel"/> class.
/// </summary>
+ /// <param name="advancedEncoderOptionsCommand">
+ /// The advanced Encoder Options Command.
+ /// </param>
public AdvancedViewModel(IAdvancedEncoderOptionsCommand advancedEncoderOptionsCommand)
{
this.advancedEncoderOptionsCommand = advancedEncoderOptionsCommand;
@@ -179,11 +182,34 @@ namespace HandBrakeWPF.ViewModels
this.UpdateUIFromAdvancedOptions();
}
+ /// <summary>
+ /// The task object property changed.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The PropertyChangedEventArgs.
+ /// </param>
+ private void Task_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == UserSettingConstants.ShowAdvancedTab)
+ {
+ ShowX264AdvancedOptions = this.Task.ShowAdvancedTab;
+ this.NotifyOfPropertyChange(() => ShowX264AdvancedOptions);
+ }
+ }
+
#endregion
#region Properties
/// <summary>
+ /// Gets or sets a value indicating whether show x 264 advanced options.
+ /// </summary>
+ public bool ShowX264AdvancedOptions { get; set; }
+
+ /// <summary>
/// Gets or sets a value indicating whether DisplayX264Options.
/// </summary>
public bool? DisplayX264Options
@@ -195,7 +221,19 @@ namespace HandBrakeWPF.ViewModels
set
{
this.displayX264Options = value;
+
+ if (this.displayX264Options == false)
+ {
+ this.ShowX264AdvancedOptions = false;
+ }
+
+ if (this.displayX264Options == true && this.Task.ShowAdvancedTab)
+ {
+ this.ShowX264AdvancedOptions = true;
+ }
+
this.NotifyOfPropertyChange(() => this.DisplayX264Options);
+ this.NotifyOfPropertyChange(() => this.ShowX264AdvancedOptions);
}
}
@@ -959,7 +997,9 @@ namespace HandBrakeWPF.ViewModels
/// </param>
public void SetPreset(Preset preset, EncodeTask task)
{
+ this.Task.PropertyChanged -= this.Task_PropertyChanged;
this.Task = task;
+ this.Task.PropertyChanged += this.Task_PropertyChanged;
this.AdvancedOptionsString = preset.Task.AdvancedEncoderOptions;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 335509150..2db2c66c7 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -213,6 +213,7 @@ namespace HandBrakeWPF.ViewModels
// Setup Properties
this.WindowTitle = "HandBrake";
this.CurrentTask = new EncodeTask();
+ this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;
this.ScannedSource = new Source();
// Setup Events
@@ -223,6 +224,7 @@ namespace HandBrakeWPF.ViewModels
this.queueProcessor.QueueCompleted += this.QueueCompleted;
this.queueProcessor.QueueChanged += this.QueueChanged;
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
+ this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;
this.Presets = this.presetService.Presets;
this.CancelScanCommand = new CancelScanCommand(this.scanService);
@@ -885,6 +887,7 @@ namespace HandBrakeWPF.ViewModels
this.queueProcessor.QueueChanged -= this.QueueChanged;
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
+ this.userSettingService.SettingChanged -= this.UserSettingServiceSettingChanged;
}
#endregion
@@ -1860,6 +1863,41 @@ namespace HandBrakeWPF.ViewModels
Caliburn.Micro.Execute.OnUIThread(() => this.SourceMenu = this.GenerateSourceMenu());
}
+ /// <summary>
+ /// Allows the main window to respond to setting changes.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void UserSettingServiceSettingChanged(object sender, HandBrake.ApplicationServices.EventArgs.SettingChangedEventArgs e)
+ {
+ if (e.Key == UserSettingConstants.ShowAdvancedTab)
+ {
+ this.NotifyOfPropertyChange(() => this.ShowAdvancedTab);
+ }
+ }
+
+ /// <summary>
+ /// Handle the property changed event of the encode task.
+ /// Allows the main window to respond to changes.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void CurrentTask_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == UserSettingConstants.ShowAdvancedTab)
+ {
+ this.NotifyOfPropertyChange(() => this.ShowAdvancedTab);
+ }
+ }
+
#endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
index 6164e3603..a59105084 100644
--- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
@@ -27,6 +27,7 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.Interop.Model.Encoding.x264;
using HandBrakeWPF.Commands.Interfaces;
+ using HandBrakeWPF.Model;
using HandBrakeWPF.ViewModels.Interfaces;
/// <summary>
@@ -95,6 +96,11 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private bool canClear;
+ /// <summary>
+ /// The use advanced tab.
+ /// </summary>
+ private bool useAdvancedTab;
+
#endregion
#region Constructors and Destructors
@@ -122,6 +128,8 @@ namespace HandBrakeWPF.ViewModels
H264Profiles = EnumHelper<x264Profile>.GetEnumList();
X264Tunes = EnumHelper<x264Tune>.GetEnumList().Where(t => t != x264Tune.Fastdecode);
this.H264Levels = Levels;
+
+ this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;
}
#endregion
@@ -134,6 +142,44 @@ namespace HandBrakeWPF.ViewModels
public EncodeTask Task { get; set; }
/// <summary>
+ /// Gets a value indicating whether show advanced tab.
+ /// </summary>
+ public bool ShowAdvancedTab
+ {
+ get
+ {
+ bool showAdvTabSetting =
+ this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowAdvancedTab);
+ if (!showAdvTabSetting)
+ {
+ this.UseAdvancedTab = false;
+ }
+
+ return showAdvTabSetting;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether use video tab.
+ /// </summary>
+ public bool UseAdvancedTab
+ {
+ get
+ {
+ return this.useAdvancedTab;
+ }
+ set
+ {
+ if (!object.Equals(value, this.useAdvancedTab))
+ {
+ this.useAdvancedTab = value;
+ this.Task.ShowAdvancedTab = value;
+ this.NotifyOfPropertyChange(() => this.UseAdvancedTab);
+ }
+ }
+ }
+
+ /// <summary>
/// Gets Framerates.
/// </summary>
public IEnumerable<string> Framerates
@@ -335,6 +381,9 @@ namespace HandBrakeWPF.ViewModels
}
}
+ /// <summary>
+ /// Gets the rfqp.
+ /// </summary>
public string Rfqp
{
get
@@ -729,6 +778,8 @@ namespace HandBrakeWPF.ViewModels
this.H264Level = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.H264Level : "Auto";
this.FastDecode = preset.Task.VideoEncoder == VideoEncoder.X264 && preset.Task.FastDecode;
this.ExtraArguments = preset.Task.ExtraAdvancedArguments;
+
+ this.UseAdvancedTab = !string.IsNullOrEmpty(preset.Task.AdvancedEncoderOptions) && this.ShowAdvancedTab;
}
}
@@ -866,5 +917,22 @@ namespace HandBrakeWPF.ViewModels
// TODO figure out what is wrong with this??
return HandBrakeUtils.CreateX264OptionsString(preset, tunes, this.ExtraArguments, profile, this.H264Level, width, height);
}
+
+ /// <summary>
+ /// The user setting service_ setting changed.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void UserSettingServiceSettingChanged(object sender, HandBrake.ApplicationServices.EventArgs.SettingChangedEventArgs e)
+ {
+ if (e.Key == UserSettingConstants.ShowAdvancedTab)
+ {
+ this.NotifyOfPropertyChange(() => this.ShowAdvancedTab);
+ }
+ }
}
} \ No newline at end of file