add:配置切换

This commit is contained in:
2026-02-23 12:31:53 +08:00
parent 559822686c
commit 06e12e2899
2 changed files with 22 additions and 7 deletions
+2 -2
View File
@@ -2887,9 +2887,9 @@
SelectionChanged="ComboBoxConfigProfile_SelectionChanged" /> SelectionChanged="ComboBoxConfigProfile_SelectionChanged" />
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left"> <ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Button x:Name="BtnDeleteConfigProfile" Content="删除方案" Click="BtnDeleteConfigProfile_Click" <Button x:Name="BtnDeleteConfigProfile" Content="删除配置文件" Click="BtnDeleteConfigProfile_Click"
Padding="10,6" Margin="0,0,8,0" /> Padding="10,6" Margin="0,0,8,0" />
<Button x:Name="BtnSaveAsConfigProfile" Content="另存为方案" Click="BtnSaveAsConfigProfile_Click" <Button x:Name="BtnSaveAsConfigProfile" Content="另存为配置文件" Click="BtnSaveAsConfigProfile_Click"
Padding="10,6" /> Padding="10,6" />
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
+20 -5
View File
@@ -4290,6 +4290,7 @@ namespace Ink_Canvas
} }
private bool _isRefreshingConfigProfileList; private bool _isRefreshingConfigProfileList;
private string _lastAppliedProfileName;
private void RefreshConfigProfileList() private void RefreshConfigProfileList()
{ {
@@ -4300,12 +4301,23 @@ namespace Ink_Canvas
try try
{ {
var names = ConfigProfileManager.ListProfileNames(); var names = ConfigProfileManager.ListProfileNames();
var selected = ComboBoxConfigProfile.SelectedItem as string;
ComboBoxConfigProfile.ItemsSource = names; ComboBoxConfigProfile.ItemsSource = names;
if (selected != null && names.Contains(selected)) if (names.Count == 0)
ComboBoxConfigProfile.SelectedItem = selected; {
else if (names.Count > 0 && ComboBoxConfigProfile.SelectedIndex < 0) ComboBoxConfigProfile.SelectedItem = null;
ComboBoxConfigProfile.SelectedIndex = 0; }
else if (_lastAppliedProfileName != null && names.Contains(_lastAppliedProfileName))
{
ComboBoxConfigProfile.SelectedItem = _lastAppliedProfileName;
}
else
{
var selected = ComboBoxConfigProfile.SelectedItem as string;
if (selected != null && names.Contains(selected))
ComboBoxConfigProfile.SelectedItem = selected;
else
ComboBoxConfigProfile.SelectedIndex = 0;
}
if (BtnDeleteConfigProfile != null) if (BtnDeleteConfigProfile != null)
BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile.SelectedItem != null; BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile.SelectedItem != null;
} }
@@ -4331,6 +4343,7 @@ namespace Ink_Canvas
{ {
if (ConfigProfileManager.ApplyProfile(name)) if (ConfigProfileManager.ApplyProfile(name))
{ {
_lastAppliedProfileName = name;
ReloadSettingsFromFile(); ReloadSettingsFromFile();
ShowNotification($"已切换至方案「{name}」"); ShowNotification($"已切换至方案「{name}」");
} }
@@ -4379,6 +4392,7 @@ namespace Ink_Canvas
var json = JsonConvert.SerializeObject(Settings, Formatting.Indented); var json = JsonConvert.SerializeObject(Settings, Formatting.Indented);
if (ConfigProfileManager.SaveAsProfile(name, json)) if (ConfigProfileManager.SaveAsProfile(name, json))
{ {
_lastAppliedProfileName = name;
RefreshConfigProfileList(); RefreshConfigProfileList();
ShowNotification($"已另存为方案:{name}"); ShowNotification($"已另存为方案:{name}");
} }
@@ -4411,6 +4425,7 @@ namespace Ink_Canvas
var nextName = ComboBoxConfigProfile?.SelectedItem as string; var nextName = ComboBoxConfigProfile?.SelectedItem as string;
if (!string.IsNullOrEmpty(nextName) && ConfigProfileManager.ApplyProfile(nextName)) if (!string.IsNullOrEmpty(nextName) && ConfigProfileManager.ApplyProfile(nextName))
{ {
_lastAppliedProfileName = nextName;
ReloadSettingsFromFile(); ReloadSettingsFromFile();
ShowNotification($"已删除方案「{name}」,已切换至「{nextName}」"); ShowNotification($"已删除方案「{name}」,已切换至「{nextName}」");
} }