summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs61
1 files changed, 60 insertions, 1 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index f04ecbff9..3090a8144 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -106,6 +106,11 @@ namespace HandBrakeWPF.ViewModels
private bool showAddSelectionToQueue;
private bool showAddAllToQueue;
private int selectedOverwriteBehaviour;
+ private int selectedCollisionBehaviour;
+
+ private string prePostFilenameText;
+
+ private bool showPrePostFilenameBox;
#endregion
@@ -661,6 +666,49 @@ namespace HandBrakeWPF.ViewModels
}
}
+ public BindingList<AutonameFileCollisionBehaviour> AutonameFileCollisionBehaviours { get; set; }
+
+ public int SelectedCollisionBehaviour
+ {
+ get => this.selectedCollisionBehaviour;
+ set
+ {
+ if (value == this.selectedCollisionBehaviour) return;
+ this.selectedCollisionBehaviour = value;
+
+ this.ShowPrePostFilenameBox = this.selectedCollisionBehaviour >= 1;
+
+ this.NotifyOfPropertyChange(() => this.SelectedCollisionBehaviour);
+ }
+ }
+
+ public string PrePostFilenameText
+ {
+ get => this.prePostFilenameText;
+ set
+ {
+ if (value == this.prePostFilenameText) return;
+
+ if (this.IsValidAutonameFormat(value, false))
+ {
+ this.prePostFilenameText = value;
+ }
+
+ this.NotifyOfPropertyChange(() => this.PrePostFilenameText);
+ }
+ }
+
+ public bool ShowPrePostFilenameBox
+ {
+ get => this.showPrePostFilenameBox;
+ set
+ {
+ if (value == this.showPrePostFilenameBox) return;
+ this.showPrePostFilenameBox = value;
+ this.NotifyOfPropertyChange(() => this.ShowPrePostFilenameBox);
+ }
+ }
+
#endregion
#region Preview
@@ -1445,9 +1493,13 @@ namespace HandBrakeWPF.ViewModels
this.FileOverwriteBehaviourList = new BindingList<FileOverwriteBehaviour>();
this.FileOverwriteBehaviourList.Add(FileOverwriteBehaviour.Ask);
this.FileOverwriteBehaviourList.Add(FileOverwriteBehaviour.ForceOverwrite);
- // this.FileOverwriteBehaviourList.Add(FileOverwriteBehaviour.Autoname);
this.SelectedOverwriteBehaviour = this.userSettingService.GetUserSetting<int>(UserSettingConstants.FileOverwriteBehaviour, typeof(int));
+ // Collision behaviour
+ this.AutonameFileCollisionBehaviours = new BindingList<AutonameFileCollisionBehaviour>() { AutonameFileCollisionBehaviour.AppendNumber, AutonameFileCollisionBehaviour.Prefix, AutonameFileCollisionBehaviour.Postfix };
+ this.SelectedCollisionBehaviour = this.userSettingService.GetUserSetting<int>(UserSettingConstants.AutonameFileCollisionBehaviour, typeof(int));
+ this.PrePostFilenameText = this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutonameFilePrePostString);
+
// #############################
// Picture Tab
// #############################
@@ -1598,6 +1650,8 @@ namespace HandBrakeWPF.ViewModels
this.userSettingService.SetUserSetting(UserSettingConstants.AutoNameTitleCase, this.ChangeToTitleCase);
this.userSettingService.SetUserSetting(UserSettingConstants.RemovePunctuation, this.RemovePunctuation);
this.userSettingService.SetUserSetting(UserSettingConstants.FileOverwriteBehaviour, this.SelectedOverwriteBehaviour);
+ this.userSettingService.SetUserSetting(UserSettingConstants.AutonameFileCollisionBehaviour, this.SelectedCollisionBehaviour);
+ this.userSettingService.SetUserSetting(UserSettingConstants.AutonameFilePrePostString, this.PrePostFilenameText);
/* Previews */
this.userSettingService.SetUserSetting(UserSettingConstants.VLCPath, this.VLCPath);
@@ -1712,6 +1766,11 @@ namespace HandBrakeWPF.ViewModels
/// <returns>True if valid</returns>
private bool IsValidAutonameFormat(string input, bool isSilent)
{
+ if (string.IsNullOrEmpty(input))
+ {
+ return true;
+ }
+
char[] invalidchars = Path.GetInvalidFileNameChars();
Array.Sort(invalidchars);
foreach (var characterToTest in input)