656863a7d0
* feat(docstring):添加docstring Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> * fix(docstring):修复部分docstring格式错误 Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> * fix(docstring):修复部分docstring Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> * chore(Docstring):MW_* 前14 * chore(Docstring):MW_* part 2 * chore(Docstring):MW_* part 3 * chore:优化缩进 * fix: 修复数学计算中的潜在除零错误和数值稳定性问题 Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> * chore:删除Rebase时多余的OOBE函数 * chore: 更新代码注释和文档格式 修复XML文档注释中的格式问题,统一使用<c>和<see>标签 更新ConfigHelper类的预留说明,明确未来扩展用途 优化TimerDisplayDate_Elapsed方法的注释,说明UI异步更新机制 合并重复的注释摘要行,提高文档可读性 添加形状识别功能的64位进程限制说明 修正视频呈现器设备选择逻辑的文档说明 * chore(IPPTLinkManager): 更新TryEndSlideShow方法的XML注释格式 * chore: 修正代码注释中的术语和格式问题 更新多个文件中的XML注释,统一使用<see langword="..."/>标记代替<c>...</c>标记 规范术语使用(如"延迟初始化"代替"懒惰初始化") 修正注释中的格式错误和补充说明 调整代码区域的注释对齐格式 --------- Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com>
360 lines
14 KiB
C#
360 lines
14 KiB
C#
using Ink_Canvas.Helpers;
|
|
using iNKORE.UI.WPF.Modern.Controls;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
|
|
namespace Ink_Canvas
|
|
{
|
|
public partial class MainWindow : Window
|
|
{
|
|
#region 悬浮窗拦截功能
|
|
|
|
/// <summary>
|
|
/// 初始化悬浮窗拦截管理器
|
|
/// </summary>
|
|
private void InitializeFloatingWindowInterceptor()
|
|
{
|
|
try
|
|
{
|
|
_floatingWindowInterceptorManager = new FloatingWindowInterceptorManager();
|
|
|
|
// 订阅事件
|
|
_floatingWindowInterceptorManager.WindowIntercepted += OnFloatingWindowIntercepted;
|
|
_floatingWindowInterceptorManager.WindowRestored += OnFloatingWindowRestored;
|
|
|
|
// 初始化拦截器
|
|
_floatingWindowInterceptorManager.Initialize(Settings.Automation.FloatingWindowInterceptor);
|
|
|
|
// 加载UI状态
|
|
LoadFloatingWindowInterceptorUI();
|
|
|
|
LogHelper.WriteLogToFile("悬浮窗拦截管理器初始化完成", LogHelper.LogType.Event);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogToFile($"初始化悬浮窗拦截管理器失败: {ex.Message}", LogHelper.LogType.Error);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载悬浮窗拦截UI状态
|
|
/// </summary>
|
|
private void LoadFloatingWindowInterceptorUI()
|
|
{
|
|
try
|
|
{
|
|
if (!isLoaded) return;
|
|
|
|
// 设置主开关状态
|
|
ToggleSwitchFloatingWindowInterceptorEnabled.IsOn = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
|
|
|
|
// 设置各个拦截规则的状态
|
|
foreach (var kvp in Settings.Automation.FloatingWindowInterceptor.InterceptRules)
|
|
{
|
|
var toggleName = $"ToggleSwitch{kvp.Key}";
|
|
var toggle = FindName(toggleName) as ToggleSwitch;
|
|
if (toggle != null)
|
|
{
|
|
toggle.IsOn = kvp.Value;
|
|
}
|
|
}
|
|
|
|
// 更新UI可见性
|
|
UpdateFloatingWindowInterceptorUI();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogToFile($"加载悬浮窗拦截UI状态失败: {ex.Message}", LogHelper.LogType.Error);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新悬浮窗拦截UI
|
|
/// </summary>
|
|
private void UpdateFloatingWindowInterceptorUI()
|
|
{
|
|
try
|
|
{
|
|
var isEnabled = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
|
|
FloatingWindowInterceptorGrid.Visibility = isEnabled ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
// 计算启用的规则数量
|
|
var enabledRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Where(kvp => kvp.Value).Count();
|
|
var totalRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Count;
|
|
|
|
// 更新状态文本
|
|
if (_floatingWindowInterceptorManager != null)
|
|
{
|
|
var stats = _floatingWindowInterceptorManager.GetStatistics();
|
|
TextBlockFloatingWindowInterceptorStatus.Text = stats.IsRunning
|
|
? $"拦截器运行中 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则"
|
|
: $"拦截器未启动 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则";
|
|
}
|
|
else
|
|
{
|
|
TextBlockFloatingWindowInterceptorStatus.Text = $"拦截器未初始化 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogToFile($"更新悬浮窗拦截UI失败: {ex.Message}", LogHelper.LogType.Error);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗口被拦截事件处理
|
|
/// </summary>
|
|
private void OnFloatingWindowIntercepted(object sender, FloatingWindowInterceptor.WindowInterceptedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// 在UI线程中更新状态
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
{
|
|
UpdateFloatingWindowInterceptorUI();
|
|
}));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogToFile($"处理窗口拦截事件失败: {ex.Message}", LogHelper.LogType.Error);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗口被恢复事件处理
|
|
/// </summary>
|
|
private void OnFloatingWindowRestored(object sender, FloatingWindowInterceptor.WindowRestoredEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// 在UI线程中更新状态
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
{
|
|
UpdateFloatingWindowInterceptorUI();
|
|
}));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogToFile($"处理窗口恢复事件失败: {ex.Message}", LogHelper.LogType.Error);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 悬浮窗拦截事件处理
|
|
|
|
/// <summary>
|
|
/// 主开关切换事件
|
|
/// </summary>
|
|
private void ToggleSwitchFloatingWindowInterceptorEnabled_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
|
|
try
|
|
{
|
|
Settings.Automation.FloatingWindowInterceptor.IsEnabled = ToggleSwitchFloatingWindowInterceptorEnabled.IsOn;
|
|
|
|
if (_floatingWindowInterceptorManager != null)
|
|
{
|
|
if (Settings.Automation.FloatingWindowInterceptor.IsEnabled)
|
|
{
|
|
_floatingWindowInterceptorManager.Start();
|
|
}
|
|
else
|
|
{
|
|
_floatingWindowInterceptorManager.Stop();
|
|
}
|
|
}
|
|
|
|
UpdateFloatingWindowInterceptorUI();
|
|
SaveSettingsToFile();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogToFile($"切换悬浮窗拦截主开关失败: {ex.Message}", LogHelper.LogType.Error);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 希沃白板3拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchSeewoWhiteboard3Floating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.SeewoWhiteboard3Floating, ToggleSwitchSeewoWhiteboard3Floating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 希沃白板5拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchSeewoWhiteboard5Floating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.SeewoWhiteboard5Floating, ToggleSwitchSeewoWhiteboard5Floating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 希沃白板5C拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchSeewoWhiteboard5CFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.SeewoWhiteboard5CFloating, ToggleSwitchSeewoWhiteboard5CFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 希沃品课侧栏拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchSeewoPincoSideBarFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.SeewoPincoSideBarFloating, ToggleSwitchSeewoPincoSideBarFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 希沃品课画笔拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchSeewoPincoDrawingFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.SeewoPincoDrawingFloating, ToggleSwitchSeewoPincoDrawingFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 希沃PPT小工具拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchSeewoPPTFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.SeewoPPTFloating, ToggleSwitchSeewoPPTFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// AiClass拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchAiClassFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.AiClassFloating, ToggleSwitchAiClassFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 鸿合屏幕书写拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchHiteAnnotationFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.HiteAnnotationFloating, ToggleSwitchHiteAnnotationFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 畅言智慧课堂拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchChangYanFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.ChangYanFloating, ToggleSwitchChangYanFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 畅言PPT拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchChangYanPptFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.ChangYanPptFloating, ToggleSwitchChangYanPptFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 天喻教育云拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchIntelligentClassFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.IntelligentClassFloating, ToggleSwitchIntelligentClassFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 希沃桌面画笔拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchSeewoDesktopAnnotationFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.SeewoDesktopAnnotationFloating, ToggleSwitchSeewoDesktopAnnotationFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 希沃桌面侧栏拦截开关
|
|
/// </summary>
|
|
private void ToggleSwitchSeewoDesktopSideBarFloating_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!isLoaded) return;
|
|
SetInterceptRule(FloatingWindowInterceptor.InterceptType.SeewoDesktopSideBarFloating, ToggleSwitchSeewoDesktopSideBarFloating.IsOn);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置拦截规则
|
|
/// </summary>
|
|
/// <param name="type">拦截类型</param>
|
|
/// <param name="enabled">是否启用拦截</param>
|
|
private void SetInterceptRule(FloatingWindowInterceptor.InterceptType type, bool enabled)
|
|
{
|
|
try
|
|
{
|
|
if (_floatingWindowInterceptorManager != null)
|
|
{
|
|
_floatingWindowInterceptorManager.SetInterceptRule(type, enabled);
|
|
}
|
|
|
|
// 更新设置
|
|
var ruleName = type.ToString();
|
|
if (Settings.Automation.FloatingWindowInterceptor.InterceptRules.ContainsKey(ruleName))
|
|
{
|
|
Settings.Automation.FloatingWindowInterceptor.InterceptRules[ruleName] = enabled;
|
|
}
|
|
|
|
// 获取规则信息以处理父子关系
|
|
var rule = _floatingWindowInterceptorManager?.GetInterceptRule(type);
|
|
if (rule != null)
|
|
{
|
|
// 如果是父规则,更新所有子规则的设置
|
|
if (rule.ChildTypes.Count > 0)
|
|
{
|
|
foreach (var childType in rule.ChildTypes)
|
|
{
|
|
var childRuleName = childType.ToString();
|
|
if (Settings.Automation.FloatingWindowInterceptor.InterceptRules.ContainsKey(childRuleName))
|
|
{
|
|
Settings.Automation.FloatingWindowInterceptor.InterceptRules[childRuleName] = enabled;
|
|
}
|
|
}
|
|
}
|
|
// 如果是子规则,更新父规则的设置
|
|
else if (rule.ParentType.HasValue)
|
|
{
|
|
var parentRule = _floatingWindowInterceptorManager?.GetInterceptRule(rule.ParentType.Value);
|
|
if (parentRule != null)
|
|
{
|
|
var parentRuleName = rule.ParentType.Value.ToString();
|
|
if (Settings.Automation.FloatingWindowInterceptor.InterceptRules.ContainsKey(parentRuleName))
|
|
{
|
|
Settings.Automation.FloatingWindowInterceptor.InterceptRules[parentRuleName] = parentRule.IsEnabled;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 更新UI显示
|
|
UpdateFloatingWindowInterceptorUI();
|
|
|
|
SaveSettingsToFile();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogToFile($"设置拦截规则失败: {ex.Message}", LogHelper.LogType.Error);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |