<value>Disable LibDVDNav. (libdvdread will be used instead)</value>\r
</data>\r
<data name="Options_Format" xml:space="preserve">\r
- <value>Format:</value>\r
+ <value>File Format:</value>\r
</data>\r
<data name="Options_General" xml:space="preserve">\r
<value>General</value>\r
<data name="SubtitleView_SubtitleDefaultsDescription" xml:space="preserve">\r
<value>Configure how the Subtitle Tracks are automatically selected and configured when you select a new title or source video.</value>\r
</data>\r
+ <data name="OptionsView_InvalidFileFormatChars" xml:space="preserve">\r
+ <value>The file format entered contained invalid characters. These have been removed. </value>\r
+ </data>\r
</root>
\ No newline at end of file
using System.Globalization;\r
using System.IO;\r
using System.Linq;\r
+ using System.Text;\r
using System.Windows;\r
\r
using Caliburn.Micro;\r
\r
private readonly IUserSettingService userSettingService;\r
private readonly IUpdateService updateService;\r
+ private readonly IErrorService errorService;\r
+\r
private string arguments;\r
private string autoNameDefaultPath;\r
private bool automaticallyNameFiles;\r
/// <param name="aboutViewModel">\r
/// The about View Model.\r
/// </param>\r
- public OptionsViewModel(IUserSettingService userSettingService, IUpdateService updateService, IAboutViewModel aboutViewModel)\r
+ public OptionsViewModel(IUserSettingService userSettingService, IUpdateService updateService, IAboutViewModel aboutViewModel, IErrorService errorService)\r
{\r
this.Title = "Options";\r
this.userSettingService = userSettingService;\r
this.updateService = updateService;\r
+ this.errorService = errorService;\r
this.AboutViewModel = aboutViewModel;\r
this.OnLoad();\r
\r
\r
set\r
{\r
- this.autonameFormat = value;\r
+ if (this.IsValidAutonameFormat(value, false))\r
+ {\r
+ this.autonameFormat = value; \r
+ } \r
+\r
this.NotifyOfPropertyChange("AutonameFormat");\r
}\r
}\r
this.AutoNameDefaultPath = "Click 'Browse' to set the default location";\r
\r
// Store auto name format\r
- this.AutonameFormat = this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) ?? string.Empty;\r
+ string anf = this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) ?? string.Empty;\r
+ this.AutonameFormat = this.IsValidAutonameFormat(anf, true) ? anf : "{source}-{title}";\r
\r
// Use iPod/iTunes friendly .m4v extension for MP4 files.\r
this.mp4ExtensionOptions.Clear();\r
{\r
this.SelectedTab = tab;\r
}\r
+\r
+ /// <summary>\r
+ /// Validate the Autoname Fileformat string\r
+ /// </summary>\r
+ /// <param name="input">The format string</param>\r
+ /// <param name="isSilent">Don't show an error dialog if true.</param>\r
+ /// <returns>True if valid</returns>\r
+ private bool IsValidAutonameFormat(string input, bool isSilent)\r
+ {\r
+ foreach (var characterToTest in input)\r
+ {\r
+ // we binary search for the character in the invalid set. This should be lightning fast.\r
+ if (Array.BinarySearch(Path.GetInvalidFileNameChars(), characterToTest) >= 0)\r
+ {\r
+ if (!isSilent)\r
+ {\r
+ this.errorService.ShowMessageBox(\r
+ ResourcesUI.OptionsView_InvalidFileFormatChars,\r
+ Resources.Error,\r
+ MessageBoxButton.OK,\r
+ MessageBoxImage.Error);\r
+ }\r
+ return false;\r
+ }\r
+ }\r
+\r
+ return true;\r
+ }\r
}\r
}
\ No newline at end of file
cal:Message.Attach="[Event Click] = [Action BrowseAutoNamePath]" />\r
\r
<TextBlock VerticalAlignment="Center" Text="{x:Static Properties:ResourcesUI.Options_Format}" Grid.Column="0" Grid.Row="1" Margin="0,5,0,0" />\r
- <TextBox Name="autoNameFormat" Text="{Binding AutonameFormat}" Width="380" Grid.Column="1" Grid.Row="1" Margin="0,5,0,0"\r
+ <TextBox Name="autoNameFormat" Text="{Binding AutonameFormat, UpdateSourceTrigger=PropertyChanged}" Width="380" Grid.Column="1" Grid.Row="1" Margin="0,5,0,0"\r
ToolTip="{x:Static Properties:Resources.Options_AdditionalFormatOptions}" Style="{StaticResource LongToolTipHolder}" />\r
</Grid>\r
\r