Compare commits

..

554 Commits

Author SHA1 Message Date
CJKmkp aa7b593b65 更新版本号 2025-12-28 15:11:55 +08:00
CJKmkp fabac7e2bb improve:点名UI
优化显示范围
2025-12-28 14:32:22 +08:00
CJKmkp 9b5ee56a09 improve:issue #175 2025-12-28 14:30:02 +08:00
CJKmkp c78d3d74c2 improve:更新提示 2025-12-28 13:59:25 +08:00
CJKmkp b1459901d0 fix:issue #329 2025-12-28 12:35:05 +08:00
CJKmkp aba56ac340 improve:直线拉直 2025-12-28 11:00:24 +08:00
CJKmkp 3d4e1872f1 add:新设置
增加搜索功能
2025-12-28 10:40:13 +08:00
doudou0720 7a4d33b7da fix(Workflow):删除obj缓存 (#336)
Removed caching of obj/ folders to prevent cross-version incremental build issues while retaining NuGet package caching.
2025-12-28 10:22:18 +08:00
CJKmkp afb65eb908 fix:触摸墨迹选中问题 2025-12-28 10:01:02 +08:00
CJKmkp df5daeeb75 add:新设置 2025-12-28 08:48:09 +08:00
CJKmkp 792779e5b2 Revert "fix:触摸墨迹选中"
This reverts commit 8172b7c776.
2025-12-28 08:37:05 +08:00
CJKmkp 3313a0a182 add:xml格式墨迹保存 2025-12-28 00:08:08 +08:00
CJKmkp 88dd53302f improve:PPT时间胶囊 2025-12-27 23:00:50 +08:00
CJKmkp e972adfbcb fix:issue #332 2025-12-27 22:57:22 +08:00
CJKmkp ab6425e0d9 fix:浮动栏收纳 2025-12-27 22:53:34 +08:00
CJKmkp a81ee5b3db add:PPT时间胶囊(没做完不好看) 2025-12-27 22:41:24 +08:00
CJKmkp fae08a5285 Revert "improve:issue #332"
This reverts commit ca4d2ac4a2.
2025-12-27 21:16:55 +08:00
CJKmkp eeb4a25d7a fix:issue #327 2025-12-27 19:46:08 +08:00
CJK_mkp fdf07180dd Merge branches 'beta' and 'beta' of https://github.com/InkCanvasForClass/community into beta 2025-12-27 18:40:55 +08:00
CJK_mkp 6387a6fcda fix:issue #334 2025-12-27 18:27:30 +08:00
CJK_mkp a6e400629a improve:墨迹纠正
纠正后补点
2025-12-27 18:22:00 +08:00
CJK_mkp 8172b7c776 fix:触摸墨迹选中 2025-12-27 18:13:54 +08:00
CJK_mkp ca4d2ac4a2 improve:issue #332 2025-12-27 17:58:53 +08:00
allcontributors[bot] abd9f850eb docs: add CJKmkp as a contributor for design (#333)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2025-12-27 17:31:08 +08:00
CJK_mkp 3aef6f5e05 fix:issue #327 2025-12-27 16:55:59 +08:00
CJK_mkp 2f957374e3 fix:issue #330 2025-12-27 16:51:46 +08:00
CJK_mkp 3f8cabc7e0 improve:PPT放映时的浮动栏定位 2025-12-27 16:41:30 +08:00
CJK_mkp 73d1dc8f48 improve:注释 2025-12-27 16:31:50 +08:00
CJK_mkp 2bfb78a257 撤销commitc99bd2b 2025-12-27 16:29:47 +08:00
PrefacedCorg 783e5c43a5 代码清理 2025-12-27 12:05:34 +08:00
PrefacedCorg d7e8330016 优化代码可读性
其实单纯就是强迫症
2025-12-27 10:51:42 +08:00
CJK_mkp 80d3836e9e fix:墨迹质量问题 2025-12-21 17:31:06 +08:00
CJK_mkp c26d1c348e fix:墨迹质量问题 2025-12-21 17:30:29 +08:00
PrefacedCorg 95c307cc0b 修改任务栏高度计算方式
应该可以解决 dock 栏偏移的问题 可能会炸 炸了再说
2025-12-21 16:32:23 +08:00
allcontributors[bot] 6e7299e445 docs: add doudou0720 as a contributor for code (#328)
* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2025-12-21 00:44:06 +08:00
CJKmkp 01fa047591 improve:pre-release
优化注释
2025-12-21 00:38:27 +08:00
CJKmkp 8c741c1fb7 improve:pre-release 2025-12-21 00:36:17 +08:00
CJK_mkp b0bfc8d5ed Update prerelease.yml 2025-12-21 00:00:52 +08:00
doudou0720 ad8d8f94ff Merge pull request #320 from doudou0720/beta-image
!refactor(CI/CD):构建工作流重构
2025-12-20 23:46:37 +08:00
PrefacedCorg c99bd2bb63 Update MainWindow.xaml 2025-12-20 23:00:04 +08:00
CJKmkp 468df7dad7 add:PPT按钮透明度设置 2025-12-20 22:56:13 +08:00
CJKmkp 3c2e4a0990 delete:新设置内选项 2025-12-20 21:26:03 +08:00
CJKmkp 87b717f6a9 improve:倒计时音效 2025-12-20 21:04:48 +08:00
PrefacedCorg 51dc45988e Revert "撤回commit8042b91"
This reverts commit 81621cb9d0.
2025-12-20 20:46:18 +08:00
CJKmkp 2f8b986f1f 更新版本号 2025-12-20 20:23:38 +08:00
CJKmkp 7f01e7acb6 improve:点名算法
改进不放回随机
2025-12-20 19:57:11 +08:00
CJKmkp d011d2ba8a improve:多指书写
优化性能
2025-12-20 19:55:37 +08:00
CJKmkp a922654c17 improve:多指书写 2025-12-20 19:36:16 +08:00
CJKmkp e70a486362 add:一言API
新增名言种类
2025-12-20 19:28:47 +08:00
CJKmkp 1683bc8418 improve:自动更新
优化线路自动测速
2025-12-20 19:18:58 +08:00
CJKmkp b6368fb0e4 add:有更新时系统级弹窗 2025-12-20 19:16:39 +08:00
CJKmkp ddfa9c2676 improve:PPT翻页打断
改进打断逻辑
2025-12-20 18:42:25 +08:00
CJKmkp f3ddd5a11a improve:PPT翻页打断
新增设置项
2025-12-20 18:37:57 +08:00
CJKmkp 39e8b2359e improve:PPT自动播放及记忆上次播放页码
改进弹窗出现时机
2025-12-20 18:25:07 +08:00
CJKmkp 4fb73c155b improve:PPT翻页打断 2025-12-20 18:11:27 +08:00
CJKmkp 3287603d0a fix:快捷键问题 2025-12-20 18:04:08 +08:00
CJKmkp 1abb317054 add;自动清理过期配置
避免老版本配置保留
2025-12-20 17:52:56 +08:00
CJKmkp 719e37c26b improve:清空点名名单
改进清空历史记录
2025-12-20 17:50:00 +08:00
CJKmkp 45d2f99fd7 improve:历史版本回滚
支持最近不再接收更新
2025-12-20 17:45:35 +08:00
CJKmkp f75fdded98 fix:开关显示异常 2025-12-20 17:38:36 +08:00
CJKmkp 22a6d87771 fix:几何绘制中断
解决绘制过程中增加触摸点导致后续失效
2025-12-20 17:33:50 +08:00
CJKmkp 2479da4bbc fix:错误注释 2025-12-20 17:31:57 +08:00
CJKmkp c22424d798 Merge branch 'beta' of https://github.com/InkCanvasForClass/community into beta 2025-12-20 17:31:03 +08:00
CJKmkp bbb30b7c25 improve:几何长按状态显示 2025-12-20 17:30:18 +08:00
CJKmkp 71cbe12cee improve:浮动栏按钮UI
优化按钮显示
2025-12-20 17:28:11 +08:00
CJKmkp 011effa047 优化代码 2025-12-20 17:22:17 +08:00
PrefacedCorg b1648dd702 更改避免全屏的解释说明 2025-12-20 17:07:52 +08:00
CJKmkp 81621cb9d0 撤回commit8042b91 2025-12-20 16:05:37 +08:00
PrefacedCorg 3f460d7a5c 代码清理 2025-12-20 13:56:46 +08:00
PrefacedCorg 6fe34c1250 feat: 白板和批注模式自动全屏 2025-12-20 13:28:47 +08:00
PrefacedCorg d5cac938c2 feat: 启用避免全屏助手时自动全屏处理白板和批注模式
- 进入白板/批注模式时自动全屏
- 退出时恢复工作区域大小
- 添加状态跟踪避免重复处理
- PPT放映模式和白板模式切换时正确管理全屏状态
2025-12-20 13:03:31 +08:00
CJKmkp 6222fabdd4 add:新下载新路 2025-12-13 22:01:21 +08:00
CJKmkp 8ed4f25499 improve:GitHub工作流 2025-12-13 21:12:18 +08:00
CJKmkp 3afd4641cd 更新版本号 2025-12-13 21:06:31 +08:00
CJKmkp e9fde97453 improve:GitHub工作流 2025-12-13 21:02:11 +08:00
CJKmkp 441f8b6e26 优化按钮名称 2025-12-13 20:47:30 +08:00
CJKmkp 8042b917a0 improve:浮动栏按钮UI
优化按钮显示
2025-12-13 20:45:31 +08:00
CJKmkp 343e7281fe improve:端点吸附
避免点线和虚线吸附
2025-12-13 20:32:43 +08:00
CJKmkp c64e6a4554 improve:issue #252
改进双指拖动
2025-12-13 20:22:23 +08:00
CJKmkp 8190bf275c Merge branch 'beta' of https://github.com/InkCanvasForClass/community into beta 2025-12-13 20:13:14 +08:00
CJKmkp e792f2637d improve:PPT墨迹加载 2025-12-13 20:13:08 +08:00
CJKmkp 3cd26323dc improve:翻页墨迹加载及浮动栏定位 2025-12-13 20:07:25 +08:00
PrefacedCorg 40e1c4d467 Update MW_FloatingBarIcons.cs 2025-12-13 19:54:10 +08:00
PrefacedCorg 86c22d373a Revert "feat: 添加白板模式自动全屏功能" 2025-12-13 19:48:21 +08:00
PrefacedCorg cb7a76efc5 Delete .vscode directory 2025-12-13 19:39:08 +08:00
PrefacedCorg 545425c4d3 Delete .kiro/steering directory 2025-12-13 19:38:34 +08:00
PrefacedCorg eb1aaa10e4 feat: 添加白板模式自动全屏功能
- 新增"白板模式自动全屏"设置选项
- 进入白板模式时自动全屏,退出时恢复工作区域大小
- 需配合"避免全屏助手"功能使用
- 用户可独立控制白板模式的全屏行为
2025-12-13 19:27:47 +08:00
CJKmkp daf0db312b improve:仅PPT模式
优化浮动栏显示
2025-12-13 18:02:05 +08:00
CJKmkp 8b2bc2f064 improve:退出放映时收纳及PPT记忆上次播放页数 2025-12-13 17:38:35 +08:00
CJKmkp 2e343cbbf9 improve:计时器
优化计时器行为
2025-12-13 17:20:18 +08:00
CJKmkp a75f0470bc improve:点名算法
缩小极差
2025-12-13 17:12:00 +08:00
CJKmkp 287d31a3a9 improve:窗口模式 2025-12-13 17:03:58 +08:00
CJKmkp 430fff0515 优化注释 2025-12-06 23:04:27 +08:00
CJKmkp fbbb7b8ad7 improve:issue #252
改进几何绘制
2025-12-06 23:01:41 +08:00
CJKmkp 54b74d7411 improve:issue #252
改进手掌擦及手势
2025-12-06 22:55:55 +08:00
CJKmkp 82dba31b2a improve:直线拉直
改进高精度拉直
2025-12-06 22:06:28 +08:00
CJKmkp 38d7e782e0 improve:issue #252
修复了几何绘制和多指书写状态问题
2025-11-30 11:51:19 +08:00
CJKmkp 05e5ceeb43 improve:计时器
改进主题加载
2025-11-29 23:11:01 +08:00
CJKmkp fcbbad71d2 更新版本号 2025-11-29 22:23:14 +08:00
CJKmkp 6f9161439f improve:直线拉直
改进直线拉直算法
2025-11-29 22:20:13 +08:00
CJKmkp aa0c4fb841 improve:Dlass服务
优化上传体验
2025-11-29 17:26:47 +08:00
CJKmkp cff50d1f81 fix:快捷键管理 2025-11-29 17:26:41 +08:00
CJKmkp b8581b6368 improve:点名算法
优化概率模型
2025-11-29 16:58:40 +08:00
CJKmkp 094f1223d1 improve:崩溃日志位置 2025-11-29 16:46:33 +08:00
CJKmkp 6802476afa improve:计时器UI
将计时器窗口整合至主窗口,优化全屏计时逻辑
2025-11-29 16:27:35 +08:00
CJKmkp a0539dce9b 更新版本号 2025-11-15 21:36:49 +08:00
CJKmkp bf2b8fec35 improve:计时器UI与点名UI
改进视觉反馈和按钮逻辑及窗口置顶
2025-11-15 21:14:08 +08:00
CJKmkp 082c9a03ec fix:issue #287 2025-11-15 20:48:04 +08:00
CJKmkp 4ccdd862ba improve:PPT模块
修复无焦点状态下键盘翻页无效
2025-11-15 20:24:28 +08:00
CJKmkp e5a20ed0fc improve:点名历史查看 2025-11-15 20:20:56 +08:00
CJKmkp a72022704e improve:点名算法 2025-11-15 19:34:52 +08:00
CJKmkp 2acc7ada30 improve:错误检测 2025-11-15 19:31:57 +08:00
CJKmkp e61882c331 improve:点名
点名算法优化
2025-11-15 19:20:35 +08:00
CJKmkp 61c145689a fix:issue #281 2025-11-15 18:41:42 +08:00
CJKmkp 40ea9664a7 improve:快抽置顶 2025-11-15 18:37:23 +08:00
CJKmkp bccd2d0f3e improve:PPT墨迹保存 2025-11-15 18:19:53 +08:00
CJKmkp b918809dca improve:线擦擦除 2025-11-15 18:06:36 +08:00
CJKmkp e7c2e92879 improve:PPT联动及墨迹管理
改回原处理模式,优化翻页操作
2025-11-15 18:04:22 +08:00
CJK_mkp cf03c921a7 更新版本号 2025-11-08 23:16:36 +08:00
CJK_mkp 2c45c839b1 Revert "improve:无焦点模式"
This reverts commit 83f5fc58d1.
2025-11-08 23:09:04 +08:00
CJK_mkp 83f5fc58d1 improve:无焦点模式 2025-11-08 22:55:18 +08:00
CJK_mkp 1a267f1e5a improve:点名 2025-11-08 22:23:44 +08:00
CJK_mkp c3fd5551d8 improve:快抽按钮 2025-11-08 22:17:52 +08:00
CJK_mkp 1baa74bb69 improve:快抽按钮 2025-11-08 22:07:38 +08:00
CJK_mkp 261ecefb17 improve:注释 2025-11-08 21:42:33 +08:00
CJK_mkp d81d8f7c5d improve:Dlass联动 2025-11-08 21:01:50 +08:00
CJK_mkp de1af12157 更新版本号 2025-11-08 20:41:43 +08:00
CJK_mkp 803cbbdee9 improve:默认设置 2025-11-08 20:29:18 +08:00
CJK_mkp 008477d5fa improve:默认设置 2025-11-08 20:17:51 +08:00
CJK_mkp 7f0d29ebd2 improve:快抽窗口 2025-11-08 20:07:00 +08:00
CJK_mkp 11bf8cffb2 improve:PPT墨迹加载 2025-11-08 19:55:10 +08:00
CJK_mkp 87b9ebc7e1 improve:PPT墨迹显示 2025-11-08 19:36:05 +08:00
CJK_mkp b89d27411b improve:计时器逻辑 2025-11-08 19:20:26 +08:00
CJK_mkp 24c37f1d3e fix:计时器时间不一致 2025-11-08 19:17:58 +08:00
CJK_mkp 58b0a0a3be fix:负数导致的计时器崩溃 2025-11-08 19:15:16 +08:00
CJK_mkp ed58873a82 fix:issue #272 2025-11-08 19:02:37 +08:00
CJK_mkp a8dcbd4af0 add:点名历史查看 2025-11-08 18:01:56 +08:00
CJK_mkp 4b2f29442a improve:点名 2025-11-07 10:36:24 +08:00
CJK_mkp dfab0d7ddf improvve:点名快抽 2025-11-07 10:35:27 +08:00
CJK_mkp ce1998b701 improve:Dlass 界面UI 2025-11-07 09:46:21 +08:00
CJK_mkp 92c631d6ce improve:操作逻辑 2025-11-02 12:34:50 +08:00
CJK_mkp 01009f9e35 更新版本号 2025-11-02 11:47:52 +08:00
CJK_mkp 74eca093da improve:悬浮快抽按钮 2025-11-02 11:40:27 +08:00
CJK_mkp e7d89e65b2 improve:AutoUpdate 2025-11-02 11:27:46 +08:00
CJK_mkp 24b2bffe8e improve:计时器窗口 2025-11-02 11:12:13 +08:00
CJK_mkp d2906476c8 add:Dlass联动 2025-11-02 10:46:16 +08:00
CJK_mkp 2b31a355ae add:Dlass联动 2025-11-02 10:30:36 +08:00
CJK_mkp b602048186 add:Dlass联动 2025-11-02 10:16:31 +08:00
CJK_mkp 4fb7031060 add:Dlass联动 2025-11-02 10:11:15 +08:00
CJK_mkp 4ef77c2e72 add:Dlass联动 2025-11-02 09:41:53 +08:00
CJK_mkp 72ba1a9f58 add:Dlass联动 2025-11-02 09:29:06 +08:00
CJK_mkp 0c3938b652 Merge pull request #274 from MKStoler1024/patch-1
Readme
2025-11-01 22:18:46 +08:00
CJK_mkp 16f80adb0d fix:issue #210 2025-11-01 22:12:47 +08:00
CJK_mkp 637b6bb4f9 fix:issue #210 2025-11-01 22:05:19 +08:00
CJK_mkp 12e91927a5 fix:issue #210 2025-11-01 21:56:31 +08:00
CJK_mkp 8f6f22ba7f 更新版本号 2025-11-01 21:37:55 +08:00
CJK_mkp b520d6a334 fix:issue #210 2025-11-01 21:00:23 +08:00
CJK_mkp b7bff30445 improve:UI 2025-11-01 20:49:37 +08:00
CJK_mkp 0d790bbd80 add:墨迹自动保存 2025-11-01 20:42:18 +08:00
CJK_mkp 8394e99127 improve:主题切换 2025-11-01 20:26:52 +08:00
CJK_mkp 16ae32bfd7 improve:点名UI 2025-11-01 19:17:52 +08:00
CJK_mkp cc6423e384 improve:点名UI 2025-11-01 18:56:38 +08:00
CJK_mkp 06cc587599 improve:启动动画 2025-11-01 18:46:04 +08:00
CJK_mkp 9d36088f1d fix:issue #210 2025-11-01 18:39:52 +08:00
CJK_mkp f9f73b015c improve:启动动画 2025-11-01 18:31:27 +08:00
CJK_mkp 77ffd696bb fix:手势面板不显示 2025-11-01 18:29:58 +08:00
CJK_mkp bdb8bed053 fix:issue #210 2025-11-01 18:25:35 +08:00
MKStoler1024 4b17c8e96e chore: remove sth in readme 2025-10-31 17:56:02 +08:00
MKStoler1024 8109711f4e chore: readme 2025-10-31 16:07:03 +08:00
CJK_mkp 327eba3fa7 Update MW_FloatingBarIcons.cs 2025-10-31 15:35:27 +08:00
CJK_mkp f3dccb2e99 Update MW_FloatingBarIcons.cs 2025-10-31 14:46:20 +08:00
CJK_mkp 7112d58e7c Update MW_ShapeDrawing.cs 2025-10-31 14:44:59 +08:00
CJK_mkp 6e0aad853c Update MW_TouchEvents.cs 2025-10-31 14:44:05 +08:00
CJK_mkp c64b1d0846 Update MW_BoardIcons.cs 2025-10-31 14:43:15 +08:00
CJK_mkp 6eba16ce99 Update MW_BoardIcons.cs 2025-10-31 12:19:30 +08:00
CJK_mkp 2f6f719843 Update MW_ShapeDrawing.cs 2025-10-31 12:18:45 +08:00
CJK_mkp f34bac49e4 Update MW_TouchEvents.cs 2025-10-31 12:16:52 +08:00
CJK_mkp 39cdc6231f Update MW_FloatingBarIcons.cs 2025-10-31 12:16:05 +08:00
CJK_mkp 745e24da70 Update MW_FloatingBarIcons.cs 2025-10-31 12:15:26 +08:00
CJK_mkp a4f4f4fb15 Update MW_TouchEvents.cs 2025-10-31 12:12:51 +08:00
CJK_mkp 3833c229c6 Update MW_FloatingBarIcons.cs 2025-10-31 12:11:02 +08:00
CJK_mkp 3dc3e9b5a8 Update MW_FloatingBarIcons.cs 2025-10-31 10:49:10 +08:00
CJK_mkp 12eeb79e9f 回滚一下 2025-10-30 12:02:29 +08:00
CJK_mkp e08c84f70d improve:点名快抽 2025-10-27 17:54:58 +08:00
CJK_mkp 10f55d5b65 fix:抽选结果截断 2025-10-27 17:45:41 +08:00
CJKmkp 761992d089 Delete PositionConverters.cs 2025-10-26 00:31:32 +08:00
CJKmkp 991a823700 更新版本号 2025-10-26 00:24:28 +08:00
CJKmkp 61dbcf762c add:点名快抽 2025-10-26 00:21:10 +08:00
CJKmkp 60b0149a9c add:新点名UI 2025-10-26 00:00:13 +08:00
CJKmkp 501c034cfa fix:点名UI按钮主题显示 2025-10-25 21:14:59 +08:00
CJKmkp 11593db23c 更新版本号 2025-10-25 20:14:07 +08:00
CJKmkp a9ae2a004f improve:注释 2025-10-25 20:09:04 +08:00
CJKmkp 7b2a31781c 优化代码 2025-10-25 19:57:56 +08:00
CJKmkp ab73eb9632 优化代码 2025-10-25 19:44:32 +08:00
CJKmkp 8ade170b4e improve:计时器数字 2025-10-25 17:27:19 +08:00
CJKmkp 91c3d1161d fix:issue #210 2025-10-25 17:03:44 +08:00
CJK_mkp bb63805e87 fix:issue #210
Removed the SimulateMultiTouchToggle method and its related comments.
2025-10-23 16:27:39 +08:00
CJK_mkp 8caf04990c 更新信息 2025-10-22 17:30:38 +08:00
CJK_mkp f28dd0a965 Update AssemblyInfo.cs 2025-10-22 17:29:12 +08:00
CJK_mkp b5d83268e5 更新信息 2025-10-22 17:28:56 +08:00
CJK_mkp 19adc42122 Change PPTNavigationBtn_MouseUp to async method 2025-10-22 12:18:03 +08:00
CJK_mkp 8afee913be Update MW_PPT.cs 2025-10-22 12:16:42 +08:00
CJK_mkp 82d101365f Update MW_PPT.cs 2025-10-22 12:12:43 +08:00
CJK_mkp 73e679f268 Make PPTNavigationBtn_MouseDown async
Changed PPTNavigationBtn_MouseDown to be asynchronous and added a delay for animation.
2025-10-22 12:08:29 +08:00
CJK_mkp 372a8a1de1 fix:PPT状态浮动栏位置异常 2025-10-20 17:45:14 +08:00
CJK_mkp 171cc34c91 撤销修改 2025-10-20 12:10:47 +08:00
CJK_mkp fbd217d674 撤销修改8d778a
Removed quick color palette visibility logic from ink editing mode.
2025-10-20 10:49:04 +08:00
CJKmkp f24960ab26 improve:UIA窗口置顶 2025-10-19 01:34:03 +08:00
CJKmkp d1a871c8f6 Reapply "fix:issue # 262"
This reverts commit 086b97906b.
2025-10-18 21:20:54 +08:00
CJKmkp 086b97906b Revert "fix:issue # 262"
This reverts commit 5bfd0c7b2f.
2025-10-18 21:16:24 +08:00
CJKmkp db76a11347 improve:窗口置顶 2025-10-18 20:45:23 +08:00
CJKmkp 729b10cce8 Reapply "improve:UIA窗口置顶"
This reverts commit 4cbd25ccb3.
2025-10-18 20:41:09 +08:00
CJKmkp 4cbd25ccb3 Revert "improve:UIA窗口置顶"
This reverts commit 0ef7b738a9.
2025-10-18 20:38:08 +08:00
CJKmkp 0ef7b738a9 improve:UIA窗口置顶 2025-10-18 20:15:40 +08:00
CJKmkp 33b5563601 更新版本号 2025-10-18 19:05:16 +08:00
CJKmkp f6f799f534 improve:墨迹清空 2025-10-18 19:03:30 +08:00
CJKmkp 8c3f1360e1 improve:注释 2025-10-18 18:45:08 +08:00
CJKmkp fafbabd603 improve:清空墨迹 2025-10-18 18:42:29 +08:00
CJKmkp 254e38895c fix:无焦点功能丢失 2025-10-18 18:29:52 +08:00
CJKmkp aa0bb22cdd add:UIA窗口置顶 2025-10-18 18:26:13 +08:00
CJKmkp 5bfd0c7b2f fix:issue # 262 2025-10-18 17:36:47 +08:00
CJKmkp c3885c170c improve:PPT墨迹管理 2025-10-18 17:24:47 +08:00
CJKmkp 88a7cce269 fix:issue #133 2025-10-18 16:46:09 +08:00
CJKmkp a1fccc2905 fix:PPT上次页数记忆跳转 2025-10-18 16:41:55 +08:00
CJKmkp a889041896 fix:issue #260 2025-10-18 16:31:07 +08:00
CJKmkp 8d778aba2c improve:PPT模块 2025-10-18 16:27:26 +08:00
CJKmkp ba5db63e0b improve:计时器UI 2025-10-18 16:15:19 +08:00
CJKmkp 0259d83429 improve:计时器 2025-10-12 18:06:44 +08:00
CJKmkp b6999e57ae improve:计时器 2025-10-12 18:05:40 +08:00
CJKmkp 04184cf731 improve:计时器 2025-10-12 17:44:44 +08:00
CJKmkp 04f98eb9e7 improve:计时器 2025-10-12 17:17:51 +08:00
CJKmkp 869dd045af improve:计时器 2025-10-12 16:08:36 +08:00
CJK_mkp 339ebb862e improve:计时器UI 2025-10-08 17:34:12 +08:00
CJKmkp 7b8598bf9f Revert "Update MainWindow.xaml.cs"
This reverts commit 298164d6ed.
2025-10-06 22:41:53 +08:00
CJKmkp ab1c460225 Reapply "add:手动更新"
This reverts commit 703a8a4e0d.
2025-10-06 22:41:42 +08:00
CJKmkp 298164d6ed Update MainWindow.xaml.cs 2025-10-06 22:39:18 +08:00
CJKmkp 703a8a4e0d Revert "add:手动更新"
This reverts commit 1fd95a2f2e.
2025-10-06 22:36:59 +08:00
CJKmkp deaf5fcbf6 更新版本号 2025-10-06 22:05:27 +08:00
CJKmkp 18b46689f1 improve:计时器 2025-10-06 21:49:19 +08:00
CJKmkp edbe3f8311 improve:计时器 2025-10-06 21:17:14 +08:00
CJKmkp 94c4c3e2d4 improve:计时器UI 2025-10-06 21:08:47 +08:00
CJKmkp 077f72737d improve:计时器UI 2025-10-06 21:05:22 +08:00
CJKmkp ae089a9390 improve:计时器UI 2025-10-06 20:57:33 +08:00
CJKmkp 0f087c2aa6 improve:计时器UI 2025-10-06 20:46:19 +08:00
CJKmkp 19d2ffb48e improve:计时器UI 2025-10-06 20:44:09 +08:00
CJKmkp a9bb6f73de improve:计时器UI 2025-10-06 20:33:50 +08:00
CJKmkp ca124732fa improve:计时器 2025-10-06 20:23:55 +08:00
CJKmkp 11da14aeab improve:计时器 2025-10-06 20:11:49 +08:00
CJKmkp 7d5f037c85 improve:计时器 2025-10-06 19:59:01 +08:00
CJKmkp f62b415227 improve:计时器UI 2025-10-06 19:56:00 +08:00
CJKmkp f2b8d4014e improve:计时器UI 2025-10-06 19:46:14 +08:00
CJKmkp 3ef047fb41 improve:计时器UI 2025-10-06 19:43:04 +08:00
CJKmkp aa3be4ab0d improve:计时器UI 2025-10-06 19:05:22 +08:00
CJKmkp 7500049ea2 improve:计时器UI 2025-10-06 19:03:10 +08:00
CJKmkp 44600df75c improve:计时器UI 2025-10-06 18:44:00 +08:00
CJKmkp dec2a15773 improve:计时器UI 2025-10-06 18:43:14 +08:00
PrefacedCorg 4da78a04cb 代码清理 2025-10-06 18:29:12 +08:00
CJKmkp 98ec204bab improve:计时器UI 2025-10-06 18:03:15 +08:00
CJKmkp cd9499b064 improve:计时器UI 2025-10-06 17:55:05 +08:00
CJKmkp f5e824be86 improve:计时器 2025-10-06 17:49:43 +08:00
CJKmkp c76254f4f9 improve:计时器UI 2025-10-06 17:28:52 +08:00
CJKmkp 77ac6f88ca improve:计时器UI 2025-10-06 17:28:32 +08:00
CJKmkp 7e10911991 improve:计时器UI 2025-10-06 17:23:16 +08:00
CJKmkp 161b67b09d improve:计时器UI 2025-10-06 17:17:56 +08:00
CJKmkp 9614536a29 improve:计时器UI 2025-10-06 17:14:40 +08:00
CJKmkp 8ba7aab468 improve:计时器UI 2025-10-06 17:08:38 +08:00
CJKmkp 4ea9f79de1 improve:计时器UI 2025-10-06 17:06:02 +08:00
CJKmkp b7f7025d97 improve:计时器UI 2025-10-06 17:00:27 +08:00
CJKmkp 20d5dd2668 improve:计时器UI 2025-10-06 16:53:00 +08:00
CJKmkp adc2d02fbb Merge branch 'beta' of https://github.com/InkCanvasForClass/community into beta 2025-10-06 16:39:08 +08:00
CJK_mkp ef2dbdc93b Merge pull request #258 from LiuYan-xwx/beta
feat: 优化滑动动画与设置面板逻辑
2025-10-06 16:38:11 +08:00
CJKmkp 9721ec1f0b improve:计时器UI 2025-10-06 16:35:21 +08:00
LiuYan-xwx 4d069d87d7 feat: 优化滑动动画与设置面板逻辑
- 调整滑动动画的目标位置,更新 From 和 To 属性值。
- 移动并优化 `BorderSettings.Visibility` 的设置逻辑。
- 提升代码可读性,减少重复代码,改进动画效果。
2025-10-06 16:32:33 +08:00
CJKmkp 0308f9ce65 improve:计时器UI 2025-10-06 16:30:55 +08:00
CJKmkp 6bcd3cb217 improve:计时器UI 2025-10-06 16:29:03 +08:00
CJKmkp 7f83c490db improve:计时器UI 2025-10-06 16:14:52 +08:00
CJKmkp bbf9c895b8 Merge branch 'beta' of https://github.com/InkCanvasForClass/community into beta 2025-10-06 16:06:15 +08:00
CJKmkp ffa2063c52 improve:计时器UI 2025-10-06 16:04:03 +08:00
CJKmkp d464b1f78e improve:计时器UI 2025-10-06 15:59:48 +08:00
CJKmkp 92cb071408 improve:计时器UI 2025-10-06 15:52:38 +08:00
PrefacedCorg 9141b60d03 Merge pull request #257 from LiuYan-xwx/beta
Update .gitignore
2025-10-06 15:44:52 +08:00
LiuYan-xwx df0a196931 Update .gitignore 2025-10-06 15:41:52 +08:00
CJKmkp a8cb1dd495 improve:计时器 2025-10-06 15:26:46 +08:00
CJKmkp adc4966d49 improve:计时器 2025-10-06 15:00:42 +08:00
CJKmkp 1b2ea8c522 improve:计时器UI 2025-10-06 14:55:52 +08:00
CJKmkp 7c8bdb489b improve:计时器 2025-10-06 14:50:56 +08:00
CJKmkp 16458fbb42 improve:计时器 2025-10-06 14:31:54 +08:00
CJKmkp c72839cdcb improve:计时器 2025-10-06 14:31:04 +08:00
CJKmkp a31ad5803c improve:计时器 2025-10-06 14:28:53 +08:00
CJKmkp cf800cbd36 improve:自动更新 2025-10-06 14:19:24 +08:00
CJKmkp 3c06ef0b1a 优化注释 2025-10-06 14:11:32 +08:00
CJKmkp 2c3b921f09 improve:计时器逻辑 2025-10-06 13:39:31 +08:00
CJKmkp 402ecc66ae improve:计时器逻辑 2025-10-06 13:38:12 +08:00
CJKmkp e25f56a9b5 improve:计时器逻辑 2025-10-06 13:34:52 +08:00
CJKmkp b28fa887a2 improve:计时器逻辑 2025-10-06 13:31:54 +08:00
CJKmkp f83a02e619 improve:UI 2025-10-06 13:15:03 +08:00
CJKmkp eaad089d68 更新版本号 2025-10-06 09:56:07 +08:00
CJKmkp a2fda16df9 improve:主题切换 2025-10-05 23:58:39 +08:00
CJKmkp e9e8ff57ae improve:主题切换 2025-10-05 23:22:02 +08:00
CJKmkp 1fd95a2f2e add:手动更新 2025-10-05 23:09:05 +08:00
CJK_mkp 228584ee48 Update README.md 2025-10-05 21:31:30 +08:00
CJK_mkp c651df0f6e Update README.md 2025-10-05 21:27:56 +08:00
CJKmkp 5cced9baf2 fix:图标数组错误 2025-10-05 21:13:37 +08:00
CJKmkp 5dd26e554b 更新版本号 2025-10-05 12:20:20 +08:00
CJK_mkp 696fd3e8cd Update privacy.txt 2025-10-05 12:07:42 +08:00
CJKmkp 1d19b705d3 fix:issue #202 2025-10-05 11:49:22 +08:00
CJKmkp d54074cb57 improve:主题切换 2025-10-05 09:44:54 +08:00
CJKmkp cc054aeb75 improve:主题切换 2025-10-05 09:33:25 +08:00
CJKmkp c32eaed534 improve:UI 2025-10-05 09:29:31 +08:00
CJKmkp fa23f73ec4 improve:UI 2025-10-05 09:26:14 +08:00
CJKmkp fbf6a13f92 improve:主题切换 2025-10-05 09:16:36 +08:00
CJKmkp 3eba662772 improve:主题切换 2025-10-05 09:14:29 +08:00
CJKmkp e007ee271f improve:主题切换 2025-10-05 08:58:16 +08:00
CJKmkp 59a8d65a89 improve:主题切换 2025-10-05 08:57:04 +08:00
CJKmkp 793519ae1b improve:主题切换 2025-10-05 08:55:18 +08:00
CJKmkp 5c44062aa2 improve:主题切换 2025-10-05 00:26:18 +08:00
CJKmkp fe03a2c2c0 improve:主题切换 2025-10-05 00:24:23 +08:00
CJKmkp d1d74a3770 improve:主题切换 2025-10-05 00:18:58 +08:00
CJKmkp 16108bf779 add:图标 2025-10-04 23:49:12 +08:00
CJKmkp 5bebf077e4 improve:主题切换 2025-10-04 22:59:11 +08:00
CJKmkp efcc01ad6b improve:主题切换 2025-10-04 22:44:47 +08:00
CJKmkp e8a4b45446 improve:主题切换 2025-10-04 22:39:32 +08:00
CJKmkp 6cba297d77 improve:主题切换 2025-10-04 22:37:46 +08:00
CJKmkp b149dc3cb9 improve:主题切换 2025-10-04 22:31:42 +08:00
CJKmkp 1ee4f934b9 improve:主题切换 2025-10-04 22:30:40 +08:00
CJKmkp f7b4adb85d Revert "improve:主题"
This reverts commit da3c41567d.
2025-10-04 22:12:47 +08:00
CJKmkp da3c41567d improve:主题 2025-10-04 22:08:30 +08:00
CJKmkp 5f73795220 improve:主题切换 2025-10-04 22:05:58 +08:00
CJKmkp 36bf1122c6 improve:主题切换 2025-10-04 22:04:24 +08:00
CJKmkp 402f8bb9f9 improve:主题切换 2025-10-04 21:55:55 +08:00
CJKmkp eef2a915fa improve:主题 2025-10-04 21:48:44 +08:00
CJKmkp 26ee4d172f improve:主题切换 2025-10-04 21:44:15 +08:00
CJKmkp 08eb450446 improve:主题切换 2025-10-04 21:40:55 +08:00
CJKmkp ecae7d818c improve:主题切换 2025-10-04 21:00:51 +08:00
CJKmkp 47ffccff68 improve:主题切换 2025-10-04 19:59:42 +08:00
CJKmkp 0ba5286c94 improve:主题切换 2025-10-04 18:42:55 +08:00
CJKmkp db8e1e3589 improve:主题切换 2025-10-04 18:29:42 +08:00
CJKmkp d0764a6a77 improve:主题切换 2025-10-04 18:19:43 +08:00
CJKmkp 7b6c347d6b improve:主题切换 2025-10-04 18:17:11 +08:00
CJKmkp d58fec180c improve:主题切换 2025-10-04 18:10:43 +08:00
CJKmkp ac4e4877a1 improve:主题切换 2025-10-04 17:49:44 +08:00
CJKmkp ddea61245d improve:主题切换 2025-10-04 17:47:52 +08:00
CJKmkp 98915bcff2 improve:主题切换 2025-10-04 17:32:17 +08:00
CJKmkp 8e0f0450df improve:主题切换 2025-10-04 17:30:26 +08:00
CJKmkp 1d9a669829 improve:主题切换 2025-10-04 17:26:11 +08:00
CJKmkp 97bcf168b7 improve:主题 2025-10-04 17:15:58 +08:00
CJKmkp e81198165b improve:主题 2025-10-04 17:14:14 +08:00
CJKmkp b03b8da586 improve:主题 2025-10-04 17:12:14 +08:00
CJKmkp d497e07187 improve:主题 2025-10-04 17:10:11 +08:00
CJKmkp f284a99194 improve:UI 2025-10-04 17:03:03 +08:00
CJKmkp 7d6dd6f805 add:仿希沃计时器 2025-10-04 17:00:15 +08:00
CJKmkp d70e28d198 improve:图标 2025-10-04 16:56:15 +08:00
CJKmkp 4c6f138e5c add:图标 2025-10-04 16:49:03 +08:00
CJKmkp 5974841a7b add:仿希沃计时器 2025-10-04 16:21:14 +08:00
CJKmkp 5df54439ba add:仿希沃计时器 2025-10-04 16:14:56 +08:00
CJKmkp 8f627c6b7f add:图标 2025-10-04 14:55:49 +08:00
CJKmkp 3f28bc5c6c improve:自动更新 2025-10-04 14:47:53 +08:00
CJKmkp 903fa699ca improve:侧边栏图标 2025-10-04 09:49:37 +08:00
PrefacedCorg d9e8f64699 1145141919810
代码清理
2025-10-03 17:08:46 +08:00
CJKmkp 8ad6ca8d41 优化代码 2025-10-03 12:26:15 +08:00
CJK_mkp 4017efc65e Merge pull request #248 from InkCanvasForClass/main
合并一下
2025-10-03 11:51:13 +08:00
CJK_mkp 6ed15d52de Merge pull request #247 from InkCanvasForClass/beta
test action
2025-10-03 11:50:15 +08:00
CJKmkp 5246a2f79b test action 2025-10-03 11:48:09 +08:00
CJK_mkp b670932dd7 Merge pull request #246 from InkCanvasForClass/beta
test action
2025-10-03 11:32:51 +08:00
CJKmkp ddf30bd96b test action 2025-10-03 11:31:54 +08:00
CJKmkp 7e92428485 test action 2025-10-03 11:30:28 +08:00
CJKmkp 4c16050c85 test action 2025-10-03 11:29:46 +08:00
CJK_mkp 2ed035525a Merge pull request #245 from InkCanvasForClass/beta
test action
2025-10-03 11:24:14 +08:00
CJKmkp 1b89b0d7b6 test action 2025-10-03 11:23:46 +08:00
CJK_mkp 0364821f0b Merge pull request #244 from InkCanvasForClass/beta
test action
2025-10-03 11:18:13 +08:00
CJKmkp fa9d6f37ae test action 2025-10-03 11:17:42 +08:00
CJK_mkp a4777904b9 Merge pull request #243 from InkCanvasForClass/beta
test action
2025-10-03 11:14:40 +08:00
CJKmkp 0b3c2f95c5 test action 2025-10-03 11:14:16 +08:00
CJK_mkp 8f54955432 Merge pull request #242 from InkCanvasForClass/beta
test action
2025-10-03 11:11:21 +08:00
CJKmkp 034db2fc27 test action 2025-10-03 11:07:58 +08:00
CJKmkp 59141b0241 test action 2025-10-03 11:04:00 +08:00
CJK_mkp 2e43b96a2c Merge pull request #241 from InkCanvasForClass/beta
合并pre-release action
2025-10-03 11:01:21 +08:00
CJKmkp edff96299c test action 2025-10-03 10:59:36 +08:00
CJKmkp 8d9587b790 test action 2025-10-03 10:57:58 +08:00
CJKmkp ad0cf2a849 test action 2025-10-03 10:56:55 +08:00
CJKmkp f928946c61 improve:白板模式切换 2025-10-03 10:47:28 +08:00
CJKmkp 6cc9d0bee2 fix:issue #219 2025-10-03 09:19:07 +08:00
CJKmkp 287e6bb91f fix:issue #219 2025-10-03 09:12:39 +08:00
CJKmkp 3509036d85 fix:issue #219 2025-10-03 09:04:40 +08:00
CJKmkp 752901dbb9 fix:issue #219 2025-10-03 08:55:28 +08:00
CJKmkp e3add94546 fix:issue #219 2025-10-03 08:52:47 +08:00
CJKmkp 8d31c74b39 add:图标 2025-10-02 22:51:44 +08:00
CJKmkp e6f608d206 add:图标 2025-10-02 22:49:29 +08:00
CJKmkp d80b9e29a7 Merge branch 'beta' of https://github.com/InkCanvasForClass/community into beta 2025-10-02 22:30:00 +08:00
CJK_mkp 092674465d Merge pull request #239 from InkCanvasForClass/all-contributors/add-Tayasui-rainnya
docs: add Tayasui-rainnya as a contributor for design
2025-10-02 22:28:55 +08:00
allcontributors[bot] b2e3a5bb18 docs: update .all-contributorsrc 2025-10-02 14:28:32 +00:00
allcontributors[bot] 147a2f957e docs: update README.md 2025-10-02 14:28:31 +00:00
CJKmkp ce56f2919c add:图标 2025-10-02 22:24:20 +08:00
CJKmkp 18059102a3 add:图标 2025-10-02 22:15:07 +08:00
CJKmkp 4542fcccbb 默认线路组改为inkeys 2025-10-02 21:52:55 +08:00
CJKmkp d12009d30c 修改 2025-10-02 20:31:08 +08:00
CJK_mkp d85e0fbd13 Merge pull request #238 from Tayasui-rainnya/beta
添加dark♂icc-ce图标
2025-10-02 20:29:50 +08:00
CJKmkp f7a5f9ae6b improve:启动动画 2025-10-02 19:51:31 +08:00
tayasui rainnya! 3d4c3d0acc dark♂icc-ce 图标 2025-10-02 19:42:24 +08:00
tayasui rainnya! c106c41048 dark♂图标 2025-10-02 19:41:18 +08:00
CJKmkp cea777e8b2 improve:启动动画 2025-10-02 19:25:57 +08:00
CJKmkp 6f069b73da improve:启动动画 2025-10-02 19:20:03 +08:00
CJKmkp c80af8c984 improve:aovidfullsreen 2025-10-02 19:13:20 +08:00
CJKmkp d51cbd0682 improve:aovidfullsreen 2025-10-02 19:08:33 +08:00
CJKmkp 7e94c945ff improve:aovidfullsreen 2025-10-02 19:05:24 +08:00
CJKmkp bd9095b4c2 improve:aovidfullsreen 2025-10-02 19:04:28 +08:00
CJKmkp c135bf8fb8 improve:aovidfullsreen 2025-10-02 18:57:49 +08:00
CJKmkp f6aebb15b4 improve:aovidfullsreen 2025-10-02 18:54:09 +08:00
CJKmkp 2b4f88becd fix:issue #237 2025-10-02 18:48:11 +08:00
CJKmkp 7fbd3639b6 fix:退出白板后收纳 2025-10-02 18:15:39 +08:00
CJKmkp 9e52c2c31d fix:退出白板后收纳 2025-10-02 18:06:08 +08:00
CJKmkp 46a1e5ff14 improve:主题切换 2025-10-02 17:39:56 +08:00
CJKmkp fa7c1fd646 fix:屏蔽压感 2025-10-02 17:04:12 +08:00
CJKmkp c347809eea improve:启动动画 2025-10-02 16:38:40 +08:00
CJKmkp dd09a42f02 improve:启动动画 2025-10-02 16:33:54 +08:00
CJKmkp db8ffd05ea improve:启动动画 2025-10-02 16:22:50 +08:00
CJK_mkp 045c29ca20 Merge pull request #236 from InkCanvasForClass/beta
ICC CE 1.7.12.0
2025-10-02 16:03:39 +08:00
CJKmkp 4ea6d19602 更新版本号 2025-10-02 15:58:33 +08:00
CJKmkp df00447c41 improve:启动动画 2025-10-02 15:36:52 +08:00
CJKmkp db5b1caea7 improve:启动动画 2025-10-02 15:35:53 +08:00
CJKmkp 8432954b8d add:issue #235 2025-10-02 15:30:51 +08:00
CJK_mkp 4a000e23e9 Update README.md 2025-10-02 15:09:27 +08:00
CJKmkp b42db51346 fix:忽略希沃白板五桌面批注窗口 2025-10-02 15:05:55 +08:00
CJKmkp 1ef968ea93 improve:悬浮窗拦截 2025-10-02 14:57:55 +08:00
CJKmkp 5b50537333 improve:开机动画 2025-10-02 14:53:57 +08:00
CJKmkp 8c624b48fb 删除无用信息 2025-10-02 14:08:22 +08:00
CJKmkp ad329fc2c8 improve:悬浮窗拦截 2025-10-02 11:50:00 +08:00
CJKmkp f045b8f659 fix:悬浮窗拦截 2025-10-02 11:45:55 +08:00
CJKmkp 00a9da45bb improve:启动动画 2025-10-02 02:59:49 +08:00
CJKmkp b7ecd12f8c improve:启动动画 2025-10-02 02:55:53 +08:00
CJKmkp a8a3164ee7 improve:启动动画 2025-10-02 02:44:45 +08:00
CJKmkp b1aec69e98 fix:issue #234 2025-10-02 02:32:29 +08:00
CJKmkp d713a8c5a4 优化注释 2025-10-02 02:30:24 +08:00
CJKmkp 3895faf941 fix:issue #133 2025-10-02 02:16:02 +08:00
CJKmkp bf336fdb10 add:issue #214 2025-10-02 02:11:54 +08:00
CJKmkp c96c26288c add:软件启动动画 2025-10-02 01:51:10 +08:00
CJKmkp 83558c089d add:软件启动动画 2025-10-02 00:17:11 +08:00
CJKmkp 26acb72e17 add:软件启动动画 2025-10-02 00:05:09 +08:00
CJKmkp 4724a432ab add:软件启动动画 2025-10-01 23:26:38 +08:00
CJKmkp 5b9c1627c0 add:软件启动动画 2025-10-01 22:38:40 +08:00
CJKmkp d06c2585cf add:软件启动动画 2025-10-01 22:24:49 +08:00
CJKmkp 3e96e51efd delete:office注册表修改 2025-10-01 22:06:23 +08:00
CJKmkp 9afa7191c4 fix:issue #232 2025-10-01 18:55:03 +08:00
CJKmkp dfddec5586 add:软件启动动画 2025-10-01 18:45:26 +08:00
CJKmkp 93022424b3 add:软件启动动画 2025-10-01 18:38:01 +08:00
CJKmkp aed77a187f add:软件启动动画 2025-10-01 18:17:39 +08:00
CJKmkp 583f47c98b 更新版本号 2025-10-01 15:20:14 +08:00
CJK_mkp ff528b3f9d Merge pull request #233 from InkCanvasForClass/beta
ICC CE 1.7.11.5
2025-10-01 15:17:17 +08:00
CJKmkp 6d98d96ccb fix:issue #217 2025-10-01 14:13:09 +08:00
CJKmkp 6f8e08c21a fix:issue #217 2025-10-01 13:03:11 +08:00
CJKmkp 3a7417f493 优化代码 2025-10-01 12:57:16 +08:00
CJKmkp 66164a0c33 improve:配置文件损坏自动恢复 2025-10-01 11:34:37 +08:00
CJKmkp 0d7a478e16 improve:配置文件损坏自动恢复 2025-10-01 11:29:59 +08:00
CJKmkp 9caef310df 优化代码 2025-10-01 10:04:40 +08:00
CJKmkp 688f742c16 add:老版UI切换 2025-10-01 09:52:15 +08:00
CJKmkp 38dd083cdc add:老版UI切换 2025-10-01 09:48:44 +08:00
CJKmkp 851bd1c3c6 improve:主题切换 2025-10-01 09:13:48 +08:00
CJKmkp c91b8a1a7a add:issue #224 2025-10-01 00:54:03 +08:00
CJKmkp 69c45764b2 Revert "add:issue #224"
This reverts commit 07a62d2f78.
2025-10-01 00:53:22 +08:00
CJKmkp 07a62d2f78 add:issue #224 2025-10-01 00:49:12 +08:00
CJKmkp 46b064b0a8 add:配置文件损坏自动恢复 2025-10-01 00:01:35 +08:00
CJKmkp 1d3b96bb65 更新Action 2025-09-30 23:45:40 +08:00
CJKmkp 916425b7f5 更新Action 2025-09-30 23:38:58 +08:00
CJKmkp 1c570ca242 fix:issue #210 2025-09-30 23:18:16 +08:00
CJKmkp ae41108971 优化代码 2025-09-30 22:56:32 +08:00
CJKmkp 395e7609a4 fix:issue #210 2025-09-30 22:55:06 +08:00
CJKmkp 185c9dc284 Reapply "fix:issue #201"
This reverts commit f40ef15a24.
2025-09-30 19:16:56 +08:00
CJKmkp a9b0ac0595 Revert "优化代码"
This reverts commit 92bb458345.
2025-09-30 19:15:03 +08:00
CJKmkp d9e3524211 fix:issue #201 2025-09-30 19:10:34 +08:00
CJKmkp f40ef15a24 Revert "fix:issue #201"
This reverts commit 9b5d157333.
2025-09-30 19:02:45 +08:00
CJKmkp 4d7544eefb deletefix:issue #210 2025-09-30 18:45:57 +08:00
CJKmkp 92bb458345 优化代码 2025-09-30 17:46:35 +08:00
CJKmkp 92e695ef7c fix:issue #213 2025-09-30 17:22:32 +08:00
CJKmkp 45ff3fbb9b fix:issue #213 2025-09-30 17:18:00 +08:00
CJKmkp ba252e92d3 fix:issue #229 2025-09-30 16:55:44 +08:00
CJK_mkp 4778f459e3 优化日志 2025-09-29 18:19:36 +08:00
CJK_mkp c997854ae0 优化日志 2025-09-29 18:14:39 +08:00
CJK_mkp 65b5322ad5 优化日志 2025-09-29 18:13:11 +08:00
CJK_mkp dd43bf0476 优化日志 2025-09-29 18:11:21 +08:00
CJKmkp 15c808eebd 更新版本号 2025-09-27 18:00:12 +08:00
CJKmkp 28748a99ca improve:手掌擦 2025-09-27 17:58:50 +08:00
CJKmkp fb37d3b9e6 improve:更新弹窗 2025-09-27 17:52:25 +08:00
CJKmkp e1f10e054c improve:issue #223 2025-09-27 17:09:06 +08:00
CJKmkp c670357c01 improve:橡皮擦 2025-09-27 17:01:33 +08:00
CJK_mkp 92dce9b36e Update MainWindow.xaml 2025-09-26 22:14:12 +08:00
PrefacedCorg aa2b62e8da 修复退出放映按钮字体显示不完全
把字体调小了()
2025-09-22 20:23:36 +08:00
CJKmkp a34a65f354 优化代码 2025-09-22 13:26:53 +08:00
CJKmkp eea5f8496c fix:高光显示 2025-09-22 13:11:22 +08:00
CJKmkp 091a256bcc Revert "Replace SymbolIcon with FontIcon throughout UI"
This reverts commit 37a69032f6.
2025-09-22 13:09:43 +08:00
CJKmkp 14c9ce3ce1 fix:issue #219 2025-09-22 12:32:53 +08:00
CJKmkp fd1e5e13fe fix:进入PPT自动收纳 2025-09-22 12:11:03 +08:00
CJKmkp 19685b8f95 fix:进入PPT自动收纳 2025-09-22 11:58:54 +08:00
CJKmkp a9da8dc10c fix:进入PPT自动收纳 2025-09-22 11:48:05 +08:00
CJKmkp fcfba7a978 fix:进入PPT自动收纳 2025-09-22 11:36:55 +08:00
PrefacedCorg 2c8c4351dd Update WenXiang.png 2025-09-25 10:26:38 +08:00
PrefacedCorg 79264b187d Remove unused exception variable in catch block
The exception variable 'ex' in the catch block was unused and has been removed for cleaner code.
2025-09-22 09:44:38 +08:00
PrefacedCorg 52eba9117b Merge branch 'beta' of https://github.com/InkCanvasForClass/community into beta 2025-09-22 09:34:45 +08:00
PrefacedCorg 37a69032f6 Replace SymbolIcon with FontIcon throughout UI
Updated all XAML and code-behind references from SymbolIcon/Symbol to FontIcon/Glyph for consistency and compatibility with the UI framework. This affects button icons, window controls, and shape drawing logic across multiple windows and components.
2025-09-22 09:34:39 +08:00
CJKmkp dd16b4f5a1 更新版本号 2025-09-21 08:28:32 +08:00
CJKmkp e9c20255a6 imporve:PPT墨迹保存 2025-09-21 08:26:55 +08:00
CJKmkp 630b4edf91 improve:PPT墨迹保存 2025-09-21 07:52:11 +08:00
CJKmkp 04ef638e17 fix:issue #190 2025-09-21 07:43:29 +08:00
CJKmkp 35bad240c2 更新版本号 2025-09-21 02:08:29 +08:00
CJKmkp 0cb4749cf3 add:主题切换 2025-09-21 02:05:49 +08:00
CJKmkp 7c8281eb00 add:主题切换 2025-09-21 01:35:13 +08:00
CJKmkp 1957288219 add:主题切换 2025-09-21 01:15:01 +08:00
CJKmkp c4d2b15c48 add:主题切换 2025-09-21 01:06:42 +08:00
CJKmkp beebfb0dae add:主题切换 2025-09-21 00:39:30 +08:00
CJKmkp d67172b795 优化代码 2025-09-21 00:28:30 +08:00
CJKmkp 2b012bc042 add:主题切换 2025-09-21 00:25:09 +08:00
CJKmkp 84da68f950 improve:历史版本回滚窗口 2025-09-20 22:27:26 +08:00
CJKmkp ad97fd13bf improve:更新弹窗 2025-09-20 22:21:05 +08:00
CJKmkp ebf6d0d5f7 improve:历史版本回滚窗口 2025-09-20 22:20:13 +08:00
CJKmkp 0f3b4b4384 Merge branch 'beta' of https://github.com/InkCanvasForClass/community into beta 2025-09-20 22:02:43 +08:00
PrefacedCorg 226cf46d6b Merge pull request #212 from Hao3288/beta
readme文件中的部分url地址填写错误
2025-09-20 21:55:56 +08:00
CJKmkp 5689e33541 improve:更新弹窗 2025-09-20 21:54:02 +08:00
NoobHao 15e59e7117 Update README.md 2025-09-20 21:46:43 +08:00
NoobHao 6b538f6662 Update README.md 2025-09-20 21:45:38 +08:00
CJKmkp ad6808b696 improve:图片拖动 2025-09-20 21:33:21 +08:00
CJKmkp 8347b18efc 优化代码 2025-09-20 21:25:30 +08:00
CJKmkp f92b132f0a 优化代码 2025-09-20 19:49:16 +08:00
CJKmkp 79057d6757 fix:issue #160 2025-09-20 19:36:00 +08:00
CJKmkp a9b5ee8f62 fix:issue #205 2025-09-20 19:03:00 +08:00
CJKmkp 65da2c449e 更新版本号 2025-09-20 17:13:04 +08:00
CJKmkp 0ef8c12650 improve:issue #180 2025-09-20 17:06:11 +08:00
PrefacedCorg 1dfa48aecb Update MainWindow.xaml 2025-09-20 16:42:35 +08:00
PrefacedCorg b5d1713b43 Merge branch 'beta' of https://github.com/InkCanvasForClass/community into beta 2025-09-20 16:36:02 +08:00
PrefacedCorg 102421997d add DeveloperAvatars 2025-09-20 16:34:55 +08:00
CJKmkp 43370bb8d1 fix:issue #202 2025-09-20 16:13:35 +08:00
CJKmkp 310f50fcde fix:issue #202 2025-09-20 16:10:52 +08:00
CJKmkp 9b5d157333 fix:issue #201 2025-09-20 15:36:45 +08:00
CJKmkp 53fbb7a0bd improve:更新弹窗 2025-09-20 15:36:24 +08:00
CJKmkp fe92117c4e improve:更新弹窗 2025-09-20 15:25:41 +08:00
CJKmkp 4a0d13457a improve:更新弹窗 2025-09-20 15:25:08 +08:00
CJKmkp 1ad6405003 improve:issue #197 2025-09-20 14:49:40 +08:00
CJKmkp 75e7e36011 improve:issue #133 2025-09-20 14:31:38 +08:00
CJKmkp 933c695b8c fix:issue #133 2025-09-20 14:02:29 +08:00
CJKmkp b34f7142f6 improve:墨迹平滑 2025-09-20 13:44:01 +08:00
CJKmkp 7392fa8165 fix:issue #204 2025-09-20 12:38:22 +08:00
CJKmkp 349d417869 fix:issue #205 2025-09-20 12:35:30 +08:00
CJKmkp b8e94cac9c fix:issue #210 2025-09-20 12:22:21 +08:00
CJKmkp cd90490b8d fix:issue #210 2025-09-20 12:15:21 +08:00
CJKmkp a9cc94ccb6 fix:issue #210 2025-09-20 12:03:30 +08:00
CJKmkp 17f137af09 fix:issue #210 2025-09-20 11:55:50 +08:00
CJKmkp ea7d0bbf71 fix:issue #206 2025-09-20 11:49:25 +08:00
CJKmkp 176f1cf405 fix:issue #208 2025-09-20 11:45:35 +08:00
CJKmkp 2ee93bbcc1 fix:issue #209 2025-09-20 11:42:33 +08:00
CJKmkp ba0629000e add:退出白板收纳 2025-09-20 11:22:09 +08:00
CJKmkp 313049f873 fix:issue #203 2025-09-20 11:08:52 +08:00
CJK_mkp d1a1b17d29 fix:白板参数 2025-09-18 18:07:45 +08:00
CJK_mkp eb91d2ce0a fix:白板参数 2025-09-18 18:06:53 +08:00
CJK_mkp 71c77da898 fix:issue #203 2025-09-18 17:58:51 +08:00
CJK_mkp 1b96c70386 fix:issue #160 2025-09-18 17:50:47 +08:00
CJK_mkp 703cecbd4f Merge pull request #196 from InkCanvasForClass/main
没事干合并一下commit
2025-09-13 23:15:56 +08:00
231 changed files with 28673 additions and 8701 deletions
+20 -1
View File
@@ -16,7 +16,8 @@
"contributions": [
"maintenance",
"doc",
"code"
"code",
"design"
]
},
{
@@ -89,6 +90,24 @@
"contributions": [
"design"
]
},
{
"login": "Tayasui-rainnya",
"name": "tayasui rainnya!",
"avatar_url": "https://avatars.githubusercontent.com/u/156585442?v=4",
"profile": "https://github.com/Tayasui-rainnya",
"contributions": [
"design"
]
},
{
"login": "doudou0720",
"name": "doudou0720",
"avatar_url": "https://avatars.githubusercontent.com/u/98651603?v=4",
"profile": "https://github.com/doudou0720",
"contributions": [
"code"
]
}
]
}
+371 -23
View File
@@ -1,35 +1,383 @@
name: .NET Build
name: .NET Build & PR Check
on:
push:
branches: [ main,beta ]
branches: [ main, beta ]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [ main ]
paths-ignore:
- '**/*.md'
- 'docs/**'
- 'Images/**'
- 'Manual.md'
- 'README.md'
- 'UpdateLog.md'
- 'CODE_OF_CONDUCT.md'
- 'LICENSE'
- 'privacy.txt'
- 'icc.png'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
build:
runs-on: windows-latest
find-or-create-pr-comment:
name: Find or Create PR Comment
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
pull-requests: write
outputs:
comment_id: ${{ steps.find-comment.outputs.comment_id }}
steps:
- uses: actions/checkout@v4.2.2
- name: Find existing bot comment
id: find-comment
run: |
# 查找包含特定标记的现有评论
COMMENTS=$(gh api \
-H "Accept: application/vnd.github.v3+json" \
"/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
--jq '.[] | select(.body | contains("<!-- github-action-pr-build -->")) | .id' | head -1)
if [ -n "$COMMENTS" ]; then
echo "📝 找到现有评论 ID: $COMMENTS"
echo "comment_id=$COMMENTS" >> $GITHUB_OUTPUT
else
echo "📝 未找到现有评论,将创建新评论"
echo "comment_id=" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Setup MSbuild
uses: microsoft/setup-msbuild@v2
- name: Setup NuGet
uses: NuGet/setup-nuget@v2.0.1
pr-preview-comment:
name: PR Preview (Building)
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: find-or-create-pr-comment
permissions:
pull-requests: write
outputs:
comment_id: ${{ steps.create-preview-comment.outputs.comment-id }}
steps:
- name: Prepare Preview Comment
id: prepare-preview
env:
GH_REPO: ${{ github.repository }}
GH_RUN_ID: ${{ github.run_id }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
IS_READY_FOR_REVIEW: ${{ github.event.action == 'ready_for_review' }}
run: |
# 构建预览评论内容
{
if [ "$IS_READY_FOR_REVIEW" = "true" ]; then
echo "# 🚀 PR 准备审查 - 构建预览"
echo ""
echo "**状态:** 🟡 正在构建(准备审查状态)..."
else
echo "# 🏗️ PR 构建预览"
echo ""
echo "**状态:** 🟡 正在构建..."
fi
echo "**分支提交:** \`$PR_HEAD_SHA\`"
echo "**操作:** [查看运行详情](https://github.com/$GH_REPO/actions/runs/$GH_RUN_ID)"
echo ""
if [ "$IS_READY_FOR_REVIEW" = "true" ]; then
echo "> 📋 此 PR 已标记为 **准备审查**,正在进行构建验证"
fi
echo "---"
echo "<!-- github-action-pr-build -->"
echo "<!-- build-id: $GH_RUN_ID -->"
echo "<!-- event-type: ${{ github.event.action }} -->"
echo "<!-- pr-head-sha: $PR_HEAD_SHA -->"
echo "<!-- merge-sha: ${{ github.sha }} -->"
echo ""
echo "🤖 构建完成后,状态将自动更新"
} > preview_comment.txt
preview_content=$(cat preview_comment.txt)
echo "preview_body<<EOF" >> $GITHUB_OUTPUT
echo "$preview_content" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Restore NuGet Packages
run: nuget restore "Ink Canvas.sln"
- name: Post/Update Preview Comment
id: create-preview-comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ needs.find-or-create-pr-comment.outputs.comment_id }}
body: ${{ steps.prepare-preview.outputs.preview_body }}
edit-mode: replace
- name: Build the Solution
run: |
msbuild -t:restore /p:GitFlow="Github Action"
msbuild /p:platform="Any CPU" /p:configuration="Release" /p:GitFlow="Github Action" "Ink Canvas/InkCanvasForClass.csproj"
build-and-package:
name: Build & Package
runs-on: windows-latest
outputs:
archive_name: ${{ steps.create-archive.outputs.archive_name }}
build_result: ${{ steps.check-exe.outputs.build_success }}
artifact_url: ${{ steps.upload-artifact.outputs.artifact-url }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Upload to artifact
uses: actions/upload-artifact@v4.5.0
with:
name: InkCanvasForClass
path: "Ink Canvas/bin/Any CPU/Release/net472/"
- name: Setup NuGet
uses: NuGet/setup-nuget@v2.0.1
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Cache NuGet global packages
id: cache-nuget
uses: actions/cache@v4
with:
path: |
~/.nuget/packages
~\AppData\Local\NuGet\Cache
key: ${{ runner.os }}-nuget-v2-${{ hashFiles('**/*.csproj', '**/packages.config', '**/*.sln', '**/nuget.config') }}
restore-keys: |
${{ runner.os }}-nuget-v2-
# Removed caching of obj/ folders to avoid cross-version incremental build issues
# NuGet packages will still be cached; always run restore to ensure packages are present
- name: Restore NuGet packages
run: |
Write-Host "📥 正在恢复 NuGet 包(始终运行以确保依赖可用)..." -ForegroundColor Yellow
# 恢复解决方案级别的包
nuget restore "Ink Canvas.sln" -Verbosity minimal
# 恢复项目级别的包(兼容 packages.config
msbuild -t:restore "Ink Canvas/InkCanvasForClass.csproj" /p:GitFlow="Github Action" /p:RestorePackagesConfig=true /verbosity:minimal
Write-Host "✅ NuGet 包恢复完成" -ForegroundColor Green
- name: Build the Solution
run: |
Write-Host "🔨 正在构建项目..." -ForegroundColor Cyan
# 如果是 ready_for_review 事件,添加特殊标记
if ("${{ github.event.action }}" -eq "ready_for_review") {
Write-Host "🚀 PR 准备审查状态构建 - 进行完整验证" -ForegroundColor Magenta
$GITFLOW = "Github Action - Ready For Review"
} else {
$GITFLOW = "Github Action"
}
# 执行构建
msbuild /p:platform="AnyCPU" /p:configuration="Debug" /p:GitFlow="$GITFLOW" "Ink Canvas/InkCanvasForClass.csproj" /m /p:UseMultiToolTask=true /p:EnforceProcessCountAcrossBuilds=true /verbosity:minimal
Write-Host "🏗️ 构建命令执行完成" -ForegroundColor Cyan
- name: Check if exe file is generated
id: check-exe
run: |
Write-Host "🔍 检查是否生成可执行文件..." -ForegroundColor Cyan
$exePath = "Ink Canvas\bin\Debug\net472\InkCanvasForClass.exe"
if (Test-Path $exePath) {
Write-Host "✅ 找到可执行文件: $exePath" -ForegroundColor Green
$fileInfo = Get-Item $exePath
Write-Host " 文件大小: $($fileInfo.Length) 字节" -ForegroundColor Gray
Write-Host " 创建时间: $($fileInfo.CreationTime)" -ForegroundColor Gray
echo "build_success=true" >> $env:GITHUB_OUTPUT
} else {
Write-Host "❌ 未找到可执行文件: $exePath" -ForegroundColor Red
Write-Host " 检查目录内容:" -ForegroundColor Yellow
if (Test-Path "Ink Canvas\bin\Debug\net472\") {
Get-ChildItem "Ink Canvas\bin\Debug\net472\" -ErrorAction SilentlyContinue | ForEach-Object {
Write-Host " - $($_.Name)" -ForegroundColor Gray
}
} else {
Write-Host " bin\Debug\net472 目录不存在" -ForegroundColor Red
}
echo "build_success=false" >> $env:GITHUB_OUTPUT
# 如果是直接触发,则抛出错误
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
Write-Host "🚨 工作流手动触发 - 构建失败,抛出错误!" -ForegroundColor Red -BackgroundColor Black
exit 1
}
}
- name: Create Package (if build succeeded)
id: create-archive
if: steps.check-exe.outputs.build_success == 'true'
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_RUN_NUMBER: ${{ github.run_number }}
run: |
# 使用合并提交的短哈希(因为构建使用的是合并后的代码)
$shortSha = $env:GITHUB_SHA.Substring(0, 7)
$version = "debug-$shortSha-$env:GITHUB_RUN_NUMBER"
$archiveName = "InkCanvasForClass.CE.$version.zip"
Write-Host "📦 正在创建归档包: $archiveName" -ForegroundColor Cyan
Write-Host " 使用合并提交哈希: $env:GITHUB_SHA" -ForegroundColor Gray
Compress-Archive -Path "Ink Canvas\bin\Debug\net472\*" -DestinationPath $archiveName -Force
echo "archive_name=$archiveName" >> $env:GITHUB_OUTPUT
Write-Host "✅ 已创建归档包: $archiveName" -ForegroundColor Green
- name: Upload Artifact (if build succeeded)
id: upload-artifact
if: steps.check-exe.outputs.build_success == 'true'
uses: actions/upload-artifact@v4.5.0
with:
name: app-package
path: "*.zip"
pr-check-comment:
name: PR Check & Comment (Final)
needs: [build-and-package, pr-preview-comment]
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Prepare Final Comment Content
id: prepare-final-comment
run: |
# 从构建作业获取构建结果
BUILD_SUCCESS="${{ needs.build-and-package.outputs.build_result }}"
ARTIFACT_URL="${{ needs.build-and-package.outputs.artifact_url }}"
# 使用 PR 分支的实际提交哈希
PR_HEAD_SHA="${{ github.event.pull_request.head.sha }}"
# 确定构建状态
if [ "$BUILD_SUCCESS" = "true" ]; then
STATUS_ICON="✅"
STATUS_TEXT="构建成功"
COLOR="#00d26a"
else
STATUS_ICON="❌"
STATUS_TEXT="构建失败"
COLOR="#f85149"
fi
# 检查是否是 ready_for_review 事件
READY_FOR_REVIEW="${{ github.event.action == 'ready_for_review' }}"
# 构建最终评论内容
{
if [ "$READY_FOR_REVIEW" = "true" ]; then
echo "# 🚀 PR 准备审查 - 构建结果"
echo ""
echo "> 📋 此 PR 已标记为 **准备审查**,构建验证完成"
echo ""
else
echo "# 📋 构建结果摘要"
echo ""
fi
echo "## 本次构建状态"
echo ""
echo "| 项目 | 结果 |"
echo "|------|------|"
echo "| 状态 | $STATUS_ICON **$STATUS_TEXT** |"
echo "| 事件类型 | \`${{ github.event.action }}\` |"
echo "| 分支提交 | \`$PR_HEAD_SHA\` |"
echo "| 工作流 | [运行 #${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |"
# 如果有构建产物,显示下载链接
if [ "$BUILD_SUCCESS" = "true" ]; then
NIGHTLY_LINK="https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/app-package.zip"
echo ""
echo "## 构建产物"
if [ -n "$ARTIFACT_URL" ]; then
echo "- 📦 [下载构建产物]($ARTIFACT_URL)"
else
echo "- 📦 [下载构建产物](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
fi
echo "- 🌙 [直链下载 (nightly.link)]($NIGHTLY_LINK)"
if [ "$READY_FOR_REVIEW" = "true" ]; then
echo ""
echo "## 🎉 审查建议"
echo "- ✅ 构建验证通过,代码可以正常编译"
echo "- 🔍 请进行代码审查"
echo "- 🧪 建议测试构建产物功能"
fi
else
if [ "$READY_FOR_REVIEW" = "true" ]; then
echo ""
echo "## ⚠️ 审查阻塞"
echo "- ❌ 构建失败,需要修复后才能继续审查"
echo "- 🔧 请检查构建错误并修复"
echo "- 📝 修复后重新标记为准备审查"
fi
fi
echo ""
echo "---"
echo "<!-- github-action-pr-build -->"
echo "<!-- build-id: ${{ github.run_id }} -->"
echo "<!-- event-type: ${{ github.event.action }} -->"
echo "<!-- pr-head-sha: $PR_HEAD_SHA -->"
echo "<!-- merge-sha: ${{ github.sha }} -->"
echo ""
echo "<sub>🤖 GitHub Actions 自动生成 • 最后更新: $(date -u +'%Y-%m-%d %H:%M:%S UTC')</sub>"
} > final_comment.txt
# 输出多行内容
final_content=$(cat final_comment.txt)
echo "final_body<<EOF" >> $GITHUB_OUTPUT
echo "$final_content" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "最终评论内容已生成"
- name: Update Final Comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ needs.pr-preview-comment.outputs.comment_id }}
body: ${{ steps.prepare-final-comment.outputs.final_body }}
edit-mode: replace
final-check:
name: Final Check (Manual Trigger)
if: always() && github.event_name == 'workflow_dispatch'
needs: [build-and-package]
runs-on: ubuntu-latest
steps:
- name: Check Build Result
id: check-build
run: |
BUILD_SUCCESS="${{ needs.build-and-package.outputs.build_result }}"
if [ "$BUILD_SUCCESS" = "true" ]; then
echo "✅ 构建成功 - 工作流完成"
echo "status=success" >> $GITHUB_OUTPUT
else
echo "❌ 构建失败 - 抛出错误"
echo "status=failure" >> $GITHUB_OUTPUT
exit 1
fi
- name: Create Summary (if successful)
if: steps.check-build.outputs.status == 'success'
run: |
echo "# 🎉 手动构建完成" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**构建状态:** ✅ 成功" >> $GITHUB_STEP_SUMMARY
echo "**提交:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "**运行编号:** #${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "[📦 下载构建产物](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**直链下载 (nightly.link):**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "[🌙 nightly.link 下载链接](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/app-package.zip)" >> $GITHUB_STEP_SUMMARY
+580
View File
@@ -0,0 +1,580 @@
name: Pre-release and Changelog
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
- build
prerelease:
description: 'Create as pre-release'
required: true
default: true
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}-${{ github.sha }}
cancel-in-progress: true
jobs:
prepare:
runs-on: windows-latest
outputs:
tag_name: ${{ steps.get_tag.outputs.tag_name }}
version: ${{ steps.get_tag.outputs.version }}
is_prerelease: ${{ steps.release_type.outputs.is_prerelease }}
changelog: ${{ steps.read_changelog.outputs.changelog }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
# ========== 获取当前版本 ==========
- name: Get current version from Git tag
id: get_version
run: |
# 获取最新的tag
$latestTag = git describe --tags --abbrev=0 2>$null
if ($latestTag) {
$version = $latestTag
echo "Found latest tag: $latestTag"
} else {
# 如果没有tag,使用默认值
$version = "1.0.0.0"
echo "No tag found, using default version: $version"
}
echo "current_version=$version" >> $env:GITHUB_OUTPUT
echo "Current version: $version"
# ========== 处理版本号和标签名 ==========
- name: Get tag name and version
id: get_tag
run: |
if ("${{ github.event_name }}" -eq "push") {
# 从 push tag 事件获取原始标签名
$tagName = "${{ github.ref }}".Replace("refs/tags/", "")
$cleanVersion = $tagName
echo "tag_name=$tagName" >> $env:GITHUB_OUTPUT
echo "version=$cleanVersion" >> $env:GITHUB_OUTPUT
echo "Using pushed tag: $tagName, version: $cleanVersion"
} else {
# 从 workflow_dispatch 计算新版本(4位格式)
$currentVersion = "${{ steps.get_version.outputs.current_version }}"
$versionParts = $currentVersion.Split('.')
# 确保版本号格式正确(至少4部分)
if ($versionParts.Length -ge 4) {
$major = [int]$versionParts[0]
$minor = [int]$versionParts[1]
$patch = [int]$versionParts[2]
$build = [int]$versionParts[3]
} else {
# 如果版本号格式不正确,补充为4位
if ($versionParts.Length -ge 3) {
$major = [int]$versionParts[0]
$minor = [int]$versionParts[1]
$patch = [int]$versionParts[2]
$build = 0
} else {
# 如果版本号格式不正确,抛出错误
echo "Error: Invalid version format. Expected format: x.y.z.w (e.g., 1.7.18.0)"
exit 1
}
}
$versionType = "${{ github.event.inputs.version_type }}"
$isPrerelease = "${{ github.event.inputs.prerelease }}" -eq "true"
switch ($versionType) {
"major" {
$major++
$minor = 0
$patch = 0
$build = 0
}
"minor" {
$minor++
$patch = 0
$build = 0
}
"patch" {
$patch++
$build = 0
}
"build" {
$build++
}
}
# 生成新版本号(4位格式,如1.7.18.0)
$newVersion = "$major.$minor.$patch.$build"
# 根据是否为预发布决定版本号最后一位
# 如果是预发布,确保最后一位不为0(使用1)
if ($isPrerelease -and $build -eq 0) {
$build = 1
$newVersion = "$major.$minor.$patch.$build"
}
$tagName = $newVersion
echo "tag_name=$tagName" >> $env:GITHUB_OUTPUT
echo "version=$newVersion" >> $env:GITHUB_OUTPUT
echo "New tag: $tagName, version: $newVersion"
}
- name: Determine release type
id: release_type
run: |
if ("${{ github.event_name }}" -eq "push") {
# 根据版本号最后一位确定是否为预发布版本
# 最后一位为0表示正式版本,非0表示预发布版本
$version = "${{ steps.get_tag.outputs.version }}"
$versionParts = $version.Split('.')
if ($versionParts.Length -ge 4) {
$build = [int]$versionParts[3]
if ($build -eq 0) {
echo "is_prerelease=false" >> $env:GITHUB_OUTPUT
echo "This is a release"
} else {
echo "is_prerelease=true" >> $env:GITHUB_OUTPUT
echo "This is a pre-release (beta)"
}
} else {
echo "is_prerelease=false" >> $env:GITHUB_OUTPUT
echo "This is a release (invalid version format)"
}
} else {
# workflow_dispatch 方式
echo "is_prerelease=${{ github.event.inputs.prerelease }}" >> $env:GITHUB_OUTPUT
}
# ========== 使用 git-cliff 生成变更日志 ==========
- name: Generate changelog with git-cliff (for pushed tag)
if: github.event_name == 'push'
id: git_cliff_tag
uses: orhun/git-cliff-action@v4
with:
config: build/cliff.toml # 使用项目build目录的 cliff.toml 配置
args: --latest --tag ${{ steps.get_tag.outputs.tag_name }} --output CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate changelog with git-cliff (for workflow_dispatch)
if: github.event_name == 'workflow_dispatch'
id: git_cliff_unreleased
uses: orhun/git-cliff-action@v4
with:
config: build/cliff.toml
args: --unreleased --tag ${{ steps.get_tag.outputs.tag_name }} --output CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Read changelog content
id: read_changelog
run: |
$changelogContent = Get-Content -Path CHANGELOG.md -Raw
echo "changelog<<EOF" >> $env:GITHUB_OUTPUT
echo $changelogContent >> $env:GITHUB_OUTPUT
echo "EOF" >> $env:GITHUB_OUTPUT
build:
needs: prepare
if: success()
runs-on: windows-latest
outputs:
archive_name: ${{ steps.create_archive.outputs.archive_name }}
zip_size: ${{ steps.calculate_size.outputs.zip_size }}
zip_hash: ${{ steps.calculate_size.outputs.zip_hash }}
installer_size: ${{ steps.calculate_installer_size.outputs.installer_size }}
installer_hash: ${{ steps.calculate_installer_size.outputs.installer_hash }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Setup NuGet
uses: NuGet/setup-nuget@v2.0.1
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Install Inno Setup Unofficial Language Files
run: |
# 创建临时目录用于下载文件
New-Item -ItemType Directory -Path "temp_lang" -Force
# 下载英语英国版语言文件
Invoke-WebRequest -Uri "https://github.com/jrsoftware/issrc/raw/refs/heads/main/Files/Languages/Unofficial/EnglishBritish.isl" -OutFile "temp_lang\EnglishBritish.isl"
# 下载简体中文版语言文件
Invoke-WebRequest -Uri "https://github.com/jrsoftware/issrc/raw/refs/heads/main/Files/Languages/Unofficial/ChineseSimplified.isl" -OutFile "temp_lang\ChineseSimplified.isl"
# 将文件移动到 Inno Setup 的语言目录
Move-Item -Path "temp_lang\EnglishBritish.isl" -Destination "C:\Program Files (x86)\Inno Setup 6\Languages\EnglishBritish.isl" -Force
Move-Item -Path "temp_lang\ChineseSimplified.isl" -Destination "C:\Program Files (x86)\Inno Setup 6\Languages\ChineseSimplified.isl" -Force
# 清理临时目录
Remove-Item -Path "temp_lang" -Recurse -Force
Write-Host "✅ Inno Setup unofficial language files installed successfully" -ForegroundColor Green
- name: Cache NuGet packages and obj files
id: cache-nuget
uses: actions/cache@v4
with:
path: |
# NuGet 全局包缓存(已下载的包)
~/.nuget/packages
# NuGet 缓存目录(包索引)
~\AppData\Local\NuGet\Cache
# 项目 obj 目录(包含 project.assets.json
Ink Canvas/obj/
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/packages.config', '**/*.sln') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore NuGet packages (if cache missed)
if: steps.cache-nuget.outputs.cache-hit != 'true'
run: |
Write-Host "📥 缓存未命中,正在恢复 NuGet 包..." -ForegroundColor Yellow
# 恢复解决方案级别的包
nuget restore "Ink Canvas.sln" -Verbosity minimal
# 恢复项目级别的包
msbuild -t:restore "Ink Canvas/InkCanvasForClass.csproj" /p:GitFlow="Github Action" /p:RestorePackagesConfig=true /verbosity:minimal
Write-Host "✅ NuGet 包恢复完成" -ForegroundColor Green
- name: Display version info
run: |
echo "Building version: ${{ needs.prepare.outputs.version }}"
echo "Tag: ${{ needs.prepare.outputs.tag_name }}"
echo "Release type: ${{ needs.prepare.outputs.is_prerelease == 'true' && 'Pre-release' || 'Release' }}"
- name: Build the Solution
run: |
Write-Host "🔨 正在构建项目..." -ForegroundColor Cyan
msbuild /p:platform="AnyCPU" /p:configuration="Release" /p:GitFlow="Github Action" "Ink Canvas/InkCanvasForClass.csproj" /m /p:UseMultiToolTask=true /p:EnforceProcessCountAcrossBuilds=true /verbosity:minimal
Write-Host "🏗️ 构建命令执行完成" -ForegroundColor Cyan
- name: Create Release Archive
id: create_archive
run: |
$version = "${{ needs.prepare.outputs.version }}"
$archiveName = "InkCanvasForClass.CE.$version.zip"
# 创建发布目录
New-Item -ItemType Directory -Path "release" -Force
# 复制发布文件
Copy-Item "Ink Canvas\bin\Release\net472\*" "release\" -Recurse -Force
# 创建压缩包
Compress-Archive -Path "release\*" -DestinationPath $archiveName -Force
echo "archive_name=$archiveName" >> $env:GITHUB_OUTPUT
- name: Prepare Inno Setup script
run: |
$version = "${{ needs.prepare.outputs.version }}"
# 更新 ISS 文件中的版本信息
$issPath = "build\InkCanvasForClass CE.iss"
$issContent = Get-Content -Path $issPath -Raw
# 替换版本信息
$issContent = $issContent -replace '#define MyAppVersion ".*"', "#define MyAppVersion `"$version`""
# 替换源文件路径为相对路径(考虑到ISS文件在build目录下,需要返回上级目录)
$issContent = $issContent -replace 'Source: ".*\\{#MyAppExeName}";', 'Source: "..\release\{#MyAppExeName}";'
$issContent = $issContent -replace 'Source: ".*\\InkCanvasForClass.exe.config";', 'Source: "..\release\InkCanvasForClass.exe.config";'
# 更新输出目录为当前目录
$issContent = $issContent -replace 'OutputDir=.*', 'OutputDir=.'
# 更新默认安装目录
$issContent = $issContent -replace 'DefaultDirName=.*', 'DefaultDirName={autopf}\{#MyAppName}'
# 更新许可证文件路径为相对路径(考虑到ISS文件在build目录下,需要返回上级目录)
$issContent = $issContent -replace 'LicenseFile=.*', 'LicenseFile=..\LICENSE'
# 保存修改后的 ISS 文件
$issContent | Set-Content -Path $issPath -Encoding UTF8
# 显示修改后的 ISS 文件内容
Write-Host "Modified ISS file content:"
Write-Host $issContent
- name: Build MSI installer with Inno Setup
uses: Minionguyjpro/Inno-Setup-Action@v1.2.2
with:
path: build\InkCanvasForClass CE.iss
options: /O.
- name: Rename installer file
run: |
$version = "${{ needs.prepare.outputs.version }}"
$setupFile = "InkCanvasForClass CE Setup.exe"
$newSetupName = "InkCanvasForClass.CE.$version.Setup.exe"
if (Test-Path $setupFile) {
Rename-Item -Path $setupFile -NewName $newSetupName
Write-Host "Renamed setup file to: $newSetupName"
} else {
Write-Host "Setup file not found: $setupFile"
}
- name: Calculate archive size and hash
id: calculate_size
run: |
$version = "${{ needs.prepare.outputs.version }}"
$archiveName = "InkCanvasForClass.CE.$version.zip"
# 获取文件大小(字节)
$fileSize = (Get-Item $archiveName).Length
# 计算SHA256哈希
$hash = (Get-FileHash $archiveName -Algorithm SHA256).Hash
echo "zip_size=$fileSize" >> $env:GITHUB_OUTPUT
echo "zip_hash=$hash" >> $env:GITHUB_OUTPUT
echo "Archive size: $fileSize bytes"
echo "SHA256 hash: $hash"
- name: Calculate installer size and hash
id: calculate_installer_size
run: |
$version = "${{ needs.prepare.outputs.version }}"
$installerName = "InkCanvasForClass.CE.$version.Setup.exe"
if (Test-Path $installerName) {
# 获取文件大小(字节)
$fileSize = (Get-Item $installerName).Length
# 计算SHA256哈希
$hash = (Get-FileHash $installerName -Algorithm SHA256).Hash
echo "installer_size=$fileSize" >> $env:GITHUB_OUTPUT
echo "installer_hash=$hash" >> $env:GITHUB_OUTPUT
echo "Installer size: $fileSize bytes"
echo "SHA256 hash: $hash"
} else {
echo "Installer file not found: $installerName"
}
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-files-${{ needs.prepare.outputs.version }}
path: |
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.zip
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.Setup.exe
sign:
needs: [prepare, build]
if: success()
runs-on: ubuntu-latest # 改为 Ubuntu 以使用 Python 签名工具
outputs:
signatures_created: ${{ steps.sign_artifacts.outputs.signatures_created }}
zip_sigstore_file: "InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.zip.sigstore.json"
installer_sigstore_file: "InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.Setup.exe.sigstore.json"
zip_sigstore_hash: ${{ steps.calculate_zip_sig_hash.outputs.sigstore_hash }}
installer_sigstore_hash: ${{ steps.calculate_installer_sig_hash.outputs.sigstore_hash }}
permissions:
contents: write
id-token: write # 需要这个权限来验证签名
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-files-${{ needs.prepare.outputs.version }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Sign release artifacts with sigstore-python
id: sign_artifacts
uses: sigstore/gh-action-sigstore-python@v3.2.0
with:
inputs: |
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.zip
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.Setup.exe
release-signing-artifacts: true
upload-signing-artifacts: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check generated signature files
run: |
version="${{ needs.prepare.outputs.version }}"
echo "Checking for generated signature files..."
ls -la *.sig* || true
echo "Current directory contents:"
pwd
ls -la
- name: Calculate ZIP signature hash
id: calculate_zip_sig_hash
run: |
version="${{ needs.prepare.outputs.version }}"
sigstoreFile="InkCanvasForClass.CE.$version.zip.sigstore.json"
if [ -f "$sigstoreFile" ]; then
# 计算SHA256哈希
sigstoreHash=$(sha256sum "$sigstoreFile" | cut -d' ' -f1)
echo "sigstore_hash=$sigstoreHash" >> $GITHUB_OUTPUT
echo "Sigstore JSON file hash: $sigstoreHash"
echo "Sigstore file size: $(stat -c%s "$sigstoreFile") bytes"
else
echo "Warning: Sigstore file not found: $sigstoreFile"
echo "sigstore_hash=" >> $GITHUB_OUTPUT
fi
- name: Calculate Installer signature hash
id: calculate_installer_sig_hash
run: |
version="${{ needs.prepare.outputs.version }}"
sigstoreFile="InkCanvasForClass.CE.$version.Setup.exe.sigstore.json"
if [ -f "$sigstoreFile" ]; then
# 计算SHA256哈希
sigstoreHash=$(sha256sum "$sigstoreFile" | cut -d' ' -f1)
echo "sigstore_hash=$sigstoreHash" >> $GITHUB_OUTPUT
echo "Sigstore JSON file hash: $sigstoreHash"
echo "Sigstore file size: $(stat -c%s "$sigstoreFile") bytes"
else
echo "Warning: Sigstore file not found: $sigstoreFile"
echo "sigstore_hash=" >> $GITHUB_OUTPUT
fi
- name: Upload Signed Artifacts
if: steps.calculate_zip_sig_hash.outputs.sigstore_hash != '' || steps.calculate_installer_sig_hash.outputs.sigstore_hash != ''
uses: actions/upload-artifact@v4
with:
name: signed-files-${{ needs.prepare.outputs.version }}
path: |
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.zip.sigstore.json
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.Setup.exe.sigstore.json
release:
needs: [prepare, build, sign]
if: success()
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-files-${{ needs.prepare.outputs.version }}
- name: Download Signed Artifacts (if exists)
uses: actions/download-artifact@v4
with:
name: signed-files-${{ needs.prepare.outputs.version }}
continue-on-error: true
- name: Create enhanced changelog with file table
id: enhanced_changelog
run: |
version="${{ needs.prepare.outputs.version }}"
# 读取git-cliff生成的changelog内容
originalChangelog="${{ needs.prepare.outputs.changelog }}"
# 构建文件信息表格
fileTable=$'\n## 文件信息 (File Information)\n'
fileTable+=$'| 文件名 | 大小 | SHA256 哈希 |\n'
fileTable+=$'|--------|------|-------------|\n'
# ZIP 文件信息
fileTable+=$'| InkCanvasForClass.CE.'"$version"
fileTable+=$'.zip | ${{ needs.build.outputs.zip_size }} bytes | ${{ needs.build.outputs.zip_hash }} |\n'
# 安装包文件信息
installerSize="${{ needs.build.outputs.installer_size }}"
installerHash="${{ needs.build.outputs.installer_hash }}"
if [ -n "$installerSize" ] && [ -n "$installerHash" ]; then
fileTable+=$'| InkCanvasForClass.CE.'"$version"'.Setup.exe | '"$installerSize"' bytes | '"$installerHash"
fileTable+=$' |\n'
fi
# 检查是否有签名文件
if [ -f "InkCanvasForClass.CE.$version.zip.sigstore.json" ]; then
sigstoreSize=$(stat -c%s "InkCanvasForClass.CE.$version.zip.sigstore.json")
sigstoreHash=$(sha256sum "InkCanvasForClass.CE.$version.zip.sigstore.json" | cut -d' ' -f1)
fileTable+=$'| InkCanvasForClass.CE.'"$version"'.zip.sigstore.json | '"$sigstoreSize"' bytes | '"$sigstoreHash"
fileTable+=$' |\n'
fi
# 检查安装程序签名文件
if [ -f "InkCanvasForClass.CE.$version.Setup.exe.sigstore.json" ]; then
sigstoreSize=$(stat -c%s "InkCanvasForClass.CE.$version.Setup.exe.sigstore.json")
sigstoreHash=$(sha256sum "InkCanvasForClass.CE.$version.Setup.exe.sigstore.json" | cut -d' ' -f1)
fileTable+=$'| InkCanvasForClass.CE.'"$version"'.Setup.exe.sigstore.json | '"$sigstoreSize"' bytes | '"$sigstoreHash"
fileTable+=$' |\n'
fi
fileTable+=$'\n*文件哈希和大小信息由GitHub Actions自动生成*\n'
# 将表格附加到原始changelog
enhancedChangelog="${originalChangelog}${fileTable}"
# 输出增强版changelog内容
echo "enhanced_changelog<<EOF" >> $GITHUB_OUTPUT
echo "$enhancedChangelog" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "Enhanced changelog created with file information table"
- name: Display Release Info
run: |
echo "=== Creating Release ==="
echo "Version: ${{ needs.prepare.outputs.version }}"
echo "Tag: ${{ needs.prepare.outputs.tag_name }}"
echo "Pre-release: ${{ needs.prepare.outputs.is_prerelease }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.tag_name }}
name: ICC CE ${{ needs.prepare.outputs.version }}
body: |
${{ steps.enhanced_changelog.outputs.enhanced_changelog }}
draft: false
prerelease: ${{ needs.prepare.outputs.is_prerelease == 'true' }}
files: |
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.zip
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.Setup.exe
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.zip.sigstore.json
InkCanvasForClass.CE.${{ needs.prepare.outputs.version }}.Setup.exe.sigstore.json
fail_on_unmatched_files: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+427 -3
View File
@@ -1,4 +1,428 @@
obj/
bin/
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
*.env
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Dd]ebug/x64/
[Dd]ebugPublic/x64/
[Rr]elease/x64/
[Rr]eleases/x64/
bin/x64/
obj/x64/
[Dd]ebug/x86/
[Dd]ebugPublic/x86/
[Rr]elease/x86/
[Rr]eleases/x86/
bin/x86/
obj/x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
[Aa][Rr][Mm]64[Ee][Cc]/
bld/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Build results on 'Bin' directories
**/[Bb]in/*
# Uncomment if you have tasks that rely on *.refresh files to move binaries
# (https://github.com/github/gitignore/pull/3736)
#!**/[Bb]in/*.refresh
# Visual Studio 2015/2017 cache/options directory
.vs/
/Ink Canvas/obj
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*.trx
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Approval Tests result files
*.received.*
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.idb
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
# but not Directory.Build.rsp, as it configures directory-level build defaults
!Directory.Build.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
**/.paket/paket.exe
paket-files/
# FAKE - F# Make
**/.fake/
# CodeRush personal settings
**/.cr/personal
# Python Tools for Visual Studio (PTVS)
**/__pycache__/
*.pyc
# Cake - Uncomment if you are using it
#tools/**
#!tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
MSBuild_Logs/
# AWS SAM Build and Temporary Artifacts folder
.aws-sam
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
**/.mfractor/
# Local History for Visual Studio
**/.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
**/.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
+1 -1
View File
@@ -1 +1 @@
1.7.11.0
1.7.18.0
-4
View File
@@ -1,4 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/PencilsConfiguration/ActualSeverity/@EntryValue">WARNING</s:String>
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe</s:String>
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">1114112</s:Int64></wpf:ResourceDictionary>
+1 -2
View File
@@ -232,12 +232,11 @@
ContextMenu="{StaticResource SysTrayMenu}"
IconSource="/Resources/icc.ico"/>
<ResourceDictionary.MergedDictionaries>
<ui:ThemeResources RequestedTheme="Light"/>
<ui:ThemeResources/>
<ui:XamlControlsResources />
<ResourceDictionary Source="Resources/SeewoImageDictionary.xaml"/>
<ResourceDictionary Source="Resources/DrawShapeImageDictionary.xaml"/>
<ResourceDictionary Source="Resources/IconImageDictionary.xaml"/>
<ResourceDictionary Source="Resources/Styles/Light.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
+317 -614
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CJK_mkp")]
[assembly: AssemblyProduct("InkCanvasForClass")]
[assembly: AssemblyCopyright("Copyright © HARKOTEK Studio 2024")]
[assembly: AssemblyCopyright("Copyright © CJK_mkp 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -49,5 +49,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.11.0")]
[assembly: AssemblyFileVersion("1.7.11.0")]
[assembly: AssemblyVersion("1.7.18.3")]
[assembly: AssemblyFileVersion("1.7.18.3")]
@@ -0,0 +1,86 @@
<UserControl x:Class="Ink_Canvas.Controls.QuickDrawFloatingButtonControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Width="65" Height="45">
<UserControl.Resources>
<ResourceDictionary>
<!-- 悬浮按钮资源 -->
<SolidColorBrush x:Key="QuickDrawFloatingButtonBackground" Color="#80000000"/>
<SolidColorBrush x:Key="QuickDrawFloatingButtonBorderBrush" Color="#40000000"/>
<SolidColorBrush x:Key="QuickDrawFloatingButtonIconForeground" Color="White"/>
</ResourceDictionary>
</UserControl.Resources>
<Border Background="{DynamicResource QuickDrawFloatingButtonBackground}"
CornerRadius="8"
BorderThickness="1"
BorderBrush="{DynamicResource QuickDrawFloatingButtonBorderBrush}">
<Border.Effect>
<DropShadowEffect Color="Black" Direction="315" ShadowDepth="3" Opacity="0.3" BlurRadius="5"/>
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="22"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 拖动区域 -->
<Border Grid.Column="0"
MouseLeftButtonDown="DragArea_MouseLeftButtonDown"
MouseMove="DragArea_MouseMove"
MouseLeftButtonUp="DragArea_MouseLeftButtonUp"
Cursor="SizeAll"
Background="Transparent">
<Grid VerticalAlignment="Center" Height="14" IsHitTestVisible="False">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="4"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="4"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 三个白色横线 -->
<Border Grid.Row="0" Background="{DynamicResource QuickDrawFloatingButtonIconForeground}" Height="2" Width="10"
HorizontalAlignment="Center"
CornerRadius="1" Opacity="0.8" IsHitTestVisible="False"/>
<Border Grid.Row="2" Background="{DynamicResource QuickDrawFloatingButtonIconForeground}" Height="2" Width="10"
HorizontalAlignment="Center"
CornerRadius="1" Opacity="0.8" IsHitTestVisible="False"/>
<Border Grid.Row="4" Background="{DynamicResource QuickDrawFloatingButtonIconForeground}" Height="2" Width="10"
HorizontalAlignment="Center"
CornerRadius="1" Opacity="0.8" IsHitTestVisible="False"/>
</Grid>
</Border>
<!-- 半透明分割线 -->
<Rectangle Grid.Column="1" Width="1" Fill="#20FFFFFF" Margin="0,8,0,8"/>
<!-- 按钮区域 -->
<Border Grid.Column="2"
MouseLeftButtonDown="FloatingButton_Click"
Cursor="Hand"
Background="Transparent">
<Grid IsHitTestVisible="False">
<Path Data="M5 7C5 8.06087 5.42143 9.07828 6.17157 9.82843C6.92172 10.5786 7.93913 11 9 11C10.0609 11 11.0783 10.5786 11.8284 9.82843C12.5786 9.07828 13 8.06087 13 7C13 5.93913 12.5786 4.92172 11.8284 4.17157C11.0783 3.42143 10.0609 3 9 3C7.93913 3 6.92172 3.42143 6.17157 4.17157C5.42143 4.92172 5 5.93913 5 7Z M3 21V19C3 17.9391 3.42143 16.9217 4.17157 16.1716C4.92172 15.4214 5.93913 15 7 15H11C12.0609 15 13.0783 15.4214 13.8284 16.1716C14.5786 16.9217 15 17.9391 15 19V21 M16 3.13C16.8604 3.35031 17.623 3.85071 18.1676 4.55232C18.7122 5.25392 19.0078 6.11683 19.0078 7.005C19.0078 7.89318 18.7122 8.75608 18.1676 9.45769C17.623 10.1593 16.8604 10.6597 16 10.88 M21 21V19C20.9949 18.1172 20.6979 17.2608 20.1553 16.5644C19.6126 15.868 18.8548 15.3707 18 15.15"
Stroke="{DynamicResource QuickDrawFloatingButtonIconForeground}"
StrokeThickness="2"
StrokeLineJoin="Round"
Fill="Transparent"
Width="20" Height="20"
Stretch="Uniform"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsHitTestVisible="False"/>
</Grid>
</Border>
</Grid>
</Border>
</UserControl>
@@ -0,0 +1,148 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using HorizontalAlignment = System.Windows.HorizontalAlignment;
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
using VerticalAlignment = System.Windows.VerticalAlignment;
namespace Ink_Canvas.Controls
{
/// <summary>
/// 快抽悬浮按钮控件
/// </summary>
public partial class QuickDrawFloatingButtonControl : UserControl
{
private bool _isDragging = false;
private Point _dragStartPoint;
private Point _controlStartPoint;
public QuickDrawFloatingButtonControl()
{
InitializeComponent();
}
/// <summary>
/// 快抽按钮点击事件
/// </summary>
private void FloatingButton_Click(object sender, MouseButtonEventArgs e)
{
try
{
// 如果正在拖动,不触发点击事件
if (_isDragging) return;
// 打开快抽窗口
var quickDrawWindow = new QuickDrawWindow();
quickDrawWindow.ShowDialog();
}
catch (Exception ex)
{
Helpers.LogHelper.WriteLogToFile($"打开快抽窗口失败: {ex.Message}", Helpers.LogHelper.LogType.Error);
}
}
/// <summary>
/// 拖动区域鼠标按下事件
/// </summary>
private void DragArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
_isDragging = false;
// 记录鼠标在屏幕上的初始位置
_dragStartPoint = this.PointToScreen(e.GetPosition(this));
// 记录控件的初始位置
var parent = this.Parent as FrameworkElement;
if (parent != null)
{
var transform = this.TransformToVisual(parent);
var currentPos = transform.Transform(new Point(0, 0));
_controlStartPoint = currentPos;
}
else
{
var currentMargin = this.Margin;
_controlStartPoint = new Point(
double.IsNaN(currentMargin.Left) ? 0 : currentMargin.Left,
double.IsNaN(currentMargin.Top) ? 0 : currentMargin.Top);
}
((UIElement)sender).CaptureMouse();
e.Handled = true;
}
/// <summary>
/// 拖动区域鼠标移动事件
/// </summary>
private void DragArea_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed && ((UIElement)sender).IsMouseCaptured)
{
// 获取鼠标在屏幕上的当前位置
Point currentScreenPoint = this.PointToScreen(e.GetPosition(this));
Vector diff = currentScreenPoint - _dragStartPoint;
if (!_isDragging && (Math.Abs(diff.X) > 3 || Math.Abs(diff.Y) > 3))
{
_isDragging = true;
// 切换到绝对定位模式
this.HorizontalAlignment = HorizontalAlignment.Left;
this.VerticalAlignment = VerticalAlignment.Top;
}
if (_isDragging)
{
// 计算新位置
var parent = this.Parent as FrameworkElement;
if (parent != null)
{
// 计算屏幕坐标相对于父容器的位置
var parentPoint = parent.PointFromScreen(currentScreenPoint);
var startParentPoint = parent.PointFromScreen(_dragStartPoint);
// 计算相对于初始位置的偏移
double offsetX = parentPoint.X - startParentPoint.X;
double offsetY = parentPoint.Y - startParentPoint.Y;
// 新位置 = 初始位置 + 偏移
double newLeft = _controlStartPoint.X + offsetX;
double newTop = _controlStartPoint.Y + offsetY;
// 限制在父容器范围内
newLeft = Math.Max(0, Math.Min(newLeft, parent.ActualWidth - this.ActualWidth));
newTop = Math.Max(0, Math.Min(newTop, parent.ActualHeight - this.ActualHeight));
// 更新Margin
this.Margin = new Thickness(newLeft, newTop, 0, 0);
}
}
}
}
/// <summary>
/// 拖动区域鼠标释放事件
/// </summary>
private void DragArea_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (((UIElement)sender).IsMouseCaptured)
{
((UIElement)sender).ReleaseMouseCapture();
}
if (_isDragging)
{
Dispatcher.BeginInvoke(new Action(() => { _isDragging = false; }),
DispatcherPriority.Background);
}
else
{
_isDragging = false;
}
e.Handled = true;
}
}
}
-176
View File
@@ -1,176 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>Obsolete, use UnmanagedWinX86Assemblies instead</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinX86Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X86 (32 bit) assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>Obsolete, use UnmanagedWinX64Assemblies instead.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinX64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X64 (64 bit) assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinArm64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableEventSubscription" type="xs:boolean">
<xs:annotation>
<xs:documentation>The attach method no longer subscribes to the `AppDomain.AssemblyResolve` (.NET 4.x) and `AssemblyLoadContext.Resolving` (.NET 6.0+) events.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>Obsolete, use UnmanagedWinX86Assemblies instead</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UnmanagedWinX86Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X86 (32 bit) assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>Obsolete, use UnmanagedWinX64Assemblies instead</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UnmanagedWinX64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X64 (64 bit) assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UnmanagedWinArm64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
+385 -30
View File
@@ -95,18 +95,22 @@ namespace Ink_Canvas.Helpers
// 使用改进的贝塞尔曲线拟合
var smoothedPoints = ApplyImprovedBezierSmoothing(originalPoints);
System.Diagnostics.Debug.WriteLine($"AsyncAdvancedBezierSmoothing: 原始点数={originalPoints.Length}, 平滑后点数={smoothedPoints.Length}");
cancellationToken.ThrowIfCancellationRequested();
// 严格控制点数,避免产生过多点
if (smoothedPoints.Length > originalPoints.Length * 2)
// 放宽点数限制
if (smoothedPoints.Length > originalPoints.Length * 3.0)
{
System.Diagnostics.Debug.WriteLine($"AsyncAdvancedBezierSmoothing: 点数过多,进行重采样");
// 如果点数增加太多,进行重采样
smoothedPoints = ResampleEquidistantOptimized(smoothedPoints, ResampleInterval);
}
// 最终检查:确保点数不会过多
if (smoothedPoints.Length > originalPoints.Length * 1.5)
// 进一步放宽最终检查
if (smoothedPoints.Length > originalPoints.Length * 2.5)
{
System.Diagnostics.Debug.WriteLine($"AsyncAdvancedBezierSmoothing: 重采样后点数仍然过多,返回原始笔画");
// 如果仍然太多点,使用原始笔画
return stroke;
}
@@ -117,6 +121,7 @@ namespace Ink_Canvas.Helpers
DrawingAttributes = stroke.DrawingAttributes.Clone()
};
System.Diagnostics.Debug.WriteLine($"AsyncAdvancedBezierSmoothing: 成功创建平滑笔画");
return smoothedStroke;
}
@@ -125,33 +130,42 @@ namespace Ink_Canvas.Helpers
/// </summary>
private StylusPoint[] ApplyImprovedBezierSmoothing(StylusPoint[] points)
{
if (points.Length < 4) return points;
if (points.Length < 6) return points; // 5次贝塞尔需要6个点
var result = new List<StylusPoint>();
// 添加第一个点
result.Add(points[0]);
// 使用非重叠的窗口进行贝塞尔曲线拟合
for (int i = 0; i < points.Length - 3; i += 3) // 每次移动3个点,避免重叠
// 使用5次贝塞尔曲线,每次移动1个点确保连续性
for (int i = 0; i < points.Length - 5; i++)
{
var p0 = points[i];
var p1 = points[Math.Min(i + 1, points.Length - 1)];
var p2 = points[Math.Min(i + 2, points.Length - 1)];
var p3 = points[Math.Min(i + 3, points.Length - 1)];
var p1 = points[i + 1];
var p2 = points[i + 2];
var p3 = points[i + 3];
var p4 = points[i + 4];
var p5 = points[i + 5];
// 计算改进的控制点
var controlPoints = CalculateImprovedControlPoints(p0, p1, p2, p3);
// 计算5次贝塞尔的控制点
var controlPoints = CalculateQuinticControlPoints(p0, p1, p2, p3, p4, p5);
// 限制插值步数,避免点数爆炸
int steps = Math.Min(UseAdaptiveInterpolation ?
CalculateAdaptiveSteps(p0, p1, p2, p3) : InterpolationSteps, 16);
// 生成贝塞尔曲线点,但跳过第一个点避免重复
for (int j = 1; j <= steps; j++)
// 生成插值点
if (i == 0)
{
double t = (double)j / steps;
var bezierPoint = CubicBezierWithControlPoints(controlPoints, t, p0, p3);
// 第一个窗口:生成更多插值点
for (int j = 1; j <= 4; j++)
{
double t = (double)j / 5;
var bezierPoint = CalculateQuinticBezierPoint(p0, controlPoints, p5, t);
result.Add(bezierPoint);
}
}
else
{
// 后续窗口:只生成最后一个插值点,避免重复
double t = 4.0 / 5.0; // 只取最后一个插值点
var bezierPoint = CalculateQuinticBezierPoint(p0, controlPoints, p5, t);
result.Add(bezierPoint);
}
}
@@ -159,8 +173,209 @@ namespace Ink_Canvas.Helpers
// 添加最后一个点
result.Add(points[points.Length - 1]);
// 去重和优化点数
return RemoveDuplicatePoints(result.ToArray());
System.Diagnostics.Debug.WriteLine($"ApplyImprovedBezierSmoothing: 原始点数={points.Length}, 生成点数={result.Count}");
// 使用更宽松的去重
return RemoveDuplicatePointsLoose(result.ToArray());
}
/// <summary>
/// 5次贝塞尔曲线控制点计算
/// </summary>
private (Point cp1, Point cp2, Point cp3, Point cp4) CalculateQuinticControlPoints(
StylusPoint p0, StylusPoint p1, StylusPoint p2, StylusPoint p3, StylusPoint p4, StylusPoint p5)
{
// 计算控制点距离(基于相邻点距离)
double dist1 = Math.Sqrt((p1.X - p0.X) * (p1.X - p0.X) + (p1.Y - p0.Y) * (p1.Y - p0.Y));
double dist2 = Math.Sqrt((p2.X - p1.X) * (p2.X - p1.X) + (p2.Y - p1.Y) * (p2.Y - p1.Y));
double dist3 = Math.Sqrt((p4.X - p3.X) * (p4.X - p3.X) + (p4.Y - p3.Y) * (p4.Y - p3.Y));
double dist4 = Math.Sqrt((p5.X - p4.X) * (p5.X - p4.X) + (p5.Y - p4.Y) * (p5.Y - p4.Y));
// 使用更小的控制点距离,产生超平滑的曲线
double controlDist1 = dist1 * 0.15;
double controlDist2 = dist2 * 0.15;
double controlDist3 = dist3 * 0.15;
double controlDist4 = dist4 * 0.15;
// 计算控制点方向 - 使用更平滑的方向计算
double dir1X = p2.X - p0.X;
double dir1Y = p2.Y - p0.Y;
double dir2X = p3.X - p1.X;
double dir2Y = p3.Y - p1.Y;
double dir3X = p4.X - p2.X;
double dir3Y = p4.Y - p2.Y;
double dir4X = p5.X - p3.X;
double dir4Y = p5.Y - p3.Y;
// 归一化方向
NormalizeVector(ref dir1X, ref dir1Y);
NormalizeVector(ref dir2X, ref dir2Y);
NormalizeVector(ref dir3X, ref dir3Y);
NormalizeVector(ref dir4X, ref dir4Y);
// 计算控制点
var cp1 = new Point(p1.X + dir1X * controlDist1, p1.Y + dir1Y * controlDist1);
var cp2 = new Point(p2.X + dir2X * controlDist2, p2.Y + dir2Y * controlDist2);
var cp3 = new Point(p3.X - dir3X * controlDist3, p3.Y - dir3Y * controlDist3);
var cp4 = new Point(p4.X - dir4X * controlDist4, p4.Y - dir4Y * controlDist4);
return (cp1, cp2, cp3, cp4);
}
/// <summary>
/// 归一化向量
/// </summary>
private void NormalizeVector(ref double x, ref double y)
{
double length = Math.Sqrt(x * x + y * y);
if (length > 0)
{
x /= length;
y /= length;
}
}
/// <summary>
/// 5次贝塞尔曲线点计算
/// </summary>
private StylusPoint CalculateQuinticBezierPoint(StylusPoint p0, (Point cp1, Point cp2, Point cp3, Point cp4) controlPoints, StylusPoint p5, double t)
{
double oneMinusT = 1 - t;
double oneMinusT2 = oneMinusT * oneMinusT;
double oneMinusT3 = oneMinusT2 * oneMinusT;
double oneMinusT4 = oneMinusT3 * oneMinusT;
double oneMinusT5 = oneMinusT4 * oneMinusT;
double t2 = t * t;
double t3 = t2 * t;
double t4 = t3 * t;
double t5 = t4 * t;
// 5次贝塞尔曲线公式
double x = oneMinusT5 * p0.X +
5 * oneMinusT4 * t * controlPoints.cp1.X +
10 * oneMinusT3 * t2 * controlPoints.cp2.X +
10 * oneMinusT2 * t3 * controlPoints.cp3.X +
5 * oneMinusT * t4 * controlPoints.cp4.X +
t5 * p5.X;
double y = oneMinusT5 * p0.Y +
5 * oneMinusT4 * t * controlPoints.cp1.Y +
10 * oneMinusT3 * t2 * controlPoints.cp2.Y +
10 * oneMinusT2 * t3 * controlPoints.cp3.Y +
5 * oneMinusT * t4 * controlPoints.cp4.Y +
t5 * p5.Y;
// 压力插值 - 使用线性插值
float pressure = (float)((1 - t) * p0.PressureFactor + t * p5.PressureFactor);
return new StylusPoint(x, y, Math.Max(pressure, 0.1f));
}
/// <summary>
/// 简化的控制点计算
/// </summary>
private (Point cp1, Point cp2) CalculateSimpleControlPoints(StylusPoint p0, StylusPoint p1, StylusPoint p2, StylusPoint p3)
{
// 计算控制点距离(基于线段长度)
double dist1 = Math.Sqrt((p1.X - p0.X) * (p1.X - p0.X) + (p1.Y - p0.Y) * (p1.Y - p0.Y));
double dist2 = Math.Sqrt((p3.X - p2.X) * (p3.X - p2.X) + (p3.Y - p2.Y) * (p3.Y - p2.Y));
// 使用更小的控制点距离,产生更平滑的曲线
double controlDist1 = dist1 * 0.2; // 进一步减少控制点影响
double controlDist2 = dist2 * 0.2;
// 计算控制点方向 - 使用更平滑的方向计算
double dir1X = p2.X - p0.X; // 使用更远的点计算方向
double dir1Y = p2.Y - p0.Y;
double dir2X = p3.X - p1.X;
double dir2Y = p3.Y - p1.Y;
// 归一化方向
double len1 = Math.Sqrt(dir1X * dir1X + dir1Y * dir1Y);
double len2 = Math.Sqrt(dir2X * dir2X + dir2Y * dir2Y);
if (len1 > 0)
{
dir1X /= len1;
dir1Y /= len1;
}
if (len2 > 0)
{
dir2X /= len2;
dir2Y /= len2;
}
// 计算控制点
var cp1 = new Point(
p1.X + dir1X * controlDist1,
p1.Y + dir1Y * controlDist1
);
var cp2 = new Point(
p2.X - dir2X * controlDist2,
p2.Y - dir2Y * controlDist2
);
return (cp1, cp2);
}
/// <summary>
/// 宽松的去重算法
/// </summary>
private StylusPoint[] RemoveDuplicatePointsLoose(StylusPoint[] points)
{
if (points.Length < 2) return points;
var result = new List<StylusPoint>();
result.Add(points[0]);
double minDistance = 0.1; // 非常小的距离阈值,几乎不去重
for (int i = 1; i < points.Length; i++)
{
var lastPoint = result[result.Count - 1];
var currentPoint = points[i];
// 计算距离
double distance = Math.Sqrt(
(currentPoint.X - lastPoint.X) * (currentPoint.X - lastPoint.X) +
(currentPoint.Y - lastPoint.Y) * (currentPoint.Y - lastPoint.Y));
// 如果距离足够大,添加这个点
if (distance >= minDistance)
{
result.Add(currentPoint);
}
}
System.Diagnostics.Debug.WriteLine($"RemoveDuplicatePointsLoose: 输入点数={points.Length}, 输出点数={result.Count}");
return result.ToArray();
}
/// <summary>
/// 计算贝塞尔曲线上的点
/// </summary>
private StylusPoint CalculateBezierPoint(StylusPoint p0, Point cp1, Point cp2, StylusPoint p3, double t)
{
double x = Math.Pow(1 - t, 3) * p0.X +
3 * Math.Pow(1 - t, 2) * t * cp1.X +
3 * (1 - t) * Math.Pow(t, 2) * cp2.X +
Math.Pow(t, 3) * p3.X;
double y = Math.Pow(1 - t, 3) * p0.Y +
3 * Math.Pow(1 - t, 2) * t * cp1.Y +
3 * (1 - t) * Math.Pow(t, 2) * cp2.Y +
Math.Pow(t, 3) * p3.Y;
// 压力插值
float pressure = (float)(Math.Pow(1 - t, 3) * p0.PressureFactor +
3 * Math.Pow(1 - t, 2) * t * p0.PressureFactor +
3 * (1 - t) * Math.Pow(t, 2) * p3.PressureFactor +
Math.Pow(t, 3) * p3.PressureFactor);
return new StylusPoint(x, y, Math.Max(pressure, 0.1f));
}
/// <summary>
@@ -251,7 +466,7 @@ namespace Ink_Canvas.Helpers
var result = new List<StylusPoint>();
result.Add(points[0]);
double minDistance = ResampleInterval * 0.5; // 最小距离阈值
double minDistance = 0.3; // 进一步减少最小距离阈值,保留更多平滑点
for (int i = 1; i < points.Length; i++)
{
@@ -270,6 +485,7 @@ namespace Ink_Canvas.Helpers
}
}
System.Diagnostics.Debug.WriteLine($"RemoveDuplicatePoints: 输入点数={points.Length}, 输出点数={result.Count}");
return result.ToArray();
}
@@ -516,23 +732,31 @@ namespace Ink_Canvas.Helpers
/// </summary>
public class AdvancedBezierSmoothing
{
public double SmoothingStrength { get; set; } = 0.3;
public double ResampleInterval { get; set; } = 3.0;
public int InterpolationSteps { get; set; } = 8;
public double SmoothingStrength { get; set; } = 0.6;
public double ResampleInterval { get; set; } = 2.0;
public int InterpolationSteps { get; set; } = 12;
public Stroke SmoothStroke(Stroke stroke)
{
if (stroke == null || stroke.StylusPoints.Count < 3)
{
System.Diagnostics.Debug.WriteLine($"AdvancedBezierSmoothing: 笔画点数不足,跳过平滑 (点数: {stroke?.StylusPoints.Count ?? 0})");
return stroke;
}
var originalPoints = stroke.StylusPoints.ToList();
System.Diagnostics.Debug.WriteLine($"AdvancedBezierSmoothing: 开始平滑处理,原始点数: {stroke.StylusPoints.Count}");
// 简化处理:只进行轻度平滑
var smoothedPoints = ApplyLightExponentialSmoothing(originalPoints, 0.2); // 很轻的平滑
var originalPoints = stroke.StylusPoints.ToArray();
// 使用真正的贝塞尔曲线平滑
var smoothedPoints = ApplyCubicBezierSmoothing(originalPoints);
System.Diagnostics.Debug.WriteLine($"AdvancedBezierSmoothing: 平滑完成,平滑后点数: {smoothedPoints.Length}");
// 检查点数是否合理
if (smoothedPoints.Count > originalPoints.Count * 1.5)
if (smoothedPoints.Length > originalPoints.Length * 10.0)
{
System.Diagnostics.Debug.WriteLine($"AdvancedBezierSmoothing: 点数增加过多,返回原始笔画 (原始:{originalPoints.Length}, 平滑后:{smoothedPoints.Length})");
return stroke; // 如果点数增加太多,返回原始笔画
}
@@ -540,9 +764,140 @@ namespace Ink_Canvas.Helpers
{
DrawingAttributes = stroke.DrawingAttributes.Clone()
};
System.Diagnostics.Debug.WriteLine($"AdvancedBezierSmoothing: 创建平滑笔画成功");
return smoothedStroke;
}
/// <summary>
/// 三次贝塞尔曲线平滑
/// </summary>
private StylusPoint[] ApplyCubicBezierSmoothing(StylusPoint[] points)
{
if (points.Length < 4) return points;
var result = new List<StylusPoint>();
result.Add(points[0]);
// 使用更保守的窗口大小和插值
int windowSize = Math.Min(4, points.Length);
int stepSize = Math.Max(1, points.Length / 10); // 根据点数动态调整步长
for (int i = 0; i <= points.Length - windowSize; i += stepSize)
{
if (i + windowSize - 1 >= points.Length) break;
var p0 = points[i];
var p1 = points[Math.Min(i + 1, points.Length - 1)];
var p2 = points[Math.Min(i + 2, points.Length - 1)];
var p3 = points[Math.Min(i + windowSize - 1, points.Length - 1)];
// 计算控制点
var controlPoints = CalculateControlPoints(p0, p1, p2, p3);
// 只生成2-3个插值点
int steps = 2;
// 生成贝塞尔曲线点
for (int j = 1; j <= steps; j++)
{
double t = (double)j / steps;
var bezierPoint = CalculateBezierPoint(p0, controlPoints.cp1, controlPoints.cp2, p3, t);
result.Add(bezierPoint);
}
}
result.Add(points[points.Length - 1]);
// 去重处理
return RemoveDuplicatePoints(result.ToArray());
}
/// <summary>
/// 去除重复点
/// </summary>
private StylusPoint[] RemoveDuplicatePoints(StylusPoint[] points)
{
if (points.Length <= 1) return points;
var result = new List<StylusPoint> { points[0] };
double minDistance = 1.0; // 最小距离阈值
for (int i = 1; i < points.Length; i++)
{
var lastPoint = result[result.Count - 1];
var currentPoint = points[i];
double distance = Math.Sqrt(Math.Pow(currentPoint.X - lastPoint.X, 2) +
Math.Pow(currentPoint.Y - lastPoint.Y, 2));
if (distance > minDistance)
{
result.Add(currentPoint);
}
}
return result.ToArray();
}
/// <summary>
/// 计算控制点
/// </summary>
private (Point cp1, Point cp2) CalculateControlPoints(StylusPoint p0, StylusPoint p1, StylusPoint p2, StylusPoint p3)
{
// 计算切线方向
var tangent1 = new Vector(p1.X - p0.X, p1.Y - p0.Y);
var tangent2 = new Vector(p3.X - p2.X, p3.Y - p2.Y);
// 归一化切线
if (tangent1.Length > 0) tangent1.Normalize();
if (tangent2.Length > 0) tangent2.Normalize();
// 计算控制点距离
double dist1 = Math.Sqrt((p1.X - p0.X) * (p1.X - p0.X) + (p1.Y - p0.Y) * (p1.Y - p0.Y));
double dist2 = Math.Sqrt((p3.X - p2.X) * (p3.X - p2.X) + (p3.Y - p2.Y) * (p3.Y - p2.Y));
double controlDist1 = dist1 * SmoothingStrength;
double controlDist2 = dist2 * SmoothingStrength;
// 计算控制点
var cp1 = new Point(
p1.X + tangent1.X * controlDist1,
p1.Y + tangent1.Y * controlDist1
);
var cp2 = new Point(
p2.X - tangent2.X * controlDist2,
p2.Y - tangent2.Y * controlDist2
);
return (cp1, cp2);
}
/// <summary>
/// 计算贝塞尔曲线上的点
/// </summary>
private StylusPoint CalculateBezierPoint(StylusPoint p0, Point cp1, Point cp2, StylusPoint p3, double t)
{
double x = Math.Pow(1 - t, 3) * p0.X +
3 * Math.Pow(1 - t, 2) * t * cp1.X +
3 * (1 - t) * Math.Pow(t, 2) * cp2.X +
Math.Pow(t, 3) * p3.X;
double y = Math.Pow(1 - t, 3) * p0.Y +
3 * Math.Pow(1 - t, 2) * t * cp1.Y +
3 * (1 - t) * Math.Pow(t, 2) * cp2.Y +
Math.Pow(t, 3) * p3.Y;
// 压力插值
float pressure = (float)(Math.Pow(1 - t, 3) * p0.PressureFactor +
3 * Math.Pow(1 - t, 2) * t * p0.PressureFactor +
3 * (1 - t) * Math.Pow(t, 2) * p3.PressureFactor +
Math.Pow(t, 3) * p3.PressureFactor);
return new StylusPoint(x, y, Math.Max(pressure, 0.1f));
}
/// <summary>
/// 轻度指数平滑
/// </summary>
+215
View File
@@ -0,0 +1,215 @@
using Newtonsoft.Json;
using System;
using System.IO;
using System.Linq;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// 自动备份管理器
/// 负责管理配置文件的自动备份功能
/// </summary>
public static class AutoBackupManager
{
private static readonly string BackupDir = Path.Combine(App.RootPath, "Backups");
private static readonly string SettingsFile = Path.Combine(App.RootPath, "Configs", "Settings.json");
private static readonly string BackupPrefix = "Settings_AutoBackup_";
/// <summary>
/// 检查是否需要执行自动备份
/// </summary>
/// <param name="settings">设置对象</param>
/// <returns>如果需要备份返回true,否则返回false</returns>
public static bool ShouldPerformAutoBackup(Settings settings)
{
try
{
// 如果自动备份功能未启用,不执行备份
if (!settings.Advanced.IsAutoBackupEnabled)
{
return false;
}
// 如果从未备份过,需要创建首次备份
if (settings.Advanced.LastAutoBackupTime == DateTime.MinValue)
{
return true;
}
// 检查是否已超过备份间隔
var daysSinceLastBackup = (DateTime.Now - settings.Advanced.LastAutoBackupTime).TotalDays;
return daysSinceLastBackup >= settings.Advanced.AutoBackupIntervalDays;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"检查自动备份条件时出错: {ex.Message}", LogHelper.LogType.Error);
return false;
}
}
/// <summary>
/// 执行自动备份
/// </summary>
/// <param name="settings">设置对象</param>
/// <returns>备份是否成功</returns>
public static bool PerformAutoBackup(Settings settings)
{
try
{
// 确保备份目录存在
if (!Directory.Exists(BackupDir))
{
Directory.CreateDirectory(BackupDir);
}
// 检查主配置文件是否存在
if (!File.Exists(SettingsFile))
{
LogHelper.WriteLogToFile("主配置文件不存在,跳过自动备份", LogHelper.LogType.Warning);
return false;
}
// 创建备份文件名(使用当前日期时间)
string backupFileName = $"{BackupPrefix}{DateTime.Now:yyyyMMdd_HHmmss}.json";
string backupPath = Path.Combine(BackupDir, backupFileName);
// 复制主配置文件到备份位置
File.Copy(SettingsFile, backupPath, true);
// 更新最后备份时间
settings.Advanced.LastAutoBackupTime = DateTime.Now;
MainWindow.SaveSettingsToFile();
return true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"执行自动备份时出错: {ex.Message}", LogHelper.LogType.Error);
return false;
}
}
/// <summary>
/// 尝试从备份恢复配置文件
/// </summary>
/// <returns>恢复是否成功</returns>
public static bool TryRestoreFromBackup()
{
try
{
// 确保备份目录存在
if (!Directory.Exists(BackupDir))
{
LogHelper.WriteLogToFile("备份目录不存在,无法从备份恢复", LogHelper.LogType.Warning);
return false;
}
// 查找最新的备份文件
var backupFiles = Directory.GetFiles(BackupDir, $"{BackupPrefix}*.json")
.OrderByDescending(f => File.GetCreationTime(f))
.ToArray();
if (backupFiles.Length == 0)
{
LogHelper.WriteLogToFile("没有找到可用的备份文件", LogHelper.LogType.Warning);
return false;
}
// 尝试使用最新的备份文件
string latestBackup = backupFiles[0];
// 验证备份文件是否有效
try
{
string backupJson = File.ReadAllText(latestBackup);
var testSettings = JsonConvert.DeserializeObject<Settings>(backupJson);
if (testSettings == null)
{
LogHelper.WriteLogToFile("备份文件内容无效,无法恢复", LogHelper.LogType.Error);
return false;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"备份文件验证失败: {ex.Message}", LogHelper.LogType.Error);
return false;
}
// 备份当前损坏的配置文件(如果存在)
if (File.Exists(SettingsFile))
{
string corruptedBackup = Path.Combine(BackupDir, $"Settings_Corrupted_{DateTime.Now:yyyyMMdd_HHmmss}.json");
File.Copy(SettingsFile, corruptedBackup, true);
}
// 从备份恢复配置文件
File.Copy(latestBackup, SettingsFile, true);
return true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"从备份恢复配置文件时出错: {ex.Message}", LogHelper.LogType.Error);
return false;
}
}
/// <summary>
/// 清理过期的备份文件
/// 保留最近30天的备份文件
/// </summary>
public static void CleanupOldBackups()
{
try
{
if (!Directory.Exists(BackupDir))
{
return;
}
var cutoffDate = DateTime.Now.AddDays(-30);
var backupFiles = Directory.GetFiles(BackupDir, $"{BackupPrefix}*.json");
int deletedCount = 0;
foreach (var file in backupFiles)
{
if (File.GetCreationTime(file) < cutoffDate)
{
File.Delete(file);
deletedCount++;
}
}
if (deletedCount > 0)
{
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理过期备份文件时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 初始化自动备份功能
/// 在应用程序启动时调用
/// </summary>
/// <param name="settings">设置对象</param>
public static void Initialize(Settings settings)
{
try
{
// 检查是否需要执行自动备份
if (ShouldPerformAutoBackup(settings))
{
PerformAutoBackup(settings);
}
// 清理过期备份
CleanupOldBackups();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"初始化自动备份功能时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
}
}
+141 -31
View File
@@ -74,6 +74,34 @@ namespace Ink_Canvas.Helpers
GroupName = "inkeys",
DownloadUrlFormat = "https://iccce.inkeys.top/Release/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://bgithub.xyz/InkCanvasForClass/community/raw/refs/heads/main/UpdateLog.md"
},
new UpdateLineGroup
{
GroupName = "gh-proxy",
VersionUrl = "https://gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community/refs/heads/main/AutomaticUpdateVersionControl.txt",
DownloadUrlFormat = "https://gh-proxy.org/https://github.com/InkCanvasForClass/community/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community/refs/heads/main/UpdateLog.md"
},
new UpdateLineGroup
{
GroupName = "hk.gh-proxy",
VersionUrl = "https://hk.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community/refs/heads/main/AutomaticUpdateVersionControl.txt",
DownloadUrlFormat = "https://hk.gh-proxy.org/https://github.com/InkCanvasForClass/community/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://hk.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community/refs/heads/main/UpdateLog.md"
},
new UpdateLineGroup
{
GroupName = "cdn.gh-proxy",
VersionUrl = "https://cdn.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community/refs/heads/main/AutomaticUpdateVersionControl.txt",
DownloadUrlFormat = "https://cdn.gh-proxy.org/https://github.com/InkCanvasForClass/community/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://cdn.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community/refs/heads/main/UpdateLog.md"
},
new UpdateLineGroup
{
GroupName = "edgeone.gh-proxy",
VersionUrl = "https://edgeone.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community/refs/heads/main/AutomaticUpdateVersionControl.txt",
DownloadUrlFormat = "https://edgeone.gh-proxy.org/https://github.com/InkCanvasForClass/community/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://edgeone.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community/refs/heads/main/UpdateLog.md"
}
}
},
@@ -111,6 +139,34 @@ namespace Ink_Canvas.Helpers
GroupName = "inkeys",
DownloadUrlFormat = "https://iccce.inkeys.top/Beta/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://bgithub.xyz/InkCanvasForClass/community-beta/raw/refs/heads/main/UpdateLog.md"
},
new UpdateLineGroup
{
GroupName = "gh-proxy",
VersionUrl = "https://gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/AutomaticUpdateVersionControl.txt",
DownloadUrlFormat = "https://gh-proxy.org/https://github.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/UpdateLog.md"
},
new UpdateLineGroup
{
GroupName = "hk.gh-proxy",
VersionUrl = "https://hk.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/AutomaticUpdateVersionControl.txt",
DownloadUrlFormat = "https://hk.gh-proxy.org/https://github.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://hk.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/UpdateLog.md"
},
new UpdateLineGroup
{
GroupName = "cdn.gh-proxy",
VersionUrl = "https://cdn.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/AutomaticUpdateVersionControl.txt",
DownloadUrlFormat = "https://cdn.gh-proxy.org/https://github.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://cdn.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/UpdateLog.md"
},
new UpdateLineGroup
{
GroupName = "edgeone.gh-proxy",
VersionUrl = "https://edgeone.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/AutomaticUpdateVersionControl.txt",
DownloadUrlFormat = "https://edgeone.gh-proxy.org/https://github.com/InkCanvasForClass/community-beta/releases/download/{0}/InkCanvasForClass.CE.{0}.zip",
LogUrl = "https://edgeone.gh-proxy.org/https://raw.githubusercontent.com/InkCanvasForClass/community-beta/refs/heads/main/UpdateLog.md"
}
}
}
@@ -188,14 +244,45 @@ namespace Ink_Canvas.Helpers
foreach (var group in groups)
{
// 跳过"智教联盟"和"inkeys"线路组,不参与延迟检测和排序
string testUrl = null;
if (group.GroupName == "智教联盟" || group.GroupName == "inkeys")
{
LogHelper.WriteLogToFile($"AutoUpdate | 跳过{group.GroupName}线路组延迟检测");
try
{
if (!string.IsNullOrEmpty(group.DownloadUrlFormat))
{
testUrl = group.DownloadUrlFormat.Replace("{0}", "test");
}
}
catch
{
testUrl = null;
}
}
else
{
testUrl = group.VersionUrl;
}
if (string.IsNullOrEmpty(testUrl))
{
LogHelper.WriteLogToFile($"AutoUpdate | 线路组 {group.GroupName} 缺少可用测速地址,跳过", LogHelper.LogType.Warning);
continue;
}
LogHelper.WriteLogToFile($"AutoUpdate | 检测线路组: {group.GroupName} ({group.VersionUrl})");
var delay = await GetUrlDelay(group.VersionUrl);
LogHelper.WriteLogToFile($"AutoUpdate | 检测线路组: {group.GroupName} ({testUrl})");
long delay;
if (group.GroupName == "智教联盟" || group.GroupName == "inkeys")
{
delay = await GetDownloadUrlDelay(testUrl);
}
else
{
delay = await GetUrlDelay(testUrl);
}
if (delay >= 0)
{
LogHelper.WriteLogToFile($"AutoUpdate | 线路组 {group.GroupName} 延迟: {delay}ms");
@@ -213,20 +300,12 @@ namespace Ink_Canvas.Helpers
.Select(x => x.group)
.ToList();
// 将"智教联盟"线路组插入到最前面(如果存在)
var zhiJiaoGroup = groups.FirstOrDefault(g => g.GroupName == "智教联盟");
if (zhiJiaoGroup != null)
{
orderedGroups.Insert(0, zhiJiaoGroup);
LogHelper.WriteLogToFile("AutoUpdate | 智教联盟线路组已插入到首位");
}
// 将"inkeys"线路组插入到第二位(如果存在)
var inkeysGroup = groups.FirstOrDefault(g => g.GroupName == "inkeys");
var inkeysGroup = orderedGroups.FirstOrDefault(g => g.GroupName == "inkeys");
if (inkeysGroup != null)
{
orderedGroups.Insert(1, inkeysGroup);
LogHelper.WriteLogToFile("AutoUpdate | inkeys线路组已插入到第二位");
orderedGroups.Remove(inkeysGroup);
orderedGroups.Insert(0, inkeysGroup);
LogHelper.WriteLogToFile("AutoUpdate | inkeys线路组已默认优先");
}
if (orderedGroups.Count > 0)
@@ -245,6 +324,47 @@ namespace Ink_Canvas.Helpers
return orderedGroups;
}
private static async Task<long> GetDownloadUrlDelay(string url)
{
try
{
var osVersion = Environment.OSVersion;
bool isWindows7 = osVersion.Version.Major == 6 && osVersion.Version.Minor == 1;
if (isWindows7)
{
using (var handler = new HttpClientHandler())
{
handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
using (var client = new HttpClient(handler))
{
client.Timeout = TimeSpan.FromSeconds(5);
var sw = Stopwatch.StartNew();
var resp = await client.SendAsync(new HttpRequestMessage(HttpMethod.Head, url));
sw.Stop();
return sw.ElapsedMilliseconds;
}
}
}
else
{
using (var client = new HttpClient())
{
client.Timeout = TimeSpan.FromSeconds(5);
var sw = Stopwatch.StartNew();
var resp = await client.SendAsync(new HttpRequestMessage(HttpMethod.Head, url));
sw.Stop();
return sw.ElapsedMilliseconds;
}
}
}
catch
{
return -1;
}
}
// 获取远程版本号
private static async Task<string> GetRemoteVersion(string fileUrl)
{
@@ -671,23 +791,13 @@ namespace Ink_Canvas.Helpers
SaveDownloadStatus(false);
// 优先尝试“智教联盟”线路组
var zhiJiaoGroup = groups.FirstOrDefault(g => g.GroupName == "智教联盟");
// 优先尝试"inkeys"线路组
var inkeysGroup = groups.FirstOrDefault(g => g.GroupName == "inkeys");
if (zhiJiaoGroup != null || inkeysGroup != null)
if (inkeysGroup != null)
{
var priorityGroups = new List<UpdateLineGroup>();
if (zhiJiaoGroup != null)
{
priorityGroups.Add(zhiJiaoGroup);
LogHelper.WriteLogToFile("AutoUpdate | 下载时优先尝试智教联盟线路组");
}
if (inkeysGroup != null)
{
priorityGroups.Add(inkeysGroup);
LogHelper.WriteLogToFile("AutoUpdate | 下载时优先尝试inkeys线路组");
}
groups = priorityGroups.Concat(groups.Where(g => g.GroupName != "智教联盟" && g.GroupName != "inkeys")).ToList();
groups.Remove(inkeysGroup);
groups.Insert(0, inkeysGroup);
LogHelper.WriteLogToFile("AutoUpdate | 下载时优先尝试inkeys线路组");
}
// 依次尝试每个线路组
+119 -10
View File
@@ -18,6 +18,11 @@ namespace Ink_Canvas.Helpers
private readonly object _frameLock = new object();
private Dispatcher _dispatcher;
// 新增属性
private int _rotationAngle = 0; // 0=0度,1=90度,2=180度,3=270度
private int _resolutionWidth = 640;
private int _resolutionHeight = 480;
public event EventHandler<Bitmap> FrameReceived;
public event EventHandler<string> ErrorOccurred;
@@ -25,6 +30,25 @@ namespace Ink_Canvas.Helpers
public List<FilterInfo> AvailableCameras { get; private set; }
public FilterInfo CurrentCamera { get; private set; }
// 新增属性
public int RotationAngle
{
get => _rotationAngle;
set => _rotationAngle = Math.Max(0, Math.Min(3, value));
}
public int ResolutionWidth
{
get => _resolutionWidth;
set => _resolutionWidth = Math.Max(320, Math.Min(1920, value));
}
public int ResolutionHeight
{
get => _resolutionHeight;
set => _resolutionHeight = Math.Max(240, Math.Min(1080, value));
}
public CameraService()
{
_dispatcher = Dispatcher.CurrentDispatcher;
@@ -32,6 +56,16 @@ namespace Ink_Canvas.Helpers
RefreshCameraList();
}
public CameraService(int rotationAngle, int resolutionWidth, int resolutionHeight)
{
_dispatcher = Dispatcher.CurrentDispatcher;
AvailableCameras = new List<FilterInfo>();
_rotationAngle = rotationAngle;
_resolutionWidth = resolutionWidth;
_resolutionHeight = resolutionHeight;
RefreshCameraList();
}
/// <summary>
/// 刷新可用摄像头列表
/// </summary>
@@ -41,13 +75,12 @@ namespace Ink_Canvas.Helpers
{
AvailableCameras.Clear();
var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo device in videoDevices)
{
AvailableCameras.Add(device);
}
LogHelper.WriteLogToFile($"发现 {AvailableCameras.Count} 个摄像头设备");
}
catch (Exception ex)
{
@@ -120,7 +153,6 @@ namespace Ink_Canvas.Helpers
}
_isCapturing = false;
LogHelper.WriteLogToFile("摄像头预览已停止");
}
catch (Exception ex)
{
@@ -233,24 +265,34 @@ namespace Ink_Canvas.Helpers
{
// 释放之前的帧
_currentFrame?.Dispose();
// 创建新的位图,避免Clone的问题
var sourceFrame = eventArgs.Frame;
if (sourceFrame != null)
{
try
{
var width = sourceFrame.Width;
var height = sourceFrame.Height;
if (width > 0 && height > 0)
{
_currentFrame = new Bitmap(width, height, PixelFormat.Format24bppRgb);
using (var graphics = Graphics.FromImage(_currentFrame))
// 应用旋转
Bitmap rotatedFrame = ApplyRotation(sourceFrame);
int targetWidth = _resolutionWidth;
int targetHeight = _resolutionHeight;
if (_rotationAngle == 1 || _rotationAngle == 3)
{
graphics.DrawImage(sourceFrame, 0, 0);
targetWidth = _resolutionHeight;
targetHeight = _resolutionWidth;
}
_currentFrame = ResizeImageWithAspectRatio(rotatedFrame, targetWidth, targetHeight);
rotatedFrame?.Dispose();
}
else
{
@@ -302,10 +344,77 @@ namespace Ink_Canvas.Helpers
return AvailableCameras.Count > 0;
}
/// <summary>
/// 应用旋转到图像
/// </summary>
private Bitmap ApplyRotation(Bitmap source)
{
if (_rotationAngle == 0)
return new Bitmap(source);
var rotationType = RotateFlipType.RotateNoneFlipNone;
switch (_rotationAngle)
{
case 1: rotationType = RotateFlipType.Rotate90FlipNone; break;
case 2: rotationType = RotateFlipType.Rotate180FlipNone; break;
case 3: rotationType = RotateFlipType.Rotate270FlipNone; break;
}
var rotated = new Bitmap(source);
rotated.RotateFlip(rotationType);
return rotated;
}
/// <summary>
/// 调整图像大小
/// </summary>
private Bitmap ResizeImageWithAspectRatio(Bitmap source, int targetWidth, int targetHeight)
{
if (source.Width == targetWidth && source.Height == targetHeight)
return new Bitmap(source);
double scaleX = (double)targetWidth / source.Width;
double scaleY = (double)targetHeight / source.Height;
double scale = Math.Min(scaleX, scaleY);
// 计算实际尺寸
int actualWidth = (int)(source.Width * scale);
int actualHeight = (int)(source.Height * scale);
var resized = new Bitmap(actualWidth, actualHeight, PixelFormat.Format24bppRgb);
using (var graphics = Graphics.FromImage(resized))
{
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
graphics.DrawImage(source, 0, 0, actualWidth, actualHeight);
}
return resized;
}
/// <summary>
/// 调整图像大小
/// </summary>
private Bitmap ResizeImage(Bitmap source, int width, int height)
{
if (source.Width == width && source.Height == height)
return new Bitmap(source);
var resized = new Bitmap(width, height, PixelFormat.Format24bppRgb);
using (var graphics = Graphics.FromImage(resized))
{
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
graphics.DrawImage(source, 0, 0, width, height);
}
return resized;
}
public void Dispose()
{
StopPreview();
lock (_frameLock)
{
_currentFrame?.Dispose();
+40
View File
@@ -112,4 +112,44 @@ namespace Ink_Canvas.Converter
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); }
}
public class InverseBooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value)
{
return Visibility.Collapsed;
}
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value)
{
return Visibility.Collapsed;
}
return Visibility.Visible;
}
}
public class RippleEffectTranslationConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is double d)
{
return -d / 2;
}
return 0.0;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}
-1
View File
@@ -1065,7 +1065,6 @@ namespace Ink_Canvas.Helpers
// 如果不是自动更新(即版本修复),则应用不同的策略
if (!isAutoUpdate)
{
// 版本修复:立即允许,不受分级策略影响
LogHelper.WriteLogToFile($"DeviceIdentifier | 版本修复 - 版本: {updateVersion}, 类型: {updateType}, 结果: 允许");
return true;
}
+455
View File
@@ -0,0 +1,455 @@
using Newtonsoft.Json;
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// Dlass API 客户端,用于与服务端通信
/// </summary>
public class DlassApiClient : IDisposable
{
private const string DEFAULT_BASE_URL = "https://dlass.tech";
private readonly string _appId;
private readonly string _appSecret;
private readonly string _baseUrl;
private HttpClient _httpClient;
private string _accessToken;
private DateTime _tokenExpiresAt;
private string _userToken;
/// <summary>
/// 初始化 Dlass API 客户端
/// </summary>
/// <param name="appId">应用ID</param>
/// <param name="appSecret">应用密钥</param>
/// <param name="baseUrl">API基础URL,如果为空则使用默认URL</param>
/// <param name="userToken">用户Token,如果提供则优先使用用户token而不是App Secret</param>
public DlassApiClient(string appId, string appSecret, string baseUrl = null, string userToken = null)
{
_appId = appId ?? throw new ArgumentNullException(nameof(appId));
_appSecret = appSecret ?? throw new ArgumentNullException(nameof(appSecret));
_userToken = userToken;
_baseUrl = baseUrl ?? DEFAULT_BASE_URL;
_baseUrl = _baseUrl.TrimEnd('/');
if (!_baseUrl.StartsWith("http://") && !_baseUrl.StartsWith("https://"))
{
_baseUrl = "https://" + _baseUrl;
}
_httpClient = new HttpClient
{
BaseAddress = new Uri(_baseUrl),
Timeout = TimeSpan.FromSeconds(30)
};
_httpClient.DefaultRequestHeaders.Add("User-Agent", "InkCanvas/1.0");
}
/// <summary>
/// 获取访问令牌(Access Token
/// </summary>
public async Task<string> GetAccessTokenAsync()
{
if (!string.IsNullOrEmpty(_userToken))
{
return _userToken;
}
if (!string.IsNullOrEmpty(_accessToken) && DateTime.Now < _tokenExpiresAt.AddMinutes(-5))
{
return _accessToken;
}
try
{
var requestData = new
{
app_id = _appId,
app_secret = _appSecret,
grant_type = "client_credentials"
};
var json = JsonConvert.SerializeObject(requestData);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync("/oauth/token", content);
var responseContent = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
var tokenResponse = JsonConvert.DeserializeObject<TokenResponse>(responseContent);
_accessToken = tokenResponse.AccessToken;
_tokenExpiresAt = DateTime.Now.AddSeconds(tokenResponse.ExpiresIn ?? 3600);
return _accessToken;
}
else
{
throw new Exception($"获取Access Token失败: {response.StatusCode}");
}
}
catch (HttpRequestException httpEx)
{
throw new Exception($"获取Access Token时网络错误: {httpEx.Message}", httpEx);
}
catch (TaskCanceledException timeoutEx)
{
throw new Exception("获取Access Token时请求超时", timeoutEx);
}
catch (Exception ex)
{
throw new Exception($"获取Access Token时出错: {ex.Message}", ex);
}
}
/// <summary>
/// 发送GET请求
/// </summary>
public async Task<T> GetAsync<T>(string endpoint, bool requireAuth = true)
{
try
{
string token = null;
if (requireAuth)
{
token = await GetAccessTokenAsync();
}
var request = new HttpRequestMessage(HttpMethod.Get, endpoint);
if (requireAuth && !string.IsNullOrEmpty(token))
{
if (!string.IsNullOrEmpty(_userToken))
{
request.Headers.Add("X-User-Token", token);
}
else
{
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
}
}
var response = await _httpClient.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
if (string.IsNullOrEmpty(content))
{
return default(T);
}
return JsonConvert.DeserializeObject<T>(content);
}
else
{
throw new Exception($"API请求失败: {response.StatusCode} - {content}");
}
}
catch (HttpRequestException httpEx)
{
throw new Exception($"发送请求时出错: {httpEx.Message}", httpEx);
}
catch (TaskCanceledException timeoutEx)
{
throw new Exception($"请求超时: {endpoint}", timeoutEx);
}
catch (Exception ex)
{
throw new Exception($"发送请求时出错: {ex.Message}", ex);
}
}
/// <summary>
/// 发送POST请求
/// </summary>
public async Task<T> PostAsync<T>(string endpoint, object data = null, bool requireAuth = true)
{
try
{
string token = null;
if (requireAuth)
{
token = await GetAccessTokenAsync();
}
var request = new HttpRequestMessage(HttpMethod.Post, endpoint);
if (requireAuth && !string.IsNullOrEmpty(token))
{
if (!string.IsNullOrEmpty(_userToken))
{
request.Headers.Add("X-User-Token", token);
}
else
{
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
}
}
if (data != null)
{
var json = JsonConvert.SerializeObject(data);
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
}
var response = await _httpClient.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
if (string.IsNullOrEmpty(content))
{
return default(T);
}
return JsonConvert.DeserializeObject<T>(content);
}
else
{
throw new Exception($"API请求失败: {response.StatusCode} - {content}");
}
}
catch (HttpRequestException httpEx)
{
throw new Exception($"发送请求时出错: {httpEx.Message}", httpEx);
}
catch (TaskCanceledException timeoutEx)
{
throw new Exception($"请求超时: {endpoint}", timeoutEx);
}
catch (Exception ex)
{
throw new Exception($"发送请求时出错: {ex.Message}", ex);
}
}
/// <summary>
/// 发送PUT请求
/// </summary>
public async Task<T> PutAsync<T>(string endpoint, object data = null, bool requireAuth = true)
{
try
{
string token = null;
if (requireAuth)
{
token = await GetAccessTokenAsync();
}
var request = new HttpRequestMessage(HttpMethod.Put, endpoint);
if (requireAuth && !string.IsNullOrEmpty(token))
{
// 如果是用户token,使用X-User-Token header
if (!string.IsNullOrEmpty(_userToken))
{
request.Headers.Add("X-User-Token", token);
}
else
{
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
}
}
if (data != null)
{
var json = JsonConvert.SerializeObject(data);
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
}
var response = await _httpClient.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
if (string.IsNullOrEmpty(content))
{
return default(T);
}
return JsonConvert.DeserializeObject<T>(content);
}
else
{
throw new Exception($"API请求失败: {response.StatusCode} - {content}");
}
}
catch (HttpRequestException httpEx)
{
throw new Exception($"发送请求时出错: {httpEx.Message}", httpEx);
}
catch (TaskCanceledException timeoutEx)
{
throw new Exception($"请求超时: {endpoint}", timeoutEx);
}
catch (Exception ex)
{
throw new Exception($"发送请求时出错: {ex.Message}", ex);
}
}
/// <summary>
/// 发送DELETE请求
/// </summary>
public async Task<bool> DeleteAsync(string endpoint, bool requireAuth = true)
{
try
{
string token = null;
if (requireAuth)
{
token = await GetAccessTokenAsync();
}
var request = new HttpRequestMessage(HttpMethod.Delete, endpoint);
if (requireAuth && !string.IsNullOrEmpty(token))
{
// 如果是用户token,使用X-User-Token header
if (!string.IsNullOrEmpty(_userToken))
{
request.Headers.Add("X-User-Token", token);
}
else
{
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
}
}
var response = await _httpClient.SendAsync(request);
if (response.IsSuccessStatusCode)
{
return true;
}
else
{
return false;
}
}
catch (HttpRequestException)
{
return false;
}
catch (TaskCanceledException)
{
return false;
}
catch (Exception)
{
return false;
}
}
/// <summary>
/// 上传笔记文件
/// </summary>
/// <param name="endpoint">上传端点</param>
/// <param name="filePath">文件路径</param>
/// <param name="boardId">白板ID</param>
/// <param name="secretKey">白板密钥</param>
/// <param name="title">笔记标题(可选)</param>
/// <param name="description">笔记描述(可选)</param>
/// <param name="tags">笔记标签(可选)</param>
public async Task<T> UploadNoteAsync<T>(string endpoint, string filePath, string boardId, string secretKey, string title = null, string description = null, string tags = null)
{
try
{
if (!File.Exists(filePath))
{
throw new FileNotFoundException($"文件不存在: {filePath}");
}
var request = new HttpRequestMessage(HttpMethod.Post, endpoint);
// 设置白板认证头
request.Headers.Add("X-Board-ID", boardId);
request.Headers.Add("X-Secret-Key", secretKey);
// 创建multipart/form-data内容
var content = new MultipartFormDataContent();
// 添加文件
var fileContent = new ByteArrayContent(File.ReadAllBytes(filePath));
var fileName = Path.GetFileName(filePath);
fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
content.Add(fileContent, "file", fileName);
// 添加可选参数
if (!string.IsNullOrEmpty(title))
{
content.Add(new StringContent(title), "title");
}
if (!string.IsNullOrEmpty(description))
{
content.Add(new StringContent(description), "description");
}
if (!string.IsNullOrEmpty(tags))
{
content.Add(new StringContent(tags), "tags");
}
request.Content = content;
var response = await _httpClient.SendAsync(request);
var responseContent = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
if (string.IsNullOrEmpty(responseContent))
{
return default(T);
}
return JsonConvert.DeserializeObject<T>(responseContent);
}
else
{
throw new Exception($"上传文件失败: {response.StatusCode} - {responseContent}");
}
}
catch (HttpRequestException httpEx)
{
throw new Exception($"上传文件时网络错误: {httpEx.Message}", httpEx);
}
catch (TaskCanceledException timeoutEx)
{
throw new Exception($"上传文件超时: {endpoint}", timeoutEx);
}
catch (Exception ex)
{
throw new Exception($"上传文件时出错: {ex.Message}", ex);
}
}
/// <summary>
/// 释放资源
/// </summary>
public void Dispose()
{
_httpClient?.Dispose();
}
#region
/// <summary>
/// Token响应模型
/// </summary>
private class TokenResponse
{
[JsonProperty("access_token")]
public string AccessToken { get; set; }
[JsonProperty("expires_in")]
public int? ExpiresIn { get; set; }
[JsonProperty("token_type")]
public string TokenType { get; set; }
}
#endregion
}
}
+757
View File
@@ -0,0 +1,757 @@
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// Dlass笔记自动上传辅助类
/// </summary>
public class DlassNoteUploader
{
private const string APP_ID = "app_WkjocWqsrVY7T6zQV2CfiA";
private const string APP_SECRET = "o7dx5b5ASGUMcM72PCpmRQYAhSijqaOVHoGyBK0IxbA";
private const int BATCH_SIZE = 10; // 批量上传大小
private const int MAX_RETRY_COUNT = 3; // 最大重试次数
private const string QUEUE_FILE_NAME = "DlassUploadQueue.json";
/// <summary>
/// 上传队列项
/// </summary>
private class UploadQueueItemData
{
[JsonProperty("file_path")]
public string FilePath { get; set; }
[JsonProperty("retry_count")]
public int RetryCount { get; set; }
[JsonProperty("added_time")]
public DateTime AddedTime { get; set; }
}
/// <summary>
/// 上传队列项
/// </summary>
private class UploadQueueItem
{
public string FilePath { get; set; }
public int RetryCount { get; set; }
}
/// <summary>
/// 上传队列
/// </summary>
private static readonly ConcurrentQueue<UploadQueueItem> _uploadQueue = new ConcurrentQueue<UploadQueueItem>();
/// <summary>
/// 队列处理锁,防止并发处理
/// </summary>
private static readonly SemaphoreSlim _queueProcessingLock = new SemaphoreSlim(1, 1);
/// <summary>
/// 队列保存锁,防止并发保存
/// </summary>
private static readonly SemaphoreSlim _queueSaveLock = new SemaphoreSlim(1, 1);
/// <summary>
/// 是否已初始化队列
/// </summary>
private static bool _isQueueInitialized = false;
/// <summary>
/// 获取队列文件路径
/// </summary>
private static string GetQueueFilePath()
{
var configsDir = Path.Combine(App.RootPath, "Configs");
if (!Directory.Exists(configsDir))
{
Directory.CreateDirectory(configsDir);
}
return Path.Combine(configsDir, QUEUE_FILE_NAME);
}
/// <summary>
/// 初始化上传队列
/// </summary>
public static void InitializeQueue()
{
if (_isQueueInitialized)
{
return;
}
try
{
var queueFilePath = GetQueueFilePath();
if (!File.Exists(queueFilePath))
{
_isQueueInitialized = true;
return;
}
var jsonContent = File.ReadAllText(queueFilePath);
if (string.IsNullOrWhiteSpace(jsonContent))
{
_isQueueInitialized = true;
return;
}
var queueData = JsonConvert.DeserializeObject<List<UploadQueueItemData>>(jsonContent);
if (queueData == null || queueData.Count == 0)
{
_isQueueInitialized = true;
return;
}
int restoredCount = 0;
int skippedCount = 0;
foreach (var item in queueData)
{
// 验证文件是否存在
if (!File.Exists(item.FilePath))
{
skippedCount++;
continue;
}
// 验证文件格式和大小
var fileExtension = Path.GetExtension(item.FilePath).ToLower();
if (fileExtension != ".png" && fileExtension != ".icstk" && fileExtension != ".zip")
{
skippedCount++;
continue;
}
try
{
var fileInfo = new FileInfo(item.FilePath);
long maxSize = fileExtension == ".zip" ? 50 * 1024 * 1024 : 10 * 1024 * 1024;
if (fileInfo.Length > maxSize)
{
skippedCount++;
continue;
}
}
catch
{
skippedCount++;
continue;
}
// 恢复队列项
_uploadQueue.Enqueue(new UploadQueueItem
{
FilePath = item.FilePath,
RetryCount = item.RetryCount
});
restoredCount++;
}
_isQueueInitialized = true;
if (restoredCount > 0)
{
LogHelper.WriteLogToFile($"已恢复上传队列:{restoredCount}个文件,跳过{skippedCount}个无效文件", LogHelper.LogType.Event);
// 如果恢复了队列,触发处理
_ = ProcessUploadQueueAsync();
}
else if (skippedCount > 0)
{
LogHelper.WriteLogToFile($"队列恢复完成:跳过{skippedCount}个无效文件", LogHelper.LogType.Event);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"恢复上传队列时出错: {ex.Message}", LogHelper.LogType.Error);
_isQueueInitialized = true; // 即使出错也标记为已初始化,避免重复尝试
}
}
/// <summary>
/// 保存队列到文件
/// </summary>
private static async Task SaveQueueToFileAsync()
{
if (!await _queueSaveLock.WaitAsync(1000)) // 最多等待1秒
{
return; // 如果无法获取锁,跳过保存(避免阻塞)
}
try
{
var queueData = new List<UploadQueueItemData>();
// 将队列转换为可序列化的格式
foreach (var item in _uploadQueue)
{
queueData.Add(new UploadQueueItemData
{
FilePath = item.FilePath,
RetryCount = item.RetryCount,
AddedTime = DateTime.Now
});
}
var queueFilePath = GetQueueFilePath();
// 如果队列为空,清空文件
if (queueData.Count == 0)
{
ClearQueueFile();
return;
}
var jsonContent = JsonConvert.SerializeObject(queueData, Formatting.Indented);
// 使用临时文件写入,然后替换,确保原子性
var tempFilePath = queueFilePath + ".tmp";
File.WriteAllText(tempFilePath, jsonContent);
// 如果原文件存在,先删除
if (File.Exists(queueFilePath))
{
File.Delete(queueFilePath);
}
// 重命名临时文件
File.Move(tempFilePath, queueFilePath);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存上传队列时出错: {ex.Message}", LogHelper.LogType.Error);
}
finally
{
_queueSaveLock.Release();
}
}
/// <summary>
/// 清空队列文件
/// </summary>
private static void ClearQueueFile()
{
try
{
var queueFilePath = GetQueueFilePath();
if (File.Exists(queueFilePath))
{
File.WriteAllText(queueFilePath, "[]");
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清空队列文件时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 上传笔记响应模型
/// </summary>
public class UploadNoteResponse
{
[JsonProperty("success")]
public bool Success { get; set; }
[JsonProperty("message")]
public string Message { get; set; }
[JsonProperty("note_id")]
public int? NoteId { get; set; }
[JsonProperty("filename")]
public string Filename { get; set; }
[JsonProperty("file_path")]
public string FilePath { get; set; }
[JsonProperty("file_url")]
public string FileUrl { get; set; }
}
/// <summary>
/// 白板信息模型(用于查找白板)
/// </summary>
private class WhiteboardInfo
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("board_id")]
public string BoardId { get; set; }
[JsonProperty("secret_key")]
public string SecretKey { get; set; }
[JsonProperty("class_name")]
public string ClassName { get; set; }
[JsonProperty("class_id")]
public int ClassId { get; set; }
}
/// <summary>
/// 认证响应模型
/// </summary>
private class AuthWithTokenResponse
{
[JsonProperty("success")]
public bool Success { get; set; }
[JsonProperty("whiteboards")]
public List<WhiteboardInfo> Whiteboards { get; set; }
}
/// <summary>
/// 异步上传笔记文件到Dlass(支持PNG、ICSTK和ZIP格式)
/// </summary>
/// <param name="filePath">文件路径(支持PNG、ICSTK和ZIP</param>
/// <returns>是否成功加入队列(不等待实际上传完成)</returns>
public static async Task<bool> UploadNoteFileAsync(string filePath)
{
try
{
// 检查是否启用自动上传
if (MainWindow.Settings?.Dlass?.IsAutoUploadNotes != true)
{
return false;
}
// 基本验证
if (!File.Exists(filePath))
{
LogHelper.WriteLogToFile($"上传失败:文件不存在 - {filePath}", LogHelper.LogType.Error);
return false;
}
var fileExtension = Path.GetExtension(filePath).ToLower();
if (fileExtension != ".png" && fileExtension != ".icstk" && fileExtension != ".zip")
{
return false;
}
var fileInfo = new FileInfo(filePath);
long maxSize = fileExtension == ".zip" ? 50 * 1024 * 1024 : 10 * 1024 * 1024;
if (fileInfo.Length > maxSize)
{
LogHelper.WriteLogToFile($"上传失败:文件过大({fileInfo.Length / 1024 / 1024}MB),超过{maxSize / 1024 / 1024}MB限制", LogHelper.LogType.Error);
return false;
}
// 获取上传延迟时间(分钟)
var delayMinutes = MainWindow.Settings?.Dlass?.AutoUploadDelayMinutes ?? 0;
// 如果设置了延迟时间,在后台任务中等待后再加入队列
if (delayMinutes > 0)
{
_ = Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromMinutes(delayMinutes));
EnqueueFile(filePath);
});
}
else
{
EnqueueFile(filePath);
}
return true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"加入上传队列时出错: {ex.Message}", LogHelper.LogType.Error);
return false;
}
}
/// <summary>
/// 将文件加入上传队列
/// </summary>
private static void EnqueueFile(string filePath, int retryCount = 0)
{
_uploadQueue.Enqueue(new UploadQueueItem
{
FilePath = filePath,
RetryCount = retryCount
});
// 异步保存队列到文件
_ = Task.Run(async () => await SaveQueueToFileAsync());
// 如果队列达到批量大小,触发批量上传
if (_uploadQueue.Count >= BATCH_SIZE)
{
_ = ProcessUploadQueueAsync();
}
}
/// <summary>
/// 处理上传队列,批量上传文件
/// </summary>
private static async Task ProcessUploadQueueAsync()
{
// 使用信号量防止并发处理
if (!await _queueProcessingLock.WaitAsync(0))
{
return; // 已有处理任务在运行
}
try
{
var filesToUpload = new List<UploadQueueItem>();
// 从队列中取出最多BATCH_SIZE个文件
while (filesToUpload.Count < BATCH_SIZE && _uploadQueue.TryDequeue(out UploadQueueItem item))
{
// 再次检查文件是否存在
if (File.Exists(item.FilePath))
{
filesToUpload.Add(item);
}
}
if (filesToUpload.Count == 0)
{
return;
}
// 获取共享的白板信息(同一批次的所有文件共享认证信息)
WhiteboardInfo sharedWhiteboard = null;
string apiBaseUrl = null;
string userToken = null;
try
{
var selectedClassName = MainWindow.Settings?.Dlass?.SelectedClassName;
if (string.IsNullOrEmpty(selectedClassName))
{
LogHelper.WriteLogToFile("上传失败:未选择班级", LogHelper.LogType.Error);
// 将文件重新加入队列
foreach (var item in filesToUpload)
{
EnqueueFile(item.FilePath, item.RetryCount);
}
return;
}
userToken = MainWindow.Settings?.Dlass?.UserToken;
if (string.IsNullOrEmpty(userToken))
{
LogHelper.WriteLogToFile("上传失败:未设置用户Token", LogHelper.LogType.Error);
// 将文件重新加入队列
foreach (var item in filesToUpload)
{
EnqueueFile(item.FilePath, item.RetryCount);
}
return;
}
apiBaseUrl = MainWindow.Settings?.Dlass?.ApiBaseUrl ?? "https://dlass.tech";
// 获取白板信息(只获取一次,所有文件共享)
using (var apiClient = new DlassApiClient(APP_ID, APP_SECRET, apiBaseUrl, userToken))
{
var authData = new
{
app_id = APP_ID,
app_secret = APP_SECRET,
user_token = userToken
};
var authResult = await apiClient.PostAsync<AuthWithTokenResponse>("/api/whiteboard/framework/auth-with-token", authData, requireAuth: false);
if (authResult == null || !authResult.Success || authResult.Whiteboards == null)
{
LogHelper.WriteLogToFile("上传失败:无法获取白板信息", LogHelper.LogType.Error);
// 将文件重新加入队列
foreach (var item in filesToUpload)
{
EnqueueFile(item.FilePath, item.RetryCount);
}
return;
}
sharedWhiteboard = authResult.Whiteboards
.FirstOrDefault(w => !string.IsNullOrEmpty(w.ClassName) && w.ClassName == selectedClassName);
if (sharedWhiteboard == null || string.IsNullOrEmpty(sharedWhiteboard.BoardId) || string.IsNullOrEmpty(sharedWhiteboard.SecretKey))
{
LogHelper.WriteLogToFile($"上传失败:未找到班级'{selectedClassName}'对应的白板", LogHelper.LogType.Error);
// 将文件重新加入队列
foreach (var item in filesToUpload)
{
EnqueueFile(item.FilePath, item.RetryCount);
}
return;
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"批量上传获取白板信息时出错: {ex.Message}", LogHelper.LogType.Error);
// 将文件重新加入队列
foreach (var item in filesToUpload)
{
EnqueueFile(item.FilePath, item.RetryCount);
}
return;
}
// 并发上传所有文件(共享白板信息),并处理失败重试
var uploadTasks = filesToUpload.Select(async item =>
{
try
{
var success = await UploadFileInternalAsync(item.FilePath, sharedWhiteboard, apiBaseUrl, userToken);
if (!success)
{
// 检查是否是可重试的错误
if (IsRetryableError(item.FilePath))
{
// 检查重试次数
if (item.RetryCount < MAX_RETRY_COUNT)
{
LogHelper.WriteLogToFile($"上传失败,将重试 ({item.RetryCount + 1}/{MAX_RETRY_COUNT}): {Path.GetFileName(item.FilePath)}", LogHelper.LogType.Event);
EnqueueFile(item.FilePath, item.RetryCount + 1);
}
else
{
LogHelper.WriteLogToFile($"上传失败,已达到最大重试次数: {Path.GetFileName(item.FilePath)}", LogHelper.LogType.Error);
}
}
}
return success;
}
catch (Exception ex)
{
// 检查是否是可重试的错误(超时、网络错误等)
var errorMessage = ex.Message.ToLower();
bool isRetryable = errorMessage.Contains("超时") ||
errorMessage.Contains("timeout") ||
errorMessage.Contains("网络错误") ||
errorMessage.Contains("network");
if (isRetryable && IsRetryableError(item.FilePath))
{
// 检查重试次数
if (item.RetryCount < MAX_RETRY_COUNT)
{
LogHelper.WriteLogToFile($"上传失败({ex.Message}),将重试 ({item.RetryCount + 1}/{MAX_RETRY_COUNT}): {Path.GetFileName(item.FilePath)}", LogHelper.LogType.Event);
EnqueueFile(item.FilePath, item.RetryCount + 1);
}
else
{
LogHelper.WriteLogToFile($"上传失败,已达到最大重试次数: {Path.GetFileName(item.FilePath)}", LogHelper.LogType.Error);
}
}
return false;
}
});
await Task.WhenAll(uploadTasks);
// 上传完成后保存队列状态
await SaveQueueToFileAsync();
// 如果队列达到批量大小,继续处理
if (_uploadQueue.Count >= BATCH_SIZE)
{
_ = ProcessUploadQueueAsync();
}
}
finally
{
_queueProcessingLock.Release();
}
}
/// <summary>
/// 内部上传方法,执行实际上传操作
/// </summary>
/// <param name="filePath">文件路径</param>
/// <param name="whiteboard">白板信息(如果为null则重新获取)</param>
/// <param name="apiBaseUrl">API基础URL(如果为null则从设置获取)</param>
/// <param name="userToken">用户Token(如果为null则从设置获取)</param>
private static async Task<bool> UploadFileInternalAsync(string filePath, WhiteboardInfo whiteboard = null, string apiBaseUrl = null, string userToken = null)
{
try
{
// 再次检查文件是否存在(可能在队列等待时被删除)
if (!File.Exists(filePath))
{
return false;
}
// 检查文件扩展名
var fileExtension = Path.GetExtension(filePath).ToLower();
if (fileExtension != ".png" && fileExtension != ".icstk" && fileExtension != ".zip")
{
return false;
}
// 检查文件大小(最大10MB,ZIP文件可能更大,允许50MB)
var fileInfo = new FileInfo(filePath);
long maxSize = fileExtension == ".zip" ? 50 * 1024 * 1024 : 10 * 1024 * 1024;
if (fileInfo.Length > maxSize)
{
LogHelper.WriteLogToFile($"上传失败:文件过大({fileInfo.Length / 1024 / 1024}MB),超过{maxSize / 1024 / 1024}MB限制", LogHelper.LogType.Error);
return false;
}
// 如果白板信息未提供,则重新获取
if (whiteboard == null)
{
var selectedClassName = MainWindow.Settings?.Dlass?.SelectedClassName;
if (string.IsNullOrEmpty(selectedClassName))
{
LogHelper.WriteLogToFile("上传失败:未选择班级", LogHelper.LogType.Error);
return false;
}
userToken = userToken ?? MainWindow.Settings?.Dlass?.UserToken;
if (string.IsNullOrEmpty(userToken))
{
LogHelper.WriteLogToFile("上传失败:未设置用户Token", LogHelper.LogType.Error);
return false;
}
apiBaseUrl = apiBaseUrl ?? MainWindow.Settings?.Dlass?.ApiBaseUrl ?? "https://dlass.tech";
// 创建API客户端并获取白板信息
using (var apiClient = new DlassApiClient(APP_ID, APP_SECRET, apiBaseUrl, userToken))
{
var authData = new
{
app_id = APP_ID,
app_secret = APP_SECRET,
user_token = userToken
};
var authResult = await apiClient.PostAsync<AuthWithTokenResponse>("/api/whiteboard/framework/auth-with-token", authData, requireAuth: false);
if (authResult == null || !authResult.Success || authResult.Whiteboards == null)
{
LogHelper.WriteLogToFile("上传失败:无法获取白板信息", LogHelper.LogType.Error);
return false;
}
// 查找匹配班级的白板
whiteboard = authResult.Whiteboards
.FirstOrDefault(w => !string.IsNullOrEmpty(w.ClassName) && w.ClassName == selectedClassName);
if (whiteboard == null || string.IsNullOrEmpty(whiteboard.BoardId) || string.IsNullOrEmpty(whiteboard.SecretKey))
{
LogHelper.WriteLogToFile($"上传失败:未找到班级'{selectedClassName}'对应的白板", LogHelper.LogType.Error);
return false;
}
}
}
// 获取API基础URL和用户Token(如果未提供)
apiBaseUrl = apiBaseUrl ?? MainWindow.Settings?.Dlass?.ApiBaseUrl ?? "https://dlass.tech";
userToken = userToken ?? MainWindow.Settings?.Dlass?.UserToken;
// 准备上传参数
var fileName = Path.GetFileNameWithoutExtension(filePath);
var title = fileName;
string fileType;
string tags;
if (fileExtension == ".zip")
{
fileType = "多页面墨迹压缩包";
tags = "自动上传,多页面,zip,压缩包";
}
else if (fileExtension == ".icstk")
{
fileType = "墨迹文件";
tags = "自动上传,墨迹,icstk";
}
else
{
fileType = "笔记";
tags = "自动上传,笔记,png";
}
var description = $"自动上传的{fileType} - {DateTime.Now:yyyy-MM-dd HH:mm:ss}";
// 创建API客户端并上传文件
using (var apiClient = new DlassApiClient(APP_ID, APP_SECRET, apiBaseUrl, userToken))
{
var uploadResult = await apiClient.UploadNoteAsync<UploadNoteResponse>(
"/api/whiteboard/upload_note",
filePath,
whiteboard.BoardId,
whiteboard.SecretKey,
title,
description,
tags);
if (uploadResult != null && uploadResult.Success)
{
LogHelper.WriteLogToFile($"笔记上传成功:{fileName} -> {uploadResult.FileUrl}", LogHelper.LogType.Event);
return true;
}
else
{
LogHelper.WriteLogToFile($"上传失败:服务器响应失败 - {uploadResult?.Message ?? ""}", LogHelper.LogType.Error);
return false;
}
}
}
catch (Exception ex)
{
// 记录错误信息,抛出异常以便调用方判断是否可重试
LogHelper.WriteLogToFile($"上传笔记时出错: {ex.Message}", LogHelper.LogType.Error);
throw;
}
}
/// <summary>
/// 判断错误是否可重试(超时、网络错误等)
/// </summary>
private static bool IsRetryableError(string filePath)
{
// 检查文件是否存在
if (!File.Exists(filePath))
{
return false; // 文件不存在,不可重试
}
// 检查文件扩展名
var fileExtension = Path.GetExtension(filePath).ToLower();
if (fileExtension != ".png" && fileExtension != ".icstk" && fileExtension != ".zip")
{
return false; // 文件格式错误,不可重试
}
// 检查文件大小
try
{
var fileInfo = new FileInfo(filePath);
long maxSize = fileExtension == ".zip" ? 50 * 1024 * 1024 : 10 * 1024 * 1024;
if (fileInfo.Length > maxSize)
{
return false; // 文件过大,不可重试
}
}
catch
{
return false; // 无法读取文件信息,不可重试
}
// 其他错误(超时、网络错误等)可以重试
return true;
}
}
}
+107 -1
View File
@@ -25,6 +25,7 @@ namespace Ink_Canvas.Helpers
private const string IpcEventName = "InkCanvasFileAssociationEvent";
private const string IpcFilePrefix = "InkCanvasFileAssociation_";
private const string IpcBoardModePrefix = "InkCanvasBoardMode_";
private const string IpcShowModePrefix = "InkCanvasShowMode_";
private const int IpcTimeout = 5000; // 5秒超时
/// <summary>
@@ -310,6 +311,56 @@ namespace Ink_Canvas.Helpers
}
}
/// <summary>
/// 尝试通过IPC将展开浮动栏命令发送给已运行的实例
/// </summary>
/// <returns>是否成功发送</returns>
public static bool TrySendShowModeCommandToExistingInstance()
{
try
{
LogHelper.WriteLogToFile("尝试通过IPC发送展开浮动栏命令给已运行实例", LogHelper.LogType.Event);
// 创建IPC文件
string tempDir = Path.GetTempPath();
string ipcFileName = IpcShowModePrefix + Guid.NewGuid().ToString("N") + ".tmp";
string ipcFilePath = Path.Combine(tempDir, ipcFileName);
// 写入展开浮动栏命令到IPC文件
File.WriteAllText(ipcFilePath, "SHOW_MODE", Encoding.UTF8);
// 创建事件通知已运行实例
using (EventWaitHandle ipcEvent = new EventWaitHandle(false, EventResetMode.ManualReset, IpcEventName))
{
ipcEvent.Set();
}
// 等待一段时间让已运行实例处理命令
Thread.Sleep(1000);
// 清理IPC文件
try
{
if (File.Exists(ipcFilePath))
{
File.Delete(ipcFilePath);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理IPC文件失败: {ex.Message}", LogHelper.LogType.Warning);
}
LogHelper.WriteLogToFile("IPC展开浮动栏命令发送完成", LogHelper.LogType.Event);
return true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"通过IPC发送展开浮动栏命令失败: {ex.Message}", LogHelper.LogType.Error);
return false;
}
}
/// <summary>
/// 启动IPC监听器,等待其他实例发送文件路径
/// </summary>
@@ -368,7 +419,7 @@ namespace Ink_Canvas.Helpers
try
{
string tempDir = Path.GetTempPath();
// 处理文件路径IPC文件
string[] ipcFiles = Directory.GetFiles(tempDir, IpcFilePrefix + "*.tmp");
foreach (string ipcFile in ipcFiles)
@@ -470,6 +521,61 @@ namespace Ink_Canvas.Helpers
catch { }
}
}
// 处理展开浮动栏命令IPC文件
string[] showModeFiles = Directory.GetFiles(tempDir, IpcShowModePrefix + "*.tmp");
foreach (string ipcFile in showModeFiles)
{
try
{
// 读取命令内容
string command = File.ReadAllText(ipcFile, Encoding.UTF8);
if (command == "SHOW_MODE")
{
LogHelper.WriteLogToFile("IPC接收到展开浮动栏命令", LogHelper.LogType.Event);
// 在UI线程中处理展开浮动栏
Application.Current.Dispatcher.BeginInvoke(new Action(async () =>
{
try
{
// 获取主窗口并展开浮动栏
if (Application.Current.MainWindow is MainWindow mainWindow)
{
// 如果当前处于收纳模式,则展开浮动栏
if (mainWindow.isFloatingBarFolded)
{
await mainWindow.UnFoldFloatingBar(new object());
}
mainWindow.ShowNotification("已退出收纳模式并恢复浮动栏");
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"IPC处理展开浮动栏失败: {ex.Message}", LogHelper.LogType.Error);
}
}));
}
// 删除IPC文件
File.Delete(ipcFile);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理展开浮动栏IPC文件失败: {ex.Message}", LogHelper.LogType.Warning);
// 尝试删除损坏的IPC文件
try
{
if (File.Exists(ipcFile))
{
File.Delete(ipcFile);
}
}
catch { }
}
}
}
catch (Exception ex)
{
File diff suppressed because it is too large Load Diff
@@ -1,8 +1,7 @@
using Ink_Canvas.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Ink_Canvas.Helpers;
namespace Ink_Canvas
{
@@ -47,7 +46,7 @@ namespace Ink_Canvas
{
_settings = settings ?? new FloatingWindowInterceptorSettings();
_interceptor = new FloatingWindowInterceptor();
// 订阅事件
_interceptor.WindowIntercepted += OnWindowIntercepted;
_interceptor.WindowRestored += OnWindowRestored;
@@ -117,13 +116,44 @@ namespace Ink_Canvas
try
{
_interceptor.SetInterceptRule(type, enabled);
// 更新设置
var ruleName = type.ToString();
if (_settings.InterceptRules.ContainsKey(ruleName))
{
_settings.InterceptRules[ruleName] = enabled;
}
// 获取规则信息以处理父子关系
var rule = _interceptor.GetInterceptRule(type);
if (rule != null)
{
// 如果是父规则,更新所有子规则的设置
if (rule.ChildTypes.Count > 0)
{
foreach (var childType in rule.ChildTypes)
{
var childRuleName = childType.ToString();
if (_settings.InterceptRules.ContainsKey(childRuleName))
{
_settings.InterceptRules[childRuleName] = enabled;
}
}
}
// 如果是子规则,更新父规则的设置
else if (rule.ParentType.HasValue)
{
var parentRule = _interceptor.GetInterceptRule(rule.ParentType.Value);
if (parentRule != null)
{
var parentRuleName = rule.ParentType.Value.ToString();
if (_settings.InterceptRules.ContainsKey(parentRuleName))
{
_settings.InterceptRules[parentRuleName] = parentRule.IsEnabled;
}
}
}
}
}
catch (Exception ex)
{
@@ -228,7 +258,7 @@ namespace Ink_Canvas
try
{
_settings.ScanIntervalMs = intervalMs;
// 如果正在运行,重启以应用新间隔
if (IsRunning)
{
+40 -4
View File
@@ -36,6 +36,24 @@ namespace Ink_Canvas.Helpers
public int Height => Bottom - Top;
}
[StructLayout(LayoutKind.Sequential)]
private struct MONITORINFO
{
public uint cbSize;
public RECT rcMonitor;
public RECT rcWork;
public uint dwFlags;
}
[DllImport("user32.dll")]
private static extern bool GetMonitorInfo(IntPtr hMonitor, ref MONITORINFO lpmi);
[DllImport("user32.dll")]
private static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags);
[DllImport("user32.dll")]
private static extern IntPtr MonitorFromRect(ref RECT lprc, uint dwFlags);
public static string WindowTitle()
{
IntPtr foregroundWindowHandle = GetForegroundWindow();
@@ -106,10 +124,28 @@ namespace Ink_Canvas.Helpers
public static double GetTaskbarHeight(Screen screen, double dpiScaleY)
{
// 获取工作区和屏幕高度的差值
var workingArea = screen.WorkingArea;
var bounds = screen.Bounds;
int taskbarHeight = bounds.Height - workingArea.Height;
// 创建RECT结构体表示屏幕边界
RECT screenRect = new RECT
{
Left = screen.Bounds.Left,
Top = screen.Bounds.Top,
Right = screen.Bounds.Right,
Bottom = screen.Bounds.Bottom
};
// 获取屏幕句柄
const uint MONITOR_DEFAULTTONEAREST = 0x00000002;
IntPtr hMonitor = MonitorFromRect(ref screenRect, MONITOR_DEFAULTTONEAREST);
// 初始化MONITORINFO结构体
MONITORINFO monitorInfo = new MONITORINFO();
monitorInfo.cbSize = (uint)Marshal.SizeOf(typeof(MONITORINFO));
// 获取监视器信息
GetMonitorInfo(hMonitor, ref monitorInfo);
// 计算任务栏高度:monitorInfo.rcMonitor.bottom减去monitorInfo.rcWork.bottom的值
int taskbarHeight = monitorInfo.rcMonitor.Bottom - monitorInfo.rcWork.Bottom;
// 考虑 DPI 缩放
return taskbarHeight / dpiScaleY;
}
+509 -20
View File
@@ -5,6 +5,8 @@ using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
namespace Ink_Canvas.Helpers
@@ -20,6 +22,16 @@ namespace Ink_Canvas.Helpers
private bool _isDisposed;
private bool _hotkeysShouldBeRegistered = true; // 启动时注册热键
// 多屏幕支持相关字段
private Screen _currentScreen;
private bool _isMultiScreenMode = false;
private bool _enableScreenSpecificHotkeys = true; // 是否启用基于屏幕的热键注册
// 智能热键管理相关字段
private bool _isWindowFocused = false;
private bool _isMouseOverWindow = false;
private System.Windows.Threading.DispatcherTimer _mousePositionTimer;
// 配置文件路径
private static readonly string HotkeyConfigFile = Path.Combine(App.RootPath, "Configs", "HotkeyConfig.json");
#endregion
@@ -30,7 +42,10 @@ namespace Ink_Canvas.Helpers
_mainWindow = mainWindow ?? throw new ArgumentNullException(nameof(mainWindow));
_registeredHotkeys = new Dictionary<string, HotkeyInfo>();
_hotkeysShouldBeRegistered = true; // 启动时注册热键
// 初始化多屏幕支持
InitializeMultiScreenSupport();
// 启动时确保配置文件存在
EnsureConfigFileExists();
}
@@ -52,11 +67,27 @@ namespace Ink_Canvas.Helpers
if (_isDisposed)
return false;
// 检查是否应该注册热键(基于屏幕和模式)
if (!ShouldRegisterHotkeys())
{
return false;
}
// 如果快捷键已存在,先注销
if (_registeredHotkeys.ContainsKey(hotkeyName))
{
UnregisterHotkey(hotkeyName);
}
else
{
try
{
HotkeyManager.Current.Remove(hotkeyName);
}
catch
{
}
}
// 创建快捷键信息
var hotkeyInfo = new HotkeyInfo
@@ -85,12 +116,14 @@ namespace Ink_Canvas.Helpers
});
_registeredHotkeys[hotkeyName] = hotkeyInfo;
// 成功注册全局快捷键
// 记录注册信息
var screenInfo = _isMultiScreenMode ? $" (屏幕: {_currentScreen?.DeviceName})" : "";
return true;
}
catch (Exception ex)
catch (Exception)
{
LogHelper.WriteLogToFile($"注册全局快捷键 {hotkeyName} 失败: {ex.Message}", LogHelper.LogType.Error);
return false;
}
}
@@ -179,7 +212,6 @@ namespace Ink_Canvas.Helpers
{
if (!File.Exists(HotkeyConfigFile))
{
LogHelper.WriteLogToFile("快捷键配置文件不存在");
return new List<HotkeyInfo>();
}
@@ -212,7 +244,6 @@ namespace Ink_Canvas.Helpers
});
}
LogHelper.WriteLogToFile($"从配置文件读取到 {hotkeyList.Count} 个快捷键信息");
return hotkeyList;
}
catch (Exception ex)
@@ -287,7 +318,6 @@ namespace Ink_Canvas.Helpers
if (!File.Exists(HotkeyConfigFile))
{
LogHelper.WriteLogToFile($"快捷键配置文件不存在: {HotkeyConfigFile}", LogHelper.LogType.Warning);
LogHelper.WriteLogToFile("配置文件不存在,创建默认配置文件并注册默认快捷键");
CreateDefaultConfigFile();
RegisterDefaultHotkeys();
_hotkeysShouldBeRegistered = true;
@@ -299,7 +329,6 @@ namespace Ink_Canvas.Helpers
{
// 成功从配置文件加载快捷键设置
_hotkeysShouldBeRegistered = true;
LogHelper.WriteLogToFile("成功从配置文件加载快捷键设置");
}
else
{
@@ -322,11 +351,9 @@ namespace Ink_Canvas.Helpers
{
try
{
LogHelper.WriteLogToFile("开始保存快捷键配置到配置文件", LogHelper.LogType.Event);
if (SaveHotkeysToConfigFile())
{
LogHelper.WriteLogToFile("快捷键配置已成功保存到配置文件", LogHelper.LogType.Event);
}
else
{
@@ -350,13 +377,28 @@ namespace Ink_Canvas.Helpers
if (!_hotkeysShouldBeRegistered)
{
_hotkeysShouldBeRegistered = true;
LogHelper.WriteLogToFile("启用快捷键注册功能");
// 立即加载快捷键设置
LoadHotkeysFromSettings();
// 启动鼠标位置监控定时器
if (_isMultiScreenMode && _enableScreenSpecificHotkeys && _mousePositionTimer != null)
{
_mousePositionTimer.Start();
}
// 根据上下文决定是否立即加载快捷键
if (ShouldEnableHotkeysBasedOnContext())
{
LoadHotkeysFromSettings();
}
}
else
{
if (_registeredHotkeys.Count == 0)
{
if (ShouldEnableHotkeysBasedOnContext())
{
LoadHotkeysFromSettings();
}
}
}
}
catch (Exception ex)
@@ -377,12 +419,17 @@ namespace Ink_Canvas.Helpers
{
_hotkeysShouldBeRegistered = false;
// 停止鼠标位置监控定时器
if (_mousePositionTimer != null && _mousePositionTimer.IsEnabled)
{
_mousePositionTimer.Stop();
}
// 注销所有快捷键
UnregisterAllHotkeys();
}
else
{
LogHelper.WriteLogToFile("快捷键注册功能已经禁用");
}
}
catch (Exception ex)
@@ -407,7 +454,11 @@ namespace Ink_Canvas.Helpers
{
// 如果设置允许,则在鼠标模式下也启用快捷键
EnableHotkeyRegistration();
LogHelper.WriteLogToFile("切换到鼠标模式,但根据设置保持快捷键启用");
if (_hotkeysShouldBeRegistered && _registeredHotkeys.Count == 0)
{
LoadHotkeysFromSettings();
}
}
else
{
@@ -419,6 +470,11 @@ namespace Ink_Canvas.Helpers
{
// 非鼠标模式下启用快捷键
EnableHotkeyRegistration();
if (_hotkeysShouldBeRegistered && _registeredHotkeys.Count == 0)
{
LoadHotkeysFromSettings();
}
}
}
catch (Exception ex)
@@ -455,7 +511,6 @@ namespace Ink_Canvas.Helpers
if (success)
{
LogHelper.WriteLogToFile($"成功更新快捷键 {hotkeyName}: {modifiers}+{key}", LogHelper.LogType.Event);
// 自动保存配置
SaveHotkeysToSettings();
}
@@ -468,9 +523,424 @@ namespace Ink_Canvas.Helpers
return false;
}
}
/// <summary>
/// 启用基于屏幕的热键注册
/// </summary>
public void EnableScreenSpecificHotkeys()
{
try
{
_enableScreenSpecificHotkeys = true;
// 如果当前在多屏幕环境下,刷新热键注册
if (_isMultiScreenMode)
{
RefreshHotkeysForCurrentScreen();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"启用基于屏幕的热键注册时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 禁用基于屏幕的热键注册
/// </summary>
public void DisableScreenSpecificHotkeys()
{
try
{
_enableScreenSpecificHotkeys = false;
// 重新注册热键(全局模式)
if (_hotkeysShouldBeRegistered)
{
RefreshHotkeysForCurrentScreen();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"禁用基于屏幕的热键注册时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 获取当前屏幕信息
/// </summary>
/// <returns>当前屏幕信息</returns>
public string GetCurrentScreenInfo()
{
try
{
if (_isMultiScreenMode && _currentScreen != null)
{
return $"多屏幕环境 - 当前屏幕: {_currentScreen.DeviceName} ({_currentScreen.Bounds.Width}x{_currentScreen.Bounds.Height})";
}
else
{
return "单屏幕环境";
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"获取当前屏幕信息时出错: {ex.Message}", LogHelper.LogType.Error);
return "无法获取屏幕信息";
}
}
/// <summary>
/// 检查是否启用了基于屏幕的热键注册
/// </summary>
/// <returns>是否启用</returns>
public bool IsScreenSpecificHotkeysEnabled()
{
return _enableScreenSpecificHotkeys && _isMultiScreenMode;
}
/// <summary>
/// 手动刷新当前屏幕的热键注册
/// </summary>
public void RefreshCurrentScreenHotkeys()
{
try
{
RefreshHotkeysForCurrentScreen();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"刷新当前屏幕热键时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
#endregion
#region Private Helper Methods
/// <summary>
/// 初始化多屏幕支持
/// </summary>
private void InitializeMultiScreenSupport()
{
try
{
// 检测是否有多个屏幕
_isMultiScreenMode = ScreenDetectionHelper.HasMultipleScreens();
if (_isMultiScreenMode)
{
// 获取当前窗口所在的屏幕
_currentScreen = ScreenDetectionHelper.GetWindowScreen(_mainWindow);
// 监听窗口位置变化事件
_mainWindow.LocationChanged += OnWindowLocationChanged;
// 初始化智能热键管理
InitializeSmartHotkeyManagement();
}
else
{
_currentScreen = ScreenDetectionHelper.GetPrimaryScreen();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"初始化多屏幕支持时出错: {ex.Message}", LogHelper.LogType.Error);
_isMultiScreenMode = false;
_currentScreen = ScreenDetectionHelper.GetPrimaryScreen();
}
}
/// <summary>
/// 初始化智能热键管理
/// </summary>
private void InitializeSmartHotkeyManagement()
{
try
{
// 监听窗口焦点事件
_mainWindow.GotFocus += OnWindowGotFocus;
_mainWindow.LostFocus += OnWindowLostFocus;
// 监听鼠标进入/离开事件
_mainWindow.MouseEnter += OnMouseEnterWindow;
_mainWindow.MouseLeave += OnMouseLeaveWindow;
// 初始化鼠标位置监控定时器
_mousePositionTimer = new System.Windows.Threading.DispatcherTimer();
_mousePositionTimer.Interval = TimeSpan.FromMilliseconds(500); // 每500ms检查一次
_mousePositionTimer.Tick += OnMousePositionTimerTick;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"初始化热键管理时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 窗口位置变化事件处理
/// </summary>
private void OnWindowLocationChanged(object sender, EventArgs e)
{
try
{
if (!_isMultiScreenMode || !_enableScreenSpecificHotkeys)
return;
var newScreen = ScreenDetectionHelper.GetWindowScreen(_mainWindow);
if (newScreen != null && newScreen != _currentScreen)
{
_currentScreen = newScreen;
// 重新注册热键以适应新屏幕
RefreshHotkeysForCurrentScreen();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理窗口位置变化时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 为当前屏幕刷新热键注册
/// </summary>
private void RefreshHotkeysForCurrentScreen()
{
try
{
if (!_hotkeysShouldBeRegistered)
return;
// 注销所有现有热键
UnregisterAllHotkeys();
// 重新注册热键
LoadHotkeysFromSettings();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"刷新当前屏幕热键时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 窗口获得焦点事件处理
/// </summary>
private void OnWindowGotFocus(object sender, RoutedEventArgs e)
{
try
{
_isWindowFocused = true;
UpdateHotkeyStateBasedOnContext();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理窗口获得焦点事件时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 窗口失去焦点事件处理
/// </summary>
private void OnWindowLostFocus(object sender, RoutedEventArgs e)
{
try
{
_isWindowFocused = false;
UpdateHotkeyStateBasedOnContext();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理窗口失去焦点事件时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 鼠标进入窗口事件处理
/// </summary>
private void OnMouseEnterWindow(object sender, System.Windows.Input.MouseEventArgs e)
{
try
{
_isMouseOverWindow = true;
UpdateHotkeyStateBasedOnContext();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理鼠标进入窗口事件时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 鼠标离开窗口事件处理
/// </summary>
private void OnMouseLeaveWindow(object sender, System.Windows.Input.MouseEventArgs e)
{
try
{
_isMouseOverWindow = false;
UpdateHotkeyStateBasedOnContext();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理鼠标离开窗口事件时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 鼠标位置定时器事件处理
/// </summary>
private void OnMousePositionTimerTick(object sender, EventArgs e)
{
try
{
if (!_isMultiScreenMode || !_enableScreenSpecificHotkeys)
return;
// 检查鼠标是否在当前窗口所在的屏幕上
var mousePosition = Control.MousePosition;
var currentScreen = Screen.FromPoint(mousePosition);
// 无论屏幕是否变化,都检查热键状态
// 这样可以确保热键状态始终与当前上下文保持一致
bool shouldEnableHotkeys = ShouldEnableHotkeysBasedOnContext();
bool currentlyHasHotkeys = _registeredHotkeys.Count > 0;
if (shouldEnableHotkeys && !currentlyHasHotkeys)
{
UpdateHotkeyStateBasedOnContext();
}
else if (!shouldEnableHotkeys && currentlyHasHotkeys)
{
UpdateHotkeyStateBasedOnContext();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理鼠标位置定时器事件时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 根据上下文更新热键状态
/// </summary>
private void UpdateHotkeyStateBasedOnContext()
{
try
{
if (!_hotkeysShouldBeRegistered)
return;
bool shouldEnableHotkeys = ShouldEnableHotkeysBasedOnContext();
bool currentlyHasHotkeys = _registeredHotkeys.Count > 0;
if (shouldEnableHotkeys && !currentlyHasHotkeys)
{
// 需要注册快捷键
LoadHotkeysFromSettings();
}
else if (!shouldEnableHotkeys && currentlyHasHotkeys)
{
// 需要注销快捷键
UnregisterAllHotkeys();
}
// 如果状态没有变化,则不进行任何操作
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"根据上下文更新热键状态时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 检查是否应该注册热键(基于屏幕和模式)
/// </summary>
/// <returns>是否应该注册热键</returns>
private bool ShouldRegisterHotkeys()
{
try
{
// 如果禁用热键注册,则不注册
if (!_hotkeysShouldBeRegistered)
return false;
// 如果启用基于屏幕的热键注册
if (_enableScreenSpecificHotkeys && _isMultiScreenMode)
{
return ShouldEnableHotkeysBasedOnContext();
}
return true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"检查是否应该注册热键时出错: {ex.Message}", LogHelper.LogType.Error);
return true; // 出错时默认注册
}
}
/// <summary>
/// 根据上下文检查是否应该启用热键
/// </summary>
/// <returns>是否应该启用热键</returns>
private bool ShouldEnableHotkeysBasedOnContext()
{
try
{
// 检查当前是否处于鼠标模式
bool isMouseMode = IsInSelectMode();
if (isMouseMode)
{
// 鼠标模式下,根据设置决定是否启用快捷键
return MainWindow.Settings.Appearance.EnableHotkeysInMouseMode;
}
else
{
// 非鼠标模式下,需要检查焦点和屏幕位置
// 策略1:鼠标在窗口上时启用热键(最高优先级)
if (_isMouseOverWindow)
{
return true;
}
// 策略2:在多屏幕环境下,检查鼠标是否在当前窗口所在的屏幕上
if (_isMultiScreenMode && _enableScreenSpecificHotkeys)
{
var mousePosition = Control.MousePosition;
var mouseScreen = Screen.FromPoint(mousePosition);
if (mouseScreen == _currentScreen)
{
return true;
}
else
{
return false;
}
}
// 策略3:单屏幕环境下,窗口有焦点时启用热键
if (_isWindowFocused)
{
return true;
}
// 策略4:如果以上都不满足,但在非鼠标模式下,仍然启用快捷键
// 这样可以确保在批注模式下快捷键始终可用
return true;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"检查是否应该启用热键时出错: {ex.Message}", LogHelper.LogType.Error);
return true; // 出错时默认启用
}
}
/// <summary>
/// 切换到指定笔类型
/// </summary>
@@ -513,7 +983,6 @@ namespace Ink_Canvas.Helpers
// 如果配置文件不存在,创建默认配置文件
if (!File.Exists(HotkeyConfigFile))
{
LogHelper.WriteLogToFile($"快捷键配置文件不存在,创建默认配置文件: {HotkeyConfigFile}", LogHelper.LogType.Event);
CreateDefaultConfigFile();
}
}
@@ -579,7 +1048,6 @@ namespace Ink_Canvas.Helpers
// 写入配置文件
File.WriteAllText(HotkeyConfigFile, jsonContent, Encoding.UTF8);
LogHelper.WriteLogToFile($"已创建默认快捷键配置文件: {HotkeyConfigFile}", LogHelper.LogType.Event);
}
catch (Exception ex)
{
@@ -643,7 +1111,6 @@ namespace Ink_Canvas.Helpers
}
}
LogHelper.WriteLogToFile($"成功加载 {successCount}/{config.Hotkeys.Count} 个快捷键配置", LogHelper.LogType.Event);
if (successCount > 0)
{
_hotkeysShouldBeRegistered = true;
@@ -702,7 +1169,6 @@ namespace Ink_Canvas.Helpers
// 直接写入原文件,覆盖原有内容
File.WriteAllText(HotkeyConfigFile, jsonContent, Encoding.UTF8);
LogHelper.WriteLogToFile($"快捷键配置已保存到: {HotkeyConfigFile}", LogHelper.LogType.Event);
return true;
}
catch (Exception ex)
@@ -908,6 +1374,29 @@ namespace Ink_Canvas.Helpers
{
if (!_isDisposed)
{
// 注销所有快捷键
UnregisterAllHotkeys();
// 停止定时器
if (_mousePositionTimer != null)
{
_mousePositionTimer.Stop();
_mousePositionTimer = null;
}
// 移除事件监听器
if (_mainWindow != null)
{
if (_isMultiScreenMode)
{
_mainWindow.LocationChanged -= OnWindowLocationChanged;
}
_mainWindow.GotFocus -= OnWindowGotFocus;
_mainWindow.LostFocus -= OnWindowLostFocus;
_mainWindow.MouseEnter -= OnMouseEnterWindow;
_mainWindow.MouseLeave -= OnMouseLeaveWindow;
}
_isDisposed = true;
}
+5
View File
@@ -71,6 +71,11 @@ namespace Ink_Canvas.Helpers
try
{
// 确保主窗口的InkCanvas保持Ink编辑模式,防止墨迹渐隐时切换到鼠标模式
if (_mainWindow.inkCanvas.EditingMode != InkCanvasEditingMode.Ink)
{
_mainWindow.inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
}
// 记录墨迹的起点和终点
_strokeStartPoints[stroke] = startPoint;
+19 -16
View File
@@ -75,39 +75,42 @@ namespace Ink_Canvas.Helpers
/// </summary>
public void ApplyQualitySettings()
{
// 保存用户设置的异步处理偏好
bool userAsyncPreference = UseAsyncProcessing;
switch (Quality)
{
case SmoothingQuality.Performance:
SmoothingStrength = 0.15;
ResampleInterval = 5.0;
InterpolationSteps = 4;
SmoothingStrength = 0.15;
ResampleInterval = 5.0;
InterpolationSteps = 4;
UseAdaptiveInterpolation = false;
CurveTension = 0.15;
CurveTension = 0.15;
MaxConcurrentTasks = Math.Max(1, Environment.ProcessorCount / 2);
UseHardwareAcceleration = true;
UseAsyncProcessing = true;
UseHardwareAcceleration = true;
UseAsyncProcessing = userAsyncPreference;
break;
case SmoothingQuality.Balanced:
SmoothingStrength = 0.3;
ResampleInterval = 3.0;
InterpolationSteps = 8;
SmoothingStrength = 0.3;
ResampleInterval = 3.0;
InterpolationSteps = 8;
UseAdaptiveInterpolation = true;
CurveTension = 0.25;
CurveTension = 0.25;
MaxConcurrentTasks = Environment.ProcessorCount;
UseHardwareAcceleration = true;
UseAsyncProcessing = true;
UseAsyncProcessing = userAsyncPreference;
break;
case SmoothingQuality.Quality:
SmoothingStrength = 0.5;
ResampleInterval = 2.0;
InterpolationSteps = 15;
SmoothingStrength = 0.5;
ResampleInterval = 2.0;
InterpolationSteps = 15;
UseAdaptiveInterpolation = true;
CurveTension = 0.35;
CurveTension = 0.35;
MaxConcurrentTasks = Environment.ProcessorCount;
UseHardwareAcceleration = true;
UseAsyncProcessing = true;
UseAsyncProcessing = userAsyncPreference;
break;
}
}
-666
View File
@@ -1,666 +0,0 @@
using Microsoft.Office.Interop.PowerPoint;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Ink;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// 多PPT墨迹管理器 - 支持多个PPT窗口分别管理墨迹
/// </summary>
public class MultiPPTInkManager : IDisposable
{
#region Properties
public bool IsAutoSaveEnabled { get; set; } = true;
public string AutoSaveLocation { get; set; } = "";
public PPTManager PPTManager { get; set; }
#endregion
#region Private Fields
private readonly Dictionary<string, PPTInkManager> _presentationManagers;
private readonly Dictionary<string, PresentationInfo> _presentationInfos;
private readonly object _lockObject = new object();
private bool _disposed;
private string _currentActivePresentationId = "";
#endregion
#region Constructor
public MultiPPTInkManager()
{
_presentationManagers = new Dictionary<string, PPTInkManager>();
_presentationInfos = new Dictionary<string, PresentationInfo>();
}
#endregion
#region Public Methods
/// <summary>
/// 初始化新的演示文稿
/// </summary>
public void InitializePresentation(Presentation presentation)
{
if (presentation == null) return;
lock (_lockObject)
{
try
{
var presentationId = GeneratePresentationId(presentation);
// 如果已存在该演示文稿的管理器,先清理
if (_presentationManagers.ContainsKey(presentationId))
{
_presentationManagers[presentationId].Dispose();
_presentationManagers.Remove(presentationId);
}
// 创建新的墨迹管理器
var inkManager = new PPTInkManager();
inkManager.IsAutoSaveEnabled = IsAutoSaveEnabled;
inkManager.AutoSaveLocation = AutoSaveLocation;
inkManager.InitializePresentation(presentation);
// 保存管理器和演示文稿信息
_presentationManagers[presentationId] = inkManager;
_presentationInfos[presentationId] = new PresentationInfo
{
Id = presentationId,
Name = presentation.Name,
FullName = presentation.FullName,
SlideCount = presentation.Slides.Count,
CreatedTime = DateTime.Now,
LastAccessTime = DateTime.Now
};
// 设置为当前活跃的演示文稿
_currentActivePresentationId = presentationId;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"初始化多PPT墨迹管理失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 切换到指定的演示文稿
/// </summary>
public bool SwitchToPresentation(Presentation presentation)
{
if (presentation == null) return false;
lock (_lockObject)
{
try
{
var presentationId = GeneratePresentationId(presentation);
if (_presentationManagers.ContainsKey(presentationId))
{
// 如果切换的是不同的演示文稿,先保存当前活跃演示文稿的墨迹
if (!string.IsNullOrEmpty(_currentActivePresentationId) &&
_currentActivePresentationId != presentationId)
{
var currentManager = GetCurrentManager();
if (currentManager != null)
{
// 获取当前活跃的演示文稿并保存墨迹
var currentPresentation = GetCurrentActivePresentation();
if (currentPresentation != null)
{
currentManager.SaveAllStrokesToFile(currentPresentation);
LogHelper.WriteLogToFile($"已保存当前演示文稿墨迹: {currentPresentation.Name}", LogHelper.LogType.Trace);
}
}
}
_currentActivePresentationId = presentationId;
// 更新最后访问时间
if (_presentationInfos.ContainsKey(presentationId))
{
_presentationInfos[presentationId].LastAccessTime = DateTime.Now;
}
if (_currentActivePresentationId != presentationId)
{
LogHelper.WriteLogToFile($"已切换到演示文稿: {presentation.Name}", LogHelper.LogType.Trace);
}
return true;
}
else
{
// 如果不存在,尝试初始化
InitializePresentation(presentation);
return true;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"切换到演示文稿失败: {ex}", LogHelper.LogType.Error);
return false;
}
}
}
/// <summary>
/// 保存当前页面的墨迹
/// </summary>
public void SaveCurrentSlideStrokes(int slideIndex, StrokeCollection strokes)
{
if (slideIndex <= 0 || strokes == null) return;
lock (_lockObject)
{
try
{
var manager = GetCurrentManager();
if (manager != null)
{
manager.SaveCurrentSlideStrokes(slideIndex, strokes);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 强制保存指定页面的墨迹(忽略锁定状态)
/// </summary>
public void ForceSaveSlideStrokes(int slideIndex, StrokeCollection strokes)
{
if (slideIndex <= 0 || strokes == null) return;
lock (_lockObject)
{
try
{
var manager = GetCurrentManager();
if (manager != null)
{
manager.ForceSaveSlideStrokes(slideIndex, strokes);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"强制保存页面墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 加载指定页面的墨迹
/// </summary>
public StrokeCollection LoadSlideStrokes(int slideIndex)
{
if (slideIndex <= 0) return new StrokeCollection();
lock (_lockObject)
{
try
{
var manager = GetCurrentManager();
if (manager != null)
{
return manager.LoadSlideStrokes(slideIndex);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"加载页面墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
return new StrokeCollection();
}
/// <summary>
/// 切换到指定页面并加载墨迹
/// </summary>
public StrokeCollection SwitchToSlide(int slideIndex, StrokeCollection currentStrokes = null)
{
lock (_lockObject)
{
try
{
var manager = GetCurrentManager();
if (manager != null)
{
return manager.SwitchToSlide(slideIndex, currentStrokes);
}
else
{
LogHelper.WriteLogToFile($"无法获取当前墨迹管理器,页面切换失败: {slideIndex}", LogHelper.LogType.Warning);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"切换页面墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
return new StrokeCollection();
}
/// <summary>
/// 保存所有墨迹到文件
/// </summary>
public void SaveAllStrokesToFile(Presentation presentation)
{
if (!IsAutoSaveEnabled || string.IsNullOrEmpty(AutoSaveLocation) || presentation == null) return;
lock (_lockObject)
{
try
{
var presentationId = GeneratePresentationId(presentation);
if (_presentationManagers.ContainsKey(presentationId))
{
_presentationManagers[presentationId].SaveAllStrokesToFile(presentation);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存所有墨迹到文件失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 从文件加载已保存的墨迹
/// </summary>
public void LoadSavedStrokes(Presentation presentation)
{
if (!IsAutoSaveEnabled || string.IsNullOrEmpty(AutoSaveLocation) || presentation == null) return;
lock (_lockObject)
{
try
{
var presentationId = GeneratePresentationId(presentation);
if (_presentationManagers.ContainsKey(presentationId))
{
_presentationManagers[presentationId].LoadSavedStrokes();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"从文件加载墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 清除指定演示文稿的所有墨迹
/// </summary>
public void ClearPresentationStrokes(Presentation presentation)
{
if (presentation == null) return;
lock (_lockObject)
{
try
{
var presentationId = GeneratePresentationId(presentation);
if (_presentationManagers.ContainsKey(presentationId))
{
_presentationManagers[presentationId].ClearAllStrokes();
LogHelper.WriteLogToFile($"已清除演示文稿墨迹: {presentation.Name}", LogHelper.LogType.Trace);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清除演示文稿墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 清除所有演示文稿的墨迹
/// </summary>
public void ClearAllStrokes()
{
lock (_lockObject)
{
try
{
foreach (var manager in _presentationManagers.Values)
{
manager?.ClearAllStrokes();
}
LogHelper.WriteLogToFile("已清除所有演示文稿墨迹", LogHelper.LogType.Trace);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清除所有墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 翻页后锁定墨迹写入
/// </summary>
public void LockInkForSlide(int slideIndex)
{
lock (_lockObject)
{
try
{
var manager = GetCurrentManager();
if (manager != null)
{
manager.LockInkForSlide(slideIndex);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"锁定墨迹写入失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 检查是否可以写入墨迹
/// </summary>
public bool CanWriteInk(int currentSlideIndex)
{
lock (_lockObject)
{
try
{
var manager = GetCurrentManager();
if (manager != null)
{
return manager.CanWriteInk(currentSlideIndex);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"检查墨迹写入权限失败: {ex}", LogHelper.LogType.Error);
}
}
return false;
}
/// <summary>
/// 重置当前演示文稿的墨迹锁定状态
/// </summary>
public void ResetCurrentPresentationLockState()
{
lock (_lockObject)
{
try
{
var manager = GetCurrentManager();
if (manager != null)
{
manager.ResetLockState();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"重置墨迹锁定状态失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 移除演示文稿管理器
/// </summary>
public void RemovePresentation(Presentation presentation)
{
if (presentation == null) return;
lock (_lockObject)
{
try
{
var presentationId = GeneratePresentationId(presentation);
if (_presentationManagers.ContainsKey(presentationId))
{
// 保存墨迹到文件
_presentationManagers[presentationId].SaveAllStrokesToFile(presentation);
// 释放资源
_presentationManagers[presentationId].Dispose();
_presentationManagers.Remove(presentationId);
}
if (_presentationInfos.ContainsKey(presentationId))
{
_presentationInfos.Remove(presentationId);
}
// 如果移除的是当前活跃的演示文稿,重置活跃ID
if (_currentActivePresentationId == presentationId)
{
_currentActivePresentationId = "";
}
}
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
if (hr == 0x8001010E || hr == 0x80004005 || hr == 0x800706BA || hr == 0x800706BE || hr == 0x80048010)
{
}
}
catch (Exception)
{
}
}
}
/// <summary>
/// 获取当前管理的演示文稿数量
/// </summary>
public int GetPresentationCount()
{
lock (_lockObject)
{
return _presentationManagers.Count;
}
}
/// <summary>
/// 获取所有演示文稿信息
/// </summary>
public List<PresentationInfo> GetAllPresentationInfos()
{
lock (_lockObject)
{
return _presentationInfos.Values.ToList();
}
}
/// <summary>
/// 清理长时间未访问的演示文稿管理器
/// </summary>
public void CleanupInactivePresentations(TimeSpan inactiveThreshold)
{
lock (_lockObject)
{
try
{
var inactiveIds = new List<string>();
var cutoffTime = DateTime.Now - inactiveThreshold;
foreach (var info in _presentationInfos.Values)
{
if (info.LastAccessTime < cutoffTime && info.Id != _currentActivePresentationId)
{
inactiveIds.Add(info.Id);
}
}
foreach (var id in inactiveIds)
{
if (_presentationManagers.ContainsKey(id))
{
_presentationManagers[id].Dispose();
_presentationManagers.Remove(id);
}
_presentationInfos.Remove(id);
LogHelper.WriteLogToFile($"已清理非活跃演示文稿: {id}", LogHelper.LogType.Trace);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理非活跃演示文稿失败: {ex}", LogHelper.LogType.Error);
}
}
}
#endregion
#region Private Methods
private PPTInkManager GetCurrentManager()
{
if (string.IsNullOrEmpty(_currentActivePresentationId) ||
!_presentationManagers.ContainsKey(_currentActivePresentationId))
{
return null;
}
return _presentationManagers[_currentActivePresentationId];
}
private Presentation GetCurrentActivePresentation()
{
try
{
// 通过PPTManager获取当前活跃的演示文稿
return PPTManager?.GetCurrentActivePresentation();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"获取当前活跃演示文稿失败: {ex}", LogHelper.LogType.Error);
return null;
}
}
private string GeneratePresentationId(Presentation presentation)
{
try
{
// 检查COM对象是否仍然有效
if (presentation == null)
{
return $"invalid_{DateTime.Now.Ticks}";
}
var presentationPath = presentation.FullName;
var fileHash = GetFileHash(presentationPath);
var processId = GetProcessId(presentation);
return $"{presentation.Name}_{fileHash}_{processId}";
}
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
if (hr == 0x8001010E || hr == 0x80004005 || hr == 0x800706BA || hr == 0x800706BE || hr == 0x80048010)
{
return $"disconnected_{DateTime.Now.Ticks}";
}
return $"error_{DateTime.Now.Ticks}";
}
catch (Exception)
{
return $"unknown_{DateTime.Now.Ticks}";
}
}
private string GetFileHash(string filePath)
{
try
{
if (string.IsNullOrEmpty(filePath)) return "unknown";
using (var md5 = MD5.Create())
{
byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(filePath));
return BitConverter.ToString(hashBytes).Replace("-", "").Substring(0, 8);
}
}
catch (Exception)
{
// 所有异常都静默处理,避免日志噪音
return "error";
}
}
private string GetProcessId(Presentation presentation)
{
try
{
// 尝试获取PowerPoint应用程序的进程ID
if (presentation.Application != null)
{
// 通过COM对象获取进程信息
var hwnd = presentation.Application.HWND;
if (hwnd != 0)
{
return hwnd.ToString();
}
}
return "unknown";
}
catch (COMException comEx)
{
// COM对象已失效,这是正常情况,完全静默处理
var hr = (uint)comEx.HResult;
if (hr == 0x8001010E || hr == 0x80004005 || hr == 0x800706BA || hr == 0x800706BE || hr == 0x80048010)
{
return "disconnected";
}
return "error";
}
catch (Exception)
{
return "error";
}
}
#endregion
#region Dispose
public void Dispose()
{
if (!_disposed)
{
lock (_lockObject)
{
foreach (var manager in _presentationManagers.Values)
{
manager?.Dispose();
}
_presentationManagers.Clear();
_presentationInfos.Clear();
}
_disposed = true;
}
}
#endregion
}
/// <summary>
/// 演示文稿信息
/// </summary>
public class PresentationInfo
{
public string Id { get; set; }
public string Name { get; set; }
public string FullName { get; set; }
public int SlideCount { get; set; }
public DateTime CreatedTime { get; set; }
public DateTime LastAccessTime { get; set; }
}
}
+121 -33
View File
@@ -1,4 +1,5 @@
using System;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Ink;
using System.Windows.Input;
@@ -8,30 +9,52 @@ namespace Ink_Canvas.Helpers
{
public class VisualCanvas : FrameworkElement
{
private readonly List<DrawingVisual> _visuals = new List<DrawingVisual>();
protected override Visual GetVisualChild(int index)
{
return Visual;
if (index < 0 || index >= _visuals.Count)
throw new ArgumentOutOfRangeException(nameof(index));
return _visuals[index];
}
protected override int VisualChildrenCount => 1;
protected override int VisualChildrenCount => _visuals.Count;
public VisualCanvas(DrawingVisual visual)
public VisualCanvas()
{
Visual = visual;
CacheMode = new BitmapCache();
RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality);
RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
RenderOptions.SetCachingHint(this, CachingHint.Cache);
}
public void AddVisual(DrawingVisual visual)
{
if (visual == null) return;
_visuals.Add(visual);
AddVisualChild(visual);
}
public void Clear()
{
foreach (var visual in _visuals)
{
RemoveVisualChild(visual);
}
_visuals.Clear();
}
public DrawingVisual Visual { get; }
public IReadOnlyList<DrawingVisual> Visuals => _visuals;
}
/// <summary>
/// 用于显示笔迹的类
/// </summary>
public class StrokeVisual : DrawingVisual
public class StrokeVisual
{
private bool _needsRedraw = true;
private int _lastPointCount = 0;
private const int REDRAW_THRESHOLD = 3;
private int _lastDrawnPointCount = 0;
private const int INCREMENTAL_DRAW_THRESHOLD = 2;
private VisualCanvas _visualCanvas;
/// <summary>
/// 创建显示笔迹的类
@@ -47,17 +70,12 @@ namespace Ink_Canvas.Helpers
}
/// <summary>
/// 创建显示笔迹的类
/// 创建显示笔迹的类
/// </summary>
/// <param name="drawingAttributes"></param>
public StrokeVisual(DrawingAttributes drawingAttributes)
{
_drawingAttributes = drawingAttributes;
// 启用硬件加速
RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality);
RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
RenderOptions.SetCachingHint(this, CachingHint.Cache);
}
/// <summary>
@@ -65,6 +83,14 @@ namespace Ink_Canvas.Helpers
/// </summary>
public Stroke Stroke { set; get; }
/// <summary>
/// 设置关联的VisualCanvas
/// </summary>
public void SetVisualCanvas(VisualCanvas visualCanvas)
{
_visualCanvas = visualCanvas;
}
/// <summary>
/// 在笔迹中添加点
/// </summary>
@@ -75,16 +101,61 @@ namespace Ink_Canvas.Helpers
{
var collection = new StylusPointCollection { point };
Stroke = new Stroke(collection) { DrawingAttributes = _drawingAttributes };
_lastPointCount = 1;
}
else
{
Stroke.StylusPoints.Add(point);
_lastPointCount++;
}
// 标记需要重绘
_needsRedraw = true;
}
/// <summary>
/// 绘制点段到新的DrawingVisual
/// </summary>
private void DrawSegmentToNewVisual(int startIndex, int endIndex)
{
if (Stroke == null || Stroke.StylusPoints.Count == 0 || _visualCanvas == null) return;
if (startIndex >= endIndex || startIndex < 0 || endIndex > Stroke.StylusPoints.Count) return;
var points = Stroke.StylusPoints;
var drawingAttributes = Stroke.DrawingAttributes;
// 创建新的DrawingVisual用于绘制这个点段
var segmentVisual = new DrawingVisual();
RenderOptions.SetBitmapScalingMode(segmentVisual, BitmapScalingMode.HighQuality);
RenderOptions.SetEdgeMode(segmentVisual, EdgeMode.Aliased);
RenderOptions.SetCachingHint(segmentVisual, CachingHint.Cache);
using (var dc = segmentVisual.RenderOpen())
{
var pen = new Pen(new SolidColorBrush(drawingAttributes.Color), drawingAttributes.Width);
pen.StartLineCap = PenLineCap.Round;
pen.EndLineCap = PenLineCap.Round;
pen.LineJoin = PenLineJoin.Round;
// 绘制指定范围内的点段
if (endIndex - startIndex >= 2)
{
// 多个点,绘制线段
for (int i = startIndex; i < endIndex - 1 && i < points.Count - 1; i++)
{
var startPoint = new Point(points[i].X, points[i].Y);
var endPoint = new Point(points[i + 1].X, points[i + 1].Y);
dc.DrawLine(pen, startPoint, endPoint);
}
}
else if (endIndex - startIndex == 1 && startIndex < points.Count)
{
// 只有一个点,绘制圆点
var brush = new SolidColorBrush(drawingAttributes.Color);
var point = points[startIndex];
dc.DrawEllipse(brush, null, new Point(point.X, point.Y),
drawingAttributes.Width / 2, drawingAttributes.Height / 2);
}
}
// 将新的DrawingVisual添加到VisualCanvas中
_visualCanvas.AddVisual(segmentVisual);
}
/// <summary>
@@ -92,22 +163,35 @@ namespace Ink_Canvas.Helpers
/// </summary>
public void Redraw()
{
if (!_needsRedraw || Stroke == null) return;
if (_lastPointCount % REDRAW_THRESHOLD != 0 && _lastPointCount > REDRAW_THRESHOLD)
{
return;
}
if (Stroke == null || _visualCanvas == null) return;
try
var currentPointCount = Stroke.StylusPoints.Count;
if (currentPointCount == 0) return;
// 计算新增的点数
int newPointCount = currentPointCount - _lastDrawnPointCount;
// 如果新增点数达到阈值,才进行增量绘制
if (newPointCount >= INCREMENTAL_DRAW_THRESHOLD || _lastDrawnPointCount == 0)
{
using (var dc = RenderOpen())
try
{
Stroke.Draw(dc);
if (_lastDrawnPointCount == 0)
{
// 首次绘制:绘制所有点
DrawSegmentToNewVisual(0, currentPointCount);
_lastDrawnPointCount = currentPointCount;
}
else
{
// 从上次绘制的最后一个点开始
int startIndex = Math.Max(0, _lastDrawnPointCount - 1);
DrawSegmentToNewVisual(startIndex, currentPointCount);
_lastDrawnPointCount = currentPointCount;
}
}
_needsRedraw = false;
catch { }
}
catch { }
}
/// <summary>
@@ -115,7 +199,11 @@ namespace Ink_Canvas.Helpers
/// </summary>
public void ForceRedraw()
{
_needsRedraw = true;
if (_visualCanvas != null)
{
_visualCanvas.Clear();
}
_lastDrawnPointCount = 0;
Redraw();
}
+191 -26
View File
@@ -30,11 +30,17 @@ namespace Ink_Canvas.Helpers
private DateTime _inkLockUntil = DateTime.MinValue;
private int _lockedSlideIndex = -1;
private const int InkLockMilliseconds = 500;
// 添加快速切换保护机制
private DateTime _lastSwitchTime = DateTime.MinValue;
private int _lastSwitchSlideIndex = -1;
private const int MinSwitchIntervalMs = 100; // 最小切换间隔100毫秒
// 内存管理相关字段
private long _totalMemoryUsage = 0;
private const long MaxMemoryUsageBytes = 100 * 1024 * 1024; // 100MB限制
private DateTime _lastMemoryCleanup = DateTime.MinValue;
private const int MemoryCleanupIntervalMinutes = 5; // 5分钟清理一次
#endregion
#region Constructor
@@ -84,7 +90,7 @@ namespace Ink_Canvas.Helpers
{
return;
}
throw;
throw;
}
_memoryStreams = new MemoryStream[slideCount + 2];
@@ -118,24 +124,34 @@ namespace Ink_Canvas.Helpers
{
if (DateTime.Now < _inkLockUntil)
{
LogHelper.WriteLogToFile($"墨迹写入被锁定,当前页:{slideIndex},锁定页:{_lockedSlideIndex}", LogHelper.LogType.Warning);
}
return;
}
if (slideIndex < _memoryStreams.Length)
{
// 先释放旧的内存流,防止内存泄漏
try
{
_memoryStreams[slideIndex]?.Dispose();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"释放旧内存流失败: {ex}", LogHelper.LogType.Warning);
}
// 创建新的内存流
var ms = new MemoryStream();
strokes.Save(ms);
ms.Position = 0;
// 释放旧的内存流
_memoryStreams[slideIndex]?.Dispose();
_memoryStreams[slideIndex] = ms;
if (ms.Length > 0)
{
}
// 检查内存使用情况
CheckAndPerformMemoryCleanup();
}
}
catch (Exception ex)
@@ -146,7 +162,7 @@ namespace Ink_Canvas.Helpers
}
/// <summary>
/// 强制保存指定页面的墨迹(忽略锁定状态)
/// 强制保存指定页面的墨迹
/// </summary>
public void ForceSaveSlideStrokes(int slideIndex, StrokeCollection strokes)
{
@@ -158,12 +174,20 @@ namespace Ink_Canvas.Helpers
{
if (slideIndex < _memoryStreams.Length)
{
// 先释放旧的内存流,防止内存泄漏
try
{
_memoryStreams[slideIndex]?.Dispose();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"释放旧内存流失败: {ex}", LogHelper.LogType.Warning);
}
// 创建新的内存流
var ms = new MemoryStream();
strokes.Save(ms);
ms.Position = 0;
// 释放旧的内存流
_memoryStreams[slideIndex]?.Dispose();
_memoryStreams[slideIndex] = ms;
LogHelper.WriteLogToFile($"已强制保存第{slideIndex}页墨迹,大小: {ms.Length} bytes", LogHelper.LogType.Trace);
@@ -214,7 +238,7 @@ namespace Ink_Canvas.Helpers
{
// 检查快速切换保护
var now = DateTime.Now;
if (now - _lastSwitchTime < TimeSpan.FromMilliseconds(MinSwitchIntervalMs) &&
if (now - _lastSwitchTime < TimeSpan.FromMilliseconds(MinSwitchIntervalMs) &&
_lastSwitchSlideIndex == slideIndex)
{
LogHelper.WriteLogToFile($"快速切换保护:忽略重复的页面切换请求 {slideIndex}", LogHelper.LogType.Warning);
@@ -227,11 +251,11 @@ namespace Ink_Canvas.Helpers
// 加载新页面的墨迹
var newStrokes = LoadSlideStrokes(slideIndex);
// 更新切换记录
_lastSwitchTime = now;
_lastSwitchSlideIndex = slideIndex;
if (newStrokes.Count > 0)
{
}
@@ -249,7 +273,9 @@ namespace Ink_Canvas.Helpers
/// <summary>
/// 保存所有墨迹到文件
/// </summary>
public void SaveAllStrokesToFile(Presentation presentation)
/// <param name="presentation">演示文稿对象</param>
/// <param name="currentSlideIndex">当前播放的页码,如果提供则使用此值保存位置,否则使用_lockedSlideIndex</param>
public void SaveAllStrokesToFile(Presentation presentation, int currentSlideIndex = -1)
{
if (!IsAutoSaveEnabled || string.IsNullOrEmpty(AutoSaveLocation) || presentation == null) return;
@@ -266,7 +292,18 @@ namespace Ink_Canvas.Helpers
// 保存位置信息
try
{
File.WriteAllText(Path.Combine(folderPath, "Position"), _lockedSlideIndex.ToString());
// 优先使用传入的当前页码,否则使用锁定的页码
int positionToSave = currentSlideIndex > 0 ? currentSlideIndex : _lockedSlideIndex;
// 如果都没有有效值,尝试使用最后切换的页码
if (positionToSave <= 0 && _lastSwitchSlideIndex > 0)
{
positionToSave = _lastSwitchSlideIndex;
}
if (positionToSave > 0)
{
File.WriteAllText(Path.Combine(folderPath, "Position"), positionToSave.ToString());
}
}
catch (Exception ex)
{
@@ -276,7 +313,7 @@ namespace Ink_Canvas.Helpers
// 保存所有页面的墨迹
int savedCount = 0;
int slideCount = 0;
try
{
slideCount = presentation.Slides.Count;
@@ -284,13 +321,13 @@ namespace Ink_Canvas.Helpers
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
if (hr == 0x80048010)
if (hr == 0x80048010)
{
return;
}
throw;
throw;
}
for (int i = 1; i <= slideCount && i < _memoryStreams.Length; i++)
{
if (_memoryStreams[i] != null)
@@ -388,13 +425,30 @@ namespace Ink_Canvas.Helpers
{
try
{
for (int i = 0; i < _memoryStreams.Length; i++)
// 安全释放所有内存流
if (_memoryStreams != null)
{
_memoryStreams[i]?.Dispose();
_memoryStreams[i] = null;
for (int i = 0; i < _memoryStreams.Length; i++)
{
try
{
_memoryStreams[i]?.Dispose();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"释放内存流{i}失败: {ex}", LogHelper.LogType.Warning);
}
finally
{
_memoryStreams[i] = null;
}
}
// 重新初始化数组
_memoryStreams = new MemoryStream[_maxSlides + 2];
}
CurrentStrokes.Clear();
CurrentStrokes?.Clear();
LogHelper.WriteLogToFile("已清除所有墨迹", LogHelper.LogType.Trace);
}
catch (Exception ex)
@@ -423,13 +477,20 @@ namespace Ink_Canvas.Helpers
{
return true;
}
// 如果当前页面与锁定页面相同,允许写入(用户在当前页面绘制)
if (currentSlideIndex == _lockedSlideIndex)
{
return true;
}
// 如果当前页面不是锁定页面,但锁定时间很短(小于50ms),允许写入
// 这样可以确保旧页面的墨迹能够及时保存
if (DateTime.Now - (_inkLockUntil.AddMilliseconds(-InkLockMilliseconds)) < TimeSpan.FromMilliseconds(50))
{
return true;
}
// 只有在快速切换且页面不同时才锁定
return false;
}
@@ -447,6 +508,110 @@ namespace Ink_Canvas.Helpers
_lastSwitchSlideIndex = -1;
}
}
/// <summary>
/// 检查并执行内存清理
/// </summary>
private void CheckAndPerformMemoryCleanup()
{
try
{
var now = DateTime.Now;
// 检查是否需要执行内存清理
if (now - _lastMemoryCleanup < TimeSpan.FromMinutes(MemoryCleanupIntervalMinutes))
{
return;
}
// 计算当前内存使用量
long currentMemoryUsage = 0;
if (_memoryStreams != null)
{
for (int i = 0; i < _memoryStreams.Length; i++)
{
if (_memoryStreams[i] != null)
{
currentMemoryUsage += _memoryStreams[i].Length;
}
}
}
_totalMemoryUsage = currentMemoryUsage;
// 如果内存使用量超过限制,执行清理
if (currentMemoryUsage > MaxMemoryUsageBytes)
{
LogHelper.WriteLogToFile($"内存使用量超限 ({currentMemoryUsage / 1024 / 1024}MB),开始清理", LogHelper.LogType.Warning);
// 清理非当前页面的墨迹
CleanupInactiveSlideStrokes();
_lastMemoryCleanup = now;
LogHelper.WriteLogToFile($"内存清理完成,当前使用量: {_totalMemoryUsage / 1024 / 1024}MB", LogHelper.LogType.Trace);
}
else
{
_lastMemoryCleanup = now;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"内存清理检查失败: {ex}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 清理非活跃页面的墨迹
/// </summary>
private void CleanupInactiveSlideStrokes()
{
try
{
if (_memoryStreams == null) return;
int cleanedCount = 0;
long freedMemory = 0;
for (int i = 0; i < _memoryStreams.Length; i++)
{
// 保留当前锁定页面和最近访问的页面
if (i == _lockedSlideIndex || i == _lastSwitchSlideIndex)
{
continue;
}
if (_memoryStreams[i] != null)
{
long memorySize = _memoryStreams[i].Length;
try
{
_memoryStreams[i].Dispose();
freedMemory += memorySize;
cleanedCount++;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理页面{i}墨迹失败: {ex}", LogHelper.LogType.Warning);
}
finally
{
_memoryStreams[i] = null;
}
}
}
if (cleanedCount > 0)
{
LogHelper.WriteLogToFile($"已清理{cleanedCount}个页面的墨迹,释放内存: {freedMemory / 1024}KB", LogHelper.LogType.Trace);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理非活跃页面墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
#endregion
#region Private Methods
@@ -456,7 +621,7 @@ namespace Ink_Canvas.Helpers
{
var presentationPath = presentation.FullName;
var fileHash = GetFileHash(presentationPath);
return $"{presentation.Name}_{fileHash}";
return $"{presentation.Name}_{presentation.Slides.Count}_{fileHash}";
}
catch (Exception ex)
{
+120 -61
View File
@@ -1,4 +1,5 @@
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -93,7 +94,6 @@ namespace Ink_Canvas.Helpers
// COM对象已失效,触发断开连接
DisconnectFromPPT();
}
LogHelper.WriteLogToFile($"验证PPT放映窗口失败: {comEx.Message} (HR: 0x{hr:X8})", LogHelper.LogType.Warning);
return false;
}
}
@@ -411,63 +411,30 @@ namespace Ink_Canvas.Helpers
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
LogHelper.WriteLogToFile($"取消PPT事件注册时COM异常: {comEx.Message} (HR: 0x{hr:X8})", LogHelper.LogType.Warning);
}
catch (InvalidCastException)
{
// COM对象类型转换失败,通常是因为对象已经被释放
LogHelper.WriteLogToFile("PPT COM对象已被释放,跳过事件注册取消", LogHelper.LogType.Trace);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"取消PPT事件注册时发生异常: {ex}", LogHelper.LogType.Warning);
}
}, DispatcherPriority.Normal, CancellationToken.None, TimeSpan.FromSeconds(1));
}
}
catch (Exception)
catch (Exception ex)
{
LogHelper.WriteLogToFile($"取消PPT事件注册失败: {ex}", LogHelper.LogType.Warning);
}
// 释放COM对象
try
{
if (Marshal.IsComObject(CurrentSlide))
{
Marshal.ReleaseComObject(CurrentSlide);
}
}
catch (Exception)
{
}
try
{
if (Marshal.IsComObject(CurrentSlides))
{
Marshal.ReleaseComObject(CurrentSlides);
}
}
catch (Exception)
{
}
try
{
if (Marshal.IsComObject(CurrentPresentation))
{
Marshal.ReleaseComObject(CurrentPresentation);
}
}
catch (Exception)
{
}
try
{
if (Marshal.IsComObject(PPTApplication))
{
Marshal.ReleaseComObject(PPTApplication);
}
}
catch (Exception)
{
}
// 安全释放COM对象
SafeReleaseComObject(CurrentSlide, "CurrentSlide");
SafeReleaseComObject(CurrentSlides, "CurrentSlides");
SafeReleaseComObject(CurrentPresentation, "CurrentPresentation");
SafeReleaseComObject(PPTApplication, "PPTApplication");
// 清理引用
PPTApplication = null;
@@ -491,6 +458,30 @@ namespace Ink_Canvas.Helpers
}
}
/// <summary>
/// 安全释放COM对象
/// </summary>
private void SafeReleaseComObject(object comObject, string objectName)
{
try
{
if (comObject != null && Marshal.IsComObject(comObject))
{
int refCount = Marshal.ReleaseComObject(comObject);
LogHelper.WriteLogToFile($"已释放COM对象 {objectName},引用计数: {refCount}", LogHelper.LogType.Trace);
}
}
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
LogHelper.WriteLogToFile($"释放COM对象 {objectName} 时COM异常: {comEx.Message} (HR: 0x{hr:X8})", LogHelper.LogType.Warning);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"释放COM对象 {objectName} 时发生异常: {ex}", LogHelper.LogType.Warning);
}
}
private void UpdateCurrentPresentationInfo()
{
try
@@ -688,14 +679,25 @@ namespace Ink_Canvas.Helpers
{
try
{
if (!IsConnected || !IsInSlideShow || PPTApplication == null) return false;
if (!IsConnected || PPTApplication == null) return false;
if (!Marshal.IsComObject(PPTApplication)) return false;
var slideShowWindow = PPTApplication.SlideShowWindows[1];
if (slideShowWindow?.View != null)
if (IsInSlideShow && PPTApplication.SlideShowWindows.Count >= 1)
{
slideShowWindow.View.GotoSlide(slideNumber);
return true;
var slideShowWindow = PPTApplication.SlideShowWindows[1];
if (slideShowWindow?.View != null)
{
slideShowWindow.View.GotoSlide(slideNumber);
return true;
}
}
else if (CurrentPresentation != null)
{
if (CurrentPresentation.Windows?.Count >= 1)
{
CurrentPresentation.Windows[1].View.GotoSlide(slideNumber);
return true;
}
}
return false;
}
@@ -717,7 +719,7 @@ namespace Ink_Canvas.Helpers
}
}
public bool TryNavigateNext()
public bool TryNavigateNext(bool skipAnimations = false)
{
try
{
@@ -728,8 +730,54 @@ namespace Ink_Canvas.Helpers
if (slideShowWindow?.View != null)
{
slideShowWindow.Activate();
slideShowWindow.View.Next();
return true;
var view = slideShowWindow.View;
var currentPosition = 0;
var totalSlides = 0;
try
{
currentPosition = view.CurrentShowPosition;
totalSlides = slideShowWindow.Presentation?.Slides?.Count ?? 0;
}
catch
{
}
if (skipAnimations && currentPosition > 0 && totalSlides > 0 && currentPosition < totalSlides)
{
try
{
view.GotoSlide(currentPosition + 1, MsoTriState.msoFalse);
return true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"跳过转场动画跳转到下一页失败: {ex}", LogHelper.LogType.Warning);
try
{
view.Next();
return true;
}
catch
{
return false;
}
}
}
else
{
try
{
view.Next();
return true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"调用下一页失败: {ex}", LogHelper.LogType.Warning);
return false;
}
}
}
return false;
}
@@ -859,10 +907,23 @@ namespace Ink_Canvas.Helpers
// 如果在放映模式,获取放映窗口的演示文稿
if (IsInSlideShow && PPTApplication.SlideShowWindows.Count > 0)
{
var slideShowWindow = PPTApplication.SlideShowWindows[1];
if (slideShowWindow?.View != null)
try
{
return (Presentation)slideShowWindow.View.Slide.Parent;
var slideShowWindow = PPTApplication.SlideShowWindows[1];
if (slideShowWindow?.View != null)
{
return (Presentation)slideShowWindow.View.Slide.Parent;
}
}
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
if (hr == 0x80048240) // Integer out of range
{
// 放映窗口已不存在,返回null
return null;
}
throw; // 重新抛出其他COM异常
}
}
@@ -935,12 +996,10 @@ namespace Ink_Canvas.Helpers
// COM对象已失效,触发断开连接
DisconnectFromPPT();
}
LogHelper.WriteLogToFile($"获取当前幻灯片编号失败: {comEx.Message}", LogHelper.LogType.Warning);
return 0;
}
catch (Exception ex)
catch (Exception)
{
LogHelper.WriteLogToFile($"获取当前幻灯片编号失败: {ex}", LogHelper.LogType.Error);
return 0;
}
}
+44 -11
View File
@@ -1,6 +1,7 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Threading;
@@ -22,6 +23,10 @@ namespace Ink_Canvas.Helpers
public int PPTRBButtonPosition { get; set; } = 0;
public bool EnablePPTButtonPageClickable { get; set; } = true;
public bool EnablePPTButtonLongPressPageTurn { get; set; } = true;
public double PPTLSButtonOpacity { get; set; } = 0.5;
public double PPTRSButtonOpacity { get; set; } = 0.5;
public double PPTLBButtonOpacity { get; set; } = 0.5;
public double PPTRBButtonOpacity { get; set; } = 0.5;
#endregion
#region Private Fields
@@ -92,17 +97,47 @@ namespace Ink_Canvas.Helpers
// 页数无效时清空页码显示
_mainWindow.PPTBtnPageNow.Text = "?";
_mainWindow.PPTBtnPageTotal.Text = "/ ?";
LogHelper.WriteLogToFile($"PPT页数无效,清空页码显示: 当前页={currentSlide}, 总页数={totalSlides}", LogHelper.LogType.Warning);
}
UpdateNavigationPanelsVisibility();
UpdateNavigationButtonStyles();
_mainWindow.UpdatePPTTimeCapsuleVisibility();
if (MainWindow.Settings.Advanced.IsEnableAvoidFullScreenHelper)
{
// 设置为画板模式,允许全屏操作
AvoidFullScreenHelper.SetBoardMode(true);
_dispatcher.BeginInvoke(new Action(() =>
{
MainWindow.MoveWindow(new WindowInteropHelper(_mainWindow).Handle, 0, 0,
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, true);
}), DispatcherPriority.ApplicationIdle);
_mainWindow.isFullScreenApplied = true; // 标记已应用全屏处理
}
}
else
{
_mainWindow.BtnPPTSlideShow.Visibility = Visibility.Visible;
_mainWindow.BtnPPTSlideShowEnd.Visibility = Visibility.Collapsed;
HideAllNavigationPanels();
_mainWindow.UpdatePPTTimeCapsuleVisibility();
if (MainWindow.Settings.Advanced.IsEnableAvoidFullScreenHelper)
{
// 恢复为非画板模式,重新启用全屏限制
AvoidFullScreenHelper.SetBoardMode(false);
_dispatcher.BeginInvoke(new Action(() =>
{
// 退出PPT放映模式,恢复到工作区域大小
var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
MainWindow.MoveWindow(new WindowInteropHelper(_mainWindow).Handle,
workingArea.X, workingArea.Y,
workingArea.Width, workingArea.Height, true);
}), DispatcherPriority.ApplicationIdle);
_mainWindow.isFullScreenApplied = false; // 标记全屏处理已还原
}
}
}
catch (Exception ex)
@@ -132,7 +167,6 @@ namespace Ink_Canvas.Helpers
// 页数无效时清空页码显示
_mainWindow.PPTBtnPageNow.Text = "?";
_mainWindow.PPTBtnPageTotal.Text = "/ ?";
LogHelper.WriteLogToFile($"PPT页数无效,清空页码显示: 当前页={currentSlide}, 总页数={totalSlides}", LogHelper.LogType.Warning);
}
}
catch (Exception ex)
@@ -182,7 +216,8 @@ namespace Ink_Canvas.Helpers
bool shouldShowButtons = ShowPPTButton &&
_mainWindow.BtnPPTSlideShowEnd.Visibility == Visibility.Visible &&
isInSlideShow &&
hasValidPageCount;
hasValidPageCount &&
!MainWindow.Settings.Automation.IsAutoFoldInPPTSlideShow;
if (!shouldShowButtons)
{
@@ -352,10 +387,9 @@ namespace Ink_Canvas.Helpers
_mainWindow.PPTLSPageButton.Visibility = pageButtonVisibility;
_mainWindow.PPTRSPageButton.Visibility = pageButtonVisibility;
// 透明度设置
var opacity = options[1] == '2' ? 0.5 : 1.0;
_mainWindow.PPTBtnLSBorder.Opacity = opacity;
_mainWindow.PPTBtnRSBorder.Opacity = opacity;
// 透明度设置 - 直接使用用户设置的透明度值
_mainWindow.PPTBtnLSBorder.Opacity = PPTLSButtonOpacity;
_mainWindow.PPTBtnRSBorder.Opacity = PPTRSButtonOpacity;
// 颜色主题
bool isDarkTheme = options[2] == '2';
@@ -381,10 +415,9 @@ namespace Ink_Canvas.Helpers
_mainWindow.PPTLBPageButton.Visibility = pageButtonVisibility;
_mainWindow.PPTRBPageButton.Visibility = pageButtonVisibility;
// 透明度设置
var opacity = options[1] == '2' ? 0.5 : 1.0;
_mainWindow.PPTBtnLBBorder.Opacity = opacity;
_mainWindow.PPTBtnRBBorder.Opacity = opacity;
// 透明度设置 - 直接使用用户设置的透明度值
_mainWindow.PPTBtnLBBorder.Opacity = PPTLBButtonOpacity;
_mainWindow.PPTBtnRBBorder.Opacity = PPTRBButtonOpacity;
// 颜色主题
bool isDarkTheme = options[2] == '2';
+156
View File
@@ -0,0 +1,156 @@
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Interop;
using Point = System.Windows.Point;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// 屏幕检测帮助类 - 用于检测窗口所在的屏幕和屏幕信息
/// </summary>
public static class ScreenDetectionHelper
{
/// <summary>
/// 获取窗口所在的屏幕
/// </summary>
/// <param name="window">要检测的窗口</param>
/// <returns>窗口所在的屏幕,如果无法检测则返回主屏幕</returns>
public static Screen GetWindowScreen(Window window)
{
try
{
if (window == null)
return Screen.PrimaryScreen;
// 获取窗口的句柄
var hwndSource = PresentationSource.FromVisual(window) as HwndSource;
if (hwndSource == null)
return Screen.PrimaryScreen;
// 获取窗口在屏幕上的位置
var windowRect = GetWindowScreenBounds(window);
// 查找与窗口重叠最多的屏幕
Screen targetScreen = null;
double maxIntersection = 0;
foreach (var screen in Screen.AllScreens)
{
var intersection = Rectangle.Intersect(windowRect, screen.Bounds);
if (intersection.Width * intersection.Height > maxIntersection)
{
maxIntersection = intersection.Width * intersection.Height;
targetScreen = screen;
}
}
return targetScreen ?? Screen.PrimaryScreen;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"检测窗口屏幕时出错: {ex.Message}", LogHelper.LogType.Warning);
return Screen.PrimaryScreen;
}
}
/// <summary>
/// 获取窗口在屏幕坐标系中的边界
/// </summary>
/// <param name="window">要检测的窗口</param>
/// <returns>窗口的屏幕边界</returns>
private static Rectangle GetWindowScreenBounds(Window window)
{
try
{
// 获取窗口左上角在屏幕上的位置
var topLeft = window.PointToScreen(new Point(0, 0));
// 获取窗口右下角在屏幕上的位置
var bottomRight = window.PointToScreen(new Point(window.ActualWidth, window.ActualHeight));
return new Rectangle(
(int)topLeft.X,
(int)topLeft.Y,
(int)(bottomRight.X - topLeft.X),
(int)(bottomRight.Y - topLeft.Y));
}
catch
{
// 如果无法获取精确位置,返回窗口的Left和Top
return new Rectangle(
(int)window.Left,
(int)window.Top,
(int)window.Width,
(int)window.Height);
}
}
/// <summary>
/// 检查是否有多个屏幕
/// </summary>
/// <returns>如果有多个屏幕返回true,否则返回false</returns>
public static bool HasMultipleScreens()
{
try
{
return Screen.AllScreens.Length > 1;
}
catch
{
return false;
}
}
/// <summary>
/// 获取主屏幕
/// </summary>
/// <returns>主屏幕</returns>
public static Screen GetPrimaryScreen()
{
try
{
return Screen.PrimaryScreen;
}
catch
{
return null;
}
}
/// <summary>
/// 获取所有屏幕信息
/// </summary>
/// <returns>所有屏幕的数组</returns>
public static Screen[] GetAllScreens()
{
try
{
return Screen.AllScreens;
}
catch
{
return new Screen[] { Screen.PrimaryScreen };
}
}
/// <summary>
/// 检查窗口是否在主屏幕上
/// </summary>
/// <param name="window">要检查的窗口</param>
/// <returns>如果窗口在主屏幕上返回true,否则返回false</returns>
public static bool IsWindowOnPrimaryScreen(Window window)
{
try
{
var windowScreen = GetWindowScreen(window);
return windowScreen == Screen.PrimaryScreen;
}
catch
{
return true; // 出错时假设在主屏幕
}
}
}
}
+165
View File
@@ -0,0 +1,165 @@
using System;
using System.IO;
using System.Reflection;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// UIAccess DLL释放器
/// </summary>
public static class UIAccessDllExtractor
{
private static readonly string[] RequiredDlls = {
"UIAccessDLL_x64.dll",
"UIAccessDLL_x86.dll"
};
/// <summary>
/// 在应用启动时释放UIAccess相关DLL
/// </summary>
public static void ExtractUIAccessDlls()
{
try
{
string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
LogHelper.WriteLogToFile("开始检查并释放UIAccess相关DLL文件");
foreach (string dllName in RequiredDlls)
{
string targetPath = Path.Combine(appDirectory, dllName);
// 检查文件是否已存在且有效
if (File.Exists(targetPath) && IsValidDll(targetPath))
{
LogHelper.WriteLogToFile($"{dllName} 已存在且有效,跳过释放");
continue;
}
// 从嵌入资源中释放DLL
if (ExtractDllFromResource(dllName, targetPath))
{
LogHelper.WriteLogToFile($"成功释放 {dllName} 到 {targetPath}");
}
else
{
LogHelper.WriteLogToFile($"警告:无法释放 {dllName},可能影响UIA置顶功能", LogHelper.LogType.Warning);
}
}
LogHelper.WriteLogToFile("UIAccess DLL释放检查完成");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"释放UIAccess DLL时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 从嵌入资源中提取DLL文件
/// </summary>
private static bool ExtractDllFromResource(string dllName, string targetPath)
{
try
{
Assembly assembly = Assembly.GetExecutingAssembly();
string resourceName = $"Ink_Canvas.{dllName}";
using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName))
{
if (resourceStream == null)
{
LogHelper.WriteLogToFile($"未找到嵌入资源: {resourceName}", LogHelper.LogType.Warning);
return false;
}
// 确保目标目录存在
string targetDirectory = Path.GetDirectoryName(targetPath);
if (!Directory.Exists(targetDirectory))
{
Directory.CreateDirectory(targetDirectory);
}
// 写入文件
using (FileStream fileStream = new FileStream(targetPath, FileMode.Create, FileAccess.Write))
{
resourceStream.CopyTo(fileStream);
}
return true;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"从资源提取 {dllName} 失败: {ex.Message}", LogHelper.LogType.Error);
return false;
}
}
/// <summary>
/// 检查DLL文件是否有效
/// </summary>
private static bool IsValidDll(string filePath)
{
try
{
if (!File.Exists(filePath))
return false;
FileInfo fileInfo = new FileInfo(filePath);
// 检查文件大小(空文件或过小的文件可能无效)
if (fileInfo.Length < 1024) // 小于1KB可能无效
return false;
// 简单检查PE头(DLL文件应该以MZ开头)
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
byte[] buffer = new byte[2];
if (fs.Read(buffer, 0, 2) == 2)
{
return buffer[0] == 0x4D && buffer[1] == 0x5A; // "MZ"
}
}
return false;
}
catch
{
return false;
}
}
/// <summary>
/// 清理释放的DLL文件(可选,在应用退出时调用)
/// </summary>
public static void CleanupExtractedDlls()
{
try
{
string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
foreach (string dllName in RequiredDlls)
{
string filePath = Path.Combine(appDirectory, dllName);
if (File.Exists(filePath))
{
try
{
File.Delete(filePath);
LogHelper.WriteLogToFile($"已清理 {dllName}");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理 {dllName} 失败: {ex.Message}", LogHelper.LogType.Warning);
}
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理UIAccess DLL时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
}
}
+479
View File
@@ -0,0 +1,479 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// 矩形结构体(用于窗口位置和大小)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct WindowRect
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public int Width => Right - Left;
public int Height => Bottom - Top;
}
/// <summary>
/// 窗口信息结构
/// </summary>
public class WindowInfo
{
public IntPtr Handle { get; set; }
public string Title { get; set; }
public string ClassName { get; set; }
public string ProcessName { get; set; }
public string ProcessPath { get; set; }
public WindowRect Rect { get; set; }
public bool IsVisible { get; set; }
public bool IsMinimized { get; set; }
public bool IsMaximized { get; set; }
public int ZOrder { get; set; }
public uint ProcessId { get; set; }
public bool IsFullScreen { get; set; }
/// <summary>
/// 计算窗口是否覆盖指定区域
/// </summary>
public bool CoversArea(WindowRect area)
{
if (!IsVisible || IsMinimized) return false;
// 计算交集
int left = Math.Max(Rect.Left, area.Left);
int top = Math.Max(Rect.Top, area.Top);
int right = Math.Min(Rect.Right, area.Right);
int bottom = Math.Min(Rect.Bottom, area.Bottom);
// 如果有交集,说明窗口覆盖了该区域
return left < right && top < bottom;
}
/// <summary>
/// 计算窗口覆盖指定区域的比例
/// </summary>
public double GetCoverageRatio(WindowRect area)
{
if (!IsVisible || IsMinimized) return 0.0;
// 计算交集
int left = Math.Max(Rect.Left, area.Left);
int top = Math.Max(Rect.Top, area.Top);
int right = Math.Min(Rect.Right, area.Right);
int bottom = Math.Min(Rect.Bottom, area.Bottom);
if (left >= right || top >= bottom) return 0.0;
// 计算交集面积
double intersectionArea = (right - left) * (bottom - top);
// 计算目标区域面积
double targetArea = area.Width * area.Height;
if (targetArea == 0) return 0.0;
return intersectionArea / targetArea;
}
}
/// <summary>
/// 窗口概览模型 - 实时监控桌面所有可见窗口并计算遮挡情况
/// </summary>
public class WindowOverviewModel : IDisposable
{
#region Win32 API Declarations
[DllImport("user32.dll")]
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
[DllImport("user32.dll")]
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
private static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetWindowRect(IntPtr hWnd, out WindowRect lpRect);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool IsIconic(IntPtr hWnd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool IsZoomed(IntPtr hWnd);
[DllImport("user32.dll")]
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
private static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);
private const uint GW_HWNDNEXT = 2;
private const uint GW_HWNDPREV = 3;
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
#endregion
private readonly object _lockObject = new object();
private List<WindowInfo> _windows = new List<WindowInfo>();
private Timer _updateTimer;
private bool _isDisposed = false;
private readonly int _updateInterval = 200; // 更新间隔(毫秒)
/// <summary>
/// 窗口列表更新事件
/// </summary>
public event EventHandler<List<WindowInfo>> WindowsUpdated;
/// <summary>
/// 当前窗口列表(按Z顺序排序,最上层在前)
/// </summary>
public List<WindowInfo> Windows
{
get
{
lock (_lockObject)
{
return new List<WindowInfo>(_windows);
}
}
}
/// <summary>
/// 构造函数
/// </summary>
public WindowOverviewModel()
{
// 立即执行一次更新
UpdateWindows();
// 启动定时器,定期更新窗口列表
_updateTimer = new Timer(OnUpdateTimer, null, _updateInterval, _updateInterval);
}
/// <summary>
/// 定时器回调
/// </summary>
private void OnUpdateTimer(object state)
{
if (_isDisposed) return;
try
{
UpdateWindows();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"窗口概览模型更新失败: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 更新窗口列表
/// </summary>
public void UpdateWindows()
{
var windows = new List<WindowInfo>();
var zOrder = 0;
EnumWindows((hWnd, lParam) =>
{
try
{
// 检查窗口是否可见
if (!IsWindowVisible(hWnd)) return true;
// 检查窗口是否最小化
bool isMinimized = IsIconic(hWnd);
if (isMinimized) return true;
// 获取窗口矩形
if (!GetWindowRect(hWnd, out WindowRect rect)) return true;
// 过滤掉无效的窗口(太小或位置异常的窗口)
if (rect.Width <= 0 || rect.Height <= 0) return true;
if (rect.Right < rect.Left || rect.Bottom < rect.Top) return true;
// 获取窗口标题
const int nChars = 256;
StringBuilder windowTitle = new StringBuilder(nChars);
GetWindowText(hWnd, windowTitle, nChars);
string title = windowTitle.ToString();
// 获取窗口类名
StringBuilder className = new StringBuilder(nChars);
GetClassName(hWnd, className, nChars);
string classNameStr = className.ToString();
// 获取进程信息
GetWindowThreadProcessId(hWnd, out uint processId);
string processName = "Unknown";
string processPath = "Unknown";
try
{
Process process = Process.GetProcessById((int)processId);
processName = process.ProcessName;
try
{
processPath = process.MainModule?.FileName ?? "Unknown";
}
catch
{
processPath = "Unknown";
}
}
catch
{
// 进程可能已退出
}
// 检查是否最大化
bool isMaximized = IsZoomed(hWnd);
// 检查是否全屏(窗口大小接近屏幕大小)
bool isFullScreen = false;
try
{
var screen = System.Windows.Forms.Screen.FromHandle(hWnd);
var screenBounds = screen.Bounds;
// 如果窗口大小接近屏幕大小(允许10像素误差),认为是全屏
isFullScreen = rect.Width >= screenBounds.Width - 10 &&
rect.Height >= screenBounds.Height - 10 &&
Math.Abs(rect.Left - screenBounds.Left) <= 10 &&
Math.Abs(rect.Top - screenBounds.Top) <= 10;
}
catch
{
// 无法获取屏幕信息,使用默认值
}
// 跳过当前应用程序的窗口(避免检测到自己)
if (processName == "InkCanvasForClass" || processName == "Ink Canvas")
{
return true;
}
var windowInfo = new WindowInfo
{
Handle = hWnd,
Title = title,
ClassName = classNameStr,
ProcessName = processName,
ProcessPath = processPath,
Rect = rect,
IsVisible = true,
IsMinimized = false,
IsMaximized = isMaximized,
ZOrder = zOrder++,
ProcessId = processId,
IsFullScreen = isFullScreen
};
windows.Add(windowInfo);
}
catch
{
// 忽略单个窗口的错误,继续枚举其他窗口
}
return true; // 继续枚举
}, IntPtr.Zero);
// 按Z顺序排序(从最上层到最下层)
// 注意:EnumWindows返回的顺序可能不是严格的Z顺序,但我们可以通过GetWindow来获取更准确的顺序
windows = windows.OrderByDescending(w => w.ZOrder).ToList();
lock (_lockObject)
{
_windows = windows;
}
// 触发更新事件
WindowsUpdated?.Invoke(this, windows);
}
/// <summary>
/// 检查指定区域是否被其他窗口覆盖
/// </summary>
/// <param name="area">要检查的区域</param>
/// <param name="excludeProcessNames">要排除的进程名列表(例如当前应用程序)</param>
/// <param name="coverageThreshold">覆盖阈值(0.0-1.0),超过此阈值认为被覆盖</param>
/// <returns>如果被覆盖返回true</returns>
public bool IsAreaCovered(WindowRect area, List<string> excludeProcessNames = null, double coverageThreshold = 0.5)
{
lock (_lockObject)
{
excludeProcessNames = excludeProcessNames ?? new List<string>();
// 从最上层窗口开始检查
foreach (var window in _windows)
{
// 跳过排除的进程
if (excludeProcessNames.Contains(window.ProcessName)) continue;
// 计算覆盖比例
double coverage = window.GetCoverageRatio(area);
if (coverage >= coverageThreshold)
{
return true;
}
}
return false;
}
}
/// <summary>
/// 检查指定区域是否被全屏窗口覆盖
/// </summary>
/// <param name="area">要检查的区域</param>
/// <param name="excludeProcessNames">要排除的进程名列表</param>
/// <returns>如果被全屏窗口覆盖返回true</returns>
public bool IsAreaCoveredByFullScreenWindow(WindowRect area, List<string> excludeProcessNames = null)
{
lock (_lockObject)
{
excludeProcessNames = excludeProcessNames ?? new List<string>();
// 查找全屏窗口
foreach (var window in _windows)
{
// 跳过排除的进程
if (excludeProcessNames.Contains(window.ProcessName)) continue;
// 只检查全屏窗口
if (window.IsFullScreen && window.CoversArea(area))
{
return true;
}
}
return false;
}
}
/// <summary>
/// 获取覆盖指定区域的所有窗口
/// </summary>
/// <param name="area">要检查的区域</param>
/// <param name="excludeProcessNames">要排除的进程名列表</param>
/// <param name="coverageThreshold">覆盖阈值</param>
/// <returns>覆盖该区域的窗口列表(按Z顺序,最上层在前)</returns>
public List<WindowInfo> GetCoveringWindows(WindowRect area, List<string> excludeProcessNames = null, double coverageThreshold = 0.1)
{
lock (_lockObject)
{
excludeProcessNames = excludeProcessNames ?? new List<string>();
var coveringWindows = new List<WindowInfo>();
foreach (var window in _windows)
{
// 跳过排除的进程
if (excludeProcessNames.Contains(window.ProcessName)) continue;
// 计算覆盖比例
double coverage = window.GetCoverageRatio(area);
if (coverage >= coverageThreshold)
{
coveringWindows.Add(window);
}
}
return coveringWindows;
}
}
/// <summary>
/// 检查是否有全屏窗口
/// </summary>
/// <param name="excludeProcessNames">要排除的进程名列表</param>
/// <returns>如果有全屏窗口返回true</returns>
public bool HasFullScreenWindow(List<string> excludeProcessNames = null)
{
lock (_lockObject)
{
excludeProcessNames = excludeProcessNames ?? new List<string>();
return _windows.Any(w => !excludeProcessNames.Contains(w.ProcessName) && w.IsFullScreen);
}
}
/// <summary>
/// 获取所有全屏窗口
/// </summary>
/// <param name="excludeProcessNames">要排除的进程名列表</param>
/// <returns>全屏窗口列表</returns>
public List<WindowInfo> GetFullScreenWindows(List<string> excludeProcessNames = null)
{
lock (_lockObject)
{
excludeProcessNames = excludeProcessNames ?? new List<string>();
return _windows.Where(w => !excludeProcessNames.Contains(w.ProcessName) && w.IsFullScreen).ToList();
}
}
/// <summary>
/// 根据进程名查找窗口
/// </summary>
/// <param name="processName">进程名</param>
/// <returns>匹配的窗口列表</returns>
public List<WindowInfo> FindWindowsByProcessName(string processName)
{
lock (_lockObject)
{
return _windows.Where(w => w.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)).ToList();
}
}
/// <summary>
/// 根据窗口标题查找窗口
/// </summary>
/// <param name="title">窗口标题(支持部分匹配)</param>
/// <returns>匹配的窗口列表</returns>
public List<WindowInfo> FindWindowsByTitle(string title)
{
lock (_lockObject)
{
return _windows.Where(w => w.Title.IndexOf(title, StringComparison.OrdinalIgnoreCase) >= 0).ToList();
}
}
/// <summary>
/// 释放资源
/// </summary>
public void Dispose()
{
if (_isDisposed) return;
_isDisposed = true;
_updateTimer?.Dispose();
_updateTimer = null;
lock (_lockObject)
{
_windows.Clear();
}
}
}
}
@@ -0,0 +1,62 @@
using Hardcodet.Wpf.TaskbarNotification;
using Microsoft.Toolkit.Uwp.Notifications;
using System;
using System.Windows;
namespace Ink_Canvas.Helpers
{
internal static class WindowsNotificationHelper
{
private const string APP_ID = "InkCanvasForClass.CE";
public static void ShowNewVersionToast(string version)
{
try
{
var os = Environment.OSVersion.Version;
if (os.Major == 6 && os.Minor == 1)
{
ShowBalloonForWin7(version);
}
else
{
ShowToastForModernWindows(version);
}
}
catch
{
}
}
private static void ShowBalloonForWin7(string version)
{
Application.Current?.Dispatcher.Invoke(() =>
{
try
{
var taskbar = Application.Current.Resources["TaskbarTrayIcon"] as TaskbarIcon;
if (taskbar == null) return;
taskbar.Visibility = Visibility.Visible;
taskbar.ShowBalloonTip(
"InkCanvasForClass CE",
$"发现新版本!:{version}",
BalloonIcon.Info);
}
catch
{
}
});
}
private static void ShowToastForModernWindows(string version)
{
new ToastContentBuilder()
.AddText("InkCanvasForClass CE")
.AddText($"发现新版本!:{version}")
.Show();
}
}
}
+83 -3
View File
@@ -153,6 +153,8 @@
<PackageReference Include="MdXaml" Version="1.27.0" />
<PackageReference Include="Microsoft.Office.Interop.PowerPoint" Version="15.0.4420.1018" />
<PackageReference Include="MicrosoftOfficeCore" Version="15.0.0" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="Microsoft.International.Converters.PinYinConverter" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
@@ -192,11 +194,14 @@
</ItemGroup>
<ItemGroup>
<None Include="Resources\TimerDownNotice.wav" />
<None Include="Resources\ProgressiveAudio.wav" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\IACore\IACore.dll" />
<EmbeddedResource Include="Resources\IACore\IALoader.dll" />
<EmbeddedResource Include="Resources\IACore\IAWinFX.dll" />
<EmbeddedResource Include="UIAccessDLL_x64.dll" />
<EmbeddedResource Include="UIAccessDLL_x86.dll" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Cursors\Cursor.cur" />
@@ -208,6 +213,7 @@
<Resource Include="Resources\DeveloperAvatars\RaspberryKan.jpg" />
<Resource Include="Resources\DeveloperAvatars\wwei.png" />
<Resource Include="Resources\DeveloperAvatars\yuwenhui2020.png" />
<Resource Include="Resources\DeveloperAvatars\CJKmkp.jpg" />
<Resource Include="Resources\icc.ico" />
<Resource Include="Resources\Icons-png\AdmoxBooth.png" />
<Resource Include="Resources\Icons-png\AdmoxWhiteboard.png" />
@@ -222,6 +228,10 @@
<Resource Include="Resources\Icons-png\icc-transparent-dark.png" />
<Resource Include="Resources\Icons-png\icc-transparent.png" />
<Resource Include="Resources\Icons-png\icc.png" />
<Resource Include="Resources\Icons-png\icc-dark.png" />
<Resource Include="Resources\Icons-png\icc-noshadow.png" />
<Resource Include="Resources\Icons-png\icc-sharpdark.png" />
<Resource Include="Resources\Icons-png\icc-transparent-light-small.png" />
<Resource Include="Resources\Icons-png\InkCanvas.png" />
<Resource Include="Resources\Icons-png\kuanciya.png" />
<Resource Include="Resources\Icons-png\kuandogeyuanliangwo.png" />
@@ -238,6 +248,10 @@
<Resource Include="Resources\Icons-png\undo.png" />
<Resource Include="Resources\Icons-png\minimize.png" />
<Resource Include="Resources\Icons-png\penUpright.png" />
<Resource Include="Resources\new-icons\multi-touch_white.png" />
<Resource Include="Resources\new-icons\hand-move_white.png" />
<Resource Include="Resources\new-icons\zoom_white.png" />
<Resource Include="Resources\new-icons\rotate_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\twoFingelMove-Blue.png" />
@@ -287,7 +301,9 @@
<Resource Include="Resources\Icons-Fluent\ic_fluent_arrow_circle_left_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_arrow_circle_right_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_weather_moon_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_weather_moon_24_regular_white.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_weather_sunny_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_weather_sunny_24_regular_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_signature_24_regular.png" />
@@ -322,6 +338,7 @@
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_arrow_rotate_clockwise_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_scale_fit_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_scale_fit_24_regular_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_scales_24_regular.png" />
@@ -339,9 +356,6 @@
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_clock_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_book_question_mark_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_keyboard_24_regular.png" />
</ItemGroup>
@@ -409,6 +423,7 @@
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\gesture.png" />
<Resource Include="Resources\new-icons\gesture_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\gesture-enabled.png" />
@@ -456,6 +471,37 @@
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\cube.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\arrow_white.png" />
<Resource Include="Resources\Icons-png\geo-icons\dashed-line_white.png" />
<Resource Include="Resources\Icons-png\geo-icons\dotted-line_white.png" />
<Resource Include="Resources\Icons-png\geo-icons\line_white.png" />
<Resource Include="Resources\Icons-png\geo-icons\paralle-lines_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\centered-square_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\centered-circle_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\centered-circle-dashed_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\centered-oval_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\square_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\cylinder_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\cone_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\cube_white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\EasiNote.png" />
<Resource Include="Resources\Icons-png\EasiNote3C.png" />
@@ -492,6 +538,19 @@
<Resource Include="Resources\new-icons\unfold-chevron.png" />
<Resource Include="Resources\new-icons\zoom.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_person_money_24_regular-light.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_people_money_24_regular-light.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_timer_24_regular-light.png" />
<Resource Include="Resources\new-icons\blackboard-light.png" />
<Resource Include="Resources\new-icons\end-slides-show-light.png" />
<Resource Include="Resources\new-icons\eye-light.png" />
<Resource Include="Resources\new-icons\chevron-left-light.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_keyboard_24_regular_white.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_control_button_24_regular_white.png" />
</ItemGroup>
<ItemGroup>
<Compile Remove="AssemblyInfo.cs" />
</ItemGroup>
@@ -518,6 +577,10 @@
<None Remove="Resources\Icons-png\icc-transparent-dark.png" />
<None Remove="Resources\Icons-png\icc-transparent.png" />
<None Remove="Resources\Icons-png\icc.png" />
<None Remove="Resources\Icons-png\icc-dark.png" />
<None Remove="Resources\Icons-png\icc-noshadow.png" />
<None Remove="Resources\Icons-png\icc-sharpdark.png" />
<None Remove="Resources\Icons-png\icc-transparent-light-small.png" />
<None Remove="Resources\Icons-png\idt.png" />
<None Remove="Resources\Icons-png\InkCanvas.png" />
<None Remove="Resources\Icons-png\kuanciya.png" />
@@ -554,14 +617,31 @@
<ItemGroup>
<Resource Include="Resources\Icons-png\idt.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Fonts\LXGWWenKaiTC-Regular.ttf" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\HiteAnnotation.png" />
<Resource Include="Resources\Icons-png\AiClass.png" />
<Resource Include="Resources\Icons-png\天喻教育云.png" />
<Resource Include="Resources\Icons-png\畅言智慧课堂.png" />
<Resource Include="Resources\PresentationExample\bottombar-dark.png" />
<Resource Include="Resources\PresentationExample\bottombar-white.png" />
<Resource Include="Resources\PresentationExample\page.jpg" />
<Resource Include="Resources\PresentationExample\sidebar-dark.png" />
<Resource Include="Resources\PresentationExample\sidebar-white.png" />
<Resource Include="Resources\PresentationExample\toolbar.png" />
<Resource Include="Resources\Startup-animation\ICC Spring.png" />
<Resource Include="Resources\Startup-animation\ICC Summer.png" />
<Resource Include="Resources\Startup-animation\ICC Autumn.png" />
<Resource Include="Resources\Startup-animation\ICC Winter.png" />
<Resource Include="Resources\Startup-animation\ICC Horse.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_copy_24_regular_white.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_copy_add_24_regular_white.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_flip_horizontal_24_regular_white.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_flip_vertical_24_regular_white.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_edit_24_regular_white.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_delete_24_regular_white.png" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>D:\vs\ica\Ink Canvas\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>
+1118 -326
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -5
View File
@@ -103,7 +103,6 @@ namespace Ink_Canvas
HideSubPanels("cursor");
SidePannelMarginAnimation(-10);
});
isFloatingBarChangingHideMode = false;
}
private async void LeftUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e)
@@ -271,7 +270,6 @@ namespace Ink_Canvas
if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation);
if (dopsc[2] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation);
if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation);
LogHelper.WriteLogToFile($"从收纳模式恢复时显示PPT翻页按钮 - 放映状态: {PPTManager?.IsInSlideShow}, 页数: {PPTManager?.SlidesCount}", LogHelper.LogType.Trace);
}
else
{
@@ -306,7 +304,6 @@ namespace Ink_Canvas
SidePannelMarginAnimation(-50, !unfoldFloatingBarByUser);
});
// 修复:在浮动栏展开后,重新设置按钮高亮状态
await Dispatcher.InvokeAsync(async () =>
{
try
@@ -327,7 +324,6 @@ namespace Ink_Canvas
}
});
isFloatingBarChangingHideMode = false;
}
private async void SidePannelMarginAnimation(int MarginFromEdge, bool isNoAnimation = false) // Possible value: -50, -10
@@ -366,4 +362,4 @@ namespace Ink_Canvas
isFloatingBarChangingHideMode = false;
}
}
}
}
+464 -3
View File
@@ -1,24 +1,45 @@
using iNKORE.UI.WPF.Modern;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Application = System.Windows.Application;
using ui = iNKORE.UI.WPF.Modern.Controls;
namespace Ink_Canvas
{
public partial class MainWindow : Window
{
private Color FloatBarForegroundColor = Color.FromRgb(102, 102, 102);
private Color FloatBarForegroundColor;
private void SetTheme(string theme)
private void SetTheme(string theme, bool autoSwitchIcon = false)
{
// 清理现有的主题资源
var resourcesToRemove = new List<ResourceDictionary>();
foreach (var dict in Application.Current.Resources.MergedDictionaries)
{
if (dict.Source != null &&
(dict.Source.ToString().Contains("Light.xaml") ||
dict.Source.ToString().Contains("Dark.xaml")))
{
resourcesToRemove.Add(dict);
}
}
foreach (var dict in resourcesToRemove)
{
Application.Current.Resources.MergedDictionaries.Remove(dict);
}
if (theme == "Light")
{
var rd1 = new ResourceDictionary
{ Source = new Uri("Resources/Styles/Light.xaml", UriKind.Relative) };
Application.Current.Resources.MergedDictionaries.Add(rd1);
// 在主题资源之后添加其他资源
var rd2 = new ResourceDictionary
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
Application.Current.Resources.MergedDictionaries.Add(rd2);
@@ -33,13 +54,39 @@ namespace Ink_Canvas
ThemeManager.SetRequestedTheme(window, ElementTheme.Light);
FloatBarForegroundColor = (Color)Application.Current.FindResource("FloatBarForegroundColor");
InitializeFloatBarForegroundColor();
// 刷新快速面板图标
RefreshQuickPanelIcons();
// 刷新墨迹选中栏图标
RefreshStrokeSelectionIcons();
// 刷新图片选中栏图标
RefreshImageSelectionIcons();
// 刷新手势按钮图标
RefreshGestureButtonIcon();
RefreshFloatingBarHighlightColors();
if (autoSwitchIcon)
{
AutoSwitchFloatingBarIconForTheme("Light");
}
// 强制刷新UI
window.InvalidateVisual();
// 通知其他窗口刷新主题
RefreshOtherWindowsTheme();
}
else if (theme == "Dark")
{
var rd1 = new ResourceDictionary { Source = new Uri("Resources/Styles/Dark.xaml", UriKind.Relative) };
Application.Current.Resources.MergedDictionaries.Add(rd1);
// 在主题资源之后添加其他资源
var rd2 = new ResourceDictionary
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
Application.Current.Resources.MergedDictionaries.Add(rd2);
@@ -54,7 +101,198 @@ namespace Ink_Canvas
ThemeManager.SetRequestedTheme(window, ElementTheme.Dark);
InitializeFloatBarForegroundColor();
// 刷新快速面板图标
RefreshQuickPanelIcons();
// 刷新墨迹选中栏图标
RefreshStrokeSelectionIcons();
// 刷新图片选中栏图标
RefreshImageSelectionIcons();
// 刷新手势按钮图标
RefreshGestureButtonIcon();
RefreshFloatingBarHighlightColors();
if (autoSwitchIcon)
{
AutoSwitchFloatingBarIconForTheme("Dark");
}
// 强制刷新UI
window.InvalidateVisual();
// 通知其他窗口刷新主题
RefreshOtherWindowsTheme();
}
}
/// <summary>
/// 初始化FloatBarForegroundColor,从当前主题资源中加载颜色
/// </summary>
private void InitializeFloatBarForegroundColor()
{
try
{
FloatBarForegroundColor = (Color)Application.Current.FindResource("FloatBarForegroundColor");
// 强制刷新浮动工具栏按钮颜色
RefreshFloatingBarButtonColors();
}
catch (Exception)
{
// 如果无法从资源中加载,使用默认颜色
FloatBarForegroundColor = Color.FromRgb(0, 0, 0);
}
}
/// <summary>
/// 刷新快速面板图标
/// </summary>
private void RefreshQuickPanelIcons()
{
try
{
if (LeftUnFoldButtonQuickPanel != null)
{
LeftUnFoldButtonQuickPanel.InvalidateVisual();
}
if (RightUnFoldButtonQuickPanel != null)
{
RightUnFoldButtonQuickPanel.InvalidateVisual();
}
if (LeftSidePanel != null)
{
LeftSidePanel.InvalidateVisual();
}
if (RightSidePanel != null)
{
RightSidePanel.InvalidateVisual();
}
}
catch (Exception)
{
}
}
/// <summary>
/// 刷新浮动栏高光条颜色
/// </summary>
private void RefreshFloatingBarHighlightColors()
{
try
{
if (FloatingbarSelectionBG != null && FloatingbarSelectionBG.Visibility == Visibility.Visible)
{
// 根据主题设置高光颜色
Color highlightBackgroundColor;
Color highlightBarColor;
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
if (isDarkTheme)
{
highlightBackgroundColor = Color.FromArgb(21, 102, 204, 255);
highlightBarColor = Color.FromRgb(102, 204, 255);
}
else
{
highlightBackgroundColor = Color.FromArgb(21, 59, 130, 246);
highlightBarColor = Color.FromRgb(37, 99, 235);
}
// 设置高光背景颜色
FloatingbarSelectionBG.Background = new SolidColorBrush(highlightBackgroundColor);
if (FloatingbarSelectionBG.Child is System.Windows.Controls.Canvas canvas && canvas.Children.Count > 0)
{
var firstChild = canvas.Children[0];
if (firstChild is Border innerBorder)
{
innerBorder.Background = new SolidColorBrush(highlightBarColor);
}
}
}
}
catch (Exception)
{
}
}
/// <summary>
/// 刷新浮动工具栏按钮颜色
/// </summary>
private void RefreshFloatingBarButtonColors()
{
try
{
// 根据主题选择高光颜色
Color selectedColor;
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
if (isDarkTheme)
{
selectedColor = Color.FromRgb(102, 204, 255);
}
else
{
selectedColor = Color.FromRgb(30, 58, 138);
}
// 根据当前模式设置按钮颜色
switch (_currentToolMode)
{
case "cursor":
CursorIconGeometry.Brush = new SolidColorBrush(selectedColor);
PenIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
StrokeEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
CircleEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
LassoSelectIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
break;
case "pen":
case "color":
CursorIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
PenIconGeometry.Brush = new SolidColorBrush(selectedColor);
StrokeEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
CircleEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
LassoSelectIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
break;
case "eraser":
CursorIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
PenIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
StrokeEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
CircleEraserIconGeometry.Brush = new SolidColorBrush(selectedColor);
LassoSelectIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
break;
case "eraserByStrokes":
CursorIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
PenIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
StrokeEraserIconGeometry.Brush = new SolidColorBrush(selectedColor);
CircleEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
LassoSelectIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
break;
case "select":
CursorIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
PenIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
StrokeEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
CircleEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
LassoSelectIconGeometry.Brush = new SolidColorBrush(selectedColor);
break;
default:
// 默认情况,所有按钮都使用主题颜色
CursorIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
PenIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
StrokeEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
CircleEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
LassoSelectIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
break;
}
}
catch (Exception)
{
}
}
@@ -91,5 +329,228 @@ namespace Ink_Canvas
return light;
}
/// <summary>
/// 根据主题自动切换浮动栏图标
/// </summary>
private void AutoSwitchFloatingBarIconForTheme(string theme)
{
try
{
if (theme == "Light")
{
Settings.Appearance.FloatingBarImg = 0;
}
else if (theme == "Dark")
{
Settings.Appearance.FloatingBarImg = 3;
}
UpdateFloatingBarIcon();
UpdateFloatingBarIconComboBox();
}
catch (Exception)
{
}
}
/// <summary>
/// 更新设置界面中的浮动栏图标选择下拉框显示
/// </summary>
private void UpdateFloatingBarIconComboBox()
{
try
{
if (ComboBoxFloatingBarImg != null)
{
ComboBoxFloatingBarImg.SelectedIndex = Settings.Appearance.FloatingBarImg;
}
}
catch (Exception)
{
}
}
/// <summary>
/// 刷新墨迹选中栏图标
/// </summary>
private void RefreshStrokeSelectionIcons()
{
try
{
if (BorderStrokeSelectionControl != null)
{
// 强制刷新墨迹选中栏的视觉状态
BorderStrokeSelectionControl.InvalidateVisual();
// 刷新墨迹选中栏内的所有图标
var viewbox = BorderStrokeSelectionControl.Child as Viewbox;
if (viewbox?.Child is ui.SimpleStackPanel stackPanel)
{
RefreshStrokeSelectionIconsRecursive(stackPanel);
}
}
}
catch (Exception)
{
// 忽略异常,确保主题切换不会因为图标刷新失败而中断
}
}
/// <summary>
/// 递归刷新墨迹选中栏内的图标
/// </summary>
private void RefreshStrokeSelectionIconsRecursive(System.Windows.Controls.Panel panel)
{
try
{
foreach (var child in panel.Children)
{
if (child is Image image)
{
// 强制刷新图像
image.InvalidateVisual();
}
else if (child is System.Windows.Controls.Panel childPanel)
{
// 递归处理子面板
RefreshStrokeSelectionIconsRecursive(childPanel);
}
else if (child is Border border && border.Child is System.Windows.Controls.Panel borderPanel)
{
// 处理Border内的面板
RefreshStrokeSelectionIconsRecursive(borderPanel);
}
}
}
catch (Exception)
{
// 忽略异常
}
}
/// <summary>
/// 刷新图片选中栏图标
/// </summary>
private void RefreshImageSelectionIcons()
{
try
{
if (BorderImageSelectionControl != null)
{
// 强制刷新图片选中栏的视觉状态
BorderImageSelectionControl.InvalidateVisual();
// 刷新图片选中栏内的所有图标
var viewbox = BorderImageSelectionControl.Child as Viewbox;
if (viewbox?.Child is ui.SimpleStackPanel stackPanel)
{
RefreshImageSelectionIconsRecursive(stackPanel);
}
}
}
catch (Exception)
{
// 忽略异常,确保主题切换不会因为图标刷新失败而中断
}
}
/// <summary>
/// 递归刷新图片选中栏内的图标
/// </summary>
private void RefreshImageSelectionIconsRecursive(System.Windows.Controls.Panel panel)
{
try
{
foreach (var child in panel.Children)
{
if (child is Image image)
{
// 强制刷新图像
image.InvalidateVisual();
}
else if (child is System.Windows.Controls.Panel childPanel)
{
// 递归处理子面板
RefreshImageSelectionIconsRecursive(childPanel);
}
else if (child is Border border && border.Child is System.Windows.Controls.Panel borderPanel)
{
// 处理Border内的面板
RefreshImageSelectionIconsRecursive(borderPanel);
}
else if (child is Grid grid)
{
// 处理Grid内的子元素
foreach (var gridChild in grid.Children)
{
if (gridChild is Image gridImage)
{
gridImage.InvalidateVisual();
}
}
}
}
}
catch (Exception)
{
// 忽略异常
}
}
/// <summary>
/// 刷新手势按钮图标
/// </summary>
private void RefreshGestureButtonIcon()
{
try
{
// 调用手势按钮颜色和图标更新方法,该方法会根据当前主题和手势状态设置正确的图标
CheckEnableTwoFingerGestureBtnColorPrompt();
}
catch (Exception)
{
}
}
/// <summary>
/// 刷新其他窗口的主题
/// </summary>
private void RefreshOtherWindowsTheme()
{
try
{
// 刷新所有打开的窗口
foreach (Window window in Application.Current.Windows)
{
if (window is CountdownTimerWindow timerWindow)
{
timerWindow.RefreshTheme();
}
else if (window is RandWindow randWindow)
{
randWindow.RefreshTheme();
}
else if (window is OperatingGuideWindow operatingGuideWindow)
{
operatingGuideWindow.RefreshTheme();
}
}
// 刷新计时器控件
if (TimerControl != null)
{
TimerControl.RefreshTheme();
}
if (MinimizedTimerControl != null)
{
MinimizedTimerControl.RefreshTheme();
}
}
catch (Exception)
{
}
}
}
}
+97 -21
View File
@@ -15,10 +15,10 @@ namespace Ink_Canvas
private StrokeCollection[] strokeCollections = new StrokeCollection[101];
private bool[] whiteboadLastModeIsRedo = new bool[101];
private StrokeCollection lastTouchDownStrokeCollection = new StrokeCollection();
private int CurrentWhiteboardIndex = 1;
private int WhiteboardTotalCount = 1;
private TimeMachineHistory[][] TimeMachineHistories = new TimeMachineHistory[101][]; //最多99页,0用来存储非白板时的墨迹以便还原
private TimeMachineHistory[][] TimeMachineHistories = new TimeMachineHistory[101][];
private bool[] savedMultiTouchModeStates = new bool[101];
// 保存每页白板图片信息
private void SaveStrokes(bool isBackupMain = false)
@@ -97,6 +97,8 @@ namespace Ink_Canvas
{
var timeMachineHistory = timeMachine.ExportTimeMachineHistory();
TimeMachineHistories[0] = timeMachineHistory;
// 保存多指书写模式状态
savedMultiTouchModeStates[0] = isInMultiTouchMode;
timeMachine.ClearStrokeHistory();
@@ -105,6 +107,8 @@ namespace Ink_Canvas
{
var timeMachineHistory = timeMachine.ExportTimeMachineHistory();
TimeMachineHistories[CurrentWhiteboardIndex] = timeMachineHistory;
// 保存多指书写模式状态
savedMultiTouchModeStates[CurrentWhiteboardIndex] = isInMultiTouchMode;
timeMachine.ClearStrokeHistory();
@@ -116,15 +120,25 @@ namespace Ink_Canvas
_currentCommitType = CommitReason.ClearingCanvas;
if (isErasedByCode) _currentCommitType = CommitReason.CodeInput;
// 只清除笔画,不清除图片元素
// 图片元素的清除由调用方决定
inkCanvas.Strokes.Clear();
// 执行内存清理
PerformLightweightMemoryCleanup();
_currentCommitType = CommitReason.UserInput;
}
/// <summary>
/// 执行内存清理
/// </summary>
private void PerformLightweightMemoryCleanup()
{
Task.Run(() =>
{
GC.Collect();
});
}
// 恢复每页白板图片信息
private void RestoreStrokes(bool isBackupMain = false)
{
@@ -161,12 +175,16 @@ namespace Ink_Canvas
{
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[0]);
foreach (var item in TimeMachineHistories[0]) ApplyHistoryToCanvas(item);
// 恢复多指书写模式状态
RestoreMultiTouchModeState(0);
}
else
{
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[CurrentWhiteboardIndex]);
// 通过时间机器历史恢复所有内容(墨迹和图片)
foreach (var item in TimeMachineHistories[CurrentWhiteboardIndex]) ApplyHistoryToCanvas(item);
// 恢复多指书写模式状态
RestoreMultiTouchModeState(CurrentWhiteboardIndex);
}
@@ -177,6 +195,39 @@ namespace Ink_Canvas
}
}
/// <summary>
/// 恢复多指书写模式状态
/// </summary>
private void RestoreMultiTouchModeState(int pageIndex)
{
try
{
// 检查是否保存了多指书写模式状态
if (savedMultiTouchModeStates[pageIndex])
{
// 更新UI状态
if (ToggleSwitchEnableMultiTouchMode != null)
{
ToggleSwitchEnableMultiTouchMode.IsOn = true;
}
LogHelper.WriteLogToFile($"恢复多指书写模式状态 - 页面索引: {pageIndex}", LogHelper.LogType.Info);
}
else
{
// 更新UI状态
if (ToggleSwitchEnableMultiTouchMode != null)
{
ToggleSwitchEnableMultiTouchMode.IsOn = false;
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"恢复多指书写模式状态失败: {ex.Message}", LogHelper.LogType.Error);
}
}
private async void BtnWhiteBoardPageIndex_Click(object sender, EventArgs e)
{
if (sender == BtnLeftPageListWB)
@@ -191,9 +242,12 @@ namespace Ink_Canvas
RefreshBlackBoardSidePageListView();
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardBorderLeftPageListView);
await Task.Delay(1);
ScrollViewToVerticalTop(
(ListViewItem)BlackBoardLeftSidePageListView.ItemContainerGenerator.ContainerFromIndex(
CurrentWhiteboardIndex - 1), BlackBoardLeftSidePageListScrollViewer);
var leftContainer = BlackBoardLeftSidePageListView.ItemContainerGenerator.ContainerFromIndex(
CurrentWhiteboardIndex - 1) as ListViewItem;
if (leftContainer != null)
{
ScrollViewToVerticalTop(leftContainer, BlackBoardLeftSidePageListScrollViewer);
}
}
}
else if (sender == BtnRightPageListWB)
@@ -208,9 +262,12 @@ namespace Ink_Canvas
RefreshBlackBoardSidePageListView();
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardBorderRightPageListView);
await Task.Delay(1);
ScrollViewToVerticalTop(
(ListViewItem)BlackBoardRightSidePageListView.ItemContainerGenerator.ContainerFromIndex(
CurrentWhiteboardIndex - 1), BlackBoardRightSidePageListScrollViewer);
var rightContainer = BlackBoardRightSidePageListView.ItemContainerGenerator.ContainerFromIndex(
CurrentWhiteboardIndex - 1) as ListViewItem;
if (rightContainer != null)
{
ScrollViewToVerticalTop(rightContainer, BlackBoardRightSidePageListScrollViewer);
}
}
}
@@ -360,13 +417,25 @@ namespace Ink_Canvas
BtnLeftWhiteBoardSwitchNextLabel.Text = isLastPage ? "新页面" : "下一页";
BtnRightWhiteBoardSwitchNextLabel.Text = isLastPage ? "新页面" : "下一页";
// 始终允许点击“下一页/新页面”按钮(除非已达最大页数)
BtnWhiteBoardSwitchNext.IsEnabled = !isMaxPage;
if (isLastPage)
{
BtnWhiteBoardSwitchNext.IsEnabled = !isMaxPage;
}
else
{
BtnWhiteBoardSwitchNext.IsEnabled = true;
}
// 保持按钮常亮(高亮)
BtnLeftWhiteBoardSwitchNextGeometry.Brush = new SolidColorBrush(Color.FromArgb(255, 24, 24, 27));
// 获取主题颜色资源
var iconForegroundBrush = Application.Current.FindResource("IconForeground") as SolidColorBrush;
// 设置下一页按钮颜色
if (iconForegroundBrush != null)
{
BtnLeftWhiteBoardSwitchNextGeometry.Brush = iconForegroundBrush;
BtnRightWhiteBoardSwitchNextGeometry.Brush = iconForegroundBrush;
}
BtnLeftWhiteBoardSwitchNextLabel.Opacity = 1;
BtnRightWhiteBoardSwitchNextGeometry.Brush = new SolidColorBrush(Color.FromArgb(255, 24, 24, 27));
BtnRightWhiteBoardSwitchNextLabel.Opacity = 1;
BtnWhiteBoardSwitchPrevious.IsEnabled = true;
@@ -374,16 +443,23 @@ namespace Ink_Canvas
if (CurrentWhiteboardIndex == 1)
{
BtnWhiteBoardSwitchPrevious.IsEnabled = false;
BtnLeftWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(127, 24, 24, 27));
if (iconForegroundBrush != null)
{
var disabledBrush = new SolidColorBrush(Color.FromArgb(127, iconForegroundBrush.Color.R, iconForegroundBrush.Color.G, iconForegroundBrush.Color.B));
BtnLeftWhiteBoardSwitchPreviousGeometry.Brush = disabledBrush;
BtnRightWhiteBoardSwitchPreviousGeometry.Brush = disabledBrush;
}
BtnLeftWhiteBoardSwitchPreviousLabel.Opacity = 0.5;
BtnRightWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(127, 24, 24, 27));
BtnRightWhiteBoardSwitchPreviousLabel.Opacity = 0.5;
}
else
{
BtnLeftWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(255, 24, 24, 27));
if (iconForegroundBrush != null)
{
BtnLeftWhiteBoardSwitchPreviousGeometry.Brush = iconForegroundBrush;
BtnRightWhiteBoardSwitchPreviousGeometry.Brush = iconForegroundBrush;
}
BtnLeftWhiteBoardSwitchPreviousLabel.Opacity = 1;
BtnRightWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(255, 24, 24, 27));
BtnRightWhiteBoardSwitchPreviousLabel.Opacity = 1;
}
+20 -18
View File
@@ -1,4 +1,4 @@
using Ink_Canvas.Helpers;
using Ink_Canvas.Helpers;
using System;
using System.Diagnostics;
using System.Windows;
@@ -61,7 +61,7 @@ namespace Ink_Canvas
ICCWaterMarkWhite.Visibility = Visibility.Collapsed;
// 设置为白板默认背景色
Color defaultWhiteboardColor = Color.FromRgb(234, 235, 237);
Color defaultWhiteboardColor = Color.FromRgb(255, 255, 255);
if (currentMode == 1) // 白板模式
{
@@ -135,7 +135,7 @@ namespace Ink_Canvas
{
Name = "BackgroundPalette",
Visibility = Visibility.Collapsed,
Background = new SolidColorBrush(Colors.White),
Background = (SolidColorBrush)Application.Current.FindResource("SettingsPageBackground"),
Opacity = 1,
BorderBrush = new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)),
BorderThickness = new Thickness(1),
@@ -166,7 +166,7 @@ namespace Ink_Canvas
var titleText = new TextBlock
{
Text = "背景设置",
Foreground = new SolidColorBrush(Colors.White),
Foreground = (SolidColorBrush)Application.Current.FindResource("FloatBarForeground"),
Padding = new Thickness(0, 5, 0, 0),
FontSize = 11,
FontWeight = FontWeights.Bold,
@@ -198,7 +198,7 @@ namespace Ink_Canvas
var modeTitle = new TextBlock
{
Text = "白板模式",
Foreground = new SolidColorBrush(Color.FromRgb(0x17, 0x25, 0x54)),
Foreground = (SolidColorBrush)Application.Current.FindResource("TextForeground"),
FontSize = 10,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
@@ -233,7 +233,7 @@ namespace Ink_Canvas
ICCWaterMarkWhite.Visibility = Visibility.Collapsed;
// 设置为白板默认背景色
Color defaultWhiteboardColor = Color.FromRgb(234, 235, 237);
Color defaultWhiteboardColor = Color.FromRgb(255, 255, 255);
if (currentMode == 1) // 白板模式
{
@@ -319,7 +319,7 @@ namespace Ink_Canvas
var separator = new Border
{
Height = 1,
Background = new SolidColorBrush(Color.FromRgb(0xd4, 0xd4, 0xd8)),
Background = (SolidColorBrush)Application.Current.FindResource("SettingsPageBorderBrush"),
Margin = new Thickness(0, 12, 0, 12)
};
contentPanel.Children.Add(separator);
@@ -328,7 +328,7 @@ namespace Ink_Canvas
var colorTitle = new TextBlock
{
Text = "背景颜色",
Foreground = new SolidColorBrush(Color.FromRgb(0x17, 0x25, 0x54)),
Foreground = (SolidColorBrush)Application.Current.FindResource("TextForeground"),
FontSize = 10,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
@@ -342,7 +342,7 @@ namespace Ink_Canvas
Width = 100,
Height = 40,
BorderThickness = new Thickness(1),
BorderBrush = new SolidColorBrush(Color.FromRgb(0xd4, 0xd4, 0xd8)),
BorderBrush = (SolidColorBrush)Application.Current.FindResource("SettingsPageBorderBrush"),
Background = new SolidColorBrush(Colors.White),
CornerRadius = new CornerRadius(4),
Margin = new Thickness(0, 0, 0, 10),
@@ -378,7 +378,7 @@ namespace Ink_Canvas
// 先创建所有滑块控件
// R滑块和文本框
var rPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 10, 5) };
var rLabel = new TextBlock { Text = "R:", Width = 20, VerticalAlignment = VerticalAlignment.Center };
var rLabel = new TextBlock { Text = "R:", Width = 20, VerticalAlignment = VerticalAlignment.Center, Foreground = (SolidColorBrush)Application.Current.FindResource("TextForeground") };
var rSlider = new Slider
{
Minimum = 0,
@@ -393,12 +393,13 @@ namespace Ink_Canvas
Text = currentBackgroundColor.R.ToString(),
Width = 30,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Right
TextAlignment = TextAlignment.Right,
Foreground = (SolidColorBrush)Application.Current.FindResource("TextForeground")
};
// G滑块和文本框
var gPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 10, 5) };
var gLabel = new TextBlock { Text = "G:", Width = 20, VerticalAlignment = VerticalAlignment.Center };
var gLabel = new TextBlock { Text = "G:", Width = 20, VerticalAlignment = VerticalAlignment.Center, Foreground = (SolidColorBrush)Application.Current.FindResource("TextForeground") };
var gSlider = new Slider
{
Minimum = 0,
@@ -413,12 +414,13 @@ namespace Ink_Canvas
Text = currentBackgroundColor.G.ToString(),
Width = 30,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Right
TextAlignment = TextAlignment.Right,
Foreground = (SolidColorBrush)Application.Current.FindResource("TextForeground")
};
// B滑块和文本框
var bPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 10, 5) };
var bLabel = new TextBlock { Text = "B:", Width = 20, VerticalAlignment = VerticalAlignment.Center };
var bLabel = new TextBlock { Text = "B:", Width = 20, VerticalAlignment = VerticalAlignment.Center, Foreground = (SolidColorBrush)Application.Current.FindResource("TextForeground") };
var bSlider = new Slider
{
Minimum = 0,
@@ -433,7 +435,8 @@ namespace Ink_Canvas
Text = currentBackgroundColor.B.ToString(),
Width = 30,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Right
TextAlignment = TextAlignment.Right,
Foreground = (SolidColorBrush)Application.Current.FindResource("TextForeground")
};
// 现在添加事件处理程序
@@ -716,7 +719,7 @@ namespace Ink_Canvas
//}
//else {
// 禁用高级橡皮擦系统
DisableAdvancedEraserSystem();
DisableEraserOverlay();
forceEraser = true;
forcePointEraser = false;
@@ -726,7 +729,6 @@ namespace Ink_Canvas
SetCurrentToolMode(InkCanvasEditingMode.EraseByStroke);
drawingShapeMode = 0;
// 修复:切换到线擦时,确保重置笔的状态
penType = 0;
drawingAttributes.IsHighlighter = false;
drawingAttributes.StylusTip = StylusTip.Ellipse;
@@ -855,4 +857,4 @@ namespace Ink_Canvas
}
}
}
}
}
@@ -192,6 +192,8 @@ namespace Ink_Canvas
elementForEvents.MouseWheel += Element_MouseWheel;
// 触摸事件
elementForEvents.TouchDown += Element_TouchDown;
elementForEvents.TouchUp += Element_TouchUp;
elementForEvents.IsManipulationEnabled = true;
elementForEvents.ManipulationDelta += Element_ManipulationDelta;
elementForEvents.ManipulationCompleted += Element_ManipulationCompleted;
+4 -1
View File
@@ -18,7 +18,10 @@ namespace Ink_Canvas
private void ColorSwitchCheck()
{
HideSubPanels("color");
if (penType != 1)
{
HideSubPanels("color");
}
if (GridTransparencyFakeBackground.Background == Brushes.Transparent)
{
if (currentMode == 1)
@@ -11,7 +11,9 @@ using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using Path = System.IO.Path;
namespace Ink_Canvas
{
@@ -150,6 +152,19 @@ namespace Ink_Canvas
}
}
// 触摸释放事件
private void Element_TouchUp(object sender, TouchEventArgs e)
{
if (sender is FrameworkElement element)
{
isDragging = false;
element.ReleaseTouchCapture(e.TouchDevice);
element.Cursor = Cursors.Hand;
e.Handled = true;
}
}
// 鼠标移动事件
private void Element_MouseMove(object sender, MouseEventArgs e)
{
@@ -166,6 +181,12 @@ namespace Ink_Canvas
UpdateImageSelectionToolbarPosition(element);
}
// 如果是图片元素,更新选择点位置
if (element is Image && ImageResizeHandlesCanvas?.Visibility == Visibility.Visible)
{
UpdateImageResizeHandlesPosition(GetElementActualBounds(element));
}
dragStartPoint = currentPoint;
e.Handled = true;
}
@@ -187,6 +208,40 @@ namespace Ink_Canvas
UpdateImageSelectionToolbarPosition(element);
}
// 如果是图片元素,更新选择点位置
if (element is Image && ImageResizeHandlesCanvas?.Visibility == Visibility.Visible)
{
UpdateImageResizeHandlesPosition(GetElementActualBounds(element));
}
e.Handled = true;
}
}
// 触摸按下事件
private void Element_TouchDown(object sender, TouchEventArgs e)
{
if (sender is FrameworkElement element)
{
// 取消之前选中的元素
if (currentSelectedElement != null && currentSelectedElement != element)
{
// 保存当前编辑模式
var previousEditingMode = inkCanvas.EditingMode;
UnselectElement(currentSelectedElement);
// 恢复编辑模式
inkCanvas.EditingMode = previousEditingMode;
}
// 选中当前元素
SelectElement(element);
// 开始拖动
isDragging = true;
dragStartPoint = e.GetTouchPoint(inkCanvas).Position;
element.CaptureTouch(e.TouchDevice);
element.Cursor = Cursors.SizeAll;
e.Handled = true;
}
}
@@ -214,6 +269,12 @@ namespace Ink_Canvas
UpdateImageSelectionToolbarPosition(element);
}
// 如果是图片元素,更新选择点位置
if (element is Image && ImageResizeHandlesCanvas?.Visibility == Visibility.Visible)
{
UpdateImageResizeHandlesPosition(GetElementActualBounds(element));
}
e.Handled = true;
}
}
@@ -290,6 +351,9 @@ namespace Ink_Canvas
BorderImageSelectionControl.Visibility = Visibility.Visible;
}
// 显示图片缩放选择点
ShowImageResizeHandles(element);
// 墨迹选择工具栏通过GridInkCanvasSelectionCover的可见性来控制
// 不需要直接设置BorderStrokeSelectionControl.Visibility
}
@@ -301,6 +365,9 @@ namespace Ink_Canvas
BorderImageSelectionControl.Visibility = Visibility.Collapsed;
}
// 隐藏图片缩放选择点
HideImageResizeHandles();
// 墨迹选择工具栏通过GridInkCanvasSelectionCover的可见性来控制
// 不需要直接设置BorderStrokeSelectionControl.Visibility
}
@@ -332,6 +399,9 @@ namespace Ink_Canvas
BorderImageSelectionControl.Visibility = Visibility.Collapsed;
}
// 隐藏图片缩放选择点
HideImageResizeHandles();
// 墨迹选择工具栏通过GridInkCanvasSelectionCover的可见性来控制
// 不需要直接设置BorderStrokeSelectionControl.Visibility
@@ -1334,6 +1404,323 @@ namespace Ink_Canvas
}
}
/// <summary>
/// 克隆墨迹集合
/// </summary>
/// <param name="strokes">要克隆的墨迹集合</param>
/// <returns>克隆后的墨迹集合</returns>
private StrokeCollection CloneStrokes(StrokeCollection strokes)
{
if (strokes == null || strokes.Count == 0) return new StrokeCollection();
try
{
// 创建墨迹集合的副本
var clonedStrokes = strokes.Clone();
// 为每个墨迹添加位置偏移以避免重叠
foreach (var stroke in clonedStrokes)
{
var offsetPoints = new StylusPointCollection();
foreach (var point in stroke.StylusPoints)
{
offsetPoints.Add(new StylusPoint(point.X + 20, point.Y + 20, point.PressureFactor));
}
stroke.StylusPoints = offsetPoints;
}
// 添加到画布
inkCanvas.Strokes.Add(clonedStrokes);
// 提交到时间机器以支持撤销
timeMachine.CommitStrokeUserInputHistory(clonedStrokes);
LogHelper.WriteLogToFile($"墨迹克隆完成: {clonedStrokes.Count} 个墨迹");
return clonedStrokes;
}
catch (Exception ex)
{
// 记录错误但不中断程序
LogHelper.WriteLogToFile($"克隆墨迹时发生错误: {ex.Message}", LogHelper.LogType.Error);
return new StrokeCollection();
}
}
/// <summary>
/// 克隆墨迹集合到新页面
/// </summary>
/// <param name="strokes">要克隆的墨迹集合</param>
private void CloneStrokesToNewBoard(StrokeCollection strokes)
{
if (strokes == null || strokes.Count == 0) return;
try
{
// 创建墨迹集合的副本
var clonedStrokes = strokes.Clone();
// 为每个墨迹添加位置偏移以避免重叠
foreach (var stroke in clonedStrokes)
{
var offsetPoints = new StylusPointCollection();
foreach (var point in stroke.StylusPoints)
{
offsetPoints.Add(new StylusPoint(point.X + 20, point.Y + 20, point.PressureFactor));
}
stroke.StylusPoints = offsetPoints;
}
// 创建新页面
BtnWhiteBoardAdd_Click(null, null);
// 添加到新页面的画布
inkCanvas.Strokes.Add(clonedStrokes);
// 提交到时间机器以支持撤销
timeMachine.CommitStrokeUserInputHistory(clonedStrokes);
LogHelper.WriteLogToFile($"墨迹克隆到新页面完成: {clonedStrokes.Count} 个墨迹");
}
catch (Exception ex)
{
// 记录错误但不中断程序
LogHelper.WriteLogToFile($"克隆墨迹到新页面时发生错误: {ex.Message}", LogHelper.LogType.Error);
}
}
#endregion
#region Image Resize Handles
// 图片缩放选择点相关变量
private bool isResizingImage = false;
private Point imageResizeStartPoint;
private string activeResizeHandle = "";
// 显示图片缩放选择点
private void ShowImageResizeHandles(FrameworkElement element)
{
try
{
if (ImageResizeHandlesCanvas == null || element == null) return;
// 获取元素的实际边界
Rect elementBounds = GetElementActualBounds(element);
// 设置选择点位置
UpdateImageResizeHandlesPosition(elementBounds);
// 显示选择点
ImageResizeHandlesCanvas.Visibility = Visibility.Visible;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"显示图片缩放选择点失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 隐藏图片缩放选择点
private void HideImageResizeHandles()
{
try
{
if (ImageResizeHandlesCanvas != null)
{
ImageResizeHandlesCanvas.Visibility = Visibility.Collapsed;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"隐藏图片缩放选择点失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 更新图片缩放选择点位置
private void UpdateImageResizeHandlesPosition(Rect elementBounds)
{
try
{
if (ImageResizeHandlesCanvas == null) return;
ImageResizeHandlesCanvas.Margin = new Thickness(elementBounds.Left, elementBounds.Top, 0, 0);
// 四个角控制点
System.Windows.Controls.Canvas.SetLeft(ImageTopLeftHandle, -4);
System.Windows.Controls.Canvas.SetTop(ImageTopLeftHandle, -4);
System.Windows.Controls.Canvas.SetLeft(ImageTopRightHandle, elementBounds.Width - 4);
System.Windows.Controls.Canvas.SetTop(ImageTopRightHandle, -4);
System.Windows.Controls.Canvas.SetLeft(ImageBottomLeftHandle, -4);
System.Windows.Controls.Canvas.SetTop(ImageBottomLeftHandle, elementBounds.Height - 4);
System.Windows.Controls.Canvas.SetLeft(ImageBottomRightHandle, elementBounds.Width - 4);
System.Windows.Controls.Canvas.SetTop(ImageBottomRightHandle, elementBounds.Height - 4);
// 四个边控制点
System.Windows.Controls.Canvas.SetLeft(ImageTopHandle, elementBounds.Width / 2 - 4);
System.Windows.Controls.Canvas.SetTop(ImageTopHandle, -4);
System.Windows.Controls.Canvas.SetLeft(ImageBottomHandle, elementBounds.Width / 2 - 4);
System.Windows.Controls.Canvas.SetTop(ImageBottomHandle, elementBounds.Height - 4);
System.Windows.Controls.Canvas.SetLeft(ImageLeftHandle, -4);
System.Windows.Controls.Canvas.SetTop(ImageLeftHandle, elementBounds.Height / 2 - 4);
System.Windows.Controls.Canvas.SetLeft(ImageRightHandle, elementBounds.Width - 4);
System.Windows.Controls.Canvas.SetTop(ImageRightHandle, elementBounds.Height / 2 - 4);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新图片缩放选择点位置失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 图片缩放选择点鼠标按下事件
private void ImageResizeHandle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
try
{
if (currentSelectedElement is Image image && sender is Ellipse ellipse)
{
isResizingImage = true;
imageResizeStartPoint = e.GetPosition(inkCanvas);
// 确定是哪个控制点
activeResizeHandle = ellipse.Name;
// 捕获鼠标
ellipse.CaptureMouse();
e.Handled = true;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"图片缩放选择点鼠标按下事件失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 图片缩放选择点鼠标释放事件
private void ImageResizeHandle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
try
{
if (isResizingImage && sender is Ellipse ellipse)
{
isResizingImage = false;
ellipse.ReleaseMouseCapture();
activeResizeHandle = "";
e.Handled = true;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"图片缩放选择点鼠标释放事件失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 图片缩放选择点鼠标移动事件
private void ImageResizeHandle_MouseMove(object sender, MouseEventArgs e)
{
try
{
if (isResizingImage && currentSelectedElement is Image image && sender is Ellipse ellipse)
{
var currentPoint = e.GetPosition(inkCanvas);
ResizeImageByHandle(image, imageResizeStartPoint, currentPoint, activeResizeHandle);
imageResizeStartPoint = currentPoint;
e.Handled = true;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"图片缩放选择点鼠标移动事件失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 根据控制点缩放图片
private void ResizeImageByHandle(Image image, Point startPoint, Point currentPoint, string handleName)
{
try
{
if (image.RenderTransform is TransformGroup transformGroup)
{
var scaleTransform = transformGroup.Children.OfType<ScaleTransform>().FirstOrDefault();
var translateTransform = transformGroup.Children.OfType<TranslateTransform>().FirstOrDefault();
if (scaleTransform == null || translateTransform == null) return;
// 获取图片的当前边界
Rect currentBounds = GetElementActualBounds(image);
double deltaX = currentPoint.X - startPoint.X;
double deltaY = currentPoint.Y - startPoint.Y;
// 计算缩放比例
double scaleX = 1.0;
double scaleY = 1.0;
double translateX = 0;
double translateY = 0;
switch (handleName)
{
case "ImageTopLeftHandle":
scaleX = (currentBounds.Width - deltaX) / currentBounds.Width;
scaleY = (currentBounds.Height - deltaY) / currentBounds.Height;
translateX = deltaX;
translateY = deltaY;
break;
case "ImageTopRightHandle":
scaleX = (currentBounds.Width + deltaX) / currentBounds.Width;
scaleY = (currentBounds.Height - deltaY) / currentBounds.Height;
translateY = deltaY;
break;
case "ImageBottomLeftHandle":
scaleX = (currentBounds.Width - deltaX) / currentBounds.Width;
scaleY = (currentBounds.Height + deltaY) / currentBounds.Height;
translateX = deltaX;
break;
case "ImageBottomRightHandle":
scaleX = (currentBounds.Width + deltaX) / currentBounds.Width;
scaleY = (currentBounds.Height + deltaY) / currentBounds.Height;
break;
case "ImageTopHandle":
scaleY = (currentBounds.Height - deltaY) / currentBounds.Height;
translateY = deltaY;
break;
case "ImageBottomHandle":
scaleY = (currentBounds.Height + deltaY) / currentBounds.Height;
break;
case "ImageLeftHandle":
scaleX = (currentBounds.Width - deltaX) / currentBounds.Width;
translateX = deltaX;
break;
case "ImageRightHandle":
scaleX = (currentBounds.Width + deltaX) / currentBounds.Width;
break;
}
// 限制缩放范围
scaleX = Math.Max(0.1, Math.Min(scaleX, 5.0));
scaleY = Math.Max(0.1, Math.Min(scaleY, 5.0));
// 应用缩放
scaleTransform.ScaleX *= scaleX;
scaleTransform.ScaleY *= scaleY;
// 应用平移
translateTransform.X += translateX;
translateTransform.Y += translateY;
// 更新选择点位置
UpdateImageResizeHandlesPosition(GetElementActualBounds(image));
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"根据控制点缩放图片失败: {ex.Message}", LogHelper.LogType.Error);
}
}
#endregion
}
}
File diff suppressed because it is too large Load Diff
+43 -33
View File
@@ -1,36 +1,46 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DrawingGroup x:Key="EraserDrawingGroup" ClipGeometry="M0,0 V56 H38 V0 H0 Z">
<GeometryDrawing Brush="#FFF2EEEB" Geometry="F1 M38,56z M0,0z M0,4C0,1.79086,1.79086,0,4,0L34,0C36.2091,0,38,1.79086,38,4L38,52C38,54.2091,36.2091,56,34,56L4,56C1.79086,56,0,54.2091,0,52L0,4z" />
<GeometryDrawing Brush="#FFCDCDCD" Geometry="F0 M38,56z M0,0z M34,1L4,1C2.34315,1,1,2.34315,1,4L1,52C1,53.6569,2.34315,55,4,55L34,55C35.6569,55,37,53.6569,37,52L37,4C37,2.34315,35.6569,1,34,1z M4,0C1.79086,0,0,1.79086,0,4L0,52C0,54.2091,1.79086,56,4,56L34,56C36.2091,56,38,54.2091,38,52L38,4C38,1.79086,36.2091,0,34,0L4,0z" />
<GeometryDrawing Brush="#FFD1CFCD" Geometry="F1 M38,56z M0,0z M12,19.5C12,18.1193,13.1193,17,14.5,17L14.5,17C15.8807,17,17,18.1193,17,19.5L17,36.5C17,37.8807,15.8807,39,14.5,39L14.5,39C13.1193,39,12,37.8807,12,36.5L12,19.5z" />
<GeometryDrawing Geometry="F0 M38,56z M0,0z M11.5,19.5C11.5,17.8431 12.8431,16.5 14.5,16.5 16.1569,16.5 17.5,17.8431 17.5,19.5L17.5,36.5C17.5,38.1569 16.1569,39.5 14.5,39.5 12.8431,39.5 11.5,38.1569 11.5,36.5L11.5,19.5z M14.5,17.5C13.3954,17.5,12.5,18.3954,12.5,19.5L12.5,36.5C12.5,37.6046 13.3954,38.5 14.5,38.5 15.6046,38.5 16.5,37.6046 16.5,36.5L16.5,19.5C16.5,18.3954,15.6046,17.5,14.5,17.5z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FF6F6F6F" Opacity="0.25" />
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing Brush="#FFD1CFCD" Geometry="F1 M38,56z M0,0z M21,19.5C21,18.1193,22.1193,17,23.5,17L23.5,17C24.8807,17,26,18.1193,26,19.5L26,36.5C26,37.8807,24.8807,39,23.5,39L23.5,39C22.1193,39,21,37.8807,21,36.5L21,19.5z" />
<GeometryDrawing Geometry="F0 M38,56z M0,0z M20.5,19.5C20.5,17.8431 21.8431,16.5 23.5,16.5 25.1569,16.5 26.5,17.8431 26.5,19.5L26.5,36.5C26.5,38.1569 25.1569,39.5 23.5,39.5 21.8431,39.5 20.5,38.1569 20.5,36.5L20.5,19.5z M23.5,17.5C22.3954,17.5,21.5,18.3954,21.5,19.5L21.5,36.5C21.5,37.6046 22.3954,38.5 23.5,38.5 24.6046,38.5 25.5,37.6046 25.5,36.5L25.5,19.5C25.5,18.3954,24.6046,17.5,23.5,17.5z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FF6F6F6F" Opacity="0.25" />
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- 矩形橡皮擦图像资源 -->
<DrawingImage x:Key="RectangleEraserImageSource">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V56 H38 V0 H0 Z">
<GeometryDrawing Brush="#FFF2EEEB" Geometry="F1 M38,56z M0,0z M0,4C0,1.79086,1.79086,0,4,0L34,0C36.2091,0,38,1.79086,38,4L38,52C38,54.2091,36.2091,56,34,56L4,56C1.79086,56,0,54.2091,0,52L0,4z" />
<GeometryDrawing Brush="#FFCDCDCD" Geometry="F0 M38,56z M0,0z M34,1L4,1C2.34315,1,1,2.34315,1,4L1,52C1,53.6569,2.34315,55,4,55L34,55C35.6569,55,37,53.6569,37,52L37,4C37,2.34315,35.6569,1,34,1z M4,0C1.79086,0,0,1.79086,0,4L0,52C0,54.2091,1.79086,56,4,56L34,56C36.2091,56,38,54.2091,38,52L38,4C38,1.79086,36.2091,0,34,0L4,0z" />
<GeometryDrawing Brush="#FFD1CFCD" Geometry="F1 M38,56z M0,0z M12,19.5C12,18.1193,13.1193,17,14.5,17L14.5,17C15.8807,17,17,18.1193,17,19.5L17,36.5C17,37.8807,15.8807,39,14.5,39L14.5,39C13.1193,39,12,37.8807,12,36.5L12,19.5z" />
<GeometryDrawing Geometry="F0 M38,56z M0,0z M11.5,19.5C11.5,17.8431 12.8431,16.5 14.5,16.5 16.1569,16.5 17.5,17.8431 17.5,19.5L17.5,36.5C17.5,38.1569 16.1569,39.5 14.5,39.5 12.8431,39.5 11.5,38.1569 11.5,36.5L11.5,19.5z M14.5,17.5C13.3954,17.5,12.5,18.3954,12.5,19.5L12.5,36.5C12.5,37.6046 13.3954,38.5 14.5,38.5 15.6046,38.5 16.5,37.6046 16.5,36.5L16.5,19.5C16.5,18.3954,15.6046,17.5,14.5,17.5z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FF6F6F6F" Opacity="0.25" />
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing Brush="#FFD1CFCD" Geometry="F1 M38,56z M0,0z M21,19.5C21,18.1193,22.1193,17,23.5,17L23.5,17C24.8807,17,26,18.1193,26,19.5L26,36.5C26,37.8807,24.8807,39,23.5,39L23.5,39C22.1193,39,21,37.8807,21,36.5L21,19.5z" />
<GeometryDrawing Geometry="F0 M38,56z M0,0z M20.5,19.5C20.5,17.8431 21.8431,16.5 23.5,16.5 25.1569,16.5 26.5,17.8431 26.5,19.5L26.5,36.5C26.5,38.1569 25.1569,39.5 23.5,39.5 21.8431,39.5 20.5,38.1569 20.5,36.5L20.5,19.5z M23.5,17.5C22.3954,17.5,21.5,18.3954,21.5,19.5L21.5,36.5C21.5,37.6046 22.3954,38.5 23.5,38.5 24.6046,38.5 25.5,37.6046 25.5,36.5L25.5,19.5C25.5,18.3954,24.6046,17.5,23.5,17.5z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FF6F6F6F" Opacity="0.25" />
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingGroup x:Key="EraserCircleDrawingGroup" ClipGeometry="M0,0 V56 H56 V0 H0 Z">
<GeometryDrawing Brush="#FFF2EEEB" Geometry="F1 M56,56z M0,0z M0,28C0,12.536,12.536,0,28,0L28,0C43.464,0,56,12.536,56,28L56,28C56,43.464,43.464,56,28,56L28,56C12.536,56,0,43.464,0,28L0,28z" />
<GeometryDrawing Brush="#FFCDCDCD" Geometry="F0 M56,56z M0,0z M1,28C1,42.9117 13.0883,55 28,55 42.9117,55 55,42.9117 55,28 55,13.0883 42.9117,1 28,1 13.0883,1 1,13.0883 1,28z M28,0C12.536,0 0,12.536 0,28 0,43.464 12.536,56 28,56 43.464,56 56,43.464 56,28 56,12.536 43.464,0 28,0z" />
<GeometryDrawing Brush="#FFD1CFCD" Geometry="F1 M56,56z M0,0z M21,19.5C21,18.1193,22.1193,17,23.5,17L23.5,17C24.8807,17,26,18.1193,26,19.5L26,36.5C26,37.8807,24.8807,39,23.5,39L23.5,39C22.1193,39,21,37.8807,21,36.5L21,19.5z" />
<GeometryDrawing Geometry="F0 M56,56z M0,0z M20.5,19.5C20.5,17.8431 21.8431,16.5 23.5,16.5 25.1569,16.5 26.5,17.8431 26.5,19.5L26.5,36.5C26.5,38.1569 25.1569,39.5 23.5,39.5 21.8431,39.5 20.5,38.1569 20.5,36.5L20.5,19.5z M23.5,17.5C22.3954,17.5,21.5,18.3954,21.5,19.5L21.5,36.5C21.5,37.6046 22.3954,38.5 23.5,38.5 24.6046,38.5 25.5,37.6046 25.5,36.5L25.5,19.5C25.5,18.3954,24.6046,17.5,23.5,17.5z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FF6F6F6F" Opacity="0.25" />
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing Brush="#FFD1CFCD" Geometry="F1 M56,56z M0,0z M30,19.5C30,18.1193,31.1193,17,32.5,17L32.5,17C33.8807,17,35,18.1193,35,19.5L35,36.5C35,37.8807,33.8807,39,32.5,39L32.5,39C31.1193,39,30,37.8807,30,36.5L30,19.5z" />
<GeometryDrawing Geometry="F0 M56,56z M0,0z M29.5,19.5C29.5,17.8431 30.8431,16.5 32.5,16.5 34.1569,16.5 35.5,17.8431 35.5,19.5L35.5,36.5C35.5,38.1569 34.1569,39.5 32.5,39.5 30.8431,39.5 29.5,38.1569 29.5,36.5L29.5,19.5z M32.5,17.5C31.3954,17.5,30.5,18.3954,30.5,19.5L30.5,36.5C30.5,37.6046 31.3954,38.5 32.5,38.5 33.6046,38.5 34.5,37.6046 34.5,36.5L34.5,19.5C34.5,18.3954,33.6046,17.5,32.5,17.5z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FF6F6F6F" Opacity="0.25" />
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup>
<!-- 圆形橡皮擦图像资源 -->
<DrawingImage x:Key="EllipseEraserImageSource">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V56 H56 V0 H0 Z">
<GeometryDrawing Brush="#FFF2EEEB" Geometry="F1 M56,56z M0,0z M0,28C0,12.536,12.536,0,28,0L28,0C43.464,0,56,12.536,56,28L56,28C56,43.464,43.464,56,28,56L28,56C12.536,56,0,43.464,0,28L0,28z" />
<GeometryDrawing Brush="#FFCDCDCD" Geometry="F0 M56,56z M0,0z M1,28C1,42.9117 13.0883,55 28,55 42.9117,55 55,42.9117 55,28 55,13.0883 42.9117,1 28,1 13.0883,1 1,13.0883 1,28z M28,0C12.536,0 0,12.536 0,28 0,43.464 12.536,56 28,56 43.464,56 56,43.464 56,28 56,12.536 43.464,0 28,0z" />
<GeometryDrawing Brush="#FFD1CFCD" Geometry="F1 M56,56z M0,0z M21,19.5C21,18.1193,22.1193,17,23.5,17L23.5,17C24.8807,17,26,18.1193,26,19.5L26,36.5C26,37.8807,24.8807,39,23.5,39L23.5,39C22.1193,39,21,37.8807,21,36.5L21,19.5z" />
<GeometryDrawing Geometry="F0 M56,56z M0,0z M20.5,19.5C20.5,17.8431 21.8431,16.5 23.5,16.5 25.1569,16.5 26.5,17.8431 26.5,19.5L26.5,36.5C26.5,38.1569 25.1569,39.5 23.5,39.5 21.8431,39.5 20.5,38.1569 20.5,36.5L20.5,19.5z M23.5,17.5C22.3954,17.5,21.5,18.3954,21.5,19.5L21.5,36.5C21.5,37.6046 22.3954,38.5 23.5,38.5 24.6046,38.5 25.5,37.6046 25.5,36.5L25.5,19.5C25.5,18.3954,24.6046,17.5,23.5,17.5z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FF6F6F6F" Opacity="0.25" />
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing Brush="#FFD1CFCD" Geometry="F1 M56,56z M0,0z M30,19.5C30,18.1193,31.1193,17,32.5,17L32.5,17C33.8807,17,35,18.1193,35,19.5L35,36.5C35,37.8807,33.8807,39,32.5,39L32.5,39C31.1193,39,30,37.8807,30,36.5L30,19.5z" />
<GeometryDrawing Geometry="F0 M56,56z M0,0z M29.5,19.5C29.5,17.8431 30.8431,16.5 32.5,16.5 34.1569,16.5 35.5,17.8431 35.5,19.5L35.5,36.5C35.5,38.1569 34.1569,39.5 32.5,39.5 30.8431,39.5 29.5,38.1569 29.5,36.5L29.5,19.5z M32.5,17.5C31.3954,17.5,30.5,18.3954,30.5,19.5L30.5,36.5C30.5,37.6046 31.3954,38.5 32.5,38.5 33.6046,38.5 34.5,37.6046 34.5,36.5L34.5,19.5C34.5,18.3954,33.6046,17.5,32.5,17.5z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FF6F6F6F" Opacity="0.25" />
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</ResourceDictionary>
File diff suppressed because it is too large Load Diff
@@ -3,7 +3,6 @@ using iNKORE.UI.WPF.Modern.Controls;
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace Ink_Canvas
{
@@ -19,17 +18,17 @@ namespace Ink_Canvas
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)
@@ -49,7 +48,7 @@ namespace Ink_Canvas
// 设置主开关状态
ToggleSwitchFloatingWindowInterceptorEnabled.IsOn = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
// 设置各个拦截规则的状态
foreach (var kvp in Settings.Automation.FloatingWindowInterceptor.InterceptRules)
{
@@ -60,7 +59,7 @@ namespace Ink_Canvas
toggle.IsOn = kvp.Value;
}
}
// 更新UI可见性
UpdateFloatingWindowInterceptorUI();
}
@@ -79,16 +78,16 @@ namespace Ink_Canvas
{
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
TextBlockFloatingWindowInterceptorStatus.Text = stats.IsRunning
? $"拦截器运行中 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则"
: $"拦截器未启动 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则";
}
@@ -151,11 +150,11 @@ namespace Ink_Canvas
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)
@@ -167,7 +166,7 @@ namespace Ink_Canvas
_floatingWindowInterceptorManager.Stop();
}
}
UpdateFloatingWindowInterceptorUI();
SaveSettingsToFile();
}
@@ -305,17 +304,48 @@ namespace Ink_Canvas
{
_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)
+8 -26
View File
@@ -7,49 +7,31 @@ namespace Ink_Canvas
{
private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
{
// 只有在PPT放映模式下才响应鼠标滚轮翻页
if (StackPanelPPTControls.Visibility != Visibility.Visible ||
currentMode != 0 ||
BtnPPTSlideShowEnd.Visibility != Visibility.Visible ||
PPTManager?.IsInSlideShow != true) return;
// 直接发送翻页请求到PPT放映软件,不通过软件处理
if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible || currentMode != 0) return;
if (e.Delta >= 120)
{
// 上一页 - 发送PageUp键到PPT放映窗口
SendKeyToPPTSlideShow(true);
BtnPPTSlidesUp_Click(null, null);
}
else if (e.Delta <= -120)
{
// 下一页 - 发送PageDown键到PPT放映窗口
SendKeyToPPTSlideShow(false);
BtnPPTSlidesDown_Click(null, null);
}
}
private void Main_Grid_PreviewKeyDown(object sender, KeyEventArgs e)
{
// 只有在PPT放映模式下才响应键盘翻页快捷键
if (StackPanelPPTControls.Visibility != Visibility.Visible ||
currentMode != 0 ||
BtnPPTSlideShowEnd.Visibility != Visibility.Visible ||
PPTManager?.IsInSlideShow != true) return;
if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible || currentMode != 0) return;
// 直接发送翻页请求到PPT放映软件,不通过软件处理
if (e.Key == Key.Down || e.Key == Key.PageDown || e.Key == Key.Right || e.Key == Key.N ||
e.Key == Key.Space)
if (e.Key == Key.Down || e.Key == Key.PageDown || e.Key == Key.Right || e.Key == Key.N || e.Key == Key.Space)
{
e.Handled = true; // 阻止事件继续传播
SendKeyToPPTSlideShow(false); // 下一页
BtnPPTSlidesDown_Click(null, null);
}
else if (e.Key == Key.Up || e.Key == Key.PageUp || e.Key == Key.Left || e.Key == Key.P)
if (e.Key == Key.Up || e.Key == Key.PageUp || e.Key == Key.Left || e.Key == Key.P)
{
e.Handled = true; // 阻止事件继续传播
SendKeyToPPTSlideShow(true); // 上一页
BtnPPTSlidesUp_Click(null, null);
}
}
// 保留PPT翻页快捷键处理
// 以下方法保留供全局快捷键调用
private void HotKey_Undo(object sender, ExecutedRoutedEventArgs e)
{
+34
View File
@@ -5,6 +5,9 @@
public static string LinedCursorIcon =
"F1 M24,24z M0,0z M5.72106,15.9716L3.71327,3.00395C3.6389,2.6693 3.65747,2.41831 3.76902,2.25099 3.88057,2.08366 4.0479,2 4.271,2 4.4941,2 4.71711,2.07437 4.94021,2.2231 6.72502,3.39438 9.28149,5.10481 12.6094,7.3544 15.677,9.45526 18.1125,11.1285 19.9159,12.3742 20.1204,12.5229 20.2505,12.6995 20.3062,12.904 20.362,13.1085 20.3249,13.2944 20.1947,13.4618 20.0832,13.6105 19.8973,13.6849 19.637,13.6849L13.3902,13.6849 17.6291,19.7365C17.722,19.8666 17.75,20.0153 17.7128,20.1827 17.6942,20.3314 17.6198,20.4522 17.4897,20.5452L15.5654,21.8838C15.4353,21.9768 15.2865,22.0139 15.1192,21.9953 14.9704,21.9582 14.8496,21.8745 14.7566,21.7444L10.2389,15.2745 7.58956,19.9038C7.45942,20.1269 7.30144,20.2756 7.11552,20.35 6.92961,20.4058 6.75292,20.3872 6.5856,20.2942 6.43686,20.2013 6.34392,20.0339 6.30673,19.7922L6.00007,17.8959C5.88852,17.0779,5.79543,16.4364,5.72106,15.9716z";
public static string SolidCursorIcon =
"F1 M24,24z M0,0z M5.72106,15.9716L3.71327,3.00395C3.6389,2.6693 3.65747,2.41831 3.76902,2.25099 3.88057,2.08366 4.0479,2 4.271,2 4.4941,2 4.71711,2.07437 4.94021,2.2231 6.72502,3.39438 9.28149,5.10481 12.6094,7.3544 15.677,9.45526 18.1125,11.1285 19.9159,12.3742 20.1204,12.5229 20.2505,12.6995 20.3062,12.904 20.362,13.1085 20.3249,13.2944 20.1947,13.4618 20.0832,13.6105 19.8973,13.6849 19.637,13.6849L13.3902,13.6849 17.6291,19.7365C17.722,19.8666 17.75,20.0153 17.7128,20.1827 17.6942,20.3314 17.6198,20.4522 17.4897,20.5452L15.5654,21.8838C15.4353,21.9768 15.2865,22.0139 15.1192,21.9953 14.9704,21.9582 14.8496,21.8745 14.7566,21.7444L10.2389,15.2745 7.58956,19.9038C7.45942,20.1269 7.30144,20.2756 7.11552,20.35 6.92961,20.4058 6.75292,20.3872 6.5856,20.2942 6.43686,20.2013 6.34392,20.0339 6.30673,19.7922L6.00007,17.8959C5.88852,17.0779,5.79543,16.4364,5.72106,15.9716z";
public static string LinedPenIcon =
"F1 M24,24z M0,0z M16.996,2.34419L21.6823,7.00397C21.8941,7.23343 22,7.49819 22,7.79825 22,8.09831 21.8941,8.35425 21.6823,8.56606L10.8271,19.4212 4.57877,13.1994 15.4339,2.34419C15.6457,2.11473 15.9017,2 16.2018,2 16.5195,2 16.7842,2.11473 16.996,2.34419z M9.63571,20.5862L9.50333,20.6391 2.6725,21.9894C2.47834,22.0247 2.31066,21.9718 2.16946,21.8306 2.02825,21.707 1.97529,21.5481 2.01059,21.354L3.38736,14.5232C3.38736,14.4879,3.40502,14.4349,3.44032,14.3643L9.63571,20.5862z";
@@ -37,5 +40,36 @@
public static string EnabledGestureIconBadgeCheck =
"M22.74,18.2234C22.74,20.8888 20.5793,23.0494 17.914,23.0494 15.2487,23.0494 13.088,20.8888 13.088,18.2234 13.088,15.5581 15.2487,13.3975 17.914,13.3975 20.5793,13.3975 22.74,15.5581 22.74,18.2234z M21.1673,15.8009C21.4651,16.0889,21.473,16.5637,21.1851,16.8614L17.5425,20.6282C17.4012,20.7743 17.2066,20.8568 17.0034,20.8568 16.8001,20.8568 16.6055,20.7743 16.4642,20.6282L14.6429,18.7448C14.355,18.447 14.3629,17.9722 14.6607,17.6843 14.9585,17.3963 15.4333,17.4043 15.7212,17.7021L17.0034,19.0279 20.1068,15.8187C20.3947,15.5209,20.8695,15.513,21.1673,15.8009z";
// 老版浮动栏按钮图标
public static string LegacyLinedCursorIcon =
"F0 M24,24z M0,0z M3.85151,2.7073C3.52422,2.57095 3.147,2.64558 2.89629,2.89629 2.64558,3.147 2.57095,3.52422 2.7073,3.85151L9.7773,20.8215C9.91729,21.1575 10.2507,21.3718 10.6145,21.3595 10.9783,21.3473 11.2965,21.1111 11.4135,20.7664L13.4711,14.7085 18.8963,20.1337C19.238,20.4754 19.792,20.4754 20.1337,20.1337 20.4754,19.792 20.4754,19.238 20.1337,18.8963L14.7085,13.4711 20.7664,11.4135C21.1111,11.2965 21.3473,10.9783 21.3595,10.6145 21.3718,10.2507 21.1575,9.91729 20.8215,9.7773L3.85151,2.7073z M10.5017,18.0097L5.13984,5.13984 18.0097,10.5017 12.8136,12.2665C12.5561,12.3539,12.3539,12.5561,12.2665,12.8136L10.5017,18.0097z";
public static string LegacySolidCursorIcon =
"F0 M24,24z M0,0z M2.89629,2.89629C3.147,2.64558,3.52422,2.57095,3.85151,2.7073L20.8215,9.7773C21.1575,9.91729 21.3718,10.2507 21.3595,10.6145 21.3473,10.9783 21.1111,11.2965 20.7664,11.4135L14.7085,13.4711 20.1337,18.8963C20.4754,19.238 20.4754,19.792 20.1337,20.1337 19.792,20.4754 19.238,20.4754 18.8963,20.1337L13.4711,14.7085 11.4135,20.7664C11.2965,21.1111 10.9783,21.3473 10.6145,21.3595 10.2507,21.3718 9.91729,21.1575 9.7773,20.8215L2.7073,3.85151C2.57095,3.52422,2.64558,3.147,2.89629,2.89629z";
public static string LegacyLinedPenIcon =
"F0 M24,24z M0,0z M18.7033,4.39761C18.4948,4.31644 18.2714,4.27922 18.0473,4.28846 17.8233,4.29771 17.6038,4.3532 17.403,4.4512 17.2022,4.54919 17.0246,4.68744 16.8813,4.8568 16.8665,4.87422 16.8511,4.89102 16.8349,4.90716L15.7108,6.03131 17.9591,8.27962 19.0832,7.15546C19.1021,7.13662 19.1218,7.11869 19.1424,7.10176 19.3143,6.96037 19.4543,6.7853 19.5537,6.58793 19.6531,6.39058 19.7099,6.1751 19.7207,5.95519 19.7314,5.73528 19.6959,5.51545 19.6163,5.30962 19.5367,5.10378 19.4147,4.91625 19.2576,4.75914 19.1004,4.60201 18.9117,4.47877 18.7033,4.39761z M16.7944,9.44428L14.5461,7.19597 5.47079,16.2713 4.62767,19.3627 7.7191,18.5196 16.7944,9.44428z M13.9636,5.44913L4.15148,15.2613C4.05014,15.3626,3.977,15.4886,3.93929,15.6269L2.65942,20.3198C2.58166,20.6049 2.66264,20.9098 2.87161,21.1188 3.08059,21.3277 3.38551,21.4087 3.67063,21.331L8.36347,20.0511C8.50174,20.0134,8.62777,19.9402,8.72911,19.8389L20.2217,8.34636C20.5551,8.06468 20.8283,7.71873 21.0247,7.3289 21.2275,6.92628 21.3437,6.48586 21.3658,6.03572 21.3878,5.58559 21.3151,5.13594 21.1525,4.71552 20.99,4.29512 20.7411,3.91338 20.4222,3.59447 20.1033,3.27558 19.7214,3.0265 19.3009,2.86277 18.8804,2.69905 18.4304,2.62417 17.9794,2.64278 17.5285,2.66139 17.0862,2.77308 16.6807,2.97095 16.2862,3.16344 15.9348,3.43348 15.6478,3.76494L13.9636,5.44913z";
public static string LegacySolidPenIcon =
"F1 M24,24z M0,0z M19.3332,2.85933C18.9193,2.69814 18.4762,2.62442 18.0322,2.64274 17.5882,2.66106 17.1527,2.77103 16.7535,2.96583 16.3643,3.15575 16.0177,3.42232 15.7349,3.74956L14.5672,4.91725 19.0731,9.4231 20.2373,8.25888C20.5666,7.98121 20.8364,7.63993 21.0302,7.25528 21.2298,6.85899 21.3442,6.42551 21.3659,5.98249 21.3876,5.53947 21.3161,5.09692 21.1561,4.68313 20.996,4.26934 20.7511,3.89359 20.4372,3.57966 20.1232,3.26574 19.7472,3.02052 19.3332,2.85933z M18.0085,10.4877L13.5026,5.98183 4.14128,15.3432C4.04864,15.4358,3.98179,15.551,3.94732,15.6774L2.65684,20.4091C2.58577,20.6698 2.65979,20.9485 2.8508,21.1395 3.04182,21.3305 3.32054,21.4045 3.58117,21.3335L8.3129,20.043C8.43929,20.0085,8.5545,19.9417,8.64713,19.849L18.0085,10.4877z";
public static string LegacyLinedEraserStrokeIcon =
"F0 M25,24z M0,0z M7.32029,21.36L13.0098,21.36 13.0122,21.36 21.5471,21.36C21.989,21.36 22.3473,21.0017 22.3473,20.5598 22.3473,20.1179 21.989,19.7596 21.5471,19.7596L14.9429,19.7596 21.4352,13.2673C22.7372,12.0786,22.6872,10.1353,21.449,8.89707L16.1515,3.59952C14.9628,2.29751,13.0195,2.34754,11.7813,3.58572L2.68992,12.6771C1.3879,13.8657,1.43793,15.8091,2.67611,17.0473L6.75447,21.1256C6.90453,21.2757,7.10807,21.36,7.32029,21.36z M14.9771,4.68685C14.4571,4.10907,13.5664,4.06392,12.9129,4.71737L6.55503,11.0753 13.9595,18.4797 20.3174,12.1218C20.3273,12.1119 20.3375,12.1022 20.3479,12.0929 20.9257,11.5729 20.9708,10.6822 20.3174,10.0287L15.006,4.71737C14.9961,4.70745,14.9864,4.69727,14.9771,4.68685z M12.8278,19.6114L5.42338,12.2069 3.80776,13.8225C3.79784,13.8324 3.78766,13.8421 3.77724,13.8515 3.19947,14.3715 3.15431,15.2622 3.80776,15.9156L7.65174,19.7596 12.6796,19.7596 12.8278,19.6114z";
public static string LegacySolidEraserStrokeIcon =
"F1 M24,24z M0,0z M11.6199,3.61372C12.8916,2.34202,14.8995,2.2837,16.1307,3.62964L21.3433,8.84225C22.615,10.1139,22.6733,12.1218,21.3274,13.353L15.1877,19.4927 5.46434,9.76928 11.6199,3.61372z M7.33167,21.36C7.08919,21.36 6.86831,21.2676 6.70232,21.116 6.69184,21.1064 6.68155,21.0966 6.67147,21.0865L2.65671,17.0718C1.385,15.8001,1.32668,13.7922,2.67262,12.561L4.14394,11.0897 12.5469,19.4927 21.3367,19.4927C21.8523,19.4927 22.2703,19.9107 22.2703,20.4263 22.2703,20.942 21.8523,21.36 21.3367,21.36L7.33167,21.36z";
public static string LegacyLinedEraserCircleIcon =
"F0 M25,24z M0,0z M2.47995,17.1206L6.56736,21.208C6.57733,21.218 6.58749,21.2277 6.59783,21.237 6.66429,21.2971 6.7405,21.3466 6.82381,21.3829L6.83712,21.3885C6.84698,21.3926 6.85693,21.3965 6.86698,21.4003 6.86818,21.4007 6.86937,21.4011 6.87057,21.4016 6.94576,21.4289 7.02412,21.4451 7.10303,21.45L7.12183,21.451 7.13076,21.4513 7.13345,21.4514 7.15549,21.4517 17.0847,21.4517C17.5973,22.3438 18.5597,22.9445 19.6624,22.9445 21.3031,22.9445 22.6332,21.6144 22.6332,19.9737 22.6332,18.3329 21.3031,17.0028 19.6624,17.0028 18.0839,17.0028 16.793,18.2338 16.6972,19.7882L14.8669,19.7882 21.3224,13.3327C22.6404,12.1289,22.5884,10.1619,21.3367,8.91021L16.0278,3.60138C14.8241,2.28336,12.8571,2.33535,11.6053,3.58706L2.49426,12.6981C1.17625,13.9019,1.22824,15.8689,2.47995,17.1206z M14.8072,4.7316C14.2984,4.16633,13.4255,4.11939,12.7816,4.76332L6.43063,11.1143 13.8094,18.4931 20.1604,12.1421C20.1707,12.1318 20.1813,12.1218 20.1921,12.112 20.7574,11.6033 20.8043,10.7304 20.1604,10.0865L14.8373,4.76332C14.8269,4.75301,14.8169,4.74243,14.8072,4.7316z M3.65621,13.8887C3.6459,13.899 3.63532,13.9091 3.62448,13.9188 3.05922,14.4276 3.01228,15.3004 3.65621,15.9444L7.50001,19.7882 12.752,19.7882 5.25437,12.2906 3.65621,13.8887z";
public static string LegacySolidEraserCircleIcon =
"F1 M24,24z M0,0z M15.0919,19.6686L21.4282,13.3322C22.7462,12.1285,22.6942,10.1616,21.4426,8.90993L16.134,3.60133C14.9303,2.28338,12.9633,2.33537,11.7117,3.58702L5.36097,9.93771 15.0919,19.6686z M6.67201,21.2053C6.82267,21.3569,7.03137,21.4508,7.26201,21.4508L17.1907,21.4508C17.7033,22.3429 18.6657,22.9437 19.7683,22.9437 21.409,22.9437 22.7391,21.6136 22.7391,19.9729 22.7391,18.3322 21.409,17.0022 19.7683,17.0022 18.19,17.0022 16.8991,18.2331 16.8033,19.7874L12.8583,19.7874 4.18476,11.1139 2.60098,12.6977C1.28303,13.9014,1.33502,15.8683,2.58667,17.12L6.67201,21.2053z";
public static string LegacyLinedLassoSelectIcon =
"F0 M24,24z M0,0z M14.4715,12.7092L14.4715,18.7882 15.8291,16.7546C15.9688,16.5453,16.2038,16.4196,16.4554,16.4196L19.0106,16.4196 14.4715,12.7092z M14.6618,10.9193C14.4981,10.784 14.2733,10.6788 14.0025,10.6788 13.9951,10.6788 13.9877,10.6789 13.9803,10.6791 13.7083,10.6872 13.4502,10.8008 13.2607,10.9961 13.0712,11.1913 12.9653,11.4526 12.9653,11.7246L12.9653,20.3314C12.9653,20.3403 12.9655,20.3491 12.9658,20.358 12.9734,20.5733 13.0468,20.7811 13.176,20.9534 13.3053,21.1258 13.4842,21.2544 13.6888,21.3219 13.765,21.3471 13.8447,21.36 13.925,21.36L14.0025,21.36C14.1661,21.36 14.3276,21.3218 14.474,21.2486 14.6204,21.1754 14.7477,21.0692 14.8459,20.9382 14.8542,20.9272 14.8622,20.9159 14.8698,20.9045L16.8582,17.9258 20.3145,17.9258C20.5287,17.9281 20.7384,17.8641 20.9149,17.7424 21.0941,17.6187 21.2299,17.4417 21.3029,17.2365 21.3759,17.0313 21.3825,16.8084 21.3217,16.5993 21.262,16.3936 21.14,16.2117 20.9729,16.0782L14.6618,10.9193z M8.14548,20.0044C7.70454,19.6737 7.34665,19.2448 7.10016,18.7519 6.94658,18.4447 6.83887,18.1179 6.7795,17.7818 7.131,17.6605 7.45404,17.4604 7.72196,17.1924 7.74959,17.1648 7.7765,17.1366 7.80267,17.1078 8.5567,17.4118 9.3392,17.6365 10.1444,17.7694 10.5548,17.8372 10.9424,17.5594 11.0101,17.149 11.0779,16.7387 10.8001,16.3511 10.3897,16.2833 9.72172,16.1731 9.06686,15.9883 8.42926,15.7362 8.44084,15.6393 8.44672,15.5413 8.44672,15.4427 8.44672,14.7865 8.18602,14.1571 7.72196,13.693 7.25791,13.229 6.62852,12.9682 5.97224,12.9682 5.65536,12.9682 5.34474,13.029 5.05598,13.1441 4.47073,12.3026 4.15196,11.303 4.14328,10.2756 4.14532,7.03688 7.49758,4.1462 11.9971,4.1462 16.4941,4.1462 19.8451,7.03371 19.8508,10.2703 19.8388,10.7807 19.7549,11.2869 19.6016,11.7739 19.4767,12.1706 19.697,12.5934 20.0938,12.7183 20.4905,12.8432 20.9134,12.6228 21.0383,12.2261 21.2351,11.6008 21.3424,10.9507 21.3568,10.2952L21.357,10.2786C21.357,5.91009 16.9982,2.64 11.9971,2.64 6.9959,2.64 2.63705,5.91009 2.63705,10.2786L2.6371,10.2845C2.6479,11.6579 3.08647,12.993 3.89074,14.1047 3.63615,14.5007 3.49777,14.9646 3.49777,15.4427 3.49777,16.099 3.75847,16.7284 4.22252,17.1924 4.51465,17.4846 4.87229,17.6961 5.26092,17.8128 5.33333,18.3726 5.49917,18.9179 5.75297,19.4255 6.10404,20.1276 6.61375,20.7383 7.24176,21.2093 7.5745,21.4589 8.04654,21.3915 8.2961,21.0587 8.54566,20.726 8.47822,20.2539 8.14548,20.0044z M5.97224,14.4745C5.71544,14.4745 5.46916,14.5765 5.28757,14.7581 5.10598,14.9396 5.00397,15.1859 5.00397,15.4427 5.00397,15.6995 5.10598,15.9458 5.28757,16.1274 5.46916,16.309 5.71544,16.411 5.97224,16.411 6.22904,16.411 6.47533,16.309 6.65692,16.1274 6.8385,15.9458 6.94052,15.6995 6.94052,15.4427 6.94052,15.1859 6.8385,14.9396 6.65692,14.7581 6.47533,14.5765 6.22904,14.4745 5.97224,14.4745z";
public static string LegacySolidLassoSelectIcon =
"F1 M24,24z M0,0z M14.6618,10.9193C14.4981,10.784 14.2733,10.6788 14.0025,10.6788 13.9951,10.6788 13.9877,10.6789 13.9803,10.6791 13.7083,10.6872 13.4502,10.8008 13.2607,10.9961 13.0712,11.1913 12.9653,11.4526 12.9653,11.7246L12.9653,20.3314C12.9653,20.3403 12.9655,20.3491 12.9658,20.358 12.9734,20.5733 13.0468,20.7811 13.176,20.9534 13.3053,21.1258 13.4842,21.2544 13.6888,21.3219 13.765,21.3471 13.8447,21.36 13.925,21.36L14.0025,21.36C14.1661,21.36 14.3276,21.3218 14.474,21.2486 14.6204,21.1754 14.7477,21.0692 14.8459,20.9382 14.8542,20.9272 14.8622,20.9159 14.8698,20.9045L16.8582,17.9258 20.3145,17.9258C20.5287,17.9281 20.7384,17.8641 20.9149,17.7424 21.0941,17.6187 21.2299,17.4417 21.3029,17.2365 21.3759,17.0313 21.3825,16.8084 21.3217,16.5993 21.262,16.3936 21.14,16.2117 20.9729,16.0782L14.6618,10.9193z M8.14548,20.0044C7.70454,19.6737 7.34665,19.2448 7.10016,18.7519 6.94658,18.4447 6.83888,18.1179 6.7795,17.7818 7.131,17.6605 7.45404,17.4604 7.72196,17.1924 7.74959,17.1648 7.77649,17.1366 7.80267,17.1078 8.5567,17.4118 9.3392,17.6365 10.1444,17.7694 10.5548,17.8372 10.9424,17.5594 11.0101,17.149 11.0779,16.7387 10.8001,16.3511 10.3897,16.2833 9.72172,16.1731 9.06686,15.9883 8.42926,15.7362 8.44084,15.6393 8.44672,15.5413 8.44672,15.4427 8.44672,14.7865 8.18602,14.1571 7.72196,13.693 7.25791,13.229 6.62852,12.9682 5.97224,12.9682 5.65536,12.9682 5.34474,13.029 5.05598,13.1441 4.47073,12.3026 4.15196,11.303 4.14328,10.2756 4.14532,7.03688 7.49758,4.1462 11.9971,4.1462 16.4941,4.1462 19.8451,7.03371 19.8508,10.2703 19.8388,10.7807 19.7549,11.2869 19.6016,11.7739 19.4767,12.1706 19.697,12.5934 20.0938,12.7183 20.4905,12.8432 20.9134,12.6228 21.0383,12.2261 21.2351,11.6008 21.3424,10.9507 21.3568,10.2952L21.357,10.2786C21.357,5.91009 16.9982,2.64 11.9971,2.64 6.9959,2.64 2.63705,5.91009 2.63705,10.2786L2.6371,10.2845C2.6479,11.6579 3.08647,12.993 3.89074,14.1047 3.63615,14.5007 3.49777,14.9646 3.49777,15.4427 3.49777,16.099 3.75847,16.7284 4.22252,17.1924 4.51465,17.4846 4.87229,17.6961 5.26092,17.8128 5.33333,18.3726 5.49917,18.9178 5.75297,19.4255 6.10404,20.1276 6.61375,20.7383 7.24176,21.2093 7.5745,21.4589 8.04654,21.3915 8.2961,21.0587 8.54566,20.726 8.47822,20.2539 8.14548,20.0044z";
}
}
+8 -8
View File
@@ -237,7 +237,6 @@ namespace Ink_Canvas
graphics.CopyFromScreen(x, y, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
}
LogHelper.WriteLogToFile($"成功截取区域: X={x}, Y={y}, Width={width}, Height={height}");
return bitmap;
}
catch (Exception ex)
@@ -261,7 +260,7 @@ namespace Ink_Canvas
// 将Bitmap转换为WPF BitmapSource
var bitmapSource = ConvertBitmapToBitmapSource(bitmap);
if (bitmapSource == null)
{
ShowNotification("转换截图失败");
@@ -405,6 +404,8 @@ namespace Ink_Canvas
image.MouseWheel += Element_MouseWheel;
// 触摸事件
image.TouchDown += Element_TouchDown;
image.TouchUp += Element_TouchUp;
image.IsManipulationEnabled = true;
image.ManipulationDelta += Element_ManipulationDelta;
image.ManipulationCompleted += Element_ManipulationCompleted;
@@ -492,7 +493,6 @@ namespace Ink_Canvas
InitializeScreenshotTransform(image);
}
LogHelper.WriteLogToFile($"截图居中完成: 位置({centerX}, {centerY}), 尺寸({newWidth}x{newHeight})");
}
catch (Exception ex)
{
@@ -649,7 +649,7 @@ namespace Ink_Canvas
catch (Exception ex)
{
LogHelper.WriteLogToFile($"转换位图失败: {ex.Message}", LogHelper.LogType.Error);
// 尝试使用备用方法:内存流转换
try
{
@@ -658,7 +658,7 @@ namespace Ink_Canvas
catch (Exception fallbackEx)
{
LogHelper.WriteLogToFile($"备用转换方法也失败: {fallbackEx.Message}", LogHelper.LogType.Error);
// 最后尝试:使用最简单的转换方法
try
{
@@ -723,18 +723,18 @@ namespace Ink_Canvas
// 使用最基础的方法:直接保存为PNG然后加载
var tempFile = Path.GetTempFileName() + ".png";
try
{
bitmap.Save(tempFile, ImageFormat.Png);
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.UriSource = new Uri(tempFile);
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
bitmapImage.Freeze();
return bitmapImage;
}
finally
+475 -202
View File
@@ -1,4 +1,4 @@
using Ink_Canvas.Helpers;
using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
@@ -11,6 +11,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Media;
using System.Windows.Threading;
using Application = System.Windows.Application;
@@ -76,8 +77,7 @@ namespace Ink_Canvas
#endregion
#region PPT State Management
private bool wasFloatingBarFoldedWhenEnterSlideShow;
private bool isEnteredSlideShowEndEvent; //防止重复调用本函数导致墨迹保存失效
private bool isEnteredSlideShowEndEvent;
private bool isPresentationHaveBlackSpace;
// 长按翻页相关字段
@@ -89,25 +89,28 @@ namespace Ink_Canvas
// PowerPoint应用程序守护相关字段
private DispatcherTimer _powerPointProcessMonitorTimer;
private const int ProcessMonitorInterval = 1000; // 应用程序监控间隔(毫秒)
// 上次播放位置相关字段
private int _lastPlaybackPage = 0;
private bool _shouldNavigateToLastPage = false;
// 当前播放页码跟踪
private int _currentSlideShowPosition = 0;
// 页面切换防抖机制
private DateTime _lastSlideSwitchTime = DateTime.MinValue;
private int _pendingSlideIndex = -1;
private System.Timers.Timer _slideSwitchDebounceTimer;
private const int SlideSwitchDebounceMs = 150; // 防抖延迟150毫秒
private const int SlideSwitchDebounceMs = 150;
private bool _isInkClearedByButton = false;
#endregion
#region PPT Managers
private PPTManager _pptManager;
private MultiPPTInkManager _multiPPTInkManager;
private PPTInkManager _singlePPTInkManager;
private PPTUIManager _pptUIManager;
/// <summary>
/// 获取PPT管理器实例(供UI管理器使用)
/// 获取PPT管理器实例
/// </summary>
public PPTManager PPTManager => _pptManager;
#endregion
@@ -133,11 +136,9 @@ namespace Ink_Canvas
_pptManager.PresentationClose += OnPPTPresentationClose;
_pptManager.SlideShowStateChanged += OnPPTSlideShowStateChanged;
// 初始化多PPT墨迹管理器
_multiPPTInkManager = new MultiPPTInkManager();
_multiPPTInkManager.IsAutoSaveEnabled = Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint;
_multiPPTInkManager.AutoSaveLocation = Settings.Automation.AutoSavedStrokesLocation;
_multiPPTInkManager.PPTManager = _pptManager;
_singlePPTInkManager = new PPTInkManager();
_singlePPTInkManager.IsAutoSaveEnabled = Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint;
_singlePPTInkManager.AutoSaveLocation = Settings.Automation.AutoSavedStrokesLocation;
// 初始化UI管理器
_pptUIManager = new PPTUIManager(this);
@@ -151,6 +152,10 @@ namespace Ink_Canvas
_pptUIManager.PPTRBButtonPosition = Settings.PowerPointSettings.PPTRBButtonPosition;
_pptUIManager.EnablePPTButtonPageClickable = Settings.PowerPointSettings.EnablePPTButtonPageClickable;
_pptUIManager.EnablePPTButtonLongPressPageTurn = Settings.PowerPointSettings.EnablePPTButtonLongPressPageTurn;
_pptUIManager.PPTLSButtonOpacity = Settings.PowerPointSettings.PPTLSButtonOpacity;
_pptUIManager.PPTRSButtonOpacity = Settings.PowerPointSettings.PPTRSButtonOpacity;
_pptUIManager.PPTLBButtonOpacity = Settings.PowerPointSettings.PPTLBButtonOpacity;
_pptUIManager.PPTRBButtonOpacity = Settings.PowerPointSettings.PPTRBButtonOpacity;
LogHelper.WriteLogToFile("PPT管理器初始化完成", LogHelper.LogType.Event);
}
@@ -420,11 +425,11 @@ namespace Ink_Canvas
try
{
_pptManager?.Dispose();
_multiPPTInkManager?.Dispose();
_singlePPTInkManager?.Dispose();
_longPressTimer?.Stop();
_longPressTimer = null;
_pptManager = null;
_multiPPTInkManager = null;
_singlePPTInkManager = null;
_pptUIManager = null;
// 清理PowerPoint进程守护
@@ -509,8 +514,7 @@ namespace Ink_Canvas
else
{
LogHelper.WriteLogToFile("PPT连接已断开", LogHelper.LogType.Event);
// 清理墨迹管理器
_multiPPTInkManager?.ClearAllStrokes();
_singlePPTInkManager?.ClearAllStrokes();
}
});
}
@@ -524,6 +528,8 @@ namespace Ink_Canvas
{
try
{
bool isInSlideShowWhenOpened = _pptManager?.IsInSlideShow == true;
Application.Current.Dispatcher.InvokeAsync(() =>
{
// 在初始化墨迹管理器之前,先清理画布上的所有墨迹
@@ -535,8 +541,7 @@ namespace Ink_Canvas
TimeMachineHistories[0] = null;
}
// 初始化多PPT墨迹管理器
_multiPPTInkManager?.InitializePresentation(pres);
_singlePPTInkManager?.InitializePresentation(pres);
// 处理跳转到首页或上次播放页的逻辑
HandlePresentationOpenNavigation(pres);
@@ -547,8 +552,7 @@ namespace Ink_Canvas
CheckAndNotifyHiddenSlides(pres);
}
// 检查自动播放设置
if (Settings.PowerPointSettings.IsNotifyAutoPlayPresentation)
if (Settings.PowerPointSettings.IsNotifyAutoPlayPresentation && !isInSlideShowWhenOpened)
{
CheckAndNotifyAutoPlaySettings(pres);
}
@@ -570,11 +574,7 @@ namespace Ink_Canvas
{
Application.Current.Dispatcher.InvokeAsync(() =>
{
// 保存所有墨迹
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
// 移除演示文稿管理器
_multiPPTInkManager?.RemovePresentation(pres);
_singlePPTInkManager?.SaveAllStrokesToFile(pres);
_pptUIManager?.UpdateConnectionStatus(false);
});
@@ -619,23 +619,56 @@ namespace Ink_Canvas
{
try
{
// 记录进入放映时浮动栏收纳状态
wasFloatingBarFoldedWhenEnterSlideShow = isFloatingBarFolded;
if (Settings.Automation.IsAutoFoldInPPTSlideShow && !isFloatingBarFolded)
FoldFloatingBar_MouseUp(new object(), null);
else if (isFloatingBarFolded)
await UnFoldFloatingBar(new object());
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
{
if (!isFloatingBarFolded)
FoldFloatingBar_MouseUp(new object(), null);
}
else
{
if (isFloatingBarFolded)
{
await UnFoldFloatingBar(new object());
}
}
isStopInkReplay = true;
await Application.Current.Dispatcher.InvokeAsync(() =>
await Application.Current.Dispatcher.InvokeAsync(async () =>
{
// 获取当前活跃的演示文稿并切换到对应的墨迹管理器
var activePresentation = _pptManager?.GetCurrentActivePresentation();
Presentation activePresentation = null;
int currentSlide = 0;
int totalSlides = 0;
if (wn?.View != null && wn.Presentation != null)
{
activePresentation = wn.Presentation;
currentSlide = wn.View.CurrentShowPosition;
totalSlides = activePresentation.Slides.Count;
// 初始化当前播放页码跟踪
_currentSlideShowPosition = currentSlide;
}
else
{
activePresentation = _pptManager?.GetCurrentActivePresentation();
currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
totalSlides = _pptManager?.SlidesCount ?? 0;
// 初始化当前播放页码跟踪
_currentSlideShowPosition = currentSlide;
}
if (activePresentation != null)
{
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
if (_singlePPTInkManager != null)
{
try
{
_singlePPTInkManager.InitializePresentation(activePresentation);
}
catch (Exception)
{
}
}
}
// 处理跳转到首页或上次播放位置
@@ -650,8 +683,6 @@ namespace Ink_Canvas
}
// 更新UI状态
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
var totalSlides = _pptManager?.SlidesCount ?? 0;
_pptUIManager?.UpdateSlideShowStatus(true, currentSlide, totalSlides);
// 设置浮动栏透明度和边距
@@ -699,22 +730,39 @@ namespace Ink_Canvas
if (Settings.PowerPointSettings.IsShowCanvasAtNewSlideShow &&
!Settings.Automation.IsAutoFoldInPPTSlideShow)
{
await Task.Delay(600);
// 先进入批注模式,这会显示调色盘
PenIcon_Click(null, null);
// 然后设置颜色
BtnColorRed_Click(null, null);
Dispatcher.BeginInvoke(new Action(() =>
try
{
try
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
{
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
UpdateCurrentToolMode("pen");
SetFloatingBarHighlightPosition("pen");
if (Settings.Appearance.IsShowQuickColorPalette && QuickColorPalettePanel != null && QuickColorPaletteSingleRowPanel != null)
{
UpdateCurrentToolMode("pen");
SetFloatingBarHighlightPosition("pen");
// 根据显示模式选择显示哪个面板
if (Settings.Appearance.QuickColorPaletteDisplayMode == 0)
{
// 单行显示模式
QuickColorPalettePanel.Visibility = Visibility.Collapsed;
QuickColorPaletteSingleRowPanel.Visibility = Visibility.Visible;
}
else
{
// 双行显示模式
QuickColorPalettePanel.Visibility = Visibility.Visible;
QuickColorPaletteSingleRowPanel.Visibility = Visibility.Collapsed;
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"PPT进入批注模式后同步浮动栏高光状态失败: {ex.Message}", LogHelper.LogType.Error);
}
}), DispatcherPriority.Loaded);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"PPT进入批注模式后同步浮动栏高光状态失败: {ex.Message}", LogHelper.LogType.Error);
}
}
isEnteredSlideShowEndEvent = false;
@@ -723,6 +771,7 @@ namespace Ink_Canvas
LoadCurrentSlideInk(currentSlide);
});
if (!isFloatingBarFolded)
{
new Thread(() =>
@@ -735,9 +784,8 @@ namespace Ink_Canvas
}).Start();
}
}
catch (Exception ex)
catch (Exception)
{
LogHelper.WriteLogToFile($"处理幻灯片放映开始事件失败: {ex}", LogHelper.LogType.Error);
}
}
@@ -745,20 +793,69 @@ namespace Ink_Canvas
{
try
{
Application.Current.Dispatcher.InvokeAsync(() =>
Application.Current.Dispatcher.Invoke(() =>
{
// 获取当前活跃的演示文稿并确保切换到正确的墨迹管理器
var activePresentation = _pptManager?.GetCurrentActivePresentation();
if (activePresentation != null)
if (wn?.View == null || wn.Presentation == null)
{
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
return;
}
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
var totalSlides = _pptManager?.SlidesCount ?? 0;
var currentSlide = wn.View.CurrentShowPosition;
var activePresentation = wn.Presentation;
var totalSlides = activePresentation.Slides.Count;
// 使用防抖机制处理页面切换
HandleSlideSwitchWithDebounce(currentSlide, totalSlides);
// 获取之前的页码(用于保存墨迹)
var previousSlide = _currentSlideShowPosition > 0 ? _currentSlideShowPosition :
(_pptManager?.GetCurrentSlideNumber() ?? 0);
if (_isInkClearedByButton)
{
_isInkClearedByButton = false;
}
else
{
StrokeCollection strokesToSave = null;
if (previousSlide > 0 && previousSlide != currentSlide && inkCanvas.Strokes.Count > 0)
{
strokesToSave = inkCanvas.Strokes.Clone();
}
// 清除墨迹
if (inkCanvas.Strokes.Count > 0)
{
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
}
// 异步保存之前页面的墨迹
if (strokesToSave != null && previousSlide > 0 && previousSlide != currentSlide)
{
Task.Run(() =>
{
try
{
Application.Current.Dispatcher.Invoke(() =>
{
bool canWrite = _singlePPTInkManager?.CanWriteInk(previousSlide) == true;
if (canWrite)
{
_singlePPTInkManager?.SaveCurrentSlideStrokes(previousSlide, strokesToSave);
}
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"异步保存PPT页面墨迹失败: {ex}", LogHelper.LogType.Error);
}
});
}
}
// 更新当前播放页码
_currentSlideShowPosition = currentSlide;
LoadCurrentSlideInk(currentSlide, skipClear: true);
_pptUIManager?.UpdateCurrentSlideNumber(currentSlide, totalSlides);
});
}
@@ -772,21 +869,39 @@ namespace Ink_Canvas
{
try
{
// 处理浮动栏状态
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow && wasFloatingBarFoldedWhenEnterSlideShow)
// PPT退出时自动收纳浮动栏
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow && !isFloatingBarFolded)
{
if (!isFloatingBarFolded) FoldFloatingBar_MouseUp(new object(), null);
}
else
{
if (isFloatingBarFolded) await UnFoldFloatingBar(new object());
FoldFloatingBar_MouseUp(new object(), null);
}
if (isEnteredSlideShowEndEvent) return;
isEnteredSlideShowEndEvent = true;
// 保存所有墨迹
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
// 获取当前播放页码,优先使用跟踪的页码,否则尝试从PPT管理器获取
int currentPage = _currentSlideShowPosition;
if (currentPage <= 0)
{
try
{
currentPage = _pptManager?.GetCurrentSlideNumber() ?? 0;
}
catch
{
// 如果无法获取,尝试从演示文稿的SlideShowWindow获取
try
{
if (pres.SlideShowWindow != null && pres.SlideShowWindow.View != null)
{
currentPage = pres.SlideShowWindow.View.CurrentShowPosition;
}
}
catch { }
}
}
// 保存墨迹和位置信息
_singlePPTInkManager?.SaveAllStrokesToFile(pres, currentPage);
await Application.Current.Dispatcher.InvokeAsync(() =>
{
@@ -846,6 +961,9 @@ namespace Ink_Canvas
if (GridTransparencyFakeBackground.Background != Brushes.Transparent)
BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
SetCurrentToolMode(InkCanvasEditingMode.None);
UpdateCurrentToolMode("cursor");
SetFloatingBarHighlightPosition("cursor");
}
catch (Exception ex)
{
@@ -856,10 +974,15 @@ namespace Ink_Canvas
await Task.Delay(100);
await Application.Current.Dispatcher.InvokeAsync(() =>
{
// 强制重新计算浮动栏位置,确保在退出PPT模式后正确复位
// 先调用桌面模式的复位方法,然后调用通用的位置计算方法
PureViewboxFloatingBarMarginAnimationInDesktopMode();
ViewboxFloatingBarMarginAnimation(100, true);
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow)
{
PureViewboxFloatingBarMarginAnimationInDesktopMode();
ViewboxFloatingBarMarginAnimation(-60);
}
else
{
PureViewboxFloatingBarMarginAnimationInDesktopMode();
}
});
}
catch (Exception ex)
@@ -880,7 +1003,10 @@ namespace Ink_Canvas
}
else if (Settings.PowerPointSettings.IsNotifyPreviousPage)
{
ShowPreviousPageNotification(pres);
if (_pptManager?.IsInSlideShow != true)
{
ShowPreviousPageNotification(pres);
}
}
}
catch (Exception ex)
@@ -908,7 +1034,24 @@ namespace Ink_Canvas
_lastPlaybackPage = page;
new YesOrNoNotificationWindow($"上次播放到了第 {page} 页, 是否立即跳转", () =>
{
_shouldNavigateToLastPage = true;
try
{
if (_pptManager?.PPTApplication != null)
{
if (_pptManager.PPTApplication.SlideShowWindows.Count >= 1)
{
pres.SlideShowWindow.View.GotoSlide(page);
}
else
{
pres.Windows[1].View.GotoSlide(page);
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"跳转到第{page}页失败: {ex}", LogHelper.LogType.Error);
}
}).ShowDialog();
}
}
@@ -975,7 +1118,7 @@ namespace Ink_Canvas
{
try
{
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) return;
if (_pptManager?.IsInSlideShow == true) return;
bool hasSlideTimings = false;
if (pres?.Slides != null)
@@ -1023,14 +1166,20 @@ namespace Ink_Canvas
}
}
private void LoadCurrentSlideInk(int slideIndex)
private void LoadCurrentSlideInk(int slideIndex, bool skipClear = false)
{
try
{
var strokes = _multiPPTInkManager?.LoadSlideStrokes(slideIndex);
if (strokes != null)
// 如果未跳过清除,则清除当前墨迹
if (!skipClear)
{
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
}
StrokeCollection strokes = _singlePPTInkManager?.LoadSlideStrokes(slideIndex);
if (strokes != null && strokes.Count > 0)
{
inkCanvas.Strokes.Clear();
inkCanvas.Strokes.Add(strokes);
}
}
@@ -1047,16 +1196,7 @@ namespace Ink_Canvas
{
try
{
// 获取当前活跃的演示文稿
var activePresentation = _pptManager?.GetCurrentActivePresentation();
if (activePresentation != null)
{
// 切换到对应的墨迹管理器
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
// 重置锁定状态
_multiPPTInkManager?.ResetCurrentPresentationLockState();
}
_singlePPTInkManager?.ResetLockState();
}
catch (Exception ex)
{
@@ -1064,79 +1204,95 @@ namespace Ink_Canvas
}
}
/// <summary>
/// 重置PPT相关的状态变量,当PPT自动收纳设置变更时调用
/// </summary>
public void ResetPPTStateVariables()
{
try
{
// 重置PPT放映结束事件标志
isEnteredSlideShowEndEvent = false;
// 重置演示文稿黑边状态
isPresentationHaveBlackSpace = false;
// 重置上次播放位置相关字段
_lastPlaybackPage = 0;
_shouldNavigateToLastPage = false;
// 重置当前播放页码跟踪
_currentSlideShowPosition = 0;
// 重置页面切换防抖机制
_lastSlideSwitchTime = DateTime.MinValue;
_pendingSlideIndex = -1;
LogHelper.WriteLogToFile("PPT状态变量已重置", LogHelper.LogType.Trace);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"重置PPT状态变量失败: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 使用防抖机制处理页面切换
/// </summary>
private void HandleSlideSwitchWithDebounce(int currentSlide, int totalSlides)
{
try
{
var now = DateTime.Now;
// 如果距离上次切换时间太短,使用防抖机制
if (now - _lastSlideSwitchTime < TimeSpan.FromMilliseconds(SlideSwitchDebounceMs))
{
_pendingSlideIndex = currentSlide;
// 停止之前的定时器
_slideSwitchDebounceTimer?.Stop();
// 创建新的定时器
_slideSwitchDebounceTimer = new System.Timers.Timer(SlideSwitchDebounceMs);
_slideSwitchDebounceTimer.Elapsed += (sender, e) =>
{
Application.Current.Dispatcher.Invoke(() =>
{
if (_pendingSlideIndex > 0)
{
SwitchSlideInk(_pendingSlideIndex);
_pptUIManager?.UpdateCurrentSlideNumber(_pendingSlideIndex, totalSlides);
_pendingSlideIndex = -1;
}
});
_slideSwitchDebounceTimer?.Stop();
};
_slideSwitchDebounceTimer.Start();
}
else
{
// 直接处理页面切换
SwitchSlideInk(currentSlide);
_pptUIManager?.UpdateCurrentSlideNumber(currentSlide, totalSlides);
}
_lastSlideSwitchTime = now;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理页面切换防抖失败: {ex}", LogHelper.LogType.Error);
}
}
private void SwitchSlideInk(int newSlideIndex)
/// <summary>
/// 切换页面墨迹
/// </summary>
/// <param name="newSlideIndex">新页面索引</param>
/// <param name="skipClear">是否跳过清除操作(如果已在翻页时立即清除,则设为true</param>
private void SwitchSlideInk(int newSlideIndex, bool skipClear = false)
{
try
{
// 检查PPT连接状态
if (_pptManager?.IsConnected != true || _pptManager?.IsInSlideShow != true)
{
return;
}
// 获取当前页面索引
var currentSlideIndex = _pptManager?.GetCurrentSlideNumber() ?? 0;
// 如果有当前墨迹且不是第一次切换,先保存到当前页面
if (inkCanvas.Strokes.Count > 0 && currentSlideIndex > 0 && currentSlideIndex != newSlideIndex)
// 验证页面索引的有效性
if (newSlideIndex <= 0)
{
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlideIndex, inkCanvas.Strokes);
LogHelper.WriteLogToFile($"切换前保存第{currentSlideIndex}页墨迹,墨迹数量: {inkCanvas.Strokes.Count}", LogHelper.LogType.Trace);
LogHelper.WriteLogToFile($"无效的新页面索引: {newSlideIndex},跳过页面切换", LogHelper.LogType.Warning);
return;
}
// 切换到新页面并加载墨迹
var newStrokes = _multiPPTInkManager?.SwitchToSlide(newSlideIndex, null);
if (newStrokes != null)
// 如果有当前墨迹且不是第一次切换,先保存到当前页面
if (currentSlideIndex > 0 && currentSlideIndex != newSlideIndex)
{
bool canWrite = _singlePPTInkManager?.CanWriteInk(currentSlideIndex) == true;
if (canWrite && inkCanvas.Strokes.Count > 0)
{
_singlePPTInkManager?.SaveCurrentSlideStrokes(currentSlideIndex, inkCanvas.Strokes);
}
}
if (!skipClear)
{
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
}
// 加载新页面的墨迹
StrokeCollection newStrokes = _singlePPTInkManager?.SwitchToSlide(newSlideIndex, null);
if (newStrokes != null && newStrokes.Count > 0)
{
inkCanvas.Strokes.Clear();
inkCanvas.Strokes.Add(newStrokes);
}
// 设置墨迹锁定
_multiPPTInkManager?.LockInkForSlide(newSlideIndex);
}
catch (Exception ex)
{
@@ -1266,25 +1422,72 @@ namespace Ink_Canvas
{
try
{
// 保存当前页墨迹
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
if (currentSlide > 0)
var previousSlideBeforeNavigate = _pptManager?.GetCurrentSlideNumber() ?? 0;
StrokeCollection strokesToSave = null;
if (previousSlideBeforeNavigate > 0 && inkCanvas.Strokes.Count > 0)
{
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
strokesToSave = inkCanvas.Strokes.Clone();
}
// 保存截图(如果启用)
if (inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber &&
Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint)
{
var presentationName = _pptManager?.GetPresentationName() ?? "";
SaveScreenShot(true, $"{presentationName}/{currentSlide}");
}
// 执行翻页
if (_pptManager?.TryNavigatePrevious() == true)
{
// 翻页成功,等待事件处理墨迹切换
var currentSlideAfterNavigate = _pptManager?.GetCurrentSlideNumber() ?? 0;
if (previousSlideBeforeNavigate == currentSlideAfterNavigate && previousSlideBeforeNavigate > 0)
{
Thread.Sleep(50);
currentSlideAfterNavigate = _pptManager?.GetCurrentSlideNumber() ?? 0;
}
if (previousSlideBeforeNavigate != currentSlideAfterNavigate && previousSlideBeforeNavigate > 0)
{
if (inkCanvas.Strokes.Count > 0)
{
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
_isInkClearedByButton = true;
}
if (strokesToSave != null && previousSlideBeforeNavigate > 0)
{
Task.Run(() =>
{
try
{
Application.Current.Dispatcher.Invoke(() =>
{
_singlePPTInkManager?.SaveCurrentSlideStrokes(previousSlideBeforeNavigate, strokesToSave);
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"异步保存PPT上一页墨迹失败: {ex}", LogHelper.LogType.Error);
}
});
// 异步保存截图(如果启用)
if (strokesToSave.Count > Settings.Automation.MinimumAutomationStrokeNumber &&
Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint)
{
Task.Run(() =>
{
try
{
Application.Current.Dispatcher.Invoke(() =>
{
var presentationName = _pptManager?.GetPresentationName() ?? "";
SaveScreenShot(true, $"{presentationName}/{previousSlideBeforeNavigate}");
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"异步保存PPT上一页截图失败: {ex}", LogHelper.LogType.Error);
}
});
}
}
}
}
else
{
@@ -1306,25 +1509,74 @@ namespace Ink_Canvas
{
try
{
// 保存当前页墨迹
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
if (currentSlide > 0)
var previousSlideBeforeNavigate = _pptManager?.GetCurrentSlideNumber() ?? 0;
StrokeCollection strokesToSave = null;
if (previousSlideBeforeNavigate > 0 && inkCanvas.Strokes.Count > 0)
{
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
strokesToSave = inkCanvas.Strokes.Clone();
}
// 保存截图(如果启用)
if (inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber &&
Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint)
{
var presentationName = _pptManager?.GetPresentationName() ?? "";
SaveScreenShot(true, $"{presentationName}/{currentSlide}");
}
var skipAnimations = Settings.PowerPointSettings.SkipAnimationsWhenGoNext;
// 执行翻页
if (_pptManager?.TryNavigateNext() == true)
if (_pptManager?.TryNavigateNext(skipAnimations: skipAnimations) == true)
{
// 翻页成功,等待事件处理墨迹切换
var currentSlideAfterNavigate = _pptManager?.GetCurrentSlideNumber() ?? 0;
if (previousSlideBeforeNavigate == currentSlideAfterNavigate && previousSlideBeforeNavigate > 0)
{
Thread.Sleep(50);
currentSlideAfterNavigate = _pptManager?.GetCurrentSlideNumber() ?? 0;
}
if (previousSlideBeforeNavigate != currentSlideAfterNavigate && previousSlideBeforeNavigate > 0)
{
if (inkCanvas.Strokes.Count > 0)
{
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
_isInkClearedByButton = true;
}
if (strokesToSave != null && previousSlideBeforeNavigate > 0)
{
Task.Run(() =>
{
try
{
Application.Current.Dispatcher.Invoke(() =>
{
_singlePPTInkManager?.SaveCurrentSlideStrokes(previousSlideBeforeNavigate, strokesToSave);
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"异步保存PPT下一页墨迹失败: {ex}", LogHelper.LogType.Error);
}
});
// 异步保存截图(如果启用)
if (strokesToSave.Count > Settings.Automation.MinimumAutomationStrokeNumber &&
Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint)
{
Task.Run(() =>
{
try
{
Application.Current.Dispatcher.Invoke(() =>
{
var presentationName = _pptManager?.GetPresentationName() ?? "";
SaveScreenShot(true, $"{presentationName}/{previousSlideBeforeNavigate}");
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"异步保存PPT下一页截图失败: {ex}", LogHelper.LogType.Error);
}
});
}
}
}
}
else
{
@@ -1340,7 +1592,7 @@ namespace Ink_Canvas
});
}
private async void PPTNavigationBtn_MouseDown(object sender, MouseButtonEventArgs e)
private void PPTNavigationBtn_MouseDown(object sender, MouseButtonEventArgs e)
{
lastBorderMouseDownObject = sender;
if (!Settings.PowerPointSettings.EnablePPTButtonPageClickable) return;
@@ -1362,7 +1614,7 @@ namespace Ink_Canvas
}
}
private async void PPTNavigationBtn_MouseLeave(object sender, MouseEventArgs e)
private void PPTNavigationBtn_MouseLeave(object sender, MouseEventArgs e)
{
lastBorderMouseDownObject = null;
if (sender == PPTLSPageButton)
@@ -1470,7 +1722,7 @@ namespace Ink_Canvas
{
Application.Current.Dispatcher.Invoke(() =>
{
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
_singlePPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
timeMachine.ClearStrokeHistory();
});
}
@@ -1478,6 +1730,7 @@ namespace Ink_Canvas
// 结束放映
if (_pptManager?.TryEndSlideShow() == true)
{
// 如果成功结束放映,等待OnPPTSlideShowEnd事件处理收纳状态恢复
}
else
{
@@ -1490,13 +1743,24 @@ namespace Ink_Canvas
_pptUIManager?.UpdateSidebarExitButtons(false);
LogHelper.WriteLogToFile("手动更新放映结束UI状态", LogHelper.LogType.Trace);
});
// 手动处理自动收纳,因为OnPPTSlideShowEnd事件可能未触发
await HandleManualSlideShowEnd();
}
HideSubPanels("cursor");
SetCurrentToolMode(InkCanvasEditingMode.None);
await Task.Delay(150);
ViewboxFloatingBarMarginAnimation(100, true);
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow)
{
ViewboxFloatingBarMarginAnimation(-60);
}
else
{
ViewboxFloatingBarMarginAnimation(100, true);
}
}
catch (Exception ex)
{
@@ -1508,6 +1772,38 @@ namespace Ink_Canvas
_pptUIManager?.UpdateSlideShowStatus(false);
_pptUIManager?.UpdateSidebarExitButtons(false);
});
// 异常情况下也手动处理自动收纳
await HandleManualSlideShowEnd();
await Task.Delay(150);
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow)
{
ViewboxFloatingBarMarginAnimation(-60);
}
else
{
ViewboxFloatingBarMarginAnimation(100, true);
}
}
}
/// <summary>
/// 手动处理PPT放映结束时的自动收纳
/// </summary>
private async Task HandleManualSlideShowEnd()
{
try
{
// PPT退出时自动收纳浮动栏
if (Settings.Automation.IsAutoFoldAfterPPTSlideShow && !isFloatingBarFolded)
{
FoldFloatingBar_MouseUp(new object(), null);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"手动处理PPT放映结束自动收纳失败: {ex}", LogHelper.LogType.Error);
}
}
@@ -1666,28 +1962,5 @@ namespace Ink_Canvas
{
BtnPPTSlideShowEnd_Click(BtnPPTSlideShowEnd, null);
}
}
}
+12 -1
View File
@@ -68,9 +68,20 @@ namespace Ink_Canvas
public static void ScrollViewToVerticalTop(FrameworkElement element, ScrollViewer scrollViewer)
{
if (element == null || scrollViewer == null)
{
return;
}
var scrollViewerOffset = scrollViewer.VerticalOffset;
var point = new Point(0, scrollViewerOffset);
var tarPos = element.TransformToVisual(scrollViewer).Transform(point);
var transform = element.TransformToVisual(scrollViewer);
if (transform == null)
{
return;
}
var tarPos = transform.Transform(point);
scrollViewer.ScrollToVerticalOffset(tarPos.Y);
}
+534 -19
View File
@@ -6,7 +6,9 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
@@ -14,6 +16,8 @@ using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml;
using System.Xml.Linq;
using Color = System.Drawing.Color;
using File = System.IO.File;
using Image = System.Windows.Controls.Image;
@@ -78,7 +82,7 @@ namespace Ink_Canvas
for (int i = 1; i <= totalSlides; i++)
{
var slideStrokes = _multiPPTInkManager?.LoadSlideStrokes(i);
var slideStrokes = _singlePPTInkManager?.LoadSlideStrokes(i);
if (slideStrokes != null && slideStrokes.Count > 0)
{
allPageStrokes.Add(slideStrokes);
@@ -126,12 +130,103 @@ namespace Ink_Canvas
SaveSinglePageStrokesAsImage(savePathWithName, newNotice);
}
}
else if (Settings.Automation.IsSaveStrokesAsXML)
{
// XML保存模式 - 检查是否存在多页面墨迹
bool hasMultiplePages = false;
List<StrokeCollection> allPageStrokes = new List<StrokeCollection>();
// 检查PPT放映模式下的多页面墨迹
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible && _pptManager?.IsConnected == true)
{
hasMultiplePages = true;
var totalSlides = _pptManager.SlidesCount;
var currentSlide = _pptManager.GetCurrentSlideNumber();
for (int i = 1; i <= totalSlides; i++)
{
var slideStrokes = _singlePPTInkManager?.LoadSlideStrokes(i);
if (slideStrokes != null && slideStrokes.Count > 0)
{
allPageStrokes.Add(slideStrokes);
}
else if (i == currentSlide && inkCanvas.Strokes.Count > 0)
{
allPageStrokes.Add(inkCanvas.Strokes.Clone());
}
else
{
allPageStrokes.Add(new StrokeCollection());
}
}
}
// 检查白板模式下的多页面墨迹
else if (currentMode != 0 && WhiteboardTotalCount > 1)
{
hasMultiplePages = true;
for (int i = 1; i <= WhiteboardTotalCount; i++)
{
if (TimeMachineHistories[i] != null)
{
var strokes = ApplyHistoriesToNewStrokeCollection(TimeMachineHistories[i]);
allPageStrokes.Add(strokes);
}
else
{
allPageStrokes.Add(new StrokeCollection());
}
}
}
if (hasMultiplePages && allPageStrokes.Count > 0)
{
// 多页面XML保存为压缩包
string zipFileName = Path.ChangeExtension(savePathWithName, "zip");
SaveMultiPageStrokesAsXMLZip(allPageStrokes, zipFileName, newNotice);
}
else
{
// 单页面XML保存
string xmlPath = Path.ChangeExtension(savePathWithName, ".xml");
SaveStrokesAsXML(inkCanvas.Strokes, xmlPath);
if (newNotice) ShowNotification("墨迹成功保存为XML格式至 " + xmlPath);
}
}
else
{
// 常规保存模式 - 仅保存墨迹对象
var fs = new FileStream(savePathWithName, FileMode.Create);
inkCanvas.Strokes.Save(fs);
fs.Close();
if (Settings.Automation.IsSaveStrokesAsXML)
{
// 保存为XML格式
string xmlPath = Path.ChangeExtension(savePathWithName, ".xml");
SaveStrokesAsXML(inkCanvas.Strokes, xmlPath);
if (newNotice) ShowNotification("墨迹成功保存为XML格式至 " + xmlPath);
}
else
{
// 保存为二进制格式
var fs = new FileStream(savePathWithName, FileMode.Create);
inkCanvas.Strokes.Save(fs);
fs.Close();
if (newNotice) ShowNotification("墨迹成功保存至 " + savePathWithName);
}
_ = Task.Run(async () =>
{
try
{
var delayMinutes = Settings?.Dlass?.AutoUploadDelayMinutes ?? 0;
if (delayMinutes > 0)
{
await Task.Delay(TimeSpan.FromMinutes(delayMinutes));
}
await Helpers.DlassNoteUploader.UploadNoteFileAsync(savePathWithName);
}
catch (Exception)
{
}
});
// 保存元素信息
var elementInfos = new List<CanvasElementInfo>();
foreach (var child in inkCanvas.Children)
@@ -150,8 +245,7 @@ namespace Ink_Canvas
});
}
}
File.WriteAllText(Path.ChangeExtension(savePathWithName, ".elements.json"), JsonConvert.SerializeObject(elementInfos, Formatting.Indented));
if (newNotice) ShowNotification("墨迹成功保存至 " + savePathWithName);
File.WriteAllText(Path.ChangeExtension(savePathWithName, ".elements.json"), JsonConvert.SerializeObject(elementInfos, Newtonsoft.Json.Formatting.Indented));
}
}
catch (Exception ex)
@@ -161,6 +255,201 @@ namespace Ink_Canvas
}
}
/// <summary>
/// 将StrokeCollection保存为XML格式
/// </summary>
private void SaveStrokesAsXML(StrokeCollection strokes, string xmlPath)
{
try
{
// 使用XDocument创建XML文档
XDocument doc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("InkCanvasStrokes",
new XAttribute("Version", "1.0"),
new XAttribute("StrokeCount", strokes.Count),
new XAttribute("SaveTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
from stroke in strokes
select new XElement("Stroke",
new XAttribute("DrawingAttributes", SerializeDrawingAttributes(stroke.DrawingAttributes)),
new XElement("StylusPoints",
from point in stroke.StylusPoints
select new XElement("StylusPoint",
new XAttribute("X", point.X),
new XAttribute("Y", point.Y),
new XAttribute("PressureFactor", point.PressureFactor)
)
)
)
)
);
// 保存XML文件
using (var writer = new XmlTextWriter(xmlPath, Encoding.UTF8))
{
writer.Formatting = System.Xml.Formatting.Indented;
doc.Save(writer);
}
// 同时保存元素信息
var elementInfos = new List<CanvasElementInfo>();
foreach (var child in inkCanvas.Children)
{
if (child is Image img && img.Source is BitmapImage bmp)
{
elementInfos.Add(new CanvasElementInfo
{
Type = "Image",
SourcePath = bmp.UriSource?.LocalPath ?? "",
Left = InkCanvas.GetLeft(img),
Top = InkCanvas.GetTop(img),
Width = img.Width,
Height = img.Height,
Stretch = img.Stretch.ToString()
});
}
}
File.WriteAllText(Path.ChangeExtension(xmlPath, ".elements.json"), JsonConvert.SerializeObject(elementInfos, Newtonsoft.Json.Formatting.Indented));
// 异步上传到Dlass
_ = Task.Run(async () =>
{
try
{
var delayMinutes = Settings?.Dlass?.AutoUploadDelayMinutes ?? 0;
if (delayMinutes > 0)
{
await Task.Delay(TimeSpan.FromMinutes(delayMinutes));
}
await Helpers.DlassNoteUploader.UploadNoteFileAsync(xmlPath);
}
catch (Exception)
{
}
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存XML格式墨迹失败: {ex}", LogHelper.LogType.Error);
throw;
}
}
/// <summary>
/// 序列化DrawingAttributes为字符串
/// </summary>
private string SerializeDrawingAttributes(DrawingAttributes da)
{
var sb = new StringBuilder();
sb.Append($"Color={da.Color};");
sb.Append($"Width={da.Width};");
sb.Append($"Height={da.Height};");
sb.Append($"FitToCurve={da.FitToCurve};");
sb.Append($"IsHighlighter={da.IsHighlighter};");
sb.Append($"IgnorePressure={da.IgnorePressure};");
sb.Append($"StylusTip={da.StylusTip};");
return sb.ToString();
}
/// <summary>
/// 将多页面墨迹保存为XML格式压缩包
/// </summary>
private void SaveMultiPageStrokesAsXMLZip(List<StrokeCollection> allPageStrokes, string zipFileName, bool newNotice)
{
try
{
// 创建临时目录来存放文件
string tempDir = Path.Combine(Path.GetTempPath(), $"InkCanvas_MultiPage_XML_{DateTime.Now:yyyyMMdd_HHmmss}");
Directory.CreateDirectory(tempDir);
try
{
// 保存所有页面的XML文件到临时目录
for (int i = 0; i < allPageStrokes.Count; i++)
{
var strokes = allPageStrokes[i];
if (strokes.Count > 0)
{
// 保存XML文件
string xmlFileName = Path.Combine(tempDir, $"page_{i + 1:D4}.xml");
SaveStrokesAsXML(strokes, xmlFileName);
}
}
// 保存元数据信息
string metadataFile = Path.Combine(tempDir, "metadata.txt");
using (var writer = new StreamWriter(metadataFile, false, Encoding.UTF8))
{
writer.WriteLine($"保存时间: {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
writer.WriteLine($"总页数: {allPageStrokes.Count}");
writer.WriteLine($"模式: {(currentMode == 0 ? "PPT放映" : "")}");
writer.WriteLine($"格式: XML");
if (currentMode != 0)
{
writer.WriteLine($"当前页面: {CurrentWhiteboardIndex}");
writer.WriteLine($"总页面数: {WhiteboardTotalCount}");
}
else if (pptApplication != null)
{
writer.WriteLine($"PPT名称: {pptApplication.SlideShowWindows[1].Presentation.Name}");
writer.WriteLine($"PPT总页数: {pptApplication.SlideShowWindows[1].Presentation.Slides.Count}");
writer.WriteLine($"PPT文件路径: {pptApplication.SlideShowWindows[1].Presentation.FullName}");
}
for (int i = 0; i < allPageStrokes.Count; i++)
{
writer.WriteLine($"页面 {i + 1}: {allPageStrokes[i].Count} 条墨迹");
}
}
// 创建ZIP文件
if (File.Exists(zipFileName))
File.Delete(zipFileName);
ZipFile.CreateFromDirectory(tempDir, zipFileName);
// 异步上传ZIP文件到Dlass
_ = Task.Run(async () =>
{
try
{
var delayMinutes = Settings?.Dlass?.AutoUploadDelayMinutes ?? 0;
if (delayMinutes > 0)
{
await Task.Delay(TimeSpan.FromMinutes(delayMinutes));
}
await Helpers.DlassNoteUploader.UploadNoteFileAsync(zipFileName);
}
catch (Exception)
{
}
});
if (newNotice) ShowNotification($"多页面XML墨迹成功保存至压缩包 {zipFileName}");
}
finally
{
// 清理临时目录
try
{
if (Directory.Exists(tempDir))
Directory.Delete(tempDir, true);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理临时目录失败: {ex}", LogHelper.LogType.Warning);
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存多页面XML墨迹压缩包失败: {ex}", LogHelper.LogType.Error);
throw;
}
}
/// <summary>
/// 将多页面墨迹保存为压缩包
/// </summary>
@@ -228,6 +517,24 @@ namespace Ink_Canvas
// 使用System.IO.Compression.FileSystem来创建ZIP
ZipFile.CreateFromDirectory(tempDir, zipFileName);
// 异步上传ZIP文件到Dlass
_ = Task.Run(async () =>
{
try
{
var delayMinutes = Settings?.Dlass?.AutoUploadDelayMinutes ?? 0;
if (delayMinutes > 0)
{
await Task.Delay(TimeSpan.FromMinutes(delayMinutes));
}
await Helpers.DlassNoteUploader.UploadNoteFileAsync(zipFileName);
}
catch (Exception)
{
}
});
if (newNotice) ShowNotification($"多页面墨迹成功保存至压缩包 {zipFileName}");
}
finally
@@ -310,6 +617,23 @@ namespace Ink_Canvas
var fs = new FileStream(savePathWithName, FileMode.Create);
inkCanvas.Strokes.Save(fs);
fs.Close();
_ = Task.Run(async () =>
{
try
{
var delayMinutes = Settings?.Dlass?.AutoUploadDelayMinutes ?? 0;
if (delayMinutes > 0)
{
await Task.Delay(TimeSpan.FromMinutes(delayMinutes));
}
await Helpers.DlassNoteUploader.UploadNoteFileAsync(imagePathWithName);
}
catch (Exception)
{
}
});
}
}
@@ -358,7 +682,7 @@ namespace Ink_Canvas
var openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = Settings.Automation.AutoSavedStrokesLocation;
openFileDialog.Title = "打开墨迹文件";
openFileDialog.Filter = "Ink Canvas Strokes File (*.icstk)|*.icstk|ICC压缩包 (*.zip)|*.zip";
openFileDialog.Filter = "Ink Canvas Strokes File (*.icstk)|*.icstk|XML墨迹文件 (*.xml)|*.xml|ICC压缩包 (*.zip)|*.zip|所有支持的文件 (*.icstk;*.xml;*.zip)|*.icstk;*.xml;*.zip";
if (openFileDialog.ShowDialog() != true) return;
LogHelper.WriteLogToFile($"Strokes Insert: Name: {openFileDialog.FileName}",
LogHelper.LogType.Event);
@@ -369,12 +693,17 @@ namespace Ink_Canvas
if (fileExtension == ".zip")
{
// 处理ICC压缩包
// 处理ICC压缩包(可能包含XML格式)
OpenICCZipFile(openFileDialog.FileName);
}
else if (fileExtension == ".xml")
{
// 处理XML格式墨迹文件
OpenXMLStrokeFile(openFileDialog.FileName);
}
else
{
// 处理单个墨迹文件
// 处理单个墨迹文件(二进制格式)
OpenSingleStrokeFile(openFileDialog.FileName);
}
@@ -528,23 +857,41 @@ namespace Ink_Canvas
timeMachine.ClearStrokeHistory();
// 重置PPT墨迹存储
_multiPPTInkManager?.ClearAllStrokes();
_singlePPTInkManager?.ClearAllStrokes();
// 读取所有页面的墨迹文件
var files = Directory.GetFiles(tempDir, "page_*.icstk");
foreach (var file in files)
// 读取所有页面的墨迹文件(支持.icstk和.xml格式)
var icstkFiles = Directory.GetFiles(tempDir, "page_*.icstk");
var xmlFiles = Directory.GetFiles(tempDir, "page_*.xml");
var allFiles = new List<string>();
allFiles.AddRange(icstkFiles);
allFiles.AddRange(xmlFiles);
foreach (var file in allFiles)
{
var fileName = Path.GetFileNameWithoutExtension(file);
if (fileName.StartsWith("page_") && int.TryParse(fileName.Substring(5), out int pageNumber))
{
using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read))
StrokeCollection strokes = null;
string extension = Path.GetExtension(file).ToLower();
if (extension == ".xml")
{
var strokes = new StrokeCollection(fs);
if (strokes.Count > 0)
// 从XML文件加载
strokes = LoadStrokesFromXML(file);
}
else
{
// 从二进制文件加载
using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read))
{
_multiPPTInkManager?.ForceSaveSlideStrokes(pageNumber, strokes);
strokes = new StrokeCollection(fs);
}
}
if (strokes != null && strokes.Count > 0)
{
_singlePPTInkManager?.ForceSaveSlideStrokes(pageNumber, strokes);
}
}
}
@@ -552,14 +899,14 @@ namespace Ink_Canvas
if (_pptManager?.IsInSlideShow == true)
{
int currentSlide = _pptManager.GetCurrentSlideNumber();
var currentStrokes = _multiPPTInkManager?.LoadSlideStrokes(currentSlide);
var currentStrokes = _singlePPTInkManager?.LoadSlideStrokes(currentSlide);
if (currentStrokes != null && currentStrokes.Count > 0)
{
inkCanvas.Strokes.Add(currentStrokes);
}
}
LogHelper.WriteLogToFile($"成功恢复PPT墨迹,共{files.Length}页");
LogHelper.WriteLogToFile($"成功恢复PPT墨迹,共{allFiles.Count}页");
}
catch (Exception ex)
{
@@ -640,6 +987,173 @@ namespace Ink_Canvas
}
}
/// <summary>
/// 打开XML格式的墨迹文件
/// </summary>
public void OpenXMLStrokeFile(string filePath)
{
try
{
XDocument doc = XDocument.Load(filePath);
var root = doc.Root;
if (root == null || root.Name != "InkCanvasStrokes")
{
throw new Exception("无效的XML墨迹文件格式");
}
var strokes = new StrokeCollection();
foreach (var strokeElement in root.Elements("Stroke"))
{
var drawingAttributesStr = strokeElement.Attribute("DrawingAttributes")?.Value ?? "";
var da = ParseDrawingAttributes(drawingAttributesStr);
var stylusPoints = new StylusPointCollection();
var stylusPointsElement = strokeElement.Element("StylusPoints");
if (stylusPointsElement != null)
{
foreach (var pointElement in stylusPointsElement.Elements("StylusPoint"))
{
double x = double.Parse(pointElement.Attribute("X")?.Value ?? "0");
double y = double.Parse(pointElement.Attribute("Y")?.Value ?? "0");
float pressure = float.Parse(pointElement.Attribute("PressureFactor")?.Value ?? "0.5");
stylusPoints.Add(new StylusPoint(x, y, pressure));
}
}
if (stylusPoints.Count > 0)
{
var stroke = new Stroke(stylusPoints) { DrawingAttributes = da };
strokes.Add(stroke);
}
}
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
inkCanvas.Strokes.Add(strokes);
LogHelper.NewLog($"XML Strokes Insert: Strokes Count: {inkCanvas.Strokes.Count}");
// 恢复元素信息
var elementsFile = Path.ChangeExtension(filePath, ".elements.json");
if (File.Exists(elementsFile))
{
var elementInfos = JsonConvert.DeserializeObject<List<CanvasElementInfo>>(File.ReadAllText(elementsFile));
foreach (var info in elementInfos)
{
if (info.Type == "Image" && File.Exists(info.SourcePath))
{
var img = new Image
{
Source = new BitmapImage(new Uri(info.SourcePath)),
Width = info.Width,
Height = info.Height,
Stretch = Enum.TryParse<Stretch>(info.Stretch, out var stretch) ? stretch : Stretch.Fill
};
InkCanvas.SetLeft(img, info.Left);
InkCanvas.SetTop(img, info.Top);
inkCanvas.Children.Add(img);
}
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"打开XML墨迹文件失败: {ex}", LogHelper.LogType.Error);
throw;
}
}
/// <summary>
/// 从XML文件加载StrokeCollection(辅助方法,用于ZIP文件恢复)
/// </summary>
private StrokeCollection LoadStrokesFromXML(string xmlPath)
{
try
{
XDocument doc = XDocument.Load(xmlPath);
var root = doc.Root;
if (root == null || root.Name != "InkCanvasStrokes")
{
return new StrokeCollection();
}
var strokes = new StrokeCollection();
foreach (var strokeElement in root.Elements("Stroke"))
{
var drawingAttributesStr = strokeElement.Attribute("DrawingAttributes")?.Value ?? "";
var da = ParseDrawingAttributes(drawingAttributesStr);
var stylusPoints = new StylusPointCollection();
var stylusPointsElement = strokeElement.Element("StylusPoints");
if (stylusPointsElement != null)
{
foreach (var pointElement in stylusPointsElement.Elements("StylusPoint"))
{
double x = double.Parse(pointElement.Attribute("X")?.Value ?? "0");
double y = double.Parse(pointElement.Attribute("Y")?.Value ?? "0");
float pressure = float.Parse(pointElement.Attribute("PressureFactor")?.Value ?? "0.5");
stylusPoints.Add(new StylusPoint(x, y, pressure));
}
}
if (stylusPoints.Count > 0)
{
var stroke = new Stroke(stylusPoints) { DrawingAttributes = da };
strokes.Add(stroke);
}
}
return strokes;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"从XML加载墨迹失败: {ex}", LogHelper.LogType.Error);
return new StrokeCollection();
}
}
/// <summary>
/// 从字符串解析DrawingAttributes
/// </summary>
private DrawingAttributes ParseDrawingAttributes(string attributesStr)
{
var da = new DrawingAttributes();
var parts = attributesStr.Split(';');
foreach (var part in parts)
{
var kv = part.Split('=');
if (kv.Length == 2)
{
var key = kv[0].Trim();
var value = kv[1].Trim();
switch (key)
{
case "Color":
da.Color = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(value);
break;
case "Width":
da.Width = double.Parse(value);
break;
case "Height":
da.Height = double.Parse(value);
break;
case "FitToCurve":
da.FitToCurve = bool.Parse(value);
break;
case "IsHighlighter":
da.IsHighlighter = bool.Parse(value);
break;
case "IgnorePressure":
da.IgnorePressure = bool.Parse(value);
break;
case "StylusTip":
da.StylusTip = Enum.TryParse<StylusTip>(value, out var tip) ? tip : StylusTip.Ellipse;
break;
}
}
}
return da;
}
/// <summary>
/// 打开单个墨迹文件
/// </summary>
@@ -695,3 +1209,4 @@ namespace Ink_Canvas
}
}
}
+17
View File
@@ -3,6 +3,7 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
@@ -65,6 +66,22 @@ namespace Ink_Canvas
{
ShowNotification($"截图成功保存至 {savePath}");
}
_ = Task.Run(async () =>
{
try
{
var delayMinutes = Settings?.Dlass?.AutoUploadDelayMinutes ?? 0;
if (delayMinutes > 0)
{
await Task.Delay(TimeSpan.FromMinutes(delayMinutes));
}
await Helpers.DlassNoteUploader.UploadNoteFileAsync(savePath);
}
catch (Exception)
{
}
});
}
// 获取日期文件夹路径
@@ -34,23 +34,24 @@ namespace Ink_Canvas
lastBorderMouseDownObject = sender;
}
private bool isStrokeSelectionCloneOn;
private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e)
{
if (lastBorderMouseDownObject != sender) return;
if (isStrokeSelectionCloneOn)
try
{
BorderStrokeSelectionClone.Background = Brushes.Transparent;
isStrokeSelectionCloneOn = false;
var strokes = inkCanvas.GetSelectedStrokes();
if (strokes.Count > 0)
{
// 直接执行克隆操作,与图片克隆保持一致
CloneStrokes(strokes);
LogHelper.WriteLogToFile($"墨迹克隆完成: {strokes.Count} 个墨迹");
}
}
else
catch (Exception ex)
{
BorderStrokeSelectionClone.Background = new SolidColorBrush(StringToColor("#FF1ED760"));
isStrokeSelectionCloneOn = true;
LogHelper.WriteLogToFile($"墨迹克隆失败: {ex.Message}", LogHelper.LogType.Error);
}
}
@@ -60,9 +61,7 @@ namespace Ink_Canvas
var strokes = inkCanvas.GetSelectedStrokes();
inkCanvas.Select(new StrokeCollection());
strokes = strokes.Clone();
BtnWhiteBoardAdd_Click(null, null);
inkCanvas.Strokes.Add(strokes);
CloneStrokesToNewBoard(strokes);
}
private void BorderStrokeSelectionDelete_MouseUp(object sender, MouseButtonEventArgs e)
@@ -355,7 +354,6 @@ namespace Ink_Canvas
private void BtnSelect_Click(object sender, RoutedEventArgs e)
{
ExitMultiTouchModeIfNeeded();
forceEraser = true;
drawingShapeMode = 0;
inkCanvas.IsManipulationEnabled = false;
@@ -408,7 +406,6 @@ namespace Ink_Canvas
// 显示墨迹选择栏和选择框
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
BorderStrokeSelectionClone.Background = Brushes.Transparent;
isStrokeSelectionCloneOn = false;
updateBorderStrokeSelectionControlLocation();
UpdateSelectionDisplay();
return;
@@ -630,50 +627,7 @@ namespace Ink_Canvas
{
var touchPoint = e.GetTouchPoint(null);
centerPoint = touchPoint.Position;
lastTouchPointOnGridInkCanvasCover = e.GetTouchPoint(inkCanvas).Position;
// 检查是否有选中的墨迹
if (inkCanvas.GetSelectedStrokes().Count > 0)
{
// 获取触摸点位置
var touchPosition = e.GetTouchPoint(inkCanvas).Position;
var selectionBounds = inkCanvas.GetSelectionBounds();
// 检查触摸位置是否在选择框边界内
if (touchPosition.X >= selectionBounds.Left &&
touchPosition.X <= selectionBounds.Right &&
touchPosition.Y >= selectionBounds.Top &&
touchPosition.Y <= selectionBounds.Bottom)
{
// 只有在选择框边界内才允许拖动
// 触摸拖动状态已通过TouchMove事件处理
}
else
{
// 触摸在选择框外,取消选择
inkCanvas.Select(new StrokeCollection());
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
return;
}
}
if (isStrokeSelectionCloneOn)
{
var strokes = inkCanvas.GetSelectedStrokes();
isProgramChangeStrokeSelection = true;
inkCanvas.Select(new StrokeCollection());
StrokesSelectionClone = strokes.Clone();
inkCanvas.Select(strokes);
isProgramChangeStrokeSelection = false;
inkCanvas.Strokes.Add(StrokesSelectionClone);
}
else
{
// 新增:启动套索选择模式
// 使用集中化的工具模式切换方法
SetCurrentToolMode(InkCanvasEditingMode.Select);
inkCanvas.Select(new StrokeCollection());
}
lastTouchPointOnGridInkCanvasCover = touchPoint.Position;
}
}
@@ -681,33 +635,25 @@ namespace Ink_Canvas
{
dec.Remove(e.TouchDevice.Id);
if (dec.Count >= 1) return;
// 重置触摸状态
lastTouchPointOnGridInkCanvasCover = new Point(0, 0);
isProgramChangeStrokeSelection = false;
// 检查是否有点击(没有移动)
var currentTouchPoint = e.GetTouchPoint(null).Position;
if (Math.Abs(currentTouchPoint.X - centerPoint.X) < 5 && Math.Abs(currentTouchPoint.Y - centerPoint.Y) < 5)
var touchUpPoint = e.GetTouchPoint(null).Position;
if (lastTouchPointOnGridInkCanvasCover == touchUpPoint)
{
// 点击在选择框内,保持选择状态
if (inkCanvas.GetSelectedStrokes().Count > 0)
var touchPointInCanvas = e.GetTouchPoint(inkCanvas).Position;
var selectionBounds = inkCanvas.GetSelectionBounds();
if (!(touchPointInCanvas.X < selectionBounds.Left) &&
!(touchPointInCanvas.Y < selectionBounds.Top) &&
!(touchPointInCanvas.X > selectionBounds.Right) &&
!(touchPointInCanvas.Y > selectionBounds.Bottom))
{
var selectionBounds = inkCanvas.GetSelectionBounds();
if (currentTouchPoint.X >= selectionBounds.Left &&
currentTouchPoint.X <= selectionBounds.Right &&
currentTouchPoint.Y >= selectionBounds.Top &&
currentTouchPoint.Y <= selectionBounds.Bottom)
{
// 点击在选择框内,保持选择
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
StrokesSelectionClone = new StrokeCollection();
return;
}
return;
}
// 点击在选择框外,取消选择
isProgramChangeStrokeSelection = true;
inkCanvas.Select(new StrokeCollection());
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
isProgramChangeStrokeSelection = false;
StrokesSelectionClone = new StrokeCollection();
}
else if (inkCanvas.GetSelectedStrokes().Count == 0)
@@ -720,12 +666,10 @@ namespace Ink_Canvas
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
StrokesSelectionClone = new StrokeCollection();
}
}
private void LassoSelect_Click(object sender, RoutedEventArgs e)
{
ExitMultiTouchModeIfNeeded();
forceEraser = false;
forcePointEraser = false;
drawingShapeMode = 0;
@@ -736,7 +680,6 @@ namespace Ink_Canvas
private void BtnLassoSelect_Click(object sender, RoutedEventArgs e)
{
ExitMultiTouchModeIfNeeded();
forceEraser = false;
forcePointEraser = false;
drawingShapeMode = 0;
File diff suppressed because it is too large Load Diff
+343 -8
View File
@@ -1,8 +1,10 @@
using Hardcodet.Wpf.TaskbarNotification;
using Hardcodet.Wpf.TaskbarNotification;
using Ink_Canvas.Helpers;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OSVersionExtension;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
@@ -10,8 +12,10 @@ using System.Windows.Ink;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using File = System.IO.File;
using OperatingSystem = OSVersionExtension.OperatingSystem;
using WinForms = System.Windows.Forms;
namespace Ink_Canvas
{
@@ -28,12 +32,103 @@ namespace Ink_Canvas
{
string text = File.ReadAllText(App.RootPath + settingsFileName);
Settings = JsonConvert.DeserializeObject<Settings>(text);
if (Settings != null)
{
CleanupObsoleteSettings(text);
}
// 验证设置是否成功加载
if (Settings == null)
{
LogHelper.WriteLogToFile("配置文件解析失败,尝试从备份恢复", LogHelper.LogType.Warning);
if (AutoBackupManager.TryRestoreFromBackup())
{
// 重新尝试加载
text = File.ReadAllText(App.RootPath + settingsFileName);
Settings = JsonConvert.DeserializeObject<Settings>(text);
if (Settings != null)
{
// 清理过期配置项
CleanupObsoleteSettings(text);
}
}
// 如果仍然失败,使用默认设置
if (Settings == null)
{
LogHelper.WriteLogToFile("从备份恢复失败,使用默认设置", LogHelper.LogType.Warning);
BtnResetToSuggestion_Click(null, null);
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"配置文件加载失败: {ex.Message}", LogHelper.LogType.Error);
// 尝试从备份恢复
LogHelper.WriteLogToFile("尝试从备份恢复配置文件", LogHelper.LogType.Warning);
if (AutoBackupManager.TryRestoreFromBackup())
{
try
{
string text = File.ReadAllText(App.RootPath + settingsFileName);
Settings = JsonConvert.DeserializeObject<Settings>(text);
if (Settings != null)
{
// 清理过期配置项
CleanupObsoleteSettings(text);
}
}
catch (Exception restoreEx)
{
LogHelper.WriteLogToFile($"从备份恢复后重新加载失败: {restoreEx.Message}", LogHelper.LogType.Error);
BtnResetToSuggestion_Click(null, null);
}
}
// 如果仍然失败,使用默认设置
if (Settings == null)
{
LogHelper.WriteLogToFile("从备份恢复失败,使用默认设置", LogHelper.LogType.Warning);
BtnResetToSuggestion_Click(null, null);
}
}
catch { }
}
else
{
BtnResetToSuggestion_Click(null, null);
LogHelper.WriteLogToFile("配置文件不存在,尝试从备份恢复", LogHelper.LogType.Warning);
if (AutoBackupManager.TryRestoreFromBackup())
{
try
{
string text = File.ReadAllText(App.RootPath + settingsFileName);
Settings = JsonConvert.DeserializeObject<Settings>(text);
if (Settings != null)
{
// 清理过期配置项
CleanupObsoleteSettings(text);
}
}
catch (Exception restoreEx)
{
LogHelper.WriteLogToFile($"从备份恢复后加载失败: {restoreEx.Message}", LogHelper.LogType.Error);
BtnResetToSuggestion_Click(null, null);
}
}
else
{
// 备份恢复失败(备份目录不存在等),使用默认设置
LogHelper.WriteLogToFile("备份恢复失败,使用默认设置", LogHelper.LogType.Warning);
BtnResetToSuggestion_Click(null, null);
}
// 如果仍然失败,使用默认设置
if (Settings == null)
{
LogHelper.WriteLogToFile("从备份恢复失败,使用默认设置", LogHelper.LogType.Warning);
BtnResetToSuggestion_Click(null, null);
}
}
}
catch (Exception ex)
@@ -75,7 +170,7 @@ namespace Ink_Canvas
Settings.Automation.AutoDelSavedFilesDaysThreshold);
}
if (Settings.Startup.IsFoldAtStartup)
if (Settings.Startup.IsFoldAtStartup && !App.StartWithBoardMode)
{
FoldFloatingBar_MouseUp(Fold_Icon, null);
}
@@ -113,7 +208,7 @@ namespace Ink_Canvas
}
}
// ToggleSwitchIsAutoUpdateWithSilence.Visibility = Settings.Startup.IsAutoUpdate ? Visibility.Visible : Visibility.Collapsed;
ToggleSwitchIsAutoUpdateWithSilence.Visibility = Settings.Startup.IsAutoUpdate ? Visibility.Visible : Visibility.Collapsed;
if (Settings.Startup.IsAutoUpdateWithSilence)
{
ToggleSwitchIsAutoUpdateWithSilence.IsOn = true;
@@ -245,10 +340,17 @@ namespace Ink_Canvas
break;
}
// 设置主题下拉框
ComboBoxTheme.SelectedIndex = Settings.Appearance.Theme;
ComboBoxChickenSoupSource.SelectedIndex = Settings.Appearance.ChickenSoupSource;
ToggleSwitchEnableQuickPanel.IsOn = Settings.Appearance.IsShowQuickPanel;
ToggleSwitchEnableSplashScreen.IsOn = Settings.Appearance.EnableSplashScreen;
ComboBoxSplashScreenStyle.SelectedIndex = Settings.Appearance.SplashScreenStyle;
ToggleSwitchEnableTrayIcon.IsOn = Settings.Appearance.EnableTrayIcon;
ICCTrayIconExampleImage.Visibility =
Settings.Appearance.EnableTrayIcon ? Visibility.Visible : Visibility.Collapsed;
@@ -320,6 +422,7 @@ namespace Ink_Canvas
Settings.Appearance.EnableChickenSoupInWhiteboardMode;
// 浮动栏按钮显示控制开关初始化
CheckBoxUseLegacyFloatingBarUI.IsChecked = Settings.Appearance.UseLegacyFloatingBarUI;
CheckBoxShowShapeButton.IsChecked = Settings.Appearance.IsShowShapeButton;
CheckBoxShowUndoButton.IsChecked = Settings.Appearance.IsShowUndoButton;
CheckBoxShowRedoButton.IsChecked = Settings.Appearance.IsShowRedoButton;
@@ -338,6 +441,9 @@ namespace Ink_Canvas
// 应用浮动栏按钮可见性设置
UpdateFloatingBarButtonsVisibility();
// 更新浮动栏图标
UpdateFloatingBarIcons();
SystemEvents_UserPreferenceChanged(null, null);
}
else
@@ -374,6 +480,21 @@ namespace Ink_Canvas
ToggleSwitchNotifyPreviousPage.IsOn = Settings.PowerPointSettings.IsNotifyPreviousPage;
// PPT时间显示胶囊设置
if (ToggleSwitchEnablePPTTimeCapsule != null)
{
ToggleSwitchEnablePPTTimeCapsule.IsOn = Settings.PowerPointSettings.EnablePPTTimeCapsule;
}
if (ComboBoxPPTTimeCapsulePosition != null)
{
int position = Settings.PowerPointSettings.PPTTimeCapsulePosition;
if (position < 0 || position > 2)
{
position = 1; // 默认右上角
}
ComboBoxPPTTimeCapsulePosition.SelectedIndex = position;
}
// -- new --
ToggleSwitchShowPPTButton.IsOn = Settings.PowerPointSettings.ShowPPTButton;
@@ -447,6 +568,38 @@ namespace Ink_Canvas
PPTButtonRBPositionValueSlider.Value = Settings.PowerPointSettings.PPTRBButtonPosition;
// 初始化PPT翻页按钮透明度滑块值,根据半透明选项设置默认值
// 重用之前定义的sopsc和bopsc变量
bool isSideHalfOpacity = sopsc.Length >= 2 && sopsc[1] == '2';
// 如果透明度为0或未设置,根据半透明选项设置默认值
if (Settings.PowerPointSettings.PPTLSButtonOpacity == 0.0 ||
(Settings.PowerPointSettings.PPTLSButtonOpacity == 1.0 && isSideHalfOpacity))
{
Settings.PowerPointSettings.PPTLSButtonOpacity = isSideHalfOpacity ? 0.5 : 1.0;
}
if (Settings.PowerPointSettings.PPTRSButtonOpacity == 0.0 ||
(Settings.PowerPointSettings.PPTRSButtonOpacity == 1.0 && isSideHalfOpacity))
{
Settings.PowerPointSettings.PPTRSButtonOpacity = isSideHalfOpacity ? 0.5 : 1.0;
}
PPTLSButtonOpacityValueSlider.Value = Settings.PowerPointSettings.PPTLSButtonOpacity;
PPTRSButtonOpacityValueSlider.Value = Settings.PowerPointSettings.PPTRSButtonOpacity;
bool isBottomHalfOpacity = bopsc.Length >= 2 && bopsc[1] == '2';
// 如果透明度为0或未设置,根据半透明选项设置默认值
if (Settings.PowerPointSettings.PPTLBButtonOpacity == 0.0 ||
(Settings.PowerPointSettings.PPTLBButtonOpacity == 1.0 && isBottomHalfOpacity))
{
Settings.PowerPointSettings.PPTLBButtonOpacity = isBottomHalfOpacity ? 0.5 : 1.0;
}
if (Settings.PowerPointSettings.PPTRBButtonOpacity == 0.0 ||
(Settings.PowerPointSettings.PPTRBButtonOpacity == 1.0 && isBottomHalfOpacity))
{
Settings.PowerPointSettings.PPTRBButtonOpacity = isBottomHalfOpacity ? 0.5 : 1.0;
}
PPTLBButtonOpacityValueSlider.Value = Settings.PowerPointSettings.PPTLBButtonOpacity;
PPTRBButtonOpacityValueSlider.Value = Settings.PowerPointSettings.PPTRBButtonOpacity;
UpdatePPTBtnSlidersStatus();
UpdatePPTBtnPreview();
@@ -499,7 +652,7 @@ namespace Ink_Canvas
ToggleSwitchEnableTwoFingerTranslate.IsOn = false;
BoardToggleSwitchEnableTwoFingerTranslate.IsOn = false;
Settings.Gesture.IsEnableTwoFingerTranslate = false;
if (!isInMultiTouchMode) ToggleSwitchEnableMultiTouchMode.IsOn = true;
// if (!isInMultiTouchMode) ToggleSwitchEnableMultiTouchMode.IsOn = true;
}
else
{
@@ -561,6 +714,7 @@ namespace Ink_Canvas
// 初始化屏蔽压感开关状态
ToggleSwitchDisablePressure.IsOn = Settings.Canvas.DisablePressure;
inkCanvas.DefaultDrawingAttributes.IgnorePressure = Settings.Canvas.DisablePressure;
ComboBoxPenStyle.SelectedIndex = Settings.Canvas.InkStyle;
BoardComboBoxPenStyle.SelectedIndex = Settings.Canvas.InkStyle;
@@ -701,6 +855,7 @@ namespace Ink_Canvas
ToggleSwitchIsLogEnabled.IsOn = Settings.Advanced.IsLogEnabled;
ToggleSwitchIsSaveLogByDate.IsOn = Settings.Advanced.IsSaveLogByDate;
ToggleSwitchIsSecondConfimeWhenShutdownApp.IsOn = Settings.Advanced.IsSecondConfirmWhenShutdownApp;
ToggleSwitchWindowMode.IsOn = Settings.Advanced.WindowMode;
ToggleSwitchIsSpecialScreen.IsOn = Settings.Advanced.IsSpecialScreen;
ToggleSwitchIsQuadIR.IsOn = Settings.Advanced.IsQuadIR;
ToggleSwitchEraserBindTouchMultiplier.IsOn = Settings.Advanced.EraserBindTouchMultiplier;
@@ -711,6 +866,17 @@ namespace Ink_Canvas
ToggleSwitchIsEnableDPIChangeDetection.IsOn = Settings.Advanced.IsEnableDPIChangeDetection;
ToggleSwitchIsEnableAvoidFullScreenHelper.IsOn = Settings.Advanced.IsEnableAvoidFullScreenHelper;
ToggleSwitchIsAutoBackupBeforeUpdate.IsOn = Settings.Advanced.IsAutoBackupBeforeUpdate;
ToggleSwitchIsAutoBackupEnabled.IsOn = Settings.Advanced.IsAutoBackupEnabled;
// 设置备份间隔下拉框
foreach (ComboBoxItem item in ComboBoxAutoBackupInterval.Items)
{
if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int interval) && interval == Settings.Advanced.AutoBackupIntervalDays)
{
ComboBoxAutoBackupInterval.SelectedItem = item;
break;
}
}
if (Settings.Advanced.IsEnableFullScreenHelper)
{
FullScreenHelper.MarkFullscreenWindowTaskbarList(new WindowInteropHelper(this).Handle, true);
@@ -718,6 +884,14 @@ namespace Ink_Canvas
if (Settings.Advanced.IsEnableAvoidFullScreenHelper)
{
AvoidFullScreenHelper.StartAvoidFullScreen(this);
Dispatcher.BeginInvoke(new Action(() =>
{
if (isLoaded)
{
MoveWindow(new WindowInteropHelper(this).Handle, 0, 0,
WinForms.Screen.PrimaryScreen.Bounds.Width, WinForms.Screen.PrimaryScreen.Bounds.Height, true);
}
}), DispatcherPriority.ApplicationIdle);
}
if (Settings.Advanced.IsEnableEdgeGestureUtil)
{
@@ -763,11 +937,36 @@ namespace Ink_Canvas
RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
ToggleSwitchShowRandomAndSingleDraw.IsOn = Settings.RandSettings.ShowRandomAndSingleDraw;
ToggleSwitchEnableQuickDraw.IsOn = Settings.RandSettings.EnableQuickDraw;
ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand;
ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType;
RandomDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
SingleDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
// 计时器设置
ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
ToggleSwitchUseNewStyleUI.IsOn = Settings.RandSettings.UseNewStyleUI;
ToggleSwitchEnableOvertimeCountUp.IsOn = Settings.RandSettings.EnableOvertimeCountUp;
// 新点名UI设置
ToggleSwitchUseNewRollCallUI.IsOn = Settings.RandSettings.UseNewRollCallUI;
ToggleSwitchEnableMLAvoidance.IsOn = Settings.RandSettings.EnableMLAvoidance;
MLAvoidanceHistorySlider.Value = Settings.RandSettings.MLAvoidanceHistoryCount;
MLAvoidanceWeightSlider.Value = Settings.RandSettings.MLAvoidanceWeight;
bool canEnableRedText = Settings.RandSettings.EnableOvertimeCountUp && Settings.RandSettings.EnableOvertimeRedText;
ToggleSwitchEnableOvertimeRedText.IsOn = canEnableRedText;
if (!canEnableRedText)
{
Settings.RandSettings.EnableOvertimeRedText = false;
}
TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
// 渐进提醒设置
ToggleSwitchEnableProgressiveReminder.IsOn = Settings.RandSettings.EnableProgressiveReminder;
ProgressiveReminderVolumeSlider.Value = Settings.RandSettings.ProgressiveReminderVolume;
// 加载自定义点名背景
UpdatePickNameBackgroundsInComboBox();
@@ -784,15 +983,32 @@ namespace Ink_Canvas
ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
ToggleSwitchEnableQuickDraw.IsOn = Settings.RandSettings.EnableQuickDraw;
ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand;
ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType;
ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
ToggleSwitchUseNewStyleUI.IsOn = Settings.RandSettings.UseNewStyleUI;
ToggleSwitchEnableOvertimeCountUp.IsOn = Settings.RandSettings.EnableOvertimeCountUp;
bool canEnableRedText = Settings.RandSettings.EnableOvertimeCountUp && Settings.RandSettings.EnableOvertimeRedText;
ToggleSwitchEnableOvertimeRedText.IsOn = canEnableRedText;
if (!canEnableRedText)
{
Settings.RandSettings.EnableOvertimeRedText = false;
}
TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
// 渐进提醒设置
ToggleSwitchEnableProgressiveReminder.IsOn = Settings.RandSettings.EnableProgressiveReminder;
ProgressiveReminderVolumeSlider.Value = Settings.RandSettings.ProgressiveReminderVolume;
}
// ModeSettings
if (Settings.ModeSettings != null)
{
ToggleSwitchMode.IsOn = Settings.ModeSettings.IsPPTOnlyMode;
// 根据加载的配置状态执行相应的窗口显示/隐藏逻辑
if (isStartup && Settings.ModeSettings.IsPPTOnlyMode)
{
@@ -898,6 +1114,25 @@ namespace Ink_Canvas
ToggleSwitchSaveFullPageStrokes.IsOn = Settings.Automation.IsSaveFullPageStrokes;
ToggleSwitchSaveStrokesAsXML.IsOn = Settings.Automation.IsSaveStrokesAsXML;
// 加载定时保存墨迹设置
ToggleSwitchEnableAutoSaveStrokes.IsOn = Settings.Automation.IsEnableAutoSaveStrokes;
// 初始化保存间隔下拉框
if (ComboBoxAutoSaveStrokesInterval != null)
{
int intervalMinutes = Settings.Automation.AutoSaveStrokesIntervalMinutes;
if (intervalMinutes < 1) intervalMinutes = 5; // 默认5分钟
foreach (System.Windows.Controls.ComboBoxItem item in ComboBoxAutoSaveStrokesInterval.Items)
{
if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int tagValue) && tagValue == intervalMinutes)
{
ComboBoxAutoSaveStrokesInterval.SelectedItem = item;
break;
}
}
}
SideControlMinimumAutomationSlider.Value = Settings.Automation.MinimumAutomationStrokeNumber;
AutoSavedStrokesLocation.Text = Settings.Automation.AutoSavedStrokesLocation;
@@ -907,6 +1142,9 @@ namespace Ink_Canvas
// 加载退出收纳模式自动切换至批注模式设置
ToggleSwitchAutoEnterAnnotationModeWhenExitFoldMode.IsOn = Settings.Automation.IsAutoEnterAnnotationModeWhenExitFoldMode;
// 加载退出白板时自动收纳设置
ToggleSwitchAutoFoldWhenExitWhiteboard.IsOn = Settings.Automation.IsAutoFoldWhenExitWhiteboard;
}
else
{
@@ -974,5 +1212,102 @@ namespace Ink_Canvas
LogHelper.WriteLogToFile($"加载墨迹渐隐设置时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <param name="userConfigJson">用户配置的JSON字符串</param>
private void CleanupObsoleteSettings(string userConfigJson)
{
try
{
// 创建默认配置对象
Settings defaultSettings = new Settings();
// 将默认配置和用户配置都序列化为JObject
JObject defaultConfigObj = JObject.FromObject(defaultSettings);
JObject userConfigObj = JObject.Parse(userConfigJson);
// 记录是否有清理操作
bool hasChanges = false;
// 递归比较并删除用户配置中多余的键
RemoveObsoleteProperties(userConfigObj, defaultConfigObj, ref hasChanges);
// 如果有清理操作,重新反序列化并保存
if (hasChanges)
{
string cleanedJson = userConfigObj.ToString(Formatting.Indented);
Settings = JsonConvert.DeserializeObject<Settings>(cleanedJson);
SaveSettingsToFile();
LogHelper.WriteLogToFile("已清理过期配置项", LogHelper.LogType.Event);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理过期配置时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <param name="userObj">用户配置的JObject</param>
/// <param name="defaultObj">默认配置的JObject</param>
/// <param name="hasChanges">是否有变更的引用标志</param>
private void RemoveObsoleteProperties(JObject userObj, JObject defaultObj, ref bool hasChanges)
{
if (userObj == null || defaultObj == null)
return;
// 获取需要删除的键列表(避免在遍历时修改集合)
List<string> keysToRemove = new List<string>();
foreach (var property in userObj.Properties())
{
string propertyName = property.Name;
// 如果默认配置中不存在该属性,标记为删除
if (!defaultObj.ContainsKey(propertyName))
{
keysToRemove.Add(propertyName);
continue;
}
// 如果两个属性都是对象类型,递归比较
JToken userValue = property.Value;
JToken defaultValue = defaultObj[propertyName];
if (userValue != null && defaultValue != null)
{
if (userValue.Type == JTokenType.Object && defaultValue.Type == JTokenType.Object)
{
RemoveObsoleteProperties(userValue as JObject, defaultValue as JObject, ref hasChanges);
}
// 处理数组中的对象(如自定义图标列表等)
else if (userValue.Type == JTokenType.Array && defaultValue.Type == JTokenType.Array)
{
JArray userArray = userValue as JArray;
JArray defaultArray = defaultValue as JArray;
if (userArray != null && defaultArray != null && userArray.Count > 0 && defaultArray.Count > 0)
{
// 如果数组元素是对象,比较第一个元素的属性结构
if (userArray[0].Type == JTokenType.Object && defaultArray[0].Type == JTokenType.Object)
{
for (int i = 0; i < userArray.Count; i++)
{
if (userArray[i] is JObject userItemObj && defaultArray[0] is JObject defaultItemObj)
{
RemoveObsoleteProperties(userItemObj, defaultItemObj, ref hasChanges);
}
}
}
}
}
}
}
// 删除标记的键
foreach (string key in keysToRemove)
{
userObj.Remove(key);
hasChanges = true;
}
}
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+497 -44
View File
@@ -1,5 +1,6 @@
using Ink_Canvas.Helpers;
using Ink_Canvas.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
@@ -12,6 +13,8 @@ using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using WinForms = System.Windows.Forms;
namespace Ink_Canvas
{
@@ -56,20 +59,27 @@ namespace Ink_Canvas
public partial class MainWindow : Window
{
private Timer timerCheckPPT = new Timer();
private Timer timerKillProcess = new Timer();
private Timer timerCheckAutoFold = new Timer();
private System.Timers.Timer timerCheckPPT = new System.Timers.Timer();
private System.Timers.Timer timerKillProcess = new System.Timers.Timer();
private System.Timers.Timer timerCheckAutoFold = new System.Timers.Timer();
private string AvailableLatestVersion;
private Timer timerCheckAutoUpdateWithSilence = new Timer();
private System.Timers.Timer timerCheckAutoUpdateWithSilence = new System.Timers.Timer();
private System.Timers.Timer timerCheckAutoUpdateRetry = new System.Timers.Timer();
private bool isHidingSubPanelsWhenInking; // 避免书写时触发二次关闭二级菜单导致动画不连续
private Timer timerDisplayTime = new Timer();
private Timer timerDisplayDate = new Timer();
private Timer timerNtpSync = new Timer();
private int updateCheckRetryCount = 0;
private const int MAX_UPDATE_CHECK_RETRIES = 6;
private System.Timers.Timer timerDisplayTime = new System.Timers.Timer();
private System.Timers.Timer timerDisplayDate = new System.Timers.Timer();
private System.Timers.Timer timerNtpSync = new System.Timers.Timer();
private TimeViewModel nowTimeVM = new TimeViewModel();
private DateTime cachedNetworkTime = DateTime.Now;
private DateTime lastNtpSyncTime = DateTime.MinValue;
private string lastDisplayedTime = "";
private bool useNetworkTime = false;
private TimeSpan networkTimeOffset = TimeSpan.Zero;
private DateTime lastLocalTime = DateTime.Now; // 记录上次的本地时间,用于检测时间跳跃
private bool isNtpSyncing = false; // 防止重复NTP同步的标志
private async Task<DateTime> GetNetworkTimeAsync()
{
@@ -82,7 +92,7 @@ namespace Ink_Canvas
var ipEndPoint = new IPEndPoint(addresses[0], 123);
using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
{
socket.ReceiveTimeout = 2000;
socket.ReceiveTimeout = 5000;
socket.Connect(ipEndPoint);
await Task.Factory.FromAsync(socket.BeginSend(ntpData, 0, ntpData.Length, SocketFlags.None, null, socket), socket.EndSend);
await Task.Factory.FromAsync(socket.BeginReceive(ntpData, 0, ntpData.Length, SocketFlags.None, null, socket), socket.EndReceive);
@@ -94,7 +104,7 @@ namespace Ink_Canvas
var networkDateTime = (new DateTime(1900, 1, 1)).AddMilliseconds((long)milliseconds);
return networkDateTime.ToLocalTime();
}
catch
catch (Exception)
{
return DateTime.Now;
}
@@ -112,9 +122,11 @@ namespace Ink_Canvas
timerCheckAutoFold.Interval = 500;
timerCheckAutoUpdateWithSilence.Elapsed += timerCheckAutoUpdateWithSilence_Elapsed;
timerCheckAutoUpdateWithSilence.Interval = 1000 * 60 * 10;
timerCheckAutoUpdateRetry.Elapsed += timerCheckAutoUpdateRetry_Elapsed;
timerCheckAutoUpdateRetry.Interval = 1000 * 60 * 10;
WaterMarkTime.DataContext = nowTimeVM;
WaterMarkDate.DataContext = nowTimeVM;
timerDisplayTime.Elapsed += async (s, e) => await TimerDisplayTime_ElapsedAsync();
timerDisplayTime.Elapsed += TimerDisplayTime_Elapsed;
timerDisplayTime.Interval = 1000;
timerDisplayTime.Start();
timerDisplayDate.Elapsed += TimerDisplayDate_Elapsed;
@@ -126,60 +138,173 @@ namespace Ink_Canvas
timerKillProcess.Start();
nowTimeVM.nowDate = DateTime.Now.ToString("yyyy'年'MM'月'dd'日' dddd");
nowTimeVM.nowTime = DateTime.Now.ToString("tt hh'时'mm'分'ss'秒'");
// 程序启动时立即进行一次NTP同步
Task.Run(async () =>
{
try
{
await TimerNtpSync_ElapsedAsync();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"程序启动时NTP同步失败: {ex.Message}", LogHelper.LogType.Error);
}
});
// 初始化定时保存墨迹定时器
InitAutoSaveStrokesTimer();
}
// 初始化定时保存墨迹定时器
private void InitAutoSaveStrokesTimer()
{
if (autoSaveStrokesTimer == null)
{
autoSaveStrokesTimer = new DispatcherTimer();
autoSaveStrokesTimer.Tick += AutoSaveStrokesTimer_Tick;
}
// 根据设置更新定时器间隔和启动状态
UpdateAutoSaveStrokesTimer();
}
// 更新定时保存墨迹定时器状态
private void UpdateAutoSaveStrokesTimer()
{
if (autoSaveStrokesTimer == null) return;
autoSaveStrokesTimer.Stop();
if (Settings.Automation.IsEnableAutoSaveStrokes)
{
int intervalMinutes = Settings.Automation.AutoSaveStrokesIntervalMinutes;
if (intervalMinutes < 1) intervalMinutes = 1; // 最小间隔1分钟
autoSaveStrokesTimer.Interval = TimeSpan.FromMinutes(intervalMinutes);
autoSaveStrokesTimer.Start();
}
}
// 定时保存墨迹定时器事件处理
private void AutoSaveStrokesTimer_Tick(object sender, EventArgs e)
{
try
{
// 只有在画布可见且有墨迹时才保存
if (inkCanvas.Visibility == Visibility.Visible && inkCanvas.Strokes.Count > 0)
{
// 静默保存
SaveInkCanvasStrokes(false, false);
}
}
catch (Exception)
{
}
}
// NTP同步定时器事件处理
private async Task TimerNtpSync_ElapsedAsync()
{
// 防止重复同步
if (isNtpSyncing) return;
isNtpSyncing = true;
try
{
DateTime networkTime = await GetNetworkTimeAsync();
// 添加超时机制,最多等待10秒
var timeoutTask = Task.Delay(10000);
var ntpTask = GetNetworkTimeAsync();
var completedTask = await Task.WhenAny(ntpTask, timeoutTask);
if (completedTask == timeoutTask)
{
cachedNetworkTime = DateTime.Now;
lastNtpSyncTime = DateTime.Now;
useNetworkTime = false;
networkTimeOffset = TimeSpan.Zero;
return;
}
DateTime networkTime = await ntpTask;
DateTime localTime = DateTime.Now;
cachedNetworkTime = networkTime;
lastNtpSyncTime = DateTime.Now;
lastNtpSyncTime = localTime;
// 计算网络时间与本地时间的偏移量
networkTimeOffset = networkTime - localTime;
// 如果时间差超过3分钟,则使用网络时间
useNetworkTime = Math.Abs(networkTimeOffset.TotalMinutes) > 3.0;
}
catch
catch (Exception ex)
{
// NTP同步失败时,保持使用本地时间
cachedNetworkTime = DateTime.Now;
lastNtpSyncTime = DateTime.Now;
useNetworkTime = false;
networkTimeOffset = TimeSpan.Zero;
LogHelper.WriteLogToFile($"NTP同步失败: {ex.Message}", LogHelper.LogType.Warning);
}
finally
{
isNtpSyncing = false;
}
}
// 修改TimerDisplayTime_ElapsedAsync方法,使用缓存的网络时间
private async Task TimerDisplayTime_ElapsedAsync()
// 优化后的时间显示方法,仅在NTP同步时计算网络时间偏移
private void TimerDisplayTime_Elapsed(object sender, ElapsedEventArgs e)
{
DateTime localTime = DateTime.Now;
DateTime displayTime = localTime; // 默认使用本地时间
// 如果还没有进行过NTP同步,或者距离上次同步超过2小时,则进行一次同步
if (lastNtpSyncTime == DateTime.MinValue ||
(DateTime.Now - lastNtpSyncTime).TotalHours >= 2)
// 检测系统时间是否发生重大跳跃(超过2分钟)
TimeSpan timeJump = localTime - lastLocalTime;
double timeJumpMinutes = Math.Abs(timeJump.TotalMinutes);
if (timeJumpMinutes > 3 && !isNtpSyncing)
{
try
// 系统时间发生重大变化(超过3分钟),立即触发NTP同步
// 使用异步方式触发NTP同步,避免阻塞主线程
Task.Run(async () =>
{
DateTime networkTime = await GetNetworkTimeAsync();
cachedNetworkTime = networkTime;
lastNtpSyncTime = DateTime.Now;
}
catch
{
// 网络时间获取失败时,使用本地时间
cachedNetworkTime = localTime;
}
try
{
await TimerNtpSync_ElapsedAsync();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"时间跳跃触发的NTP同步失败: {ex.Message}", LogHelper.LogType.Error);
}
});
}
lastLocalTime = localTime;
// 如果启用网络时间且偏移量已计算,则应用偏移量
if (useNetworkTime && networkTimeOffset != TimeSpan.Zero)
{
displayTime = localTime + networkTimeOffset;
}
// 使用缓存的网络时间进行显示
TimeSpan timeDifference = cachedNetworkTime - localTime;
double timeDifferenceMinutes = Math.Abs(timeDifference.TotalMinutes);
// 格式化时间字符串
string timeString = displayTime.ToString("tt hh'时'mm'分'ss'秒'");
// 如果网络时间与本地时间相差不超过3分钟,则使用本地时间
// 否则使用网络时间
displayTime = timeDifferenceMinutes <= 3.0 ? localTime : cachedNetworkTime;
// 只更新时间,日期由原有逻辑定时更新即可
Dispatcher.Invoke(() =>
// 只有当时间字符串发生变化时才更新UI,避免不必要的UI刷新
if (timeString != lastDisplayedTime)
{
nowTimeVM.nowTime = displayTime.ToString("tt hh'时'mm'分'ss'秒'");
});
lastDisplayedTime = timeString;
// 使用BeginInvoke异步更新UI,避免阻塞
Dispatcher.BeginInvoke(new Action(() =>
{
nowTimeVM.nowTime = timeString;
}));
}
}
// 修改TimerDisplayDate_Elapsed方法中的日期格式
@@ -206,6 +331,8 @@ namespace Ink_Canvas
{
var processes = Process.GetProcessesByName("EasiNote");
if (processes.Length > 0) arg += " /IM EasiNote.exe";
var seewoStartProcesses = Process.GetProcessesByName("SeewoStart");
if (seewoStartProcesses.Length > 0) arg += " /IM SeewoStart.exe";
}
if (Settings.Automation.IsAutoKillHiteAnnotation)
@@ -387,6 +514,14 @@ namespace Ink_Canvas
if (isFloatingBarChangingHideMode) return;
try
{
// 优先使用窗口概览模型进行检测
if (_windowOverviewModel != null)
{
CheckAutoFoldWithWindowOverviewModel();
return;
}
// 如果窗口概览模型未初始化,回退到传统的进程检测方式
var windowProcessName = ForegroundWindowInfo.ProcessName();
var windowTitle = ForegroundWindowInfo.WindowTitle();
//LogHelper.WriteLogToFile("windowTitle | " + windowTitle + " | windowProcessName | " + windowProcessName);
@@ -402,10 +537,22 @@ namespace Ink_Canvas
Trace.WriteLine(ForegroundWindowInfo.ProcessPath());
Trace.WriteLine(version);
Trace.WriteLine(prodName);
if (version.StartsWith("5.") && Settings.Automation.IsAutoFoldInEasiNote && (!(windowTitle.Length == 0 && ForegroundWindowInfo.WindowRect().Height < 500) ||
!Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno))
if (version.StartsWith("5.") && Settings.Automation.IsAutoFoldInEasiNote)
{ // EasiNote5
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
// 检查是否是桌面批注窗口
bool isAnnotationWindow = windowTitle.Length == 0 && ForegroundWindowInfo.WindowRect().Height < 500;
// 如果启用了忽略桌面批注窗口功能,且当前是批注窗口
if (Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno && isAnnotationWindow)
{
// 强制保持收纳状态
if (!isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
}
else if (!isAnnotationWindow)
{
// 非批注窗口时正常收纳
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
}
}
else if (version.StartsWith("3.") && Settings.Automation.IsAutoFoldInEasiNote3)
{ // EasiNote3
@@ -595,6 +742,225 @@ namespace Ink_Canvas
catch { }
}
/// <summary>
/// 检查进程是否在用户的自动收纳设置中启用
/// </summary>
private bool IsProcessInAutoFoldSettings(string processName, WindowInfo windowInfo = null)
{
// 根据进程名和窗口信息检查是否在自动收纳设置中
switch (processName)
{
case "EasiNote":
// EasiNote需要检查版本
if (windowInfo != null && !string.IsNullOrEmpty(windowInfo.ProcessPath) && windowInfo.ProcessPath != "Unknown")
{
try
{
var versionInfo = FileVersionInfo.GetVersionInfo(windowInfo.ProcessPath);
string version = versionInfo.FileVersion;
string prodName = versionInfo.ProductName;
if (version != null && version.StartsWith("5.") && Settings.Automation.IsAutoFoldInEasiNote)
return true;
if (version != null && version.StartsWith("3.") && Settings.Automation.IsAutoFoldInEasiNote3)
return true;
if (prodName != null && prodName.Contains("3C") && Settings.Automation.IsAutoFoldInEasiNote3C)
return true;
}
catch { }
}
return false;
case "EasiCamera":
return Settings.Automation.IsAutoFoldInEasiCamera;
case "EasiNote5C":
return Settings.Automation.IsAutoFoldInEasiNote5C;
case "BoardService":
case "seewoPincoTeacher":
return Settings.Automation.IsAutoFoldInSeewoPincoTeacher;
case "HiteCamera":
return Settings.Automation.IsAutoFoldInHiteCamera;
case "HiteTouchPro":
return Settings.Automation.IsAutoFoldInHiteTouchPro;
case "HiteLightBoard":
return Settings.Automation.IsAutoFoldInHiteLightBoard;
case "WxBoardMain":
return Settings.Automation.IsAutoFoldInWxBoardMain;
case "MicrosoftWhiteboard":
case "msedgewebview2":
return Settings.Automation.IsAutoFoldInMSWhiteboard;
case "Amdox.WhiteBoard":
return Settings.Automation.IsAutoFoldInAdmoxWhiteboard;
case "Amdox.Booth":
return Settings.Automation.IsAutoFoldInAdmoxBooth;
case "QPoint":
return Settings.Automation.IsAutoFoldInQPoint;
case "YiYunVisualPresenter":
return Settings.Automation.IsAutoFoldInYiYunVisualPresenter;
case "WhiteBoard":
// MaxHub需要检查窗口标题
if (windowInfo != null && !string.IsNullOrEmpty(windowInfo.Title) &&
windowInfo.Title.Contains("白板书写") && Settings.Automation.IsAutoFoldInMaxHubWhiteboard)
{
if (!string.IsNullOrEmpty(windowInfo.ProcessPath) && windowInfo.ProcessPath != "Unknown")
{
try
{
var versionInfo = FileVersionInfo.GetVersionInfo(windowInfo.ProcessPath);
if (versionInfo.FileVersion != null && versionInfo.FileVersion.StartsWith("6.") &&
versionInfo.ProductName == "WhiteBoard")
return true;
}
catch { }
}
}
return false;
default:
return false;
}
}
/// <summary>
/// 使用窗口概览模型检测是否需要自动收纳
/// </summary>
private void CheckAutoFoldWithWindowOverviewModel()
{
try
{
if (_windowOverviewModel == null) return;
// 获取浮动栏的位置和大小
Application.Current.Dispatcher.Invoke(() =>
{
try
{
var floatingBarMargin = ViewboxFloatingBar.Margin;
var floatingBarWidth = ViewboxFloatingBar.ActualWidth;
var floatingBarHeight = ViewboxFloatingBar.ActualHeight;
// 如果浮动栏未显示或大小为0,跳过检测
if (floatingBarWidth <= 0 || floatingBarHeight <= 0) return;
// 计算浮动栏在屏幕上的位置(考虑DPI缩放)
var screen = WinForms.Screen.PrimaryScreen;
var dpiScaleX = PresentationSource.FromVisual(this)?.CompositionTarget?.TransformToDevice.M11 ?? 1.0;
var dpiScaleY = PresentationSource.FromVisual(this)?.CompositionTarget?.TransformToDevice.M22 ?? 1.0;
// 将WPF坐标转换为屏幕坐标
var point = ViewboxFloatingBar.PointToScreen(new System.Windows.Point(0, 0));
int left = (int)(point.X);
int top = (int)(point.Y);
int right = left + (int)(floatingBarWidth * dpiScaleX);
int bottom = top + (int)(floatingBarHeight * dpiScaleY);
// 创建检测区域(稍微扩大一点,确保检测到覆盖)
var detectionArea = new WindowRect
{
Left = left - 5,
Top = top - 5,
Right = right + 5,
Bottom = bottom + 5
};
// 排除当前应用程序的进程
var excludeProcesses = new List<string> { "InkCanvasForClass", "Ink Canvas" };
// 检查 OldZyBoard(通过窗口标题检测)
bool isOldZyBoardWindowExisted = Settings.Automation.IsAutoFoldInOldZyBoard &&
(WinTabWindowsChecker.IsWindowExisted("WhiteBoard - DrawingWindow") ||
WinTabWindowsChecker.IsWindowExisted("InstantAnnotationWindow"));
if (isOldZyBoardWindowExisted)
{
if (!isFloatingBarFolded)
{
FoldFloatingBar_MouseUp(new object(), null);
}
}
else if (!isOldZyBoardWindowExisted && isFloatingBarFolded && !foldFloatingBarByUser)
{
// OldZyBoard窗口退出时,如果未开启保持收纳模式,则展开
if (!Settings.Automation.KeepFoldAfterSoftwareExit)
{
UnFoldFloatingBar_MouseUp(new object(), null);
}
return; // OldZyBoard 使用特殊检测方式,处理完后直接返回
}
if (isOldZyBoardWindowExisted)
{
return; // OldZyBoard 窗口存在时,直接返回,不继续检测其他窗口
}
// 获取覆盖浮动栏的所有窗口
var coveringWindows = _windowOverviewModel.GetCoveringWindows(detectionArea, excludeProcesses, 0.1);
// 检查是否有覆盖窗口在用户的自动收纳设置中
bool shouldFold = false;
foreach (var window in coveringWindows)
{
// 检查窗口是否全屏(全屏窗口优先)
bool isFullScreen = window.IsFullScreen;
// 检查窗口大小是否接近全屏(用于检测二级菜单等)
bool isNearFullScreen = false;
try
{
var screenBounds = WinForms.Screen.FromHandle(window.Handle).Bounds;
isNearFullScreen = window.Rect.Width >= screenBounds.Width - 16 &&
window.Rect.Height >= screenBounds.Height - 16;
}
catch { }
// 如果窗口是全屏或接近全屏,且进程在自动收纳设置中,则应该收纳
if ((isFullScreen || isNearFullScreen) && IsProcessInAutoFoldSettings(window.ProcessName, window))
{
shouldFold = true;
break; // 找到匹配的窗口就退出
}
}
// 如果检测到应该收纳的窗口,且当前未收纳,则收纳
if (shouldFold && !isFloatingBarFolded)
{
FoldFloatingBar_MouseUp(new object(), null);
}
// 如果未检测到应该收纳的窗口,且当前已收纳(且不是用户手动收纳),则展开
else if (!shouldFold && isFloatingBarFolded && !foldFloatingBarByUser)
{
// 检查是否启用了软件退出后保持收纳模式
if (!Settings.Automation.KeepFoldAfterSoftwareExit)
{
UnFoldFloatingBar_MouseUp(new object(), null);
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"窗口概览模型检测失败: {ex.Message}", LogHelper.LogType.Error);
}
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"窗口概览模型自动收纳检测异常: {ex.Message}", LogHelper.LogType.Error);
}
}
private void timerCheckAutoUpdateWithSilence_Elapsed(object sender, ElapsedEventArgs e)
{
// 停止计时器,避免重复触发
@@ -747,5 +1113,92 @@ namespace Ink_Canvas
timerCheckAutoUpdateWithSilence.Start();
}
}
// 检查更新失败重试定时器事件处理
private async void timerCheckAutoUpdateRetry_Elapsed(object sender, ElapsedEventArgs e)
{
// 停止定时器,避免重复触发
timerCheckAutoUpdateRetry.Stop();
try
{
// 检查是否启用了自动更新
if (!Settings.Startup.IsAutoUpdate)
{
LogHelper.WriteLogToFile("AutoUpdate | Auto update is disabled, stopping retry timer");
return;
}
// 增加重试计数
updateCheckRetryCount++;
LogHelper.WriteLogToFile($"AutoUpdate | Retry check attempt {updateCheckRetryCount}/{MAX_UPDATE_CHECK_RETRIES}");
// 检查是否超过最大重试次数
if (updateCheckRetryCount > MAX_UPDATE_CHECK_RETRIES)
{
LogHelper.WriteLogToFile("AutoUpdate | Maximum retry attempts reached, stopping retry timer", LogHelper.LogType.Warning);
return;
}
// 执行更新检查
LogHelper.WriteLogToFile("AutoUpdate | Retrying update check after failure");
// 清除之前的更新状态
AvailableLatestVersion = null;
AvailableLatestLineGroup = null;
// 使用当前选择的更新通道检查更新
var (remoteVersion, lineGroup, apiReleaseNotes) = await AutoUpdateHelper.CheckForUpdates(Settings.Startup.UpdateChannel);
AvailableLatestVersion = remoteVersion;
AvailableLatestLineGroup = lineGroup;
if (AvailableLatestVersion != null)
{
// 检查更新成功,重置重试计数
updateCheckRetryCount = 0;
LogHelper.WriteLogToFile($"AutoUpdate | Retry successful, found new version: {AvailableLatestVersion}");
// 停止重试定时器,因为已经找到了更新
return;
}
else
{
// 检查更新仍然失败,继续重试
LogHelper.WriteLogToFile($"AutoUpdate | Retry {updateCheckRetryCount} failed, will retry in 10 minutes");
// 重新启动定时器,10分钟后再次尝试
timerCheckAutoUpdateRetry.Start();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"AutoUpdate | Error in retry check: {ex.Message}", LogHelper.LogType.Error);
// 出错时也重新启动定时器,稍后再检查
if (updateCheckRetryCount <= MAX_UPDATE_CHECK_RETRIES)
{
timerCheckAutoUpdateRetry.Start();
}
}
}
// 重置更新检查重试状态
public void ResetUpdateCheckRetry()
{
try
{
// 停止重试定时器
timerCheckAutoUpdateRetry.Stop();
// 重置重试计数
updateCheckRetryCount = 0;
LogHelper.WriteLogToFile("AutoUpdate | Update check retry state reset");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"AutoUpdate | Error resetting retry state: {ex.Message}", LogHelper.LogType.Error);
}
}
}
}
}
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -209,15 +209,15 @@ namespace Ink_Canvas
try
{
// 获取全局快捷键管理器
var hotkeyManagerField = typeof(MainWindow).GetField("_globalHotkeyManager",
var hotkeyManagerField = typeof(MainWindow).GetField("_globalHotkeyManager",
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var hotkeyManager = hotkeyManagerField?.GetValue(mainWin) as GlobalHotkeyManager;
if (hotkeyManager != null)
{
// 禁用所有快捷键
hotkeyManager.DisableHotkeyRegistration();
// 更新菜单项文本和状态
var menuItem = sender as MenuItem;
if (menuItem != null)
+3 -3
View File
@@ -10,7 +10,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CJK_mkp")]
[assembly: AssemblyProduct("InkCanvasForClass")]
[assembly: AssemblyCopyright("Copyright © HARKOTEK Studio 2024")]
[assembly: AssemblyCopyright("Copyright © CJK_mkp 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -49,5 +49,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.11.0")]
[assembly: AssemblyFileVersion("1.7.11.0")]
[assembly: AssemblyVersion("1.7.18.3")]
[assembly: AssemblyFileVersion("1.7.18.3")]
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>dist\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
</PropertyGroup>
</Project>
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
</Project>
+9
View File
@@ -74,5 +74,14 @@ namespace Ink_Canvas.Properties {
return ResourceManager.GetStream("TimerDownNotice", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream.
/// </summary>
internal static UnmanagedMemoryStream ProgressiveAudio {
get {
return ResourceManager.GetStream("ProgressiveAudio", resourceCulture);
}
}
}
}
+3
View File
@@ -121,4 +121,7 @@
<data name="TimerDownNotice" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\TimerDownNotice.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="ProgressiveAudio" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ProgressiveAudio.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.
+32 -32
View File
@@ -1,100 +1,100 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="IconBrush" Color="White"></SolidColorBrush>
<SolidColorBrush x:Key="IconBrush" Color="{DynamicResource IconForeground}"></SolidColorBrush>
<DrawingImage x:Key="CursorIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M22.7989,10.1653L1.14304,1.14304 10.1653,22.7989 12.8305,14.9518 19.6892,21.8105 21.8105,19.6892 14.9518,12.8305 22.7989,10.1653z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M22.7989,10.1653L1.14304,1.14304 10.1653,22.7989 12.8305,14.9518 19.6892,21.8105 21.8105,19.6892 14.9518,12.8305 22.7989,10.1653z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="PenIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M20.4786,1.42438C19.9985,1.23743 19.4847,1.15194 18.9698,1.17319 18.4549,1.19444 17.9499,1.32197 17.4869,1.54789 17.0368,1.76752 16.6358,2.07554 16.3083,2.45361L3.85516,14.9067 9.08243,20.134 21.5311,7.68529C21.9113,7.36382 22.223,6.96912 22.447,6.52438 22.6786,6.06462 22.8113,5.56167 22.8365,5.04763 22.8616,4.5336 22.7787,4.02012 22.593,3.54002 22.4073,3.05994 22.1232,2.62403 21.759,2.25988 21.3949,1.89574 20.9587,1.61132 20.4786,1.42438z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M7.28056,21.1605L2.8286,16.7086 1.15912,22.83 7.28056,21.1605z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M20.4786,1.42438C19.9985,1.23743 19.4847,1.15194 18.9698,1.17319 18.4549,1.19444 17.9499,1.32197 17.4869,1.54789 17.0368,1.76752 16.6358,2.07554 16.3083,2.45361L3.85516,14.9067 9.08243,20.134 21.5311,7.68529C21.9113,7.36382 22.223,6.96912 22.447,6.52438 22.6786,6.06462 22.8113,5.56167 22.8365,5.04763 22.8616,4.5336 22.7787,4.02012 22.593,3.54002 22.4073,3.05994 22.1232,2.62403 21.759,2.25988 21.3949,1.89574 20.9587,1.61132 20.4786,1.42438z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M7.28056,21.1605L2.8286,16.7086 1.15912,22.83 7.28056,21.1605z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="EraserIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M15.6314,20.7262L22.7921,13.5655C24.3494,12.141,24.2819,9.81776,22.8105,8.34633L16.7793,2.31508C15.3547,0.757753,13.0315,0.825236,11.5601,2.29666L4.38099,9.47574 15.6314,20.7262z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M14.2172,22.1404L2.96677,10.89 1.20761,12.6491C-0.34971,14.0737,-0.281711,16.3974,1.18971,17.8688L6.15089,22.83 13.5276,22.83 14.2172,22.1404z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M15.6314,20.7262L22.7921,13.5655C24.3494,12.141,24.2819,9.81776,22.8105,8.34633L16.7793,2.31508C15.3547,0.757753,13.0315,0.825236,11.5601,2.29666L4.38099,9.47574 15.6314,20.7262z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M14.2172,22.1404L2.96677,10.89 1.20761,12.6491C-0.34971,14.0737,-0.281711,16.3974,1.18971,17.8688L6.15089,22.83 13.5276,22.83 14.2172,22.1404z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="TrashBinIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M2.15454,7.07729L2.15454,5.1082 7.07727,5.1082 7.07727,4.12365C7.07727,3.30648 7.47109,2.57791 7.98305,2.0758 8.49501,1.56383 9.22358,1.17001 10.0309,1.17001L13.9691,1.17001C14.7863,1.17001 15.5148,1.56383 16.0169,2.0758 16.5289,2.58776 16.9227,3.31632 16.9227,4.12365L16.9227,5.1082 21.8454,5.1082 21.8454,7.07729 2.15454,7.07729z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F0 M24,24z M0,0z M4.12363,19.7779C4.12363,20.6148 4.51745,21.3729 5.02941,21.8947 5.54138,22.4165 6.26994,22.83 7.07727,22.83L16.9227,22.83C17.7399,22.83 18.4685,22.4165 18.9706,21.8947 19.4825,21.3729 19.8764,20.6148 19.8764,19.7779L19.8764,8.06183 4.12363,8.06183 4.12363,19.7779z M12.9845,11.0155L14.9536,11.0155 14.9536,18.8918 12.9845,18.8918 12.9845,11.0155z M9.04636,11.0155L11.0154,11.0155 11.0154,18.8918 9.04636,18.8918 9.04636,11.0155z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M2.15454,7.07729L2.15454,5.1082 7.07727,5.1082 7.07727,4.12365C7.07727,3.30648 7.47109,2.57791 7.98305,2.0758 8.49501,1.56383 9.22358,1.17001 10.0309,1.17001L13.9691,1.17001C14.7863,1.17001 15.5148,1.56383 16.0169,2.0758 16.5289,2.58776 16.9227,3.31632 16.9227,4.12365L16.9227,5.1082 21.8454,5.1082 21.8454,7.07729 2.15454,7.07729z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F0 M24,24z M0,0z M4.12363,19.7779C4.12363,20.6148 4.51745,21.3729 5.02941,21.8947 5.54138,22.4165 6.26994,22.83 7.07727,22.83L16.9227,22.83C17.7399,22.83 18.4685,22.4165 18.9706,21.8947 19.4825,21.3729 19.8764,20.6148 19.8764,19.7779L19.8764,8.06183 4.12363,8.06183 4.12363,19.7779z M12.9845,11.0155L14.9536,11.0155 14.9536,18.8918 12.9845,18.8918 12.9845,11.0155z M9.04636,11.0155L11.0154,11.0155 11.0154,18.8918 9.04636,18.8918 9.04636,11.0155z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="LassoSelectIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M2.12162,2.12162C2.73093,1.51232,3.55732,1.17001,4.41901,1.17001L5.50201,1.17001 5.50201,3.33601 4.41901,3.33601C4.13178,3.33601 3.85632,3.45011 3.65321,3.65321 3.45011,3.85632 3.33601,4.13178 3.33601,4.41901L3.33601,5.50201 1.17001,5.50201 1.17001,4.41901C1.17001,3.55732,1.51232,2.73093,2.12162,2.12162z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M18.498,1.17001L19.581,1.17001C20.4427,1.17001 21.2691,1.51232 21.8784,2.12162 22.4877,2.73093 22.83,3.55732 22.83,4.41901L22.83,5.50201 20.664,5.50201 20.664,4.41901C20.664,4.13178 20.5499,3.85632 20.3468,3.65321 20.1437,3.45011 19.8682,3.33601 19.581,3.33601L18.498,3.33601 18.498,1.17001z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.33601,19.581L3.33601,18.498 1.17001,18.498 1.17001,19.581C1.17001,20.4427 1.51232,21.2691 2.12162,21.8784 2.73093,22.4877 3.55732,22.83 4.41901,22.83L5.50201,22.83 5.50201,20.664 4.41901,20.664C4.13178,20.664 3.85632,20.5499 3.65321,20.3468 3.45011,20.1437 3.33601,19.8682 3.33601,19.581z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M7.66801,1.17001L10.917,1.17001 10.917,3.33601 7.66801,3.33601 7.66801,1.17001z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M12,20.664L7.66801,20.664 7.66801,22.83 12,22.83 12,20.664z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M13.083,1.17001L16.332,1.17001 16.332,3.33601 13.083,3.33601 13.083,1.17001z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.33601,10.917L3.33601,7.66801 1.17001,7.66801 1.17001,10.917 3.33601,10.917z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M22.83,7.66801L22.83,12 20.664,12 20.664,7.66801 22.83,7.66801z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.33601,16.332L3.33601,13.083 1.17001,13.083 1.17001,16.332 3.33601,16.332z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M10.7469,10.747L22.83,15.781 18.4517,17.2681 22.2785,21.0949 21.0949,22.2785 17.2681,18.4517 15.781,22.83 10.7469,10.747z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M2.12162,2.12162C2.73093,1.51232,3.55732,1.17001,4.41901,1.17001L5.50201,1.17001 5.50201,3.33601 4.41901,3.33601C4.13178,3.33601 3.85632,3.45011 3.65321,3.65321 3.45011,3.85632 3.33601,4.13178 3.33601,4.41901L3.33601,5.50201 1.17001,5.50201 1.17001,4.41901C1.17001,3.55732,1.51232,2.73093,2.12162,2.12162z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M18.498,1.17001L19.581,1.17001C20.4427,1.17001 21.2691,1.51232 21.8784,2.12162 22.4877,2.73093 22.83,3.55732 22.83,4.41901L22.83,5.50201 20.664,5.50201 20.664,4.41901C20.664,4.13178 20.5499,3.85632 20.3468,3.65321 20.1437,3.45011 19.8682,3.33601 19.581,3.33601L18.498,3.33601 18.498,1.17001z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.33601,19.581L3.33601,18.498 1.17001,18.498 1.17001,19.581C1.17001,20.4427 1.51232,21.2691 2.12162,21.8784 2.73093,22.4877 3.55732,22.83 4.41901,22.83L5.50201,22.83 5.50201,20.664 4.41901,20.664C4.13178,20.664 3.85632,20.5499 3.65321,20.3468 3.45011,20.1437 3.33601,19.8682 3.33601,19.581z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M7.66801,1.17001L10.917,1.17001 10.917,3.33601 7.66801,3.33601 7.66801,1.17001z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M12,20.664L7.66801,20.664 7.66801,22.83 12,22.83 12,20.664z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M13.083,1.17001L16.332,1.17001 16.332,3.33601 13.083,3.33601 13.083,1.17001z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.33601,10.917L3.33601,7.66801 1.17001,7.66801 1.17001,10.917 3.33601,10.917z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M22.83,7.66801L22.83,12 20.664,12 20.664,7.66801 22.83,7.66801z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.33601,16.332L3.33601,13.083 1.17001,13.083 1.17001,16.332 3.33601,16.332z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M10.7469,10.747L22.83,15.781 18.4517,17.2681 22.2785,21.0949 21.0949,22.2785 17.2681,18.4517 15.781,22.83 10.7469,10.747z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="ShapesIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M17.8604,10.7597L12.0068,1.17001 6.13961,10.7597 17.8604,10.7597z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M10.9345,13.2403L1.34476,13.2403 1.34476,22.83 10.9345,22.83 10.9345,13.2403z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M17.8604,13.2403C15.2122,13.2403 13.0655,15.387 13.0655,18.0352 13.0655,20.6833 15.2122,22.83 17.8604,22.83 20.5085,22.83 22.6552,20.6833 22.6552,18.0352 22.6552,15.387 20.5085,13.2403 17.8604,13.2403z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M17.8604,10.7597L12.0068,1.17001 6.13961,10.7597 17.8604,10.7597z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M10.9345,13.2403L1.34476,13.2403 1.34476,22.83 10.9345,22.83 10.9345,13.2403z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M17.8604,13.2403C15.2122,13.2403 13.0655,15.387 13.0655,18.0352 13.0655,20.6833 15.2122,22.83 17.8604,22.83 20.5085,22.83 22.6552,20.6833 22.6552,18.0352 22.6552,15.387 20.5085,13.2403 17.8604,13.2403z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="UndoIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M8.71408,16.8493L0.874451,9.00964 8.71408,1.17001 8.71408,7.42358 15.7239,7.42358C16.7074,7.42358 17.6791,7.62744 18.583,8.02124 19.4866,8.41493 20.3023,8.98966 20.9857,9.70849 21.6689,10.4271 22.2069,11.276 22.5726,12.2047 22.9383,13.1333 23.1256,14.126 23.1256,15.1268 23.1256,16.1276 22.9383,17.1203 22.5726,18.0489 22.2069,18.9776 21.6689,19.8264 20.9857,20.5451 20.3023,21.2639 19.4866,21.8387 18.583,22.2324 17.6791,22.6262 16.7074,22.83 15.7239,22.83L10.437,22.83 10.437,19.6579 15.7239,19.6579C16.2679,19.6579 16.8086,19.5453 17.3159,19.3243 17.8235,19.1031 18.29,18.7767 18.6867,18.3594 19.0835,17.942 19.4023,17.4422 19.6211,16.8866 19.8399,16.3308 19.9534,15.7326 19.9534,15.1268 19.9534,14.5209 19.8399,13.9227 19.6211,13.367 19.4023,12.8114 19.0835,12.3115 18.6867,11.8941 18.29,11.4769 17.8235,11.1505 17.3159,10.9293 16.8086,10.7083 16.2679,10.5957 15.7239,10.5957L8.71408,10.5957 8.71408,16.8493z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M8.71408,16.8493L0.874451,9.00964 8.71408,1.17001 8.71408,7.42358 15.7239,7.42358C16.7074,7.42358 17.6791,7.62744 18.583,8.02124 19.4866,8.41493 20.3023,8.98966 20.9857,9.70849 21.6689,10.4271 22.2069,11.276 22.5726,12.2047 22.9383,13.1333 23.1256,14.126 23.1256,15.1268 23.1256,16.1276 22.9383,17.1203 22.5726,18.0489 22.2069,18.9776 21.6689,19.8264 20.9857,20.5451 20.3023,21.2639 19.4866,21.8387 18.583,22.2324 17.6791,22.6262 16.7074,22.83 15.7239,22.83L10.437,22.83 10.437,19.6579 15.7239,19.6579C16.2679,19.6579 16.8086,19.5453 17.3159,19.3243 17.8235,19.1031 18.29,18.7767 18.6867,18.3594 19.0835,17.942 19.4023,17.4422 19.6211,16.8866 19.8399,16.3308 19.9534,15.7326 19.9534,15.1268 19.9534,14.5209 19.8399,13.9227 19.6211,13.367 19.4023,12.8114 19.0835,12.3115 18.6867,11.8941 18.29,11.4769 17.8235,11.1505 17.3159,10.9293 16.8086,10.7083 16.2679,10.5957 15.7239,10.5957L8.71408,10.5957 8.71408,16.8493z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="RedoIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M15.2859,16.8493L23.1255,9.00964 15.2859,1.17001 15.2859,7.42358 8.27607,7.42358C7.29262,7.42358 6.32086,7.62744 5.41703,8.02124 4.51341,8.41493 3.69773,8.98966 3.01434,9.70849 2.33111,10.4271 1.79312,11.276 1.42741,12.2047 1.06174,13.1333 0.874422,14.126 0.874422,15.1268 0.874422,16.1276 1.06174,17.1203 1.42741,18.0489 1.79312,18.9776 2.33111,19.8264 3.01434,20.5451 3.69773,21.2639 4.51341,21.8387 5.41703,22.2324 6.32086,22.6262 7.29262,22.83 8.27607,22.83L13.563,22.83 13.563,19.6579 8.27607,19.6579C7.7321,19.6579 7.19139,19.5453 6.68406,19.3243 6.17652,19.1031 5.70999,18.7767 5.31333,18.3594 4.91651,17.942 4.59775,17.4422 4.37894,16.8866 4.1601,16.3308 4.04656,15.7326 4.04656,15.1268 4.04656,14.5209 4.1601,13.9227 4.37894,13.367 4.59775,12.8114 4.91651,12.3115 5.31333,11.8941 5.70999,11.4769 6.17652,11.1505 6.68406,10.9293 7.19139,10.7083 7.7321,10.5957 8.27607,10.5957L15.2859,10.5957 15.2859,16.8493z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M15.2859,16.8493L23.1255,9.00964 15.2859,1.17001 15.2859,7.42358 8.27607,7.42358C7.29262,7.42358 6.32086,7.62744 5.41703,8.02124 4.51341,8.41493 3.69773,8.98966 3.01434,9.70849 2.33111,10.4271 1.79312,11.276 1.42741,12.2047 1.06174,13.1333 0.874422,14.126 0.874422,15.1268 0.874422,16.1276 1.06174,17.1203 1.42741,18.0489 1.79312,18.9776 2.33111,19.8264 3.01434,20.5451 3.69773,21.2639 4.51341,21.8387 5.41703,22.2324 6.32086,22.6262 7.29262,22.83 8.27607,22.83L13.563,22.83 13.563,19.6579 8.27607,19.6579C7.7321,19.6579 7.19139,19.5453 6.68406,19.3243 6.17652,19.1031 5.70999,18.7767 5.31333,18.3594 4.91651,17.942 4.59775,17.4422 4.37894,16.8866 4.1601,16.3308 4.04656,15.7326 4.04656,15.1268 4.04656,14.5209 4.1601,13.9227 4.37894,13.367 4.59775,12.8114 4.91651,12.3115 5.31333,11.8941 5.70999,11.4769 6.17652,11.1505 6.68406,10.9293 7.19139,10.7083 7.7321,10.5957 8.27607,10.5957L15.2859,10.5957 15.2859,16.8493z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="MoreToolsIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.336,1.17001C2.13975,1.17001,1.17,2.13976,1.17,3.33601L1.17,8.75101C1.17,9.94726,2.13975,10.917,3.336,10.917L8.751,10.917C9.94725,10.917,10.917,9.94726,10.917,8.75101L10.917,3.33601C10.917,2.13976,9.94725,1.17001,8.751,1.17001L3.336,1.17001z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M15.249,1.17001C14.0527,1.17001,13.083,2.13976,13.083,3.33601L13.083,8.75101C13.083,9.94726,14.0527,10.917,15.249,10.917L20.664,10.917C21.8602,10.917,22.83,9.94726,22.83,8.75101L22.83,3.33601C22.83,2.13976,21.8602,1.17001,20.664,1.17001L15.249,1.17001z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.336,13.083C2.13975,13.083,1.17,14.0528,1.17,15.249L1.17,20.664C1.17,21.8603,2.13975,22.83,3.336,22.83L8.751,22.83C9.94725,22.83,10.917,21.8603,10.917,20.664L10.917,15.249C10.917,14.0528,9.94725,13.083,8.751,13.083L3.336,13.083z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M15.249,13.083C14.0527,13.083,13.083,14.0528,13.083,15.249L13.083,20.664C13.083,21.8603,14.0527,22.83,15.249,22.83L20.664,22.83C21.8602,22.83,22.83,21.8603,22.83,20.664L22.83,15.249C22.83,14.0528,21.8602,13.083,20.664,13.083L15.249,13.083z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.336,1.17001C2.13975,1.17001,1.17,2.13976,1.17,3.33601L1.17,8.75101C1.17,9.94726,2.13975,10.917,3.336,10.917L8.751,10.917C9.94725,10.917,10.917,9.94726,10.917,8.75101L10.917,3.33601C10.917,2.13976,9.94725,1.17001,8.751,1.17001L3.336,1.17001z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M15.249,1.17001C14.0527,1.17001,13.083,2.13976,13.083,3.33601L13.083,8.75101C13.083,9.94726,14.0527,10.917,15.249,10.917L20.664,10.917C21.8602,10.917,22.83,9.94726,22.83,8.75101L22.83,3.33601C22.83,2.13976,21.8602,1.17001,20.664,1.17001L15.249,1.17001z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M3.336,13.083C2.13975,13.083,1.17,14.0528,1.17,15.249L1.17,20.664C1.17,21.8603,2.13975,22.83,3.336,22.83L8.751,22.83C9.94725,22.83,10.917,21.8603,10.917,20.664L10.917,15.249C10.917,14.0528,9.94725,13.083,8.751,13.083L3.336,13.083z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M15.249,13.083C14.0527,13.083,13.083,14.0528,13.083,15.249L13.083,20.664C13.083,21.8603,14.0527,22.83,15.249,22.83L20.664,22.83C21.8602,22.83,22.83,21.8603,22.83,20.664L22.83,15.249C22.83,14.0528,21.8602,13.083,20.664,13.083L15.249,13.083z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="GestureIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F0 M24,24z M0,0z M7.82154,10.0753L7.82154,3.74613C7.82154,3.06604 8.08946,2.40655 8.57377,1.92224 9.05808,1.43793 9.70726,1.17001 10.3977,1.17001 11.0881,1.17001 11.7372,1.43793 12.2216,1.92224 12.7059,2.40655 12.9738,3.05573 12.9738,3.74613L12.9738,6.37308C13.1415,6.33947 13.3139,6.32225 13.489,6.32225 14.1794,6.32225 14.8286,6.59016 15.3129,7.07447 15.4484,7.21001 15.567,7.35845 15.6675,7.5171 15.9551,7.40916 16.2634,7.35269 16.5803,7.35269 17.2707,7.35269 17.9199,7.62061 18.4042,8.10492 18.5461,8.24683 18.6695,8.4029 18.7729,8.57001 19.6856,8.26338 20.7674,8.45871 21.4647,9.15599 21.949,9.6403 22.2169,10.2998 22.2169,10.9799L22.2169,15.6169C22.2169,17.5438 21.4647,19.3574 20.1045,20.7176 18.7443,22.0778 16.9307,22.83 15.0038,22.83L13.149,22.83 13.1799,22.8094 12.8398,22.8094C11.7682,22.7579 10.7068,22.4694 9.75878,21.9541 8.70773,21.3874 7.81124,20.563 7.15175,19.5738L6.94566,19.2647C6.60562,18.7494 5.49273,16.8019 3.52458,13.3087 3.19484,12.7213 3.1021,12.0412 3.27727,11.3818 3.45245,10.7326 3.86463,10.1761 4.44168,9.83608 5.00842,9.49604 5.66791,9.35177 6.31709,9.43421 6.86548,9.50385 7.39181,9.7279 7.82154,10.0753z M10.037,3.38547C10.1297,3.28243 10.2637,3.23091 10.3977,3.23091 10.5316,3.23091 10.6656,3.29273 10.7583,3.38547 10.8614,3.47821 10.9129,3.61217 10.9129,3.74613L10.9129,11.4745C10.9129,12.0412 11.3766,12.5049 11.9433,12.5049 12.5101,12.5049 12.9738,12.0412 12.9738,11.4745L12.9738,8.89836C12.9738,8.7644 13.0356,8.63045 13.1283,8.53771 13.2211,8.43466 13.355,8.38314 13.489,8.38314 13.623,8.38314 13.7569,8.44497 13.8497,8.53771 13.9527,8.63045 14.0042,8.7644 14.0042,8.89836L14.0042,11.4745C14.0042,12.0412 14.4679,12.5049 15.0347,12.5049 15.6014,12.5049 16.0651,12.0412 16.0651,11.4745L16.0651,9.92881C16.0651,9.79485 16.1269,9.66089 16.2197,9.56815 16.3124,9.46511 16.4464,9.41359 16.5803,9.41359 16.7143,9.41359 16.8483,9.47541 16.941,9.56815 17.044,9.66089 17.0956,9.79485 17.0956,9.92881L17.0956,10.5869C17.0752,10.7163 17.0646,10.8477 17.0646,10.9799 17.0646,11.0661 17.0754,11.1499 17.0956,11.2301L17.0956,11.4745C17.0956,12.0412 17.5593,12.5049 18.126,12.5049 18.6928,12.5049 19.1565,12.0412 19.1565,11.4745L19.1565,10.8128C19.1834,10.7399 19.2266,10.6727 19.2801,10.6192 19.4759,10.4234 19.8159,10.4234 20.0117,10.6192 20.1148,10.712 20.1663,10.8459 20.1663,10.9799L20.1663,15.6169C20.1663,16.9977 19.6408,18.296 18.6618,19.2647 17.6829,20.2333 16.3949,20.7691 15.0141,20.7691L13.1593,20.7691C12.3143,20.7691 11.4796,20.5527 10.7274,20.1509 9.98548,19.749 9.3363,19.1616 8.8726,18.4506L8.66651,18.1415C8.35738,17.6675 7.23419,15.7096 5.31756,12.2989 5.24543,12.1752 5.23512,12.0412 5.26604,11.9073 5.30725,11.7733 5.38969,11.6703 5.50304,11.5981 5.66791,11.4951 5.874,11.4539 6.06978,11.4745 6.26557,11.5054 6.45105,11.5878 6.59531,11.7321L8.11007,13.2469C8.49419,13.631 9.10425,13.648 9.50833,13.2978 9.73651,13.1084 9.88244,12.8229 9.88244,12.5049L9.88244,3.74613C9.88244,3.61217,9.94426,3.47821,10.037,3.38547z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M2.99905,6.31195L1.78313,4.65293 2.61779,4.04497C3.46275,3.4267,4.37985,2.89087,5.33817,2.46838L6.27587,2.0459 7.12084,3.93162 6.18313,4.3541C5.35878,4.72506,4.56533,5.17846,3.83372,5.71429L2.99905,6.32225 2.99905,6.31195z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M18.2806,5.20935L19.1565,5.75549 20.259,4.01404 19.3832,3.4679C18.1157,2.67446,16.7452,2.0768,15.3026,1.68523L14.303,1.41731 13.7672,3.40607 14.7667,3.67399C16.0033,4.00373,17.1883,4.51895,18.2806,5.20935z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F0 M24,24z M0,0z M7.82154,10.0753L7.82154,3.74613C7.82154,3.06604 8.08946,2.40655 8.57377,1.92224 9.05808,1.43793 9.70726,1.17001 10.3977,1.17001 11.0881,1.17001 11.7372,1.43793 12.2216,1.92224 12.7059,2.40655 12.9738,3.05573 12.9738,3.74613L12.9738,6.37308C13.1415,6.33947 13.3139,6.32225 13.489,6.32225 14.1794,6.32225 14.8286,6.59016 15.3129,7.07447 15.4484,7.21001 15.567,7.35845 15.6675,7.5171 15.9551,7.40916 16.2634,7.35269 16.5803,7.35269 17.2707,7.35269 17.9199,7.62061 18.4042,8.10492 18.5461,8.24683 18.6695,8.4029 18.7729,8.57001 19.6856,8.26338 20.7674,8.45871 21.4647,9.15599 21.949,9.6403 22.2169,10.2998 22.2169,10.9799L22.2169,15.6169C22.2169,17.5438 21.4647,19.3574 20.1045,20.7176 18.7443,22.0778 16.9307,22.83 15.0038,22.83L13.149,22.83 13.1799,22.8094 12.8398,22.8094C11.7682,22.7579 10.7068,22.4694 9.75878,21.9541 8.70773,21.3874 7.81124,20.563 7.15175,19.5738L6.94566,19.2647C6.60562,18.7494 5.49273,16.8019 3.52458,13.3087 3.19484,12.7213 3.1021,12.0412 3.27727,11.3818 3.45245,10.7326 3.86463,10.1761 4.44168,9.83608 5.00842,9.49604 5.66791,9.35177 6.31709,9.43421 6.86548,9.50385 7.39181,9.7279 7.82154,10.0753z M10.037,3.38547C10.1297,3.28243 10.2637,3.23091 10.3977,3.23091 10.5316,3.23091 10.6656,3.29273 10.7583,3.38547 10.8614,3.47821 10.9129,3.61217 10.9129,3.74613L10.9129,11.4745C10.9129,12.0412 11.3766,12.5049 11.9433,12.5049 12.5101,12.5049 12.9738,12.0412 12.9738,11.4745L12.9738,8.89836C12.9738,8.7644 13.0356,8.63045 13.1283,8.53771 13.2211,8.43466 13.355,8.38314 13.489,8.38314 13.623,8.38314 13.7569,8.44497 13.8497,8.53771 13.9527,8.63045 14.0042,8.7644 14.0042,8.89836L14.0042,11.4745C14.0042,12.0412 14.4679,12.5049 15.0347,12.5049 15.6014,12.5049 16.0651,12.0412 16.0651,11.4745L16.0651,9.92881C16.0651,9.79485 16.1269,9.66089 16.2197,9.56815 16.3124,9.46511 16.4464,9.41359 16.5803,9.41359 16.7143,9.41359 16.8483,9.47541 16.941,9.56815 17.044,9.66089 17.0956,9.79485 17.0956,9.92881L17.0956,10.5869C17.0752,10.7163 17.0646,10.8477 17.0646,10.9799 17.0646,11.0661 17.0754,11.1499 17.0956,11.2301L17.0956,11.4745C17.0956,12.0412 17.5593,12.5049 18.126,12.5049 18.6928,12.5049 19.1565,12.0412 19.1565,11.4745L19.1565,10.8128C19.1834,10.7399 19.2266,10.6727 19.2801,10.6192 19.4759,10.4234 19.8159,10.4234 20.0117,10.6192 20.1148,10.712 20.1663,10.8459 20.1663,10.9799L20.1663,15.6169C20.1663,16.9977 19.6408,18.296 18.6618,19.2647 17.6829,20.2333 16.3949,20.7691 15.0141,20.7691L13.1593,20.7691C12.3143,20.7691 11.4796,20.5527 10.7274,20.1509 9.98548,19.749 9.3363,19.1616 8.8726,18.4506L8.66651,18.1415C8.35738,17.6675 7.23419,15.7096 5.31756,12.2989 5.24543,12.1752 5.23512,12.0412 5.26604,11.9073 5.30725,11.7733 5.38969,11.6703 5.50304,11.5981 5.66791,11.4951 5.874,11.4539 6.06978,11.4745 6.26557,11.5054 6.45105,11.5878 6.59531,11.7321L8.11007,13.2469C8.49419,13.631 9.10425,13.648 9.50833,13.2978 9.73651,13.1084 9.88244,12.8229 9.88244,12.5049L9.88244,3.74613C9.88244,3.61217,9.94426,3.47821,10.037,3.38547z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M2.99905,6.31195L1.78313,4.65293 2.61779,4.04497C3.46275,3.4267,4.37985,2.89087,5.33817,2.46838L6.27587,2.0459 7.12084,3.93162 6.18313,4.3541C5.35878,4.72506,4.56533,5.17846,3.83372,5.71429L2.99905,6.32225 2.99905,6.31195z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M18.2806,5.20935L19.1565,5.75549 20.259,4.01404 19.3832,3.4679C18.1157,2.67446,16.7452,2.0768,15.3026,1.68523L14.303,1.41731 13.7672,3.40607 14.7667,3.67399C16.0033,4.00373,17.1883,4.51895,18.2806,5.20935z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="EyeOffIconV2">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F0 M24,24z M0,0z M22.8347,21.5006L2.50417,1.17001 1.16525,2.50893 5.45737,6.80104C3.85257,8.10197 2.53265,9.72576 1.64954,11.5964 1.53559,11.8433 1.52609,12.1282 1.63055,12.3751L1.63055,12.3941C1.63055,12.4131 1.64954,12.4321 1.65904,12.4606 1.68752,12.5175 1.72551,12.5935 1.77299,12.698 1.87744,12.8974 2.01988,13.1822 2.21929,13.5146 2.61812,14.1793 3.21635,15.0719 4.04249,15.9645 5.69477,17.7497 8.30612,19.5919 11.981,19.5919 13.7282,19.5919 15.4375,19.1551 16.9568,18.31L21.4768,22.83 22.8158,21.4911 22.8347,21.5006z M11.9905,15.8791C12.5033,15.8696 13.0066,15.7556 13.4719,15.5467 13.6428,15.4707 13.7852,15.3758 13.9372,15.2808L8.72394,10.0676C8.62898,10.2195 8.53402,10.3715 8.45805,10.5329 8.24915,10.9982 8.1257,11.5015 8.1257,12.0143 8.1162,12.527 8.21116,13.0303 8.40108,13.5051 8.591,13.9799 8.87587,14.4072 9.23671,14.768 9.59755,15.1289 10.0249,15.4138 10.4997,15.6037 10.9745,15.7936 11.4777,15.8791 11.9905,15.8791z" />
<GeometryDrawing Brush="{StaticResource IconBrush}" Geometry="F1 M24,24z M0,0z M10.9063,6.37657C11.2749,6.33269 11.6452,6.30726 12,6.30726 14.974,6.30726 17.1134,7.78595 18.5447,9.32737 19.2601,10.0978 19.7852,10.8712 20.1309,11.4519 20.2587,11.6665 20.3611,11.8535 20.4389,12.0025 20.0809,12.6966 19.6562,13.3505 19.1703,13.9543L18.5749,14.694 20.0544,15.8848 20.6498,15.145C21.3248,14.3064 21.8966,13.387 22.3556,12.4078 22.4706,12.1625 22.475,11.8789 22.3683,11.6299L22.3669,11.6266 22.364,11.6201 22.3551,11.5998C22.3477,11.5833 22.3375,11.5605 22.3243,11.5319 22.2979,11.4748 22.2598,11.3946 22.2098,11.2945 22.1097,11.0944 21.9615,10.8142 21.7628,10.4805 21.3666,9.81482 20.7641,8.92644 19.9364,8.03508 18.2816,6.25295 15.6731,4.4081 12,4.4081 11.5572,4.4081 11.1108,4.43965 10.6818,4.49072L9.73885,4.60297 9.96336,6.48883 10.9063,6.37657z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F0 M24,24z M0,0z M22.8347,21.5006L2.50417,1.17001 1.16525,2.50893 5.45737,6.80104C3.85257,8.10197 2.53265,9.72576 1.64954,11.5964 1.53559,11.8433 1.52609,12.1282 1.63055,12.3751L1.63055,12.3941C1.63055,12.4131 1.64954,12.4321 1.65904,12.4606 1.68752,12.5175 1.72551,12.5935 1.77299,12.698 1.87744,12.8974 2.01988,13.1822 2.21929,13.5146 2.61812,14.1793 3.21635,15.0719 4.04249,15.9645 5.69477,17.7497 8.30612,19.5919 11.981,19.5919 13.7282,19.5919 15.4375,19.1551 16.9568,18.31L21.4768,22.83 22.8158,21.4911 22.8347,21.5006z M11.9905,15.8791C12.5033,15.8696 13.0066,15.7556 13.4719,15.5467 13.6428,15.4707 13.7852,15.3758 13.9372,15.2808L8.72394,10.0676C8.62898,10.2195 8.53402,10.3715 8.45805,10.5329 8.24915,10.9982 8.1257,11.5015 8.1257,12.0143 8.1162,12.527 8.21116,13.0303 8.40108,13.5051 8.591,13.9799 8.87587,14.4072 9.23671,14.768 9.59755,15.1289 10.0249,15.4138 10.4997,15.6037 10.9745,15.7936 11.4777,15.8791 11.9905,15.8791z" />
<GeometryDrawing Brush="{DynamicResource IconBrush}" Geometry="F1 M24,24z M0,0z M10.9063,6.37657C11.2749,6.33269 11.6452,6.30726 12,6.30726 14.974,6.30726 17.1134,7.78595 18.5447,9.32737 19.2601,10.0978 19.7852,10.8712 20.1309,11.4519 20.2587,11.6665 20.3611,11.8535 20.4389,12.0025 20.0809,12.6966 19.6562,13.3505 19.1703,13.9543L18.5749,14.694 20.0544,15.8848 20.6498,15.145C21.3248,14.3064 21.8966,13.387 22.3556,12.4078 22.4706,12.1625 22.475,11.8789 22.3683,11.6299L22.3669,11.6266 22.364,11.6201 22.3551,11.5998C22.3477,11.5833 22.3375,11.5605 22.3243,11.5319 22.2979,11.4748 22.2598,11.3946 22.2098,11.2945 22.1097,11.0944 21.9615,10.8142 21.7628,10.4805 21.3666,9.81482 20.7641,8.92644 19.9364,8.03508 18.2816,6.25295 15.6731,4.4081 12,4.4081 11.5572,4.4081 11.1108,4.43965 10.6818,4.49072L9.73885,4.60297 9.96336,6.48883 10.9063,6.37657z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Some files were not shown because too many files have changed in this diff Show More