根据 https://github.com/doudou0720/ICC-CE/pull/21 中的建议修改代码
This commit is contained in:
@@ -105,6 +105,15 @@ namespace Ink_Canvas
|
||||
HideSubPanels("cursor");
|
||||
SidePannelMarginAnimation(-10);
|
||||
});
|
||||
|
||||
// 新增:如果开启了彻底隐藏,则隐藏主窗口
|
||||
if (Settings.Automation.ThoroughlyHideWhenFolded)
|
||||
{
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
this.Visibility = Visibility.Hidden;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async void LeftUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
@@ -230,6 +239,15 @@ namespace Ink_Canvas
|
||||
|
||||
public async Task UnFoldFloatingBar(object sender)
|
||||
{
|
||||
// 新增:如果之前彻底隐藏了,先恢复显示
|
||||
if (this.Visibility != Visibility.Visible)
|
||||
{
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
this.Visibility = Visibility.Visible;
|
||||
});
|
||||
}
|
||||
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
|
||||
|
||||
@@ -2856,24 +2856,55 @@ namespace Ink_Canvas
|
||||
private void ToggleSwitchIsEnableUriScheme_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Advanced.IsEnableUriScheme = ToggleSwitchIsEnableUriScheme.IsOn;
|
||||
|
||||
if (Settings.Advanced.IsEnableUriScheme)
|
||||
bool newState = ToggleSwitchIsEnableUriScheme.IsOn;
|
||||
bool success = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (!UriSchemeHelper.IsUriSchemeRegistered())
|
||||
if (newState)
|
||||
{
|
||||
UriSchemeHelper.RegisterUriScheme();
|
||||
if (!UriSchemeHelper.IsUriSchemeRegistered())
|
||||
{
|
||||
success = UriSchemeHelper.RegisterUriScheme();
|
||||
}
|
||||
else
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UriSchemeHelper.IsUriSchemeRegistered())
|
||||
{
|
||||
success = UriSchemeHelper.UnregisterUriScheme();
|
||||
}
|
||||
else
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"切换URI Scheme状态失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
Settings.Advanced.IsEnableUriScheme = newState;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UriSchemeHelper.IsUriSchemeRegistered())
|
||||
{
|
||||
UriSchemeHelper.UnregisterUriScheme();
|
||||
}
|
||||
}
|
||||
// 回滚 UI 状态
|
||||
isLoaded = false;
|
||||
ToggleSwitchIsEnableUriScheme.IsOn = !newState;
|
||||
isLoaded = true;
|
||||
|
||||
SaveSettingsToFile();
|
||||
ShowNotification("设置外部协议失败,请检查权限或日志");
|
||||
}
|
||||
}
|
||||
|
||||
private void TouchMultiplierSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
|
||||
@@ -12,18 +12,32 @@ namespace Ink_Canvas
|
||||
{
|
||||
if (string.IsNullOrEmpty(uri)) return;
|
||||
|
||||
// 检查是否启用了外部协议
|
||||
if (!Settings.Advanced.IsEnableUriScheme)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"URI协议已禁用,忽略请求: {uri}", LogHelper.LogType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"正在处理URI命令: {uri}", LogHelper.LogType.Event);
|
||||
|
||||
// 解析URI
|
||||
// 格式: icc://command?param=value
|
||||
// 如果URI以icc:开头但不是标准URI格式,尝试手动解析
|
||||
string command = "";
|
||||
|
||||
|
||||
if (Uri.TryCreate(uri, UriKind.Absolute, out Uri uriObj))
|
||||
{
|
||||
command = uriObj.Host.ToLower();
|
||||
// 处理像 icc:fold 这样 Host 可能为空的情况
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
command = uriObj.AbsolutePath.Trim('/').ToLower();
|
||||
}
|
||||
}
|
||||
else if (uri.StartsWith("icc:", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
// 如果解析失败且是 icc: 协议,则手动处理
|
||||
if (string.IsNullOrEmpty(command) && uri.StartsWith("icc:", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// 简单的手动解析: icc:fold
|
||||
string path = uri.Substring(4);
|
||||
@@ -63,6 +77,52 @@ namespace Ink_Canvas
|
||||
}
|
||||
break;
|
||||
|
||||
case "thoroughhideon":
|
||||
Settings.Automation.ThoroughlyHideWhenFolded = true;
|
||||
SaveSettingsToFile();
|
||||
ShowNotification("已开启:收起时彻底隐藏");
|
||||
// 如果当前已经是在收纳模式,立即隐藏
|
||||
if (isFloatingBarFolded)
|
||||
{
|
||||
this.Visibility = Visibility.Hidden;
|
||||
}
|
||||
break;
|
||||
|
||||
case "thoroughhideoff":
|
||||
Settings.Automation.ThoroughlyHideWhenFolded = false;
|
||||
SaveSettingsToFile();
|
||||
ShowNotification("已关闭:收起时彻底隐藏");
|
||||
// 确保窗口可见
|
||||
this.Visibility = Visibility.Visible;
|
||||
break;
|
||||
|
||||
case "thoroughhidetoggle":
|
||||
Settings.Automation.ThoroughlyHideWhenFolded = !Settings.Automation.ThoroughlyHideWhenFolded;
|
||||
SaveSettingsToFile();
|
||||
ShowNotification(Settings.Automation.ThoroughlyHideWhenFolded ? "已开启:收起时彻底隐藏" : "已关闭:收起时彻底隐藏");
|
||||
if (isFloatingBarFolded)
|
||||
{
|
||||
this.Visibility = Settings.Automation.ThoroughlyHideWhenFolded ? Visibility.Hidden : Visibility.Visible;
|
||||
}
|
||||
break;
|
||||
|
||||
case "randone":
|
||||
SymbolIconRandOne_MouseUp(null, null);
|
||||
break;
|
||||
|
||||
case "rand":
|
||||
SymbolIconRand_MouseUp(null, null);
|
||||
break;
|
||||
|
||||
case "timer":
|
||||
ImageCountdownTimer_MouseUp(null, null);
|
||||
break;
|
||||
|
||||
case "whiteboard":
|
||||
case "board":
|
||||
ImageBlackboard_MouseUp(null, null);
|
||||
break;
|
||||
|
||||
default:
|
||||
LogHelper.WriteLogToFile($"未知的URI命令: {command}", LogHelper.LogType.Warning);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user