add:配置切换
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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}」");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user