diff --git a/DownKyi.Core/Settings/SettingsManager.Video.cs b/DownKyi.Core/Settings/SettingsManager.Video.cs index 4c307a0..aa50f59 100644 --- a/DownKyi.Core/Settings/SettingsManager.Video.cs +++ b/DownKyi.Core/Settings/SettingsManager.Video.cs @@ -240,7 +240,7 @@ namespace DownKyi.Core.Settings public List GetFileNameParts() { appSettings = GetSettings(); - if (appSettings.Video.FileNameParts == null) + if (appSettings.Video.FileNameParts == null || appSettings.Video.FileNameParts.Count == 0) { // 第一次获取,先设置默认值 SetFileNameParts(fileNameParts); diff --git a/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs b/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs index 9dbb9e9..5f47ece 100644 --- a/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs @@ -85,6 +85,13 @@ namespace DownKyi.ViewModels.Settings set => SetProperty(ref optionalFields, value); } + private int selectedOptionalField; + public int SelectedOptionalField + { + get => selectedOptionalField; + set => SetProperty(ref selectedOptionalField, value); + } + #endregion @@ -112,6 +119,8 @@ namespace DownKyi.ViewModels.Settings OptionalFields.Add(new DisplayFileNamePart { Id = item, Title = display }); } + SelectedOptionalField = -1; + #endregion } @@ -279,6 +288,11 @@ namespace DownKyi.ViewModels.Settings /// private void ExecuteOptionalFieldsCommand(object parameter) { + if (SelectedOptionalField == -1) + { + return; + } + SelectedFileName.Add((DisplayFileNamePart)parameter); List fileName = new List(); @@ -289,6 +303,8 @@ namespace DownKyi.ViewModels.Settings bool isSucceed = SettingsManager.GetInstance().SetFileNameParts(fileName); PublishTip(isSucceed); + + SelectedOptionalField = -1; } diff --git a/DownKyi/Views/Settings/ViewVideo.xaml b/DownKyi/Views/Settings/ViewVideo.xaml index 49d2a53..eba06b7 100644 --- a/DownKyi/Views/Settings/ViewVideo.xaml +++ b/DownKyi/Views/Settings/ViewVideo.xaml @@ -160,6 +160,7 @@ x:Name="nameSelectedFileName" Grid.Row="0" Grid.Column="1" + MinHeight="30" Margin="0,0,0,20" ItemContainerStyle="{StaticResource TagItem2Style}" ItemsSource="{Binding SelectedFileName, Mode=TwoWay}" @@ -184,6 +185,7 @@ Grid.Column="1" ItemContainerStyle="{StaticResource TagItem2Style}" ItemsSource="{Binding OptionalFields, Mode=TwoWay}" + SelectedIndex="{Binding SelectedOptionalField}" SelectionMode="Single" Style="{StaticResource Tag2Style}">