From 966b707165e89201e125815159a9a28374574c4c Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Sun, 19 Dec 2021 00:51:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=BE=E7=BD=AE=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=91=BD=E5=90=8D=E6=A0=BC=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi.Core/Settings/SettingsManager.Video.cs | 2 +- .../ViewModels/Settings/ViewVideoViewModel.cs | 16 ++++++++++++++++ DownKyi/Views/Settings/ViewVideo.xaml | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) 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}">