This commit is contained in:
2025-08-23 21:39:21 +08:00
parent 7bac32e3c4
commit f67b4db4ba
562 changed files with 37981 additions and 38280 deletions
-93
View File
@@ -1,93 +0,0 @@
{
"projectName": "community",
"projectOwner": "InkCanvasForClass",
"files": [
"README.md"
],
"commitType": "docs",
"commitConvention": "angular",
"contributorsPerLine": 7,
"contributors": [
{
"login": "CJKmkp",
"name": "CJK_mkp",
"avatar_url": "https://avatars.githubusercontent.com/u/113243675?v=4",
"profile": "https://github.com/CJKmkp",
"contributions": [
"maintenance",
"doc",
"code"
]
},
{
"login": "Hydro11451",
"name": "Hydrogen",
"avatar_url": "https://avatars.githubusercontent.com/u/214308559?v=4",
"profile": "http://hydro11451.qzz.io",
"contributions": [
"code"
]
},
{
"login": "CreeperAWA",
"name": "CreeperAWA",
"avatar_url": "https://avatars.githubusercontent.com/u/134939494?v=4",
"profile": "https://github.com/CreeperAWA",
"contributions": [
"code"
]
},
{
"login": "2-2-3-trimethylpentane",
"name": "2,2,3-三甲基戊烷",
"avatar_url": "https://avatars.githubusercontent.com/u/141403762?v=4",
"profile": "https://github.com/2-2-3-trimethylpentane",
"contributions": [
"blog",
"doc",
"design"
]
},
{
"login": "Alan-CRL",
"name": "Alan-CRL",
"avatar_url": "https://avatars.githubusercontent.com/u/92425617?v=4",
"profile": "https://github.com/Alan-CRL",
"contributions": [
"code",
"infra",
"doc",
"financial"
]
},
{
"login": "MKStoler1024",
"name": "MKStoler1024",
"avatar_url": "https://avatars.githubusercontent.com/u/158786854?v=4",
"profile": "https://github.com/MKStoler1024",
"contributions": [
"doc",
"code",
"design"
]
},
{
"login": "awesome-iwb",
"name": "Awesome Iwb",
"avatar_url": "https://avatars.githubusercontent.com/u/184760810?v=4",
"profile": "https://github.com/awesome-iwb",
"contributions": [
"doc"
]
},
{
"login": "PrefacedCorg",
"name": "PrefacedCorg",
"avatar_url": "https://avatars.githubusercontent.com/u/129855423?v=4",
"profile": "https://github.com/PrefacedCorg",
"contributions": [
"code"
]
}
]
}
+22
View File
@@ -0,0 +1,22 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
## Description
## Reproduction
## Expected behavior
## Screenshots
## Additional context
-56
View File
@@ -1,56 +0,0 @@
name: Bug 报告 | Bug Report
description: 反馈软件缺陷或异常 | Report a bug to help us improve
labels: [bug]
body:
- type: markdown
attributes:
value: |
感谢你的反馈!请详细填写以下内容,便于我们定位问题。
Thank you for your feedback! Please fill out the following information to help us locate the issue.
- type: input
id: version
attributes:
label: 软件版本 | App Version
description: 可在设置中的“关于”界面查看 | You can find it on the "About" interface in the settings
placeholder: 例如 v1.2.3 | e.g. v1.2.3
validations:
required: true
- type: input
id: os
attributes:
label: 操作系统及版本 | OS & Version
placeholder: 例如 Windows 10 22H2 64位 | e.g. Windows 10 22H2 64bit
validations:
required: true
- type: textarea
id: description
attributes:
label: 问题描述 | Description
description: 简要描述遇到的问题 | Briefly describe the problem
validations:
required: true
- type: textarea
id: steps
attributes:
label: 复现步骤 | Steps to Reproduce
description: 如何复现该问题?如有必要可附截图/录屏 | How to reproduce this bug? Screenshots/recordings if needed
placeholder: |
1.
2.
3.
validations:
required: false
- type: textarea
id: expected
attributes:
label: 期望结果 | Expected Behavior
description: 你期望的正确行为或结果 | What did you expect to happen?
validations:
required: false
- type: textarea
id: extra
attributes:
label: 其他补充信息 | Additional Info
description: 其他相关信息(如日志、配置、特殊环境等)| Any other context, logs, configs, special environment, etc.
validations:
required: false
-1
View File
@@ -1 +0,0 @@
blank_issues_enabled: false
+10
View File
@@ -0,0 +1,10 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
## Description
@@ -1,37 +0,0 @@
name: 功能请求 | Feature Request
description: 提出你对本项目的功能建议 | Suggest an idea for this project
labels: [enhancement]
body:
- type: markdown
attributes:
value: |
感谢你的建议!请详细描述你的需求。
Thank you for your suggestion! Please describe your needs in detail.
- type: textarea
id: description
attributes:
label: 功能描述 | Description
description: 请描述你希望添加的功能 | Describe the feature you want
validations:
required: true
- type: textarea
id: motivation
attributes:
label: 需求动机 | Motivation
description: 为什么需要这个功能?| Why do you need this feature?
validations:
required: false
- type: textarea
id: design
attributes:
label: 期望设计 | Expected Design
description: (可选)描述或画出你期望的界面或交互 | (Optional) Describe or sketch the expected UI/UX
validations:
required: false
- type: textarea
id: extra
attributes:
label: 其他补充信息 | Additional Info
description: 其他补充说明或建议 | Any other context or suggestions
validations:
required: false
-35
View File
@@ -1,35 +0,0 @@
name: .NET Build
on:
push:
branches: [ main,beta ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Setup MSbuild
uses: microsoft/setup-msbuild@v2
- name: Setup NuGet
uses: NuGet/setup-nuget@v2.0.1
- name: Restore NuGet Packages
run: nuget restore "Ink Canvas.sln"
- 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"
- name: Upload to artifact
uses: actions/upload-artifact@v4.5.0
with:
name: InkCanvasForClass
path: "Ink Canvas/bin/Any CPU/Release/net472/"
+16 -4
View File
@@ -1,4 +1,16 @@
obj/
bin/
.vs/
/Ink Canvas/obj
InkCanvasForClass/obj
InkCanvasForClass/bin
InkCanvasForClassX/obj
InkCanvasForClassX/bin
InkCanvasForClass.IACoreHelper/obj
InkCanvasForClass.IACoreHelper/bin
InkCanvasForClass.PowerPoint.InteropHelper/obj
InkCanvasForClass.PowerPoint.InteropHelper/bin
InkCanvasForClass.PowerPoint.VstoPlugin/obj
InkCanvasForClass.PowerPoint.VstoPlugin/bin
InkCanvasForClass.IccInkCanvas/obj
InkCanvasForClass.IccInkCanvas/bin
InkCanvasForClass.IccInkCanvas.Demo/obj
InkCanvasForClass.IccInkCanvas.Demo/bin
.vs
.idea
+4 -4
View File
@@ -1,12 +1,12 @@
# Default ignored files
# 默认忽略的文件
/shelf/
/workspace.xml
# Rider ignored files
# Rider 忽略的文件
/contentModel.xml
/projectSettingsUpdater.xml
/modules.xml
/contentModel.xml
/.idea.Ink Canvas.iml
# Editor-based HTTP Client requests
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
+1 -3
View File
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders>
<Path>../../ICC CE main</Path>
</attachedFolders>
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
-1
View File
@@ -1 +0,0 @@
1.7.6.0
+36
View File
@@ -0,0 +1,36 @@
rev-1.0.0.0:
1. 重写大部分代码中...
5.0.5.0:
1. 支持自动收纳希沃轻白板5C,希沃白板3,鸿合轻量白板。
2. 支持自动查杀鸿合屏幕书写。
3. 带来FitToCurve,给平滑墨迹加上了开关。
4. 修复了FitToCurve导致的部分形状绘制出错的问题也保留了其他墨迹的FitToCurve。
5. 白板,浮动工具栏,子面板,设置UI几乎全部优化。
6. 添加修改橡皮大小,橡皮形状的菜单。
7. PPT现在会自动提示是否关闭自动播放和排练计时。
8. 条件性的墨迹识别,可以关闭部分不需要的形状识别。可以修改是否为墨迹识别的三角形或矩形应用模拟压感值。
9. 带来了荧光笔功能并为荧光笔适配了形状识别。
10. 允许清空墨迹时可删除历史记录。
11. 带来了Quick Panel。
12. 浮动工具栏缩放调节,取消收纳按钮图标修改。
13. 修复了多指书写StylusDown事件可能触发在工具栏而不是inkCanvas上导致的Bug。
14. 修复了鼠标和触摸屏(无RealTimeStylus和非多指书写模式)的绘制时Pointer捕获Bug。
15. Merge了Ink Canvas的新撤回行为
16. 修复了白板模式下直接新增页面导致的TimeMachine不记录历史记录的Bug
17. 添加了一个简陋的白板页面列表。
18. 优化了墨迹重播,支持暂停,重新开始和倍速,拥有更人性化的UI。
19. 优化自动收纳行为和FoldFloatingBar函数的相关Bug修复。
20. 添加了EdgeGestureUtil实验性选项。
21. 添加了ForceFullScreen实验性选项
22. 添加了FullScreenHelper实验性选项。
23. 添加了ResolutionChangeDetection和DPIChangeDetection实验性选项。
24. 修复了同时打开ICC和ICA的冲突。
25. 修复浮动工具栏手势按钮开启多指书写时InkCanvas的InkCanvasEditingMode被修改为None的Bug。
26. 修复Merge ICA仓库代码后导致浮动工具栏批注按钮UI MouseLeave反馈的问题。
27. 为大部分UI的按钮添加了lastBorderMouseDown的检测代码和MouseDown的视觉反馈。
28. 支持自动收纳安道系列,艺云系列和 MAXHUB 白板书写。
4.5.8.0:
1. 将ICA的代码换了个名字变成了InkCanvasForClass,万物起源。
2. 优化了ICA的部分UI界面设计。
-128
View File
@@ -1,128 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
QQ:2564608840.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 KiB

+228 -21
View File
@@ -3,7 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InkCanvasForClass", "Ink Canvas\InkCanvasForClass.csproj", "{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InkCanvasForClassX", "InkCanvasForClassX\InkCanvasForClassX.csproj", "{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InkCanvasForClass", "InkCanvasForClass\InkCanvasForClass.csproj", "{2474F5B0-6FA7-4D70-8A00-167BBB03264D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkCanvasForClass.IACoreHelper", "InkCanvasForClass.IACoreHelper\InkCanvasForClass.IACoreHelper.csproj", "{693973B6-69C1-4A37-B329-F366A07BF60A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkCanvasForClass.PowerPoint.InteropHelper", "InkCanvasForClass.PowerPoint.InteropHelper\InkCanvasForClass.PowerPoint.InteropHelper.csproj", "{2D8A9217-465A-4F57-BD58-CE02450390C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkCanvasForClass.PowerPoint.VstoPlugin", "InkCanvasForClass.PowerPoint.VstoPlugin\InkCanvasForClass.PowerPoint.VstoPlugin.csproj", "{8C593467-E54D-4FA7-881C-78F3CC48A867}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkCanvasForClass.IccInkCanvas", "InkCanvasForClass.IccInkCanvas\InkCanvasForClass.IccInkCanvas.csproj", "{43929D8F-5630-4786-B75D-E203EA3E992F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkCanvasForClass.IccInkCanvas.Demo", "InkCanvasForClass.IccInkCanvas.Demo\InkCanvasForClass.IccInkCanvas.Demo.csproj", "{94E97F70-CACD-453B-8114-08DFFDDA5A46}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,28 +29,223 @@ Global
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
x86 Debug|Any CPU = x86 Debug|Any CPU
x86 Debug|ARM = x86 Debug|ARM
x86 Debug|ARM64 = x86 Debug|ARM64
x86 Debug|x64 = x86 Debug|x64
x86 Debug|x86 = x86 Debug|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|ARM.Build.0 = Debug|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|ARM64.ActiveCfg = Debug|ARM64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|ARM64.Build.0 = Debug|ARM64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|x64.ActiveCfg = Debug|x64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|x64.Build.0 = Debug|x64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|x86.ActiveCfg = Debug|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|x86.Build.0 = Debug|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|Any CPU.Build.0 = Release|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|ARM.ActiveCfg = Release|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|ARM.Build.0 = Release|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|ARM64.ActiveCfg = Release|ARM64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|ARM64.Build.0 = Release|ARM64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|x64.ActiveCfg = Release|x64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|x64.Build.0 = Release|x64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|x86.ActiveCfg = Release|x86
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|x86.Build.0 = Release|x86
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|ARM.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|ARM.Build.0 = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|ARM64.Build.0 = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|x64.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|x64.Build.0 = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|x86.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Debug|x86.Build.0 = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|Any CPU.Build.0 = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|ARM.ActiveCfg = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|ARM.Build.0 = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|ARM64.ActiveCfg = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|ARM64.Build.0 = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|x64.ActiveCfg = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|x64.Build.0 = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|x86.ActiveCfg = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.Release|x86.Build.0 = Release|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|Any CPU.Build.0 = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|ARM.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|ARM.Build.0 = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|ARM64.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|ARM64.Build.0 = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|x64.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|x64.Build.0 = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|x86.ActiveCfg = Debug|Any CPU
{98DF6AA1-DD4D-4C70-A0A2-4B2974D97D51}.x86 Debug|x86.Build.0 = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|ARM.ActiveCfg = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|ARM.Build.0 = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|ARM64.Build.0 = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|x64.ActiveCfg = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|x64.Build.0 = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|x86.ActiveCfg = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Debug|x86.Build.0 = Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|Any CPU.Build.0 = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|ARM.ActiveCfg = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|ARM.Build.0 = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|ARM64.ActiveCfg = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|ARM64.Build.0 = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|x64.ActiveCfg = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|x64.Build.0 = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|x86.ActiveCfg = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.Release|x86.Build.0 = Release|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|Any CPU.ActiveCfg = x86 Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|Any CPU.Build.0 = x86 Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|ARM.ActiveCfg = x86 Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|ARM.Build.0 = x86 Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|ARM64.ActiveCfg = x86 Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|ARM64.Build.0 = x86 Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|x64.ActiveCfg = x86 Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|x64.Build.0 = x86 Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|x86.ActiveCfg = x86 Debug|Any CPU
{2474F5B0-6FA7-4D70-8A00-167BBB03264D}.x86 Debug|x86.Build.0 = x86 Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|ARM.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|ARM.Build.0 = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|ARM64.Build.0 = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|x64.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|x64.Build.0 = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|x86.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Debug|x86.Build.0 = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|Any CPU.Build.0 = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|ARM.ActiveCfg = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|ARM.Build.0 = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|ARM64.ActiveCfg = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|ARM64.Build.0 = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|x64.ActiveCfg = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|x64.Build.0 = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|x86.ActiveCfg = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.Release|x86.Build.0 = Release|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|Any CPU.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|Any CPU.Build.0 = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|ARM.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|ARM.Build.0 = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|ARM64.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|ARM64.Build.0 = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|x64.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|x64.Build.0 = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|x86.ActiveCfg = Debug|Any CPU
{693973B6-69C1-4A37-B329-F366A07BF60A}.x86 Debug|x86.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|ARM.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|ARM.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|ARM64.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|x64.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|x64.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|x86.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Debug|x86.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|Any CPU.Build.0 = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|ARM.ActiveCfg = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|ARM.Build.0 = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|ARM64.ActiveCfg = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|ARM64.Build.0 = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|x64.ActiveCfg = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|x64.Build.0 = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|x86.ActiveCfg = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.Release|x86.Build.0 = Release|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|Any CPU.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|ARM.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|ARM.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|ARM64.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|ARM64.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|x64.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|x64.Build.0 = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|x86.ActiveCfg = Debug|Any CPU
{2D8A9217-465A-4F57-BD58-CE02450390C4}.x86 Debug|x86.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|ARM.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|ARM64.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|x64.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|x64.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|x86.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Debug|x86.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|Any CPU.Build.0 = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|ARM.ActiveCfg = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|ARM.Build.0 = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|ARM64.ActiveCfg = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|ARM64.Build.0 = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|x64.ActiveCfg = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|x64.Build.0 = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|x86.ActiveCfg = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.Release|x86.Build.0 = Release|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|Any CPU.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|ARM.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|ARM.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|ARM64.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|ARM64.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|x64.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|x64.Build.0 = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|x86.ActiveCfg = Debug|Any CPU
{8C593467-E54D-4FA7-881C-78F3CC48A867}.x86 Debug|x86.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|ARM.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|ARM.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|ARM64.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|x64.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|x64.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|x86.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Debug|x86.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|Any CPU.Build.0 = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|ARM.ActiveCfg = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|ARM.Build.0 = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|ARM64.ActiveCfg = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|ARM64.Build.0 = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|x64.ActiveCfg = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|x64.Build.0 = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|x86.ActiveCfg = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.Release|x86.Build.0 = Release|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|Any CPU.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|ARM.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|ARM.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|ARM64.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|ARM64.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|x64.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|x64.Build.0 = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|x86.ActiveCfg = Debug|Any CPU
{43929D8F-5630-4786-B75D-E203EA3E992F}.x86 Debug|x86.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|ARM.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|ARM.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|ARM64.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|x64.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|x64.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|x86.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Debug|x86.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|Any CPU.Build.0 = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|ARM.ActiveCfg = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|ARM.Build.0 = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|ARM64.ActiveCfg = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|ARM64.Build.0 = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|x64.ActiveCfg = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|x64.Build.0 = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|x86.ActiveCfg = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.Release|x86.Build.0 = Release|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|Any CPU.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|ARM.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|ARM.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|ARM64.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|ARM64.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|x64.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|x64.Build.0 = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|x86.ActiveCfg = Debug|Any CPU
{94E97F70-CACD-453B-8114-08DFFDDA5A46}.x86 Debug|x86.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+3 -2
View File
@@ -1,4 +1,5 @@
<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>
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="D:\vs\ica\InkCanvasForClass\IAWinFX.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary>
File diff suppressed because it is too large Load Diff
-3
View File
@@ -1,3 +0,0 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura ExcludeAssemblies="IACore|IALoader|IAWinFX" />
</Weavers>
-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>
@@ -1,562 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Threading;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// 异步硬件加速的墨迹平滑处理器
/// </summary>
public class AsyncAdvancedBezierSmoothing
{
private readonly SemaphoreSlim _processingSemaphore;
private readonly ConcurrentDictionary<Stroke, CancellationTokenSource> _processingTasks;
private readonly Dispatcher _uiDispatcher;
public AsyncAdvancedBezierSmoothing(Dispatcher uiDispatcher)
{
_uiDispatcher = uiDispatcher;
_processingSemaphore = new SemaphoreSlim(Environment.ProcessorCount, Environment.ProcessorCount);
_processingTasks = new ConcurrentDictionary<Stroke, CancellationTokenSource>();
}
public double SmoothingStrength { get; set; } = 0.3; // 大幅降低强度
public double ResampleInterval { get; set; } = 3.0; // 大幅增加间隔减少点数
public int InterpolationSteps { get; set; } = 8; // 从4增加到8,提高插值步数
public bool UseHardwareAcceleration { get; set; } = true;
public int MaxConcurrentTasks { get; set; } = Environment.ProcessorCount;
/// <summary>
/// 异步平滑笔画
/// </summary>
public async Task<Stroke> SmoothStrokeAsync(Stroke originalStroke,
Action<Stroke, Stroke> onCompleted = null,
CancellationToken cancellationToken = default)
{
if (originalStroke == null || originalStroke.StylusPoints.Count < 2)
return originalStroke;
// 取消之前对同一笔画的处理
if (_processingTasks.TryGetValue(originalStroke, out var existingCts))
{
existingCts.Cancel();
_processingTasks.TryRemove(originalStroke, out _);
}
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
_processingTasks[originalStroke] = cts;
try
{
await _processingSemaphore.WaitAsync(cts.Token);
var smoothedStroke = await Task.Run(() =>
ProcessStrokeInternal(originalStroke, cts.Token), cts.Token);
// 在UI线程上执行回调
if (onCompleted != null && !cts.Token.IsCancellationRequested)
{
await _uiDispatcher.InvokeAsync(() => onCompleted(originalStroke, smoothedStroke));
}
return smoothedStroke;
}
catch (OperationCanceledException)
{
return originalStroke;
}
finally
{
_processingSemaphore.Release();
_processingTasks.TryRemove(originalStroke, out _);
cts.Dispose();
}
}
private Stroke ProcessStrokeInternal(Stroke stroke, CancellationToken cancellationToken)
{
var originalPoints = stroke.StylusPoints.ToArray();
// 如果点数太少,直接返回原始笔画
if (originalPoints.Length < 3)
return stroke;
cancellationToken.ThrowIfCancellationRequested();
// 简化处理:只进行轻度平滑,避免点数爆炸
var smoothedPoints = ApplyLightSmoothing(originalPoints);
cancellationToken.ThrowIfCancellationRequested();
// 确保点数不会过多
if (smoothedPoints.Length > originalPoints.Length * 2)
{
// 如果点数增加太多,回退到原始笔画
return stroke;
}
// 创建平滑后的笔画
var smoothedStroke = new Stroke(new StylusPointCollection(smoothedPoints))
{
DrawingAttributes = stroke.DrawingAttributes.Clone()
};
return smoothedStroke;
}
/// <summary>
/// 轻度平滑处理,避免点数爆炸
/// </summary>
private StylusPoint[] ApplyLightSmoothing(StylusPoint[] points)
{
if (points.Length < 3) return points;
var result = new List<StylusPoint>();
result.Add(points[0]); // 保持第一个点
// 简单的3点平均平滑
for (int i = 1; i < points.Length - 1; i++)
{
var prev = points[i - 1];
var curr = points[i];
var next = points[i + 1];
// 3点平均
double x = (prev.X + curr.X + next.X) / 3.0;
double y = (prev.Y + curr.Y + next.Y) / 3.0;
float pressure = (prev.PressureFactor + curr.PressureFactor + next.PressureFactor) / 3.0f;
result.Add(new StylusPoint(x, y, Math.Max(pressure, 0.1f)));
}
result.Add(points[points.Length - 1]); // 保持最后一个点
return result.ToArray();
}
/// <summary>
/// 硬件加速的向量化指数平滑
/// </summary>
private StylusPoint[] ApplyExponentialSmoothingVectorized(StylusPoint[] points, double alpha)
{
if (points.Length == 0) return points;
var result = new StylusPoint[points.Length];
result[0] = points[0];
double lastX = points[0].X;
double lastY = points[0].Y;
float lastPressure = points[0].PressureFactor;
double oneMinusAlpha = 1.0 - alpha;
// 向量化处理,减少分支预测失败
for (int i = 1; i < points.Length; i++)
{
var p = points[i];
lastX = alpha * p.X + oneMinusAlpha * lastX;
lastY = alpha * p.Y + oneMinusAlpha * lastY;
lastPressure = (float)(alpha * p.PressureFactor + oneMinusAlpha * lastPressure);
lastPressure = Math.Max(lastPressure, 0.1f); // 避免分支
result[i] = new StylusPoint(lastX, lastY, lastPressure);
}
return result;
}
/// <summary>
/// 优化的等距重采样
/// </summary>
private StylusPoint[] ResampleEquidistantOptimized(StylusPoint[] points, double interval)
{
if (points.Length == 0) return points;
var result = new List<StylusPoint>(points.Length) { points[0] };
double accumulated = 0;
for (int i = 1; i < points.Length; i++)
{
var prev = result[result.Count - 1];
var curr = points[i];
double dx = curr.X - prev.X;
double dy = curr.Y - prev.Y;
double dist = Math.Sqrt(dx * dx + dy * dy);
if (dist + accumulated >= interval)
{
double t = (interval - accumulated) / dist;
double x = prev.X + t * dx;
double y = prev.Y + t * dy;
float pressure = (float)(prev.PressureFactor * (1 - t) + curr.PressureFactor * t);
pressure = Math.Max(pressure, 0.1f);
result.Add(new StylusPoint(x, y, pressure));
accumulated = 0;
i--; // 重新处理当前点
}
else
{
accumulated += dist;
}
}
return result.ToArray();
}
/// <summary>
/// 硬件加速的贝塞尔曲线拟合
/// </summary>
private StylusPoint[] SlidingBezierFitHardwareAccelerated(StylusPoint[] points, int window, int steps)
{
if (points.Length < window) return points;
var result = new List<StylusPoint>(points.Length * steps / window);
// 使用并行处理加速计算
var segments = new List<StylusPoint[]>();
Parallel.For(0, points.Length - window + 1, i =>
{
var segmentPoints = new StylusPoint[steps];
var p0 = points[i];
var p1 = points[i + 1];
var p2 = points[i + 2];
var p3 = points[i + 3];
for (int j = 0; j < steps; j++)
{
double t = (double)j / steps;
segmentPoints[j] = CubicBezierOptimized(p0, p1, p2, p3, t);
}
lock (segments)
{
segments.Add(segmentPoints);
}
});
// 合并结果
foreach (var segment in segments)
{
result.AddRange(segment);
}
result.Add(points[points.Length - 1]);
return result.ToArray();
}
/// <summary>
/// 优化的单线程贝塞尔拟合
/// </summary>
private StylusPoint[] SlidingBezierFitOptimized(StylusPoint[] points, int window, int steps)
{
if (points.Length < window) return points;
var result = new List<StylusPoint>(points.Length * steps / window);
for (int i = 0; i <= points.Length - window; i++)
{
var p0 = points[i];
var p1 = points[i + 1];
var p2 = points[i + 2];
var p3 = points[i + 3];
for (int j = 0; j < steps; j++)
{
double t = (double)j / steps;
result.Add(CubicBezierOptimized(p0, p1, p2, p3, t));
}
}
result.Add(points[points.Length - 1]);
return result.ToArray();
}
/// <summary>
/// 优化的三次贝塞尔曲线计算
/// </summary>
private StylusPoint CubicBezierOptimized(StylusPoint p0, StylusPoint p1, StylusPoint p2, StylusPoint p3, double t)
{
double u = 1 - t;
double tt = t * t;
double uu = u * u;
double uuu = uu * u;
double ttt = tt * t;
// 预计算系数
double c0 = uuu;
double c1 = 3 * uu * t;
double c2 = 3 * u * tt;
double c3 = ttt;
double x = c0 * p0.X + c1 * p1.X + c2 * p2.X + c3 * p3.X;
double y = c0 * p0.Y + c1 * p1.Y + c2 * p2.Y + c3 * p3.Y;
float pressure = (float)(p1.PressureFactor * u + p2.PressureFactor * t);
pressure = Math.Max(pressure, 0.1f);
return new StylusPoint(x, y, pressure);
}
/// <summary>
/// 兼容性方法:传统指数平滑
/// </summary>
private StylusPoint[] ApplyExponentialSmoothing(StylusPoint[] points, double alpha)
{
if (points.Length == 0) return points;
var result = new StylusPoint[points.Length];
result[0] = points[0];
double lastX = points[0].X;
double lastY = points[0].Y;
float lastPressure = points[0].PressureFactor;
for (int i = 1; i < points.Length; i++)
{
var p = points[i];
lastX = alpha * p.X + (1 - alpha) * lastX;
lastY = alpha * p.Y + (1 - alpha) * lastY;
lastPressure = (float)(alpha * p.PressureFactor + (1 - alpha) * lastPressure);
lastPressure = Math.Max(lastPressure, 0.1f);
result[i] = new StylusPoint(lastX, lastY, lastPressure);
}
return result;
}
/// <summary>
/// 取消所有正在进行的处理任务
/// </summary>
public void CancelAllTasks()
{
foreach (var kvp in _processingTasks)
{
kvp.Value.Cancel();
}
_processingTasks.Clear();
}
/// <summary>
/// 释放资源
/// </summary>
public void Dispose()
{
CancelAllTasks();
_processingSemaphore?.Dispose();
}
}
/// <summary>
/// 原有的同步版本(保持向后兼容)
/// </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 Stroke SmoothStroke(Stroke stroke)
{
if (stroke == null || stroke.StylusPoints.Count < 3)
return stroke;
var originalPoints = stroke.StylusPoints.ToList();
// 简化处理:只进行轻度平滑
var smoothedPoints = ApplyLightExponentialSmoothing(originalPoints, 0.2); // 很轻的平滑
// 检查点数是否合理
if (smoothedPoints.Count > originalPoints.Count * 1.5)
{
return stroke; // 如果点数增加太多,返回原始笔画
}
var smoothedStroke = new Stroke(new StylusPointCollection(smoothedPoints))
{
DrawingAttributes = stroke.DrawingAttributes.Clone()
};
return smoothedStroke;
}
/// <summary>
/// 轻度指数平滑
/// </summary>
private List<StylusPoint> ApplyLightExponentialSmoothing(List<StylusPoint> points, double alpha)
{
var result = new List<StylusPoint>();
if (points.Count == 0) return result;
result.Add(points[0]);
for (int i = 1; i < points.Count; i++)
{
var prev = result[result.Count - 1];
var curr = points[i];
double x = alpha * curr.X + (1 - alpha) * prev.X;
double y = alpha * curr.Y + (1 - alpha) * prev.Y;
float pressure = (float)(alpha * curr.PressureFactor + (1 - alpha) * prev.PressureFactor);
pressure = Math.Max(pressure, 0.1f);
result.Add(new StylusPoint(x, y, pressure));
}
return result;
}
private List<StylusPoint> ApplyExponentialSmoothing(List<StylusPoint> points, double alpha)
{
var result = new List<StylusPoint>();
if (points.Count == 0) return result;
result.Add(points[0]);
double lastX = points[0].X;
double lastY = points[0].Y;
float lastPressure = points[0].PressureFactor;
for (int i = 1; i < points.Count; i++)
{
var p = points[i];
lastX = alpha * p.X + (1 - alpha) * lastX;
lastY = alpha * p.Y + (1 - alpha) * lastY;
lastPressure = (float)(alpha * p.PressureFactor + (1 - alpha) * lastPressure);
if (lastPressure < 0.1f) lastPressure = 0.1f;
result.Add(new StylusPoint(lastX, lastY, lastPressure));
}
return result;
}
private List<StylusPoint> ResampleEquidistant(List<StylusPoint> points, double interval = 2.0)
{
var result = new List<StylusPoint>();
if (points.Count == 0) return result;
result.Add(points[0]);
double accumulated = 0;
for (int i = 1; i < points.Count; i++)
{
var prev = result.Last();
var curr = points[i];
double dx = curr.X - prev.X;
double dy = curr.Y - prev.Y;
double dist = Math.Sqrt(dx * dx + dy * dy);
if (dist + accumulated >= interval)
{
double t = (interval - accumulated) / dist;
double x = prev.X + t * dx;
double y = prev.Y + t * dy;
float pressure = (float)(prev.PressureFactor * (1 - t) + curr.PressureFactor * t);
if (pressure < 0.1f) pressure = 0.1f;
var newPoint = new StylusPoint(x, y, pressure);
result.Add(newPoint);
accumulated = 0;
i--; // 重新处理当前点
}
else
{
accumulated += dist;
}
}
return result;
}
private List<StylusPoint> SlidingBezierFit(List<StylusPoint> points, int window = 4, int steps = 48) // 从24增加到48
{
var result = new List<StylusPoint>();
if (points.Count < window) return points;
for (int i = 0; i <= points.Count - window; i++)
{
var p0 = points[i];
var p1 = points[i + 1];
var p2 = points[i + 2];
var p3 = points[i + 3];
for (int j = 0; j < steps; j++)
{
double t = (double)j / steps;
var pt = CubicBezier(p0, p1, p2, p3, t);
result.Add(pt);
}
}
// 保证最后一个点被包含
result.Add(points.Last());
return result;
}
private StylusPoint CubicBezier(StylusPoint p0, StylusPoint p1, StylusPoint p2, StylusPoint p3, double t)
{
double u = 1 - t;
double tt = t * t;
double uu = u * u;
double uuu = uu * u;
double ttt = tt * t;
double x = uuu * p0.X + 3 * uu * t * p1.X + 3 * u * tt * p2.X + ttt * p3.X;
double y = uuu * p0.Y + 3 * uu * t * p1.Y + 3 * u * tt * p2.Y + ttt * p3.Y;
float pressure = (float)(p1.PressureFactor * (1 - t) + p2.PressureFactor * t);
if (pressure < 0.1f) pressure = 0.1f;
return new StylusPoint(x, y, pressure);
}
private List<StylusPoint> SlidingWindowSmooth(List<StylusPoint> points, int window = 5)
{
var result = new List<StylusPoint>();
int half = window / 2;
for (int i = 0; i < points.Count; i++)
{
double sumX = 0, sumY = 0, sumP = 0;
int count = 0;
for (int j = Math.Max(0, i - half); j <= Math.Min(points.Count - 1, i + half); j++)
{
sumX += points[j].X;
sumY += points[j].Y;
sumP += points[j].PressureFactor;
count++;
}
result.Add(new StylusPoint(sumX / count, sumY / count, (float)(sumP / count)));
}
return result;
}
}
/// <summary>
/// 性能监控器
/// </summary>
public class InkSmoothingPerformanceMonitor
{
private readonly Queue<TimeSpan> _processingTimes = new Queue<TimeSpan>();
private readonly object _lock = new object();
private const int MaxSamples = 100;
public void RecordProcessingTime(TimeSpan time)
{
lock (_lock)
{
_processingTimes.Enqueue(time);
if (_processingTimes.Count > MaxSamples)
_processingTimes.Dequeue();
}
}
public double GetAverageProcessingTimeMs()
{
lock (_lock)
{
return _processingTimes.Count > 0 ?
_processingTimes.Average(t => t.TotalMilliseconds) : 0;
}
}
public double GetMaxProcessingTimeMs()
{
lock (_lock)
{
return _processingTimes.Count > 0 ?
_processingTimes.Max(t => t.TotalMilliseconds) : 0;
}
}
public int GetSampleCount()
{
lock (_lock)
{
return _processingTimes.Count;
}
}
}
}
File diff suppressed because it is too large Load Diff
-209
View File
@@ -1,209 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Interop;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// 防止窗口进入全屏状态的辅助类
/// </summary>
public static class AvoidFullScreenHelper
{
private static readonly DependencyProperty IsAvoidFullScreenEnabledProperty =
DependencyProperty.RegisterAttached(
"IsAvoidFullScreenEnabled",
typeof(bool),
typeof(AvoidFullScreenHelper));
private static bool _isBoardMode;
public static void SetBoardMode(bool isBoardMode)
{
_isBoardMode = isBoardMode;
}
public static void StartAvoidFullScreen(Window window)
{
if (window == null)
throw new ArgumentNullException(nameof(window));
if (!(bool)window.GetValue(IsAvoidFullScreenEnabledProperty))
{
var hwndSource = PresentationSource.FromVisual(window) as HwndSource;
if (hwndSource != null)
{
hwndSource.AddHook(KeepInWorkingAreaHook);
window.SetValue(IsAvoidFullScreenEnabledProperty, true);
}
}
}
public static void StopAvoidFullScreen(Window window)
{
if (window == null)
throw new ArgumentNullException(nameof(window));
if ((bool)window.GetValue(IsAvoidFullScreenEnabledProperty))
{
var hwndSource = PresentationSource.FromVisual(window) as HwndSource;
if (hwndSource != null)
{
hwndSource.RemoveHook(KeepInWorkingAreaHook);
window.ClearValue(IsAvoidFullScreenEnabledProperty);
}
}
}
public static bool GetIsAvoidFullScreenEnabled(DependencyObject obj) => (bool)obj.GetValue(IsAvoidFullScreenEnabledProperty);
public static void SetIsAvoidFullScreenEnabled(DependencyObject obj, bool value) => obj.SetValue(IsAvoidFullScreenEnabledProperty, value);
private static IntPtr KeepInWorkingAreaHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
// 只拦截主画布窗口的全屏(最大化)操作
var window = HwndSource.FromHwnd(hwnd)?.RootVisual as Window;
if (window == null) return IntPtr.Zero;
// 这里假设主画布窗口类名为MainWindow(如有不同请调整)
if (window.GetType().Name != "MainWindow") return IntPtr.Zero;
if (_isBoardMode)
{
// 画板模式下允许全屏/最大化,不拦截
return IntPtr.Zero;
}
const int WM_WINDOWPOSCHANGING = 0x0046;
const int WM_SYSCOMMAND = 0x0112;
const int SC_MAXIMIZE = 0xF030;
if (msg == WM_SYSCOMMAND && wParam.ToInt32() == SC_MAXIMIZE)
{
// 拦截最大化命令,强制还原窗口并调整到工作区
window.WindowState = WindowState.Normal;
var workingArea = GetWorkingArea(new Rect(window.Left, window.Top, window.Width, window.Height));
window.Left = workingArea.Left;
window.Top = workingArea.Top;
window.Width = workingArea.Width;
window.Height = workingArea.Height;
handled = true;
return IntPtr.Zero;
}
if (msg != WM_WINDOWPOSCHANGING)
return IntPtr.Zero;
try
{
var pos = (WindowPosition)Marshal.PtrToStructure(lParam, typeof(WindowPosition));
if ((pos.Flags & (WindowPositionFlags.SWP_NOMOVE | WindowPositionFlags.SWP_NOSIZE)) != 0)
return IntPtr.Zero;
// 只处理主画布窗口
// 计算目标矩形
var targetRect = new Rect(
(pos.Flags & WindowPositionFlags.SWP_NOMOVE) == 0 ? pos.X : window.Left,
(pos.Flags & WindowPositionFlags.SWP_NOMOVE) == 0 ? pos.Y : window.Top,
(pos.Flags & WindowPositionFlags.SWP_NOSIZE) == 0 ? pos.Width : window.Width,
(pos.Flags & WindowPositionFlags.SWP_NOSIZE) == 0 ? pos.Height : window.Height);
var workingArea = GetWorkingArea(targetRect);
var adjustedRect = AdjustRectToWorkingArea(targetRect, workingArea);
pos.X = (int)adjustedRect.Left;
pos.Y = (int)adjustedRect.Top;
pos.Width = (int)adjustedRect.Width;
pos.Height = (int)adjustedRect.Height;
pos.Flags &= ~(WindowPositionFlags.SWP_NOSIZE | WindowPositionFlags.SWP_NOMOVE | WindowPositionFlags.SWP_NOREDRAW);
pos.Flags |= WindowPositionFlags.SWP_NOCOPYBITS;
Marshal.StructureToPtr(pos, lParam, false);
}
catch (Exception ex)
{
Console.WriteLine($"窗口位置调整失败: {ex.Message}");
}
return IntPtr.Zero;
}
private static Rect GetWorkingArea(Rect windowRect)
{
// 获取所有显示器
var screens = Screen.AllScreens;
// 确定窗口主要位于哪个显示器上
Screen targetScreen = null;
double maxIntersection = 0;
foreach (var screen in screens)
{
var screenRect = new Rect(
screen.WorkingArea.X,
screen.WorkingArea.Y,
screen.WorkingArea.Width,
screen.WorkingArea.Height);
var intersection = Rect.Intersect(windowRect, screenRect);
if (intersection.Width * intersection.Height > maxIntersection)
{
maxIntersection = intersection.Width * intersection.Height;
targetScreen = screen;
}
}
// 如果没找到,使用主显示器
if (targetScreen == null)
targetScreen = Screen.PrimaryScreen;
return new Rect(
targetScreen.WorkingArea.X,
targetScreen.WorkingArea.Y,
targetScreen.WorkingArea.Width,
targetScreen.WorkingArea.Height);
}
private static Rect AdjustRectToWorkingArea(Rect windowRect, Rect workingArea)
{
// 调整尺寸以适应工作区域
if (windowRect.Width > workingArea.Width)
windowRect.Width = workingArea.Width;
if (windowRect.Height > workingArea.Height)
windowRect.Height = workingArea.Height;
// 调整位置以确保窗口完全在工作区域内
if (windowRect.Left < workingArea.Left)
windowRect.X = workingArea.Left;
else if (windowRect.Right > workingArea.Right)
windowRect.X = workingArea.Right - windowRect.Width;
if (windowRect.Top < workingArea.Top)
windowRect.Y = workingArea.Top;
else if (windowRect.Bottom > workingArea.Bottom)
windowRect.Y = workingArea.Bottom - windowRect.Height;
return windowRect;
}
}
// 使用WPF原生类型替代Win32结构
[StructLayout(LayoutKind.Sequential)]
internal struct WindowPosition
{
public IntPtr Hwnd;
public IntPtr HwndInsertAfter;
public int X;
public int Y;
public int Width;
public int Height;
public WindowPositionFlags Flags;
}
[Flags]
internal enum WindowPositionFlags : uint
{
SWP_NOSIZE = 0x0001,
SWP_NOMOVE = 0x0002,
SWP_NOZORDER = 0x0004,
SWP_NOREDRAW = 0x0008,
SWP_NOACTIVATE = 0x0010,
SWP_FRAMECHANGED = 0x0020,
SWP_SHOWWINDOW = 0x0040,
SWP_HIDEWINDOW = 0x0080,
SWP_NOCOPYBITS = 0x0100,
SWP_NOOWNERZORDER = 0x0200,
SWP_NOSENDCHANGING = 0x0400,
}
}
-115
View File
@@ -1,115 +0,0 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace Ink_Canvas.Converter
{
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value)
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value)
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}
}
public class VisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Visibility visibility = (Visibility)value;
if (visibility == Visibility.Visible)
{
return Visibility.Collapsed;
}
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
Visibility visibility = (Visibility)value;
if (visibility == Visibility.Visible)
{
return Visibility.Collapsed;
}
return Visibility.Visible;
}
}
public class IntNumberToString : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((double)value == 0)
{
return "无限制";
}
return ((double)value) + "人";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((double)value == 0)
{
return "无限制";
}
return ((double)value) + "人";
}
}
public class IntNumberToString2 : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((double)value == 0)
{
return "自动截图";
}
return ((double)value) + "条";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((double)value == 0)
{
return "自动截图";
}
return ((double)value) + "条";
}
}
public class IsEnabledToOpacityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool isChecked = (bool)value;
if (isChecked)
{
return 1d;
}
return 0.35;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); }
}
}
File diff suppressed because it is too large Load Diff
@@ -1,257 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// 硬件加速的墨迹处理器,利用WPF的GPU渲染能力
/// </summary>
public class HardwareAcceleratedInkProcessor
{
private readonly RenderTargetBitmap _renderTarget;
private readonly DrawingVisual _drawingVisual;
private readonly DrawingContext _drawingContext;
private bool _isInitialized;
public HardwareAcceleratedInkProcessor(int width = 1920, int height = 1080)
{
// 创建硬件加速的渲染目标
_renderTarget = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
_drawingVisual = new DrawingVisual();
// 启用硬件加速
RenderOptions.SetBitmapScalingMode(_drawingVisual, BitmapScalingMode.HighQuality);
RenderOptions.SetEdgeMode(_drawingVisual, EdgeMode.Aliased);
_isInitialized = true;
}
/// <summary>
/// 使用GPU加速的贝塞尔曲线平滑
/// </summary>
public async Task<Stroke> SmoothStrokeWithGPU(Stroke originalStroke)
{
if (!_isInitialized || originalStroke == null || originalStroke.StylusPoints.Count < 2)
return originalStroke;
return await Task.Run(() =>
{
try
{
// 使用PathGeometry进行硬件加速的曲线拟合
var pathGeometry = CreateSmoothPathGeometry(originalStroke.StylusPoints);
// 将PathGeometry转换回StylusPoint集合
var smoothedPoints = ConvertPathGeometryToStylusPoints(pathGeometry, originalStroke.StylusPoints);
return new Stroke(new StylusPointCollection(smoothedPoints))
{
DrawingAttributes = originalStroke.DrawingAttributes.Clone()
};
}
catch
{
return originalStroke;
}
});
}
/// <summary>
/// 创建平滑的路径几何体
/// </summary>
private PathGeometry CreateSmoothPathGeometry(StylusPointCollection points)
{
var pathGeometry = new PathGeometry();
var pathFigure = new PathFigure();
if (points.Count < 2) return pathGeometry;
pathFigure.StartPoint = new Point(points[0].X, points[0].Y);
// 使用贝塞尔曲线段创建平滑路径,增加插点密度
for (int i = 0; i < points.Count - 1; i += 2) // 从i+=3改为i+=2,增加插点密度
{
var p1 = i + 1 < points.Count ? new Point(points[i + 1].X, points[i + 1].Y) : pathFigure.StartPoint;
var p2 = i + 2 < points.Count ? new Point(points[i + 2].X, points[i + 2].Y) : p1;
var p3 = i + 3 < points.Count ? new Point(points[i + 3].X, points[i + 3].Y) : p2;
var bezierSegment = new BezierSegment(p1, p2, p3, true);
pathFigure.Segments.Add(bezierSegment);
}
pathGeometry.Figures.Add(pathFigure);
return pathGeometry;
}
/// <summary>
/// 将PathGeometry转换为StylusPoint集合
/// </summary>
private List<StylusPoint> ConvertPathGeometryToStylusPoints(PathGeometry pathGeometry, StylusPointCollection originalPoints)
{
var result = new List<StylusPoint>();
var flattened = pathGeometry.GetFlattenedPathGeometry();
foreach (var figure in flattened.Figures)
{
result.Add(new StylusPoint(figure.StartPoint.X, figure.StartPoint.Y, 0.5f));
foreach (var segment in figure.Segments)
{
if (segment is LineSegment lineSegment)
{
result.Add(new StylusPoint(lineSegment.Point.X, lineSegment.Point.Y, 0.5f));
}
else if (segment is PolyLineSegment polyLineSegment)
{
foreach (var point in polyLineSegment.Points)
{
result.Add(new StylusPoint(point.X, point.Y, 0.5f));
}
}
}
}
// 保持原始压感信息
InterpolatePressure(result, originalPoints);
return result;
}
/// <summary>
/// 插值压感信息
/// </summary>
private void InterpolatePressure(List<StylusPoint> smoothedPoints, StylusPointCollection originalPoints)
{
if (originalPoints.Count == 0 || smoothedPoints.Count == 0) return;
for (int i = 0; i < smoothedPoints.Count; i++)
{
double ratio = (double)i / (smoothedPoints.Count - 1);
int originalIndex = (int)(ratio * (originalPoints.Count - 1));
originalIndex = Math.Max(0, Math.Min(originalIndex, originalPoints.Count - 1));
var point = smoothedPoints[i];
float pressure = originalPoints[originalIndex].PressureFactor;
smoothedPoints[i] = new StylusPoint(point.X, point.Y, Math.Max(pressure, 0.1f));
}
}
/// <summary>
/// 使用GPU加速的并行贝塞尔计算
/// </summary>
public static StylusPoint[] ParallelBezierInterpolation(StylusPoint[] controlPoints, int segments = 32)
{
if (controlPoints.Length < 4) return controlPoints;
var result = new StylusPoint[segments * (controlPoints.Length / 4)];
Parallel.For(0, controlPoints.Length / 4, segmentIndex =>
{
var p0 = controlPoints[segmentIndex * 4];
var p1 = controlPoints[segmentIndex * 4 + 1];
var p2 = controlPoints[segmentIndex * 4 + 2];
var p3 = controlPoints[segmentIndex * 4 + 3];
for (int i = 0; i < segments; i++)
{
double t = (double)i / (segments - 1);
result[segmentIndex * segments + i] = CubicBezierFast(p0, p1, p2, p3, t);
}
});
return result;
}
/// <summary>
/// 优化的三次贝塞尔曲线计算
/// </summary>
private static StylusPoint CubicBezierFast(StylusPoint p0, StylusPoint p1, StylusPoint p2, StylusPoint p3, double t)
{
double u = 1 - t;
double tt = t * t;
double uu = u * u;
double uuu = uu * u;
double ttt = tt * t;
double x = uuu * p0.X + 3 * uu * t * p1.X + 3 * u * tt * p2.X + ttt * p3.X;
double y = uuu * p0.Y + 3 * uu * t * p1.Y + 3 * u * tt * p2.Y + ttt * p3.Y;
float pressure = (float)(p1.PressureFactor * u + p2.PressureFactor * t);
return new StylusPoint(x, y, Math.Max(pressure, 0.1f));
}
/// <summary>
/// 释放GPU资源
/// </summary>
public void Dispose()
{
_drawingContext?.Close();
_renderTarget?.Clear();
_isInitialized = false;
}
}
/// <summary>
/// 质量配置枚举
/// </summary>
public enum InkSmoothingQuality
{
HighPerformance = 0, // 高性能低质量
Balanced = 1, // 平衡
HighQuality = 2 // 高质量低性能
}
/// <summary>
/// 墨迹平滑配置
/// </summary>
public class InkSmoothingConfig
{
public InkSmoothingQuality Quality { get; set; } = InkSmoothingQuality.HighQuality;
public bool UseHardwareAcceleration { get; set; } = true;
public bool UseAsyncProcessing { get; set; } = true;
public int MaxConcurrentTasks { get; set; } = Environment.ProcessorCount;
public double SmoothingStrength { get; set; } = 0.8; // 高质量模式的平滑强度
public double ResampleInterval { get; set; } = 0.8; // 高质量模式的重采样间隔
public int InterpolationSteps { get; set; } = 64; // 高质量模式的插值步数
public static InkSmoothingConfig FromSettings()
{
return new InkSmoothingConfig
{
Quality = (InkSmoothingQuality)MainWindow.Settings.Canvas.InkSmoothingQuality,
UseHardwareAcceleration = MainWindow.Settings.Canvas.UseHardwareAcceleration,
UseAsyncProcessing = MainWindow.Settings.Canvas.UseAsyncInkSmoothing,
MaxConcurrentTasks = MainWindow.Settings.Canvas.MaxConcurrentSmoothingTasks > 0 ?
MainWindow.Settings.Canvas.MaxConcurrentSmoothingTasks : Environment.ProcessorCount
};
}
public void ApplyQualitySettings()
{
switch (Quality)
{
case InkSmoothingQuality.HighPerformance:
SmoothingStrength = 0.4;
ResampleInterval = 2.0;
InterpolationSteps = 16;
break;
case InkSmoothingQuality.Balanced:
SmoothingStrength = 0.6;
ResampleInterval = 1.2;
InterpolationSteps = 32;
break;
case InkSmoothingQuality.HighQuality:
SmoothingStrength = 0.8;
ResampleInterval = 0.8;
InterpolationSteps = 64;
break;
}
}
}
}
-168
View File
@@ -1,168 +0,0 @@
using System;
using System.IO;
using System.Reflection;
using System.Windows;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// IACore DLL自动释放器
/// 在应用启动时自动释放IACore相关的DLL文件到应用程序目录
/// </summary>
public static class IACoreDllExtractor
{
private static readonly string[] RequiredDlls = {
"IACore.dll",
"IALoader.dll",
"IAWinFX.dll"
};
/// <summary>
/// 在应用启动时释放IACore相关DLL
/// </summary>
public static void ExtractIACoreDlls()
{
try
{
string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
LogHelper.WriteLogToFile("开始检查并释放IACore相关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},可能影响形状识别功能", LogHelper.LogType.Warning);
}
}
LogHelper.WriteLogToFile("IACore DLL释放检查完成");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"释放IACore 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.Resources.IACore.{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($"清理IACore DLL时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
}
}
-262
View File
@@ -1,262 +0,0 @@
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Ink;
using System.Windows.Media;
using System.Windows.Threading;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// 统一的墨迹平滑管理器,整合异步处理和硬件加速
/// </summary>
public class InkSmoothingManager : IDisposable
{
private readonly AsyncAdvancedBezierSmoothing _asyncSmoothing;
private readonly HardwareAcceleratedInkProcessor _hardwareProcessor;
private readonly InkSmoothingPerformanceMonitor _performanceMonitor;
private readonly InkSmoothingConfig _config;
private readonly Dispatcher _uiDispatcher;
private bool _disposed;
public InkSmoothingManager(Dispatcher uiDispatcher)
{
_uiDispatcher = uiDispatcher;
_config = InkSmoothingConfig.FromSettings();
_config.ApplyQualitySettings();
_asyncSmoothing = new AsyncAdvancedBezierSmoothing(uiDispatcher)
{
SmoothingStrength = _config.SmoothingStrength,
ResampleInterval = _config.ResampleInterval,
InterpolationSteps = _config.InterpolationSteps,
UseHardwareAcceleration = _config.UseHardwareAcceleration,
MaxConcurrentTasks = _config.MaxConcurrentTasks
};
_hardwareProcessor = new HardwareAcceleratedInkProcessor();
_performanceMonitor = new InkSmoothingPerformanceMonitor();
}
/// <summary>
/// 平滑笔画(自动选择最佳方法)
/// </summary>
public async Task<Stroke> SmoothStrokeAsync(Stroke originalStroke,
Action<Stroke, Stroke> onCompleted = null,
CancellationToken cancellationToken = default)
{
if (originalStroke == null || originalStroke.StylusPoints.Count < 2)
return originalStroke;
var stopwatch = Stopwatch.StartNew();
Stroke result = originalStroke;
try
{
if (_config.UseAsyncProcessing)
{
// 使用异步处理
result = await _asyncSmoothing.SmoothStrokeAsync(originalStroke, onCompleted, cancellationToken);
}
else if (_config.UseHardwareAcceleration)
{
// 使用硬件加速但同步处理
result = await _hardwareProcessor.SmoothStrokeWithGPU(originalStroke);
onCompleted?.Invoke(originalStroke, result);
}
else
{
// 回退到传统同步处理
result = await Task.Run(() =>
{
var traditionalSmoothing = new AdvancedBezierSmoothing();
return traditionalSmoothing.SmoothStroke(originalStroke);
}, cancellationToken);
onCompleted?.Invoke(originalStroke, result);
}
}
catch (OperationCanceledException)
{
result = originalStroke;
}
catch (Exception ex)
{
Debug.WriteLine($"墨迹平滑失败: {ex.Message}");
result = originalStroke;
}
finally
{
stopwatch.Stop();
_performanceMonitor.RecordProcessingTime(stopwatch.Elapsed);
}
return result;
}
/// <summary>
/// 同步平滑笔画(用于向后兼容)
/// </summary>
public Stroke SmoothStroke(Stroke originalStroke)
{
if (originalStroke == null || originalStroke.StylusPoints.Count < 2)
return originalStroke;
var stopwatch = Stopwatch.StartNew();
Stroke result;
try
{
if (_config.UseHardwareAcceleration)
{
// 使用硬件加速的同步版本
var task = _hardwareProcessor.SmoothStrokeWithGPU(originalStroke);
task.Wait(5000); // 5秒超时
result = task.Status == TaskStatus.RanToCompletion ? task.Result : originalStroke;
}
else
{
// 传统同步处理
var traditionalSmoothing = new AdvancedBezierSmoothing();
result = traditionalSmoothing.SmoothStroke(originalStroke);
}
}
catch (Exception ex)
{
Debug.WriteLine($"同步墨迹平滑失败: {ex.Message}");
result = originalStroke;
}
finally
{
stopwatch.Stop();
_performanceMonitor.RecordProcessingTime(stopwatch.Elapsed);
}
return result;
}
/// <summary>
/// 更新配置
/// </summary>
public void UpdateConfig()
{
var newConfig = InkSmoothingConfig.FromSettings();
newConfig.ApplyQualitySettings();
_asyncSmoothing.SmoothingStrength = newConfig.SmoothingStrength;
_asyncSmoothing.ResampleInterval = newConfig.ResampleInterval;
_asyncSmoothing.InterpolationSteps = newConfig.InterpolationSteps;
_asyncSmoothing.UseHardwareAcceleration = newConfig.UseHardwareAcceleration;
_asyncSmoothing.MaxConcurrentTasks = newConfig.MaxConcurrentTasks;
}
/// <summary>
/// 获取性能统计信息
/// </summary>
public string GetPerformanceStats()
{
return $"平均处理时间: {_performanceMonitor.GetAverageProcessingTimeMs():F2}ms, " +
$"最大处理时间: {_performanceMonitor.GetMaxProcessingTimeMs():F2}ms, " +
$"样本数: {_performanceMonitor.GetSampleCount()}";
}
/// <summary>
/// 取消所有正在进行的任务
/// </summary>
public void CancelAllTasks()
{
_asyncSmoothing?.CancelAllTasks();
}
/// <summary>
/// 检查系统是否支持硬件加速
/// </summary>
public static bool IsHardwareAccelerationSupported()
{
try
{
return RenderCapability.Tier >= 0x00020000;
}
catch
{
return false;
}
}
/// <summary>
/// 获取推荐的配置
/// </summary>
public static InkSmoothingConfig GetRecommendedConfig()
{
var config = new InkSmoothingConfig();
// 根据系统性能调整配置
var processorCount = Environment.ProcessorCount;
var isHardwareAccelerated = IsHardwareAccelerationSupported();
if (processorCount >= 4 && isHardwareAccelerated)
{
// 降低高质量模式的门槛,4核以上且支持硬件加速就使用高质量
config.Quality = InkSmoothingQuality.HighQuality;
config.UseHardwareAcceleration = true;
config.UseAsyncProcessing = true;
config.MaxConcurrentTasks = Math.Min(processorCount, 8);
}
else if (processorCount >= 2)
{
// 2核以上使用平衡模式
config.Quality = InkSmoothingQuality.Balanced;
config.UseHardwareAcceleration = isHardwareAccelerated;
config.UseAsyncProcessing = true;
config.MaxConcurrentTasks = Math.Min(processorCount, 4);
}
else
{
// 单核或性能较低的设备使用高性能模式
config.Quality = InkSmoothingQuality.HighPerformance;
config.UseHardwareAcceleration = false;
config.UseAsyncProcessing = false;
config.MaxConcurrentTasks = 1;
}
config.ApplyQualitySettings();
return config;
}
/// <summary>
/// 应用推荐配置到设置
/// </summary>
public static void ApplyRecommendedSettings()
{
var config = GetRecommendedConfig();
MainWindow.Settings.Canvas.InkSmoothingQuality = (int)config.Quality;
MainWindow.Settings.Canvas.UseHardwareAcceleration = config.UseHardwareAcceleration;
MainWindow.Settings.Canvas.UseAsyncInkSmoothing = config.UseAsyncProcessing;
MainWindow.Settings.Canvas.MaxConcurrentSmoothingTasks = config.MaxConcurrentTasks;
}
public void Dispose()
{
if (!_disposed)
{
CancelAllTasks();
_asyncSmoothing?.Dispose();
_hardwareProcessor?.Dispose();
_disposed = true;
}
}
}
/// <summary>
/// 墨迹平滑事件参数
/// </summary>
public class InkSmoothingEventArgs : EventArgs
{
public Stroke OriginalStroke { get; set; }
public Stroke SmoothedStroke { get; set; }
public TimeSpan ProcessingTime { get; set; }
public bool WasAsync { get; set; }
public bool UsedHardwareAcceleration { get; set; }
}
}
-142
View File
@@ -1,142 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
namespace Ink_Canvas.Helpers
{
class LogHelper
{
public static string LogFile = "Log.txt";
private static string LogsFolder = "Logs";
private static string AppStartTime = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
private static readonly long MaxLogsFolderSizeBytes = 5 * 1024 * 1024; // 5MB
public static void NewLog(string str)
{
WriteLogToFile(str);
}
public static void NewLog(Exception ex)
{
if (ex == null) return;
var stackTrace = ex.StackTrace ?? "<no stack trace>";
var msg = $"[Exception] Type: {ex.GetType().FullName}\nMessage: {ex.Message}\nStackTrace: {stackTrace}";
if (ex.InnerException != null)
{
msg += $"\nInnerException: {ex.InnerException.GetType().FullName} - {ex.InnerException.Message}\n{ex.InnerException.StackTrace}";
}
WriteLogToFile(msg, LogType.Error);
}
public static void WriteLogToFile(string str, LogType logType = LogType.Info)
{
// 检查日志是否启用
if (MainWindow.Settings != null && MainWindow.Settings.Advanced != null && !MainWindow.Settings.Advanced.IsLogEnabled) return;
string strLogType = logType.ToString();
try
{
string file;
// 检查是否启用了日期保存功能
if (MainWindow.Settings != null && MainWindow.Settings.Advanced != null && MainWindow.Settings.Advanced.IsSaveLogByDate)
{
// 确保Logs文件夹存在
string logsPath = Path.Combine(App.RootPath, LogsFolder);
if (!Directory.Exists(logsPath))
{
Directory.CreateDirectory(logsPath);
}
// 检查Logs文件夹大小,如果超过5MB则清空
CheckAndCleanLogsFolder(logsPath);
// 使用软件启动时间作为日志文件名
file = Path.Combine(logsPath, $"Log_{AppStartTime}.txt");
}
else
{
file = App.RootPath + LogFile;
}
if (!Directory.Exists(App.RootPath))
{
Directory.CreateDirectory(App.RootPath);
}
var threadId = Thread.CurrentThread.ManagedThreadId;
var callingMethod = new StackTrace(2, true).GetFrame(0);
string callerInfo = "<unknown>";
if (callingMethod != null)
{
var method = callingMethod.GetMethod();
if (method != null)
{
var className = method.DeclaringType != null ? method.DeclaringType.FullName : "<no class>";
callerInfo = $"{className}.{method.Name}";
}
}
string logLine = string.Format("{0} [T{1}] [{2}] [{3}] {4}", DateTime.Now.ToString("O"), threadId, strLogType, callerInfo, str);
using (StreamWriter sw = new StreamWriter(file, true))
{
sw.WriteLine(logLine);
}
}
catch { }
}
private static void CheckAndCleanLogsFolder(string logsPath)
{
try
{
long totalSize = 0;
DirectoryInfo dirInfo = new DirectoryInfo(logsPath);
// 如果目录不存在,直接返回
if (!dirInfo.Exists) return;
// 计算文件夹大小
foreach (FileInfo file in dirInfo.GetFiles())
{
totalSize += file.Length;
}
// 如果超过5MB,清空文件夹
if (totalSize > MaxLogsFolderSizeBytes)
{
foreach (FileInfo file in dirInfo.GetFiles())
{
try
{
file.Delete();
}
catch { }
}
// 记录清理操作
string cleanupMessage = $"Logs folder exceeded size limit ({totalSize / 1024.0 / 1024.0:F2} MB > {MaxLogsFolderSizeBytes / 1024.0 / 1024.0:F2} MB). Folder cleaned.";
using (StreamWriter sw = new StreamWriter(Path.Combine(logsPath, $"Log_{AppStartTime}.txt"), true))
{
sw.WriteLine($"{DateTime.Now:O} [Cleanup] {cleanupMessage}");
}
}
}
catch { }
}
internal static void WriteLogToFile(string v, object warning)
{
WriteLogToFile($"[Warning] {v}", LogType.Warning);
}
public enum LogType
{
Info,
Trace,
Error,
Event,
Warning
}
}
}
-397
View File
@@ -1,397 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Ink;
using System.Windows.Threading;
using Microsoft.Office.Interop.PowerPoint;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// PPT墨迹管理器 - 负责PPT中墨迹的保存、加载和同步
/// </summary>
public class PPTInkManager : IDisposable
{
#region Properties
public bool IsAutoSaveEnabled { get; set; } = true;
public string AutoSaveLocation { get; set; } = "";
public StrokeCollection CurrentStrokes { get; private set; } = new StrokeCollection();
#endregion
#region Private Fields
private MemoryStream[] _memoryStreams;
private int _maxSlides = 100;
private string _currentPresentationId = "";
private readonly object _lockObject = new object();
private bool _disposed = false;
// 墨迹锁定机制,防止翻页时的墨迹冲突
private DateTime _inkLockUntil = DateTime.MinValue;
private int _lockedSlideIndex = -1;
private const int InkLockMilliseconds = 500;
#endregion
#region Constructor
public PPTInkManager()
{
InitializeMemoryStreams();
}
private void InitializeMemoryStreams()
{
_memoryStreams = new MemoryStream[_maxSlides + 2];
}
#endregion
#region Public Methods
/// <summary>
/// 初始化新的演示文稿
/// </summary>
public void InitializePresentation(Presentation presentation)
{
if (presentation == null) return;
lock (_lockObject)
{
try
{
// 生成演示文稿唯一标识符
_currentPresentationId = GeneratePresentationId(presentation);
// 重新初始化内存流数组
var slideCount = presentation.Slides.Count;
_memoryStreams = new MemoryStream[slideCount + 2];
// 如果启用自动保存,尝试加载已保存的墨迹
if (IsAutoSaveEnabled && !string.IsNullOrEmpty(AutoSaveLocation))
{
LoadSavedStrokes();
}
LogHelper.WriteLogToFile($"已初始化演示文稿墨迹管理: {presentation.Name}, 幻灯片数量: {slideCount}", LogHelper.LogType.Trace);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"初始化演示文稿墨迹管理失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 保存当前页面的墨迹
/// </summary>
public void SaveCurrentSlideStrokes(int slideIndex, StrokeCollection strokes)
{
if (slideIndex <= 0 || strokes == null) return;
lock (_lockObject)
{
try
{
// 检查墨迹锁定
if (!CanWriteInk(slideIndex))
{
LogHelper.WriteLogToFile($"墨迹写入被锁定,当前页:{slideIndex},锁定页:{_lockedSlideIndex}", LogHelper.LogType.Warning);
return;
}
if (slideIndex < _memoryStreams.Length)
{
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);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存第{slideIndex}页墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 加载指定页面的墨迹
/// </summary>
public StrokeCollection LoadSlideStrokes(int slideIndex)
{
if (slideIndex <= 0) return new StrokeCollection();
lock (_lockObject)
{
try
{
if (slideIndex < _memoryStreams.Length && _memoryStreams[slideIndex] != null && _memoryStreams[slideIndex].Length > 0)
{
_memoryStreams[slideIndex].Position = 0;
var strokes = new StrokeCollection(_memoryStreams[slideIndex]);
LogHelper.WriteLogToFile($"已加载第{slideIndex}页墨迹,笔画数量: {strokes.Count}", LogHelper.LogType.Trace);
return strokes;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"加载第{slideIndex}页墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
return new StrokeCollection();
}
/// <summary>
/// 切换到指定页面并加载墨迹
/// </summary>
public StrokeCollection SwitchToSlide(int slideIndex, StrokeCollection currentStrokes = null)
{
lock (_lockObject)
{
try
{
// 如果有当前墨迹,先保存
if (currentStrokes != null && currentStrokes.Count > 0)
{
SaveCurrentSlideStrokes(_lockedSlideIndex > 0 ? _lockedSlideIndex : slideIndex, currentStrokes);
}
// 设置墨迹锁定
LockInkForSlide(slideIndex);
// 加载新页面的墨迹
return LoadSlideStrokes(slideIndex);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"切换到第{slideIndex}页失败: {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 folderPath = GetPresentationFolderPath();
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
// 保存位置信息
try
{
File.WriteAllText(Path.Combine(folderPath, "Position"), _lockedSlideIndex.ToString());
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存位置信息失败: {ex}", LogHelper.LogType.Error);
}
// 保存所有页面的墨迹
int savedCount = 0;
for (int i = 1; i <= presentation.Slides.Count && i < _memoryStreams.Length; i++)
{
if (_memoryStreams[i] != null)
{
try
{
if (_memoryStreams[i].Length > 8)
{
var srcBuf = new byte[_memoryStreams[i].Length];
_memoryStreams[i].Position = 0;
var byteLength = _memoryStreams[i].Read(srcBuf, 0, srcBuf.Length);
var filePath = Path.Combine(folderPath, i.ToString("0000") + ".icstk");
File.WriteAllBytes(filePath, srcBuf);
savedCount++;
LogHelper.WriteLogToFile($"已保存第{i}页墨迹,大小: {byteLength} bytes", LogHelper.LogType.Trace);
}
else
{
// 删除空的墨迹文件
var filePath = Path.Combine(folderPath, i.ToString("0000") + ".icstk");
if (File.Exists(filePath))
{
File.Delete(filePath);
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存第{i}页墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
}
LogHelper.WriteLogToFile($"已保存{savedCount}页墨迹到文件", LogHelper.LogType.Event);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存墨迹到文件失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 从文件加载已保存的墨迹
/// </summary>
public void LoadSavedStrokes()
{
if (!IsAutoSaveEnabled || string.IsNullOrEmpty(AutoSaveLocation)) return;
lock (_lockObject)
{
try
{
var folderPath = GetPresentationFolderPath();
if (!Directory.Exists(folderPath)) return;
var files = new DirectoryInfo(folderPath).GetFiles("*.icstk");
int loadedCount = 0;
foreach (var file in files)
{
try
{
if (int.TryParse(Path.GetFileNameWithoutExtension(file.Name), out int slideIndex))
{
if (slideIndex > 0 && slideIndex < _memoryStreams.Length)
{
var fileBytes = File.ReadAllBytes(file.FullName);
_memoryStreams[slideIndex] = new MemoryStream(fileBytes);
_memoryStreams[slideIndex].Position = 0;
loadedCount++;
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"加载墨迹文件{file.Name}失败: {ex}", LogHelper.LogType.Error);
}
}
LogHelper.WriteLogToFile($"已从文件加载{loadedCount}页墨迹", LogHelper.LogType.Event);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"从文件加载墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 清除所有墨迹
/// </summary>
public void ClearAllStrokes()
{
lock (_lockObject)
{
try
{
for (int i = 0; i < _memoryStreams.Length; i++)
{
_memoryStreams[i]?.Dispose();
_memoryStreams[i] = null;
}
CurrentStrokes.Clear();
LogHelper.WriteLogToFile("已清除所有墨迹", LogHelper.LogType.Trace);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清除墨迹失败: {ex}", LogHelper.LogType.Error);
}
}
}
/// <summary>
/// 翻页后锁定墨迹写入
/// </summary>
public void LockInkForSlide(int slideIndex)
{
_inkLockUntil = DateTime.Now.AddMilliseconds(InkLockMilliseconds);
_lockedSlideIndex = slideIndex;
}
/// <summary>
/// 检查是否可以写入墨迹
/// </summary>
public bool CanWriteInk(int currentSlideIndex)
{
if (DateTime.Now < _inkLockUntil) return false;
if (currentSlideIndex != _lockedSlideIndex && _lockedSlideIndex > 0) return false;
return true;
}
#endregion
#region Private Methods
private string GeneratePresentationId(Presentation presentation)
{
try
{
var presentationPath = presentation.FullName;
var fileHash = GetFileHash(presentationPath);
return $"{presentation.Name}_{presentation.Slides.Count}_{fileHash}";
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"生成演示文稿ID失败: {ex}", LogHelper.LogType.Error);
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 ex)
{
LogHelper.WriteLogToFile($"计算文件哈希值失败: {ex}", LogHelper.LogType.Error);
return "error";
}
}
private string GetPresentationFolderPath()
{
return Path.Combine(AutoSaveLocation, "Auto Saved - Presentations", _currentPresentationId);
}
#endregion
#region Dispose
public void Dispose()
{
if (!_disposed)
{
lock (_lockObject)
{
ClearAllStrokes();
}
_disposed = true;
}
}
#endregion
}
}
File diff suppressed because it is too large Load Diff
-435
View File
@@ -1,435 +0,0 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
namespace Ink_Canvas.Helpers
{
/// <summary>
/// PPT UI管理器 - 统一管理PPT相关的UI更新和样式设置
/// </summary>
public class PPTUIManager
{
#region Properties
public bool ShowPPTButton { get; set; } = true;
public int PPTButtonsDisplayOption { get; set; } = 2222;
public int PPTSButtonsOption { get; set; } = 221;
public int PPTBButtonsOption { get; set; } = 121;
public int PPTLSButtonPosition { get; set; } = 0;
public int PPTRSButtonPosition { get; set; } = 0;
public bool EnablePPTButtonPageClickable { get; set; } = true;
#endregion
#region Private Fields
private readonly MainWindow _mainWindow;
private readonly Dispatcher _dispatcher;
#endregion
#region Constructor
public PPTUIManager(MainWindow mainWindow)
{
_mainWindow = mainWindow ?? throw new ArgumentNullException(nameof(mainWindow));
_dispatcher = _mainWindow.Dispatcher;
}
#endregion
#region Public Methods
/// <summary>
/// 更新PPT连接状态UI
/// </summary>
public void UpdateConnectionStatus(bool isConnected)
{
_dispatcher.InvokeAsync(() =>
{
try
{
if (isConnected)
{
_mainWindow.StackPanelPPTControls.Visibility = Visibility.Visible;
_mainWindow.BtnPPTSlideShow.Visibility = Visibility.Visible;
}
else
{
_mainWindow.StackPanelPPTControls.Visibility = Visibility.Collapsed;
_mainWindow.BtnPPTSlideShow.Visibility = Visibility.Collapsed;
_mainWindow.BtnPPTSlideShowEnd.Visibility = Visibility.Collapsed;
HideAllNavigationPanels();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新PPT连接状态UI失败: {ex}", LogHelper.LogType.Error);
}
});
}
/// <summary>
/// 更新幻灯片放映状态UI
/// </summary>
public void UpdateSlideShowStatus(bool isInSlideShow, int currentSlide = 0, int totalSlides = 0)
{
_dispatcher.InvokeAsync(() =>
{
try
{
if (isInSlideShow)
{
_mainWindow.BtnPPTSlideShow.Visibility = Visibility.Collapsed;
_mainWindow.BtnPPTSlideShowEnd.Visibility = Visibility.Visible;
if (currentSlide > 0 && totalSlides > 0)
{
_mainWindow.PPTBtnPageNow.Text = currentSlide.ToString();
_mainWindow.PPTBtnPageTotal.Text = $"/ {totalSlides}";
}
UpdateNavigationPanelsVisibility();
UpdateNavigationButtonStyles();
}
else
{
_mainWindow.BtnPPTSlideShow.Visibility = Visibility.Visible;
_mainWindow.BtnPPTSlideShowEnd.Visibility = Visibility.Collapsed;
HideAllNavigationPanels();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新幻灯片放映状态UI失败: {ex}", LogHelper.LogType.Error);
}
});
}
/// <summary>
/// 更新当前页码显示
/// </summary>
public void UpdateCurrentSlideNumber(int currentSlide, int totalSlides)
{
_dispatcher.InvokeAsync(() =>
{
try
{
_mainWindow.PPTBtnPageNow.Text = currentSlide.ToString();
_mainWindow.PPTBtnPageTotal.Text = $"/ {totalSlides}";
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新页码显示失败: {ex}", LogHelper.LogType.Error);
}
});
}
/// <summary>
/// 更新导航面板显示状态
/// </summary>
public void UpdateNavigationPanelsVisibility()
{
_dispatcher.InvokeAsync(() =>
{
try
{
// 检查是否应该显示PPT按钮
bool shouldShowButtons = ShowPPTButton && _mainWindow.BtnPPTSlideShowEnd.Visibility == Visibility.Visible;
if (!shouldShowButtons)
{
HideAllNavigationPanels();
return;
}
// 设置侧边按钮位置
_mainWindow.LeftSidePanelForPPTNavigation.Margin = new Thickness(0, 0, 0, PPTLSButtonPosition * 2);
_mainWindow.RightSidePanelForPPTNavigation.Margin = new Thickness(0, 0, 0, PPTRSButtonPosition * 2);
// 根据显示选项设置面板可见性
var displayOption = PPTButtonsDisplayOption.ToString();
if (displayOption.Length >= 4)
{
var options = displayOption.ToCharArray();
// 左下角面板
if (options[0] == '2')
AnimationsHelper.ShowWithFadeIn(_mainWindow.LeftBottomPanelForPPTNavigation);
else
_mainWindow.LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
// 右下角面板
if (options[1] == '2')
AnimationsHelper.ShowWithFadeIn(_mainWindow.RightBottomPanelForPPTNavigation);
else
_mainWindow.RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
// 左侧面板
if (options[2] == '2')
AnimationsHelper.ShowWithFadeIn(_mainWindow.LeftSidePanelForPPTNavigation);
else
_mainWindow.LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
// 右侧面板
if (options[3] == '2')
AnimationsHelper.ShowWithFadeIn(_mainWindow.RightSidePanelForPPTNavigation);
else
_mainWindow.RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新导航面板显示状态失败: {ex}", LogHelper.LogType.Error);
}
});
}
/// <summary>
/// 更新导航按钮样式
/// </summary>
public void UpdateNavigationButtonStyles()
{
_dispatcher.InvokeAsync(() =>
{
try
{
UpdateSideButtonStyles();
UpdateBottomButtonStyles();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新导航按钮样式失败: {ex}", LogHelper.LogType.Error);
}
});
}
/// <summary>
/// 隐藏所有导航面板
/// </summary>
public void HideAllNavigationPanels()
{
_dispatcher.InvokeAsync(() =>
{
try
{
_mainWindow.LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
_mainWindow.RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
_mainWindow.LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
_mainWindow.RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"隐藏导航面板失败: {ex}", LogHelper.LogType.Error);
}
});
}
/// <summary>
/// 显示/隐藏侧边栏退出按钮
/// </summary>
public void UpdateSidebarExitButtons(bool show)
{
_dispatcher.InvokeAsync(() =>
{
try
{
var visibility = show ? Visibility.Visible : Visibility.Collapsed;
if (_mainWindow.BtnExitPptFromSidebarLeft != null)
_mainWindow.BtnExitPptFromSidebarLeft.Visibility = visibility;
if (_mainWindow.BtnExitPptFromSidebarRight != null)
_mainWindow.BtnExitPptFromSidebarRight.Visibility = visibility;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新侧边栏退出按钮失败: {ex}", LogHelper.LogType.Error);
}
});
}
/// <summary>
/// 设置浮动栏透明度
/// </summary>
public void SetFloatingBarOpacity(double opacity)
{
_dispatcher.InvokeAsync(() =>
{
try
{
_mainWindow.ViewboxFloatingBar.Opacity = opacity;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"设置浮动栏透明度失败: {ex}", LogHelper.LogType.Error);
}
});
}
/// <summary>
/// 设置主面板边距
/// </summary>
public void SetMainPanelMargin(Thickness margin)
{
_dispatcher.InvokeAsync(() =>
{
try
{
_mainWindow.ViewBoxStackPanelMain.Margin = margin;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"设置主面板边距失败: {ex}", LogHelper.LogType.Error);
}
});
}
#endregion
#region Private Methods
private void UpdateSideButtonStyles()
{
try
{
var sideOption = PPTSButtonsOption.ToString();
if (sideOption.Length < 3) return;
var options = sideOption.ToCharArray();
// 页码按钮显示
var pageButtonVisibility = options[0] == '2' ? Visibility.Visible : Visibility.Collapsed;
_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;
// 颜色主题
bool isDarkTheme = options[2] == '2';
ApplyButtonTheme(_mainWindow.PPTBtnLSBorder, _mainWindow.PPTBtnRSBorder, isDarkTheme, true);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新侧边按钮样式失败: {ex}", LogHelper.LogType.Error);
}
}
private void UpdateBottomButtonStyles()
{
try
{
var bottomOption = PPTBButtonsOption.ToString();
if (bottomOption.Length < 3) return;
var options = bottomOption.ToCharArray();
// 页码按钮显示
var pageButtonVisibility = options[0] == '2' ? Visibility.Visible : Visibility.Collapsed;
_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;
// 颜色主题
bool isDarkTheme = options[2] == '2';
ApplyButtonTheme(_mainWindow.PPTBtnLBBorder, _mainWindow.PPTBtnRBBorder, isDarkTheme, false);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新底部按钮样式失败: {ex}", LogHelper.LogType.Error);
}
}
private void ApplyButtonTheme(Border leftBorder, Border rightBorder, bool isDarkTheme, bool isSideButton)
{
try
{
Color backgroundColor, borderColor, foregroundColor, feedbackColor;
if (isDarkTheme)
{
backgroundColor = Color.FromRgb(39, 39, 42);
borderColor = Color.FromRgb(82, 82, 91);
foregroundColor = Colors.White;
feedbackColor = Colors.White;
}
else
{
backgroundColor = Color.FromRgb(244, 244, 245);
borderColor = Color.FromRgb(161, 161, 170);
foregroundColor = Color.FromRgb(39, 39, 42);
feedbackColor = Color.FromRgb(24, 24, 27);
}
// 应用背景和边框颜色
var backgroundBrush = new SolidColorBrush(backgroundColor);
var borderBrush = new SolidColorBrush(borderColor);
leftBorder.Background = backgroundBrush;
leftBorder.BorderBrush = borderBrush;
rightBorder.Background = backgroundBrush;
rightBorder.BorderBrush = borderBrush;
// 应用图标和文字颜色
var foregroundBrush = new SolidColorBrush(foregroundColor);
var feedbackBrush = new SolidColorBrush(feedbackColor);
if (isSideButton)
{
ApplySideButtonColors(foregroundBrush, feedbackBrush);
}
else
{
ApplyBottomButtonColors(foregroundBrush, feedbackBrush);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"应用按钮主题失败: {ex}", LogHelper.LogType.Error);
}
}
private void ApplySideButtonColors(SolidColorBrush foregroundBrush, SolidColorBrush feedbackBrush)
{
// 图标颜色
_mainWindow.PPTLSPreviousButtonGeometry.Brush = foregroundBrush;
_mainWindow.PPTRSPreviousButtonGeometry.Brush = foregroundBrush;
_mainWindow.PPTLSNextButtonGeometry.Brush = foregroundBrush;
_mainWindow.PPTRSNextButtonGeometry.Brush = foregroundBrush;
// 反馈背景颜色
_mainWindow.PPTLSPreviousButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTRSPreviousButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTLSPageButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTRSPageButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTLSNextButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTRSNextButtonFeedbackBorder.Background = feedbackBrush;
// 文字颜色
TextBlock.SetForeground(_mainWindow.PPTLSPageButton, foregroundBrush);
TextBlock.SetForeground(_mainWindow.PPTRSPageButton, foregroundBrush);
}
private void ApplyBottomButtonColors(SolidColorBrush foregroundBrush, SolidColorBrush feedbackBrush)
{
// 图标颜色
_mainWindow.PPTLBPreviousButtonGeometry.Brush = foregroundBrush;
_mainWindow.PPTRBPreviousButtonGeometry.Brush = foregroundBrush;
_mainWindow.PPTLBNextButtonGeometry.Brush = foregroundBrush;
_mainWindow.PPTRBNextButtonGeometry.Brush = foregroundBrush;
// 反馈背景颜色
_mainWindow.PPTLBPreviousButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTRBPreviousButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTLBPageButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTRBPageButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTLBNextButtonFeedbackBorder.Background = feedbackBrush;
_mainWindow.PPTRBNextButtonFeedbackBorder.Background = feedbackBrush;
// 文字颜色
TextBlock.SetForeground(_mainWindow.PPTLBPageButton, foregroundBrush);
TextBlock.SetForeground(_mainWindow.PPTRBPageButton, foregroundBrush);
}
#endregion
}
}
@@ -1,274 +0,0 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using iNKORE.UI.WPF.Modern.Controls;
namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
{
/// <summary>
/// 启动台按钮控件
/// </summary>
public class LauncherButton
{
/// <summary>
/// 父插件
/// </summary>
private readonly SuperLauncherPlugin _plugin;
/// <summary>
/// 实际按钮控件
/// </summary>
private readonly SimpleStackPanel _panel;
/// <summary>
/// 获取按钮UI元素
/// </summary>
public UIElement Element => _panel;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="plugin">父插件</param>
public LauncherButton(SuperLauncherPlugin plugin)
{
try
{
_plugin = plugin;
LogHelper.WriteLogToFile("开始创建启动台按钮");
// 创建SimpleStackPanel
_panel = new SimpleStackPanel
{
Name = "Launcher_Icon",
Orientation = Orientation.Vertical,
HorizontalAlignment = HorizontalAlignment.Center,
Width = 28,
Margin = new Thickness(0, -2, 0, 0),
Background = Brushes.Transparent
};
LogHelper.WriteLogToFile("创建SimpleStackPanel完成");
// 添加图标
var image = CreateIconImage();
_panel.Children.Add(image);
// 添加文本
TextBlock textBlock = new TextBlock
{
Text = "启动台",
Foreground = Brushes.Black,
FontSize = 8,
Margin = new Thickness(0, 1, 0, 0),
TextAlignment = TextAlignment.Center
};
_panel.Children.Add(textBlock);
// 设置鼠标事件
_panel.MouseDown += Panel_MouseDown;
_panel.MouseUp += Panel_MouseUp;
_panel.MouseLeave += Panel_MouseLeave;
// 右键菜单支持
_panel.ContextMenu = CreateContextMenu();
// 设置工具提示
_panel.ToolTip = "启动台";
LogHelper.WriteLogToFile("启动台按钮创建完成");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"创建启动台按钮时出错: {ex.Message}", LogHelper.LogType.Error);
LogHelper.NewLog(ex);
}
}
/// <summary>
/// 创建右键菜单
/// </summary>
private ContextMenu CreateContextMenu()
{
try
{
// 创建菜单
ContextMenu menu = new ContextMenu();
// 创建位置切换菜单项
MenuItem positionMenuItem = new MenuItem();
positionMenuItem.Header = _plugin.Config.ButtonPosition == LauncherButtonPosition.Left ?
"移至右侧" : "移至左侧";
positionMenuItem.Click += (s, e) =>
{
// 切换位置
_plugin.Config.ButtonPosition = _plugin.Config.ButtonPosition == LauncherButtonPosition.Left ?
LauncherButtonPosition.Right : LauncherButtonPosition.Left;
// 更新按钮位置
_plugin.UpdateButtonPosition();
// 保存配置
_plugin.SaveConfig();
LogHelper.WriteLogToFile($"通过右键菜单切换启动台按钮位置为: {_plugin.Config.ButtonPosition}");
};
menu.Items.Add(positionMenuItem);
// 添加设置菜单项
MenuItem settingsMenuItem = new MenuItem();
settingsMenuItem.Header = "打开设置";
settingsMenuItem.Click += (s, e) =>
{
// 打开插件设置窗口
var mainWindow = Application.Current.MainWindow;
if (mainWindow != null)
{
try
{
// 使用反射调用主窗口的ShowPluginSettings方法
var method = mainWindow.GetType().GetMethod("ShowPluginSettings");
if (method != null)
{
method.Invoke(mainWindow, null);
LogHelper.WriteLogToFile("已打开插件设置窗口");
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"打开插件设置窗口失败: {ex.Message}", LogHelper.LogType.Error);
}
}
};
menu.Items.Add(settingsMenuItem);
return menu;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"创建右键菜单时出错: {ex.Message}", LogHelper.LogType.Error);
return null;
}
}
/// <summary>
/// 获取实际的UI元素
/// </summary>
[Obsolete("使用Element属性代替")]
public UIElement GetUIElement()
{
return _panel;
}
/// <summary>
/// 创建图标图像
/// </summary>
private Image CreateIconImage()
{
try
{
// 创建图像
Image image = new Image
{
Height = 17,
Margin = new Thickness(0, 3, 0, 0)
};
// 设置位图缩放模式
RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.HighQuality);
// 创建绘图图像
DrawingImage drawingImage = new DrawingImage();
DrawingGroup drawingGroup = new DrawingGroup();
drawingGroup.ClipGeometry = Geometry.Parse("M0,0 V24 H24 V0 H0 Z");
// 使用提供的应用网格图标
GeometryDrawing geometryDrawing = new GeometryDrawing
{
Brush = new SolidColorBrush(Color.FromRgb(0x1B, 0x1B, 0x1B)),
Geometry = Geometry.Parse("F0 M24,24z M0,0z M4.41721,4.29873C4.35178,4.29873,4.29873,4.35178,4.29873,4.41721L4.29873,9.15646C4.29873,9.22189,4.35178,9.27494,4.41721,9.27494L9.15646,9.27494C9.22189,9.27494,9.27494,9.22189,9.27494,9.15646L9.27494,4.41721C9.27494,4.35178,9.22189,4.29873,9.15646,4.29873L4.41721,4.29873z M2.64,4.41721C2.64,3.43569,3.43569,2.64,4.41721,2.64L9.15646,2.64C10.138,2.64,10.9337,3.43569,10.9337,4.41721L10.9337,9.15646C10.9337,10.138,10.138,10.9337,9.15646,10.9337L4.41721,10.9337C3.43569,10.9337,2.64,10.138,2.64,9.15646L2.64,4.41721z M14.8435,4.29873C14.7781,4.29873,14.7251,4.35178,14.7251,4.41721L14.7251,9.15646C14.7251,9.22189,14.7781,9.27494,14.8435,9.27494L19.5828,9.27494C19.6482,9.27494,19.7013,9.22189,19.7013,9.15646L19.7013,4.41721C19.7013,4.35178,19.6482,4.29873,19.5828,4.29873L14.8435,4.29873z M13.0663,4.41721C13.0663,3.43569,13.862,2.64,14.8435,2.64L19.5828,2.64C20.5643,2.64,21.36,3.43569,21.36,4.41721L21.36,9.15646C21.36,10.138,20.5643,10.9337,19.5828,10.9337L14.8435,10.9337C13.862,10.9337,13.0663,10.138,13.0663,9.15646L13.0663,4.41721z M14.8435,14.7251C14.7781,14.7251,14.7251,14.7781,14.7251,14.8435L14.7251,19.5828C14.7251,19.6482,14.7781,19.7013,14.8435,19.7013L19.5828,19.7013C19.6482,19.7013,19.7013,19.6482,19.7013,19.5828L19.7013,14.8435C19.7013,14.7781,19.6482,14.7251,19.5828,14.7251L14.8435,14.7251z M13.0663,14.8435C13.0663,13.862,13.862,13.0663,14.8435,13.0663L19.5828,13.0663C20.5643,13.0663,21.36,13.862,21.36,14.8435L21.36,19.5828C21.36,20.5643,20.5643,21.36,19.5828,21.36L14.8435,21.36C13.862,21.36,13.0663,20.5643,13.0663,19.5828L13.0663,14.8435z M4.41721,14.7251C4.35178,14.7251,4.29873,14.7781,4.29873,14.8435L4.29873,19.5828C4.29873,19.6482,4.35178,19.7013,4.41721,19.7013L9.15646,19.7013C9.22189,19.7013,9.27494,19.6482,9.27494,19.5828L9.27494,14.8435C9.27494,14.7781,9.22189,14.7251,9.15646,14.7251L4.41721,14.7251z M2.64,14.8435C2.64,13.862,3.43569,13.0663,4.41721,13.0663L9.15646,13.0663C10.138,13.0663,10.9337,13.862,10.9337,14.8435L10.9337,19.5828C10.9337,20.5643,10.138,21.36,9.15646,21.36L4.41721,21.36C3.43569,21.36,2.64,20.5643,2.64,19.5828L2.64,14.8435z")
};
drawingGroup.Children.Add(geometryDrawing);
// 设置图像源
drawingImage.Drawing = drawingGroup;
image.Source = drawingImage;
return image;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"创建图标图像时出错: {ex.Message}", LogHelper.LogType.Error);
LogHelper.NewLog(ex);
// 返回一个空图像
return new Image();
}
}
/// <summary>
/// 鼠标按下事件
/// </summary>
private void Panel_MouseDown(object sender, MouseButtonEventArgs e)
{
try
{
// 提供反馈
_panel.Background = new SolidColorBrush(Color.FromArgb(40, 0, 0, 0));
LogHelper.WriteLogToFile("启动台按钮鼠标按下");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"启动台按钮鼠标按下事件出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 鼠标抬起事件
/// </summary>
private void Panel_MouseUp(object sender, MouseButtonEventArgs e)
{
try
{
// 只有左键点击才显示启动台窗口
if (e.ChangedButton != MouseButton.Left)
{
return;
}
// 恢复背景
_panel.Background = Brushes.Transparent;
LogHelper.WriteLogToFile("启动台按钮鼠标抬起,准备显示启动台窗口");
// 获取按钮在屏幕上的位置
Point buttonPosition = _panel.PointToScreen(new Point(_panel.ActualWidth / 2, 0));
// 显示启动台窗口
_plugin.ShowLauncherWindow(buttonPosition);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"启动台按钮鼠标抬起事件出错: {ex.Message}", LogHelper.LogType.Error);
LogHelper.NewLog(ex);
}
}
/// <summary>
/// 鼠标离开事件
/// </summary>
private void Panel_MouseLeave(object sender, MouseEventArgs e)
{
try
{
// 恢复背景
_panel.Background = Brushes.Transparent;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"启动台按钮鼠标离开事件出错: {ex.Message}", LogHelper.LogType.Error);
}
}
}
}
@@ -1,332 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Win32;
using Newtonsoft.Json;
namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
{
/// <summary>
/// 启动台按钮位置
/// </summary>
public enum LauncherButtonPosition
{
/// <summary>
/// 左侧
/// </summary>
Left,
/// <summary>
/// 右侧
/// </summary>
Right
}
/// <summary>
/// 启动台配置
/// </summary>
public class LauncherConfig
{
/// <summary>
/// 启动台按钮位置
/// </summary>
public LauncherButtonPosition ButtonPosition { get; set; } = LauncherButtonPosition.Right;
/// <summary>
/// 启动台应用程序列表
/// </summary>
public List<LauncherItem> Items { get; set; } = new List<LauncherItem>();
}
/// <summary>
/// 启动台应用项
/// </summary>
public class LauncherItem
{
/// <summary>
/// 应用程序名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 应用程序路径
/// </summary>
public string Path { get; set; }
/// <summary>
/// 是否可见
/// </summary>
public bool IsVisible { get; set; } = true;
/// <summary>
/// 在启动台中的位置(0-39
/// </summary>
public int Position { get; set; } = -1;
/// <summary>
/// 是否已固定位置
/// </summary>
public bool IsPositionFixed { get; set; } = false;
/// <summary>
/// 图标缓存
/// </summary>
[JsonIgnore]
private ImageSource _iconCache;
/// <summary>
/// 获取应用程序图标
/// </summary>
[JsonIgnore]
public ImageSource Icon
{
get
{
if (_iconCache != null)
{
return _iconCache;
}
try
{
if (File.Exists(Path))
{
// 从文件中获取图标
Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(Path);
if (icon != null)
{
_iconCache = Imaging.CreateBitmapSourceFromHIcon(
icon.Handle,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
icon.Dispose();
return _iconCache;
}
}
else
{
// 从注册表中获取文件类型关联图标
string extension = System.IO.Path.GetExtension(Path);
if (!string.IsNullOrEmpty(extension))
{
string fileType = Registry.ClassesRoot.OpenSubKey(extension)?.GetValue(string.Empty) as string;
if (!string.IsNullOrEmpty(fileType))
{
string iconPath = Registry.ClassesRoot.OpenSubKey(fileType + "\\DefaultIcon")?.GetValue(string.Empty) as string;
if (!string.IsNullOrEmpty(iconPath))
{
string[] parts = iconPath.Split(',');
string iconFile = parts[0].Trim('"');
int iconIndex = parts.Length > 1 ? Convert.ToInt32(parts[1]) : 0;
if (File.Exists(iconFile))
{
Icon icon = IconExtractor.Extract(iconFile, iconIndex, true);
if (icon != null)
{
_iconCache = Imaging.CreateBitmapSourceFromHIcon(
icon.Handle,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
icon.Dispose();
return _iconCache;
}
}
}
}
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"获取应用图标时出错: {ex.Message}", LogHelper.LogType.Error);
}
// 返回默认图标
return GetDefaultIcon();
}
}
/// <summary>
/// 获取默认图标
/// </summary>
private ImageSource GetDefaultIcon()
{
try
{
// 对于资源管理器,使用特定图标
if (Path.EndsWith("explorer.exe", StringComparison.OrdinalIgnoreCase))
{
try
{
// 直接从C:\Windows\explorer.exe获取图标
string explorerPath = @"C:\Windows\explorer.exe";
if (File.Exists(explorerPath))
{
Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(explorerPath);
if (icon != null)
{
_iconCache = Imaging.CreateBitmapSourceFromHIcon(
icon.Handle,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
icon.Dispose();
return _iconCache;
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"获取资源管理器图标时出错: {ex.Message}", LogHelper.LogType.Warning);
// 如果获取Windows图标失败,回退到默认图标
}
// 回退到备用图标
string explorerIconPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "Icons-Fluent", "ic_fluent_folder_24_regular.png");
if (File.Exists(explorerIconPath))
{
Uri uri = new Uri(explorerIconPath);
BitmapImage image = new BitmapImage(uri);
_iconCache = image;
return _iconCache;
}
}
// 返回一个简单的默认图标
string iconPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "Icons-png", "icc.png");
if (File.Exists(iconPath))
{
Uri uri = new Uri(iconPath);
BitmapImage image = new BitmapImage(uri);
_iconCache = image;
return _iconCache;
}
// 如果还是没有找到,尝试使用应用程序图标
string appIconPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "Icons-Fluent", "ic_fluent_apps_24_regular.png");
if (File.Exists(appIconPath))
{
Uri uri = new Uri(appIconPath);
BitmapImage image = new BitmapImage(uri);
_iconCache = image;
return _iconCache;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"获取默认图标时出错: {ex.Message}", LogHelper.LogType.Error);
}
return null;
}
/// <summary>
/// 启动应用程序
/// </summary>
public void Launch()
{
try
{
if (string.IsNullOrEmpty(Path))
{
LogHelper.WriteLogToFile("无法启动应用程序:路径为空", LogHelper.LogType.Error);
return;
}
// 检查文件是否存在
if (!File.Exists(Path) && !Path.Contains(":\\"))
{
// 可能是系统命令,如explorer.exe
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = Path,
UseShellExecute = true
};
Process.Start(psi);
}
else
{
// 使用Process.Start启动应用程序
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = Path,
UseShellExecute = true
};
Process.Start(psi);
}
LogHelper.WriteLogToFile($"已启动应用程序: {Path}");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"启动应用程序时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"启动应用程序时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
/// <summary>
/// 图标提取工具类
/// </summary>
public static class IconExtractor
{
/// <summary>
/// 从文件中提取图标
/// </summary>
/// <param name="file">文件路径</param>
/// <param name="index">图标索引</param>
/// <param name="largeIcon">是否提取大图标</param>
/// <returns>提取的图标</returns>
public static Icon Extract(string file, int index, bool largeIcon)
{
try
{
IntPtr large;
IntPtr small;
ExtractIconEx(file, index, out large, out small, 1);
try
{
return Icon.FromHandle(largeIcon ? large : small);
}
catch
{
return null;
}
finally
{
if (large != IntPtr.Zero)
DestroyIcon(large);
if (small != IntPtr.Zero)
DestroyIcon(small);
}
}
catch
{
return null;
}
}
[DllImport("Shell32.dll", EntryPoint = "ExtractIconEx")]
private static extern int ExtractIconEx(
[MarshalAs(UnmanagedType.LPStr)] string lpszFile,
int nIconIndex,
out IntPtr phiconLarge,
out IntPtr phiconSmall,
int nIcons);
[DllImport("User32.dll")]
private static extern int DestroyIcon(IntPtr hIcon);
}
}
@@ -1,143 +0,0 @@
<UserControl x:Class="Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher.LauncherSettingsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher"
mc:Ignorable="d"
d:DesignHeight="500" d:DesignWidth="600">
<UserControl.Resources>
<!-- 自定义按钮样式 -->
<Style x:Key="DefaultButtonStyle" TargetType="Button">
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
TextElement.Foreground="{TemplateBinding Foreground}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Opacity" Value="0.8"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Color="Black" Direction="270" ShadowDepth="2" Opacity="0.3" BlurRadius="4"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="border" Property="Opacity" Value="0.6"/>
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.95" ScaleY="0.95"/>
</Setter.Value>
</Setter>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="border" Property="Opacity" Value="0.4"/>
<Setter Property="Cursor" Value="Arrow"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 标题 -->
<TextBlock Grid.Row="0" Text="超级启动台设置" FontSize="16" FontWeight="Bold" Margin="0,0,0,15" Foreground="Black"/>
<!-- 基本设置 -->
<StackPanel Grid.Row="1" Margin="0,0,0,15">
<TextBlock Text="基本设置" FontSize="14" FontWeight="SemiBold" Margin="0,0,0,10" Foreground="Black"/>
<Grid Margin="10,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 按钮位置 -->
<TextBlock Grid.Row="0" Grid.Column="0" Text="按钮位置:" VerticalAlignment="Center" Foreground="Black"/>
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Margin="0,5">
<RadioButton x:Name="RbtnLeft" Content="浮动栏左侧" Margin="0,0,20,0" Checked="RbtnPosition_Checked" Foreground="Black"/>
<RadioButton x:Name="RbtnRight" Content="浮动栏右侧" IsChecked="True" Checked="RbtnPosition_Checked" Foreground="Black"/>
</StackPanel>
</Grid>
</StackPanel>
<!-- 应用管理 -->
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="应用管理" FontSize="14" FontWeight="SemiBold" Margin="0,0,0,10" Foreground="Black"/>
<Border Grid.Row="1" BorderThickness="1" BorderBrush="#CCCCCC" CornerRadius="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 应用列表 -->
<DataGrid Grid.Row="0" x:Name="DgApps" AutoGenerateColumns="False" Margin="5"
CanUserAddRows="False" CanUserDeleteRows="False"
HeadersVisibility="Column" SelectionMode="Single"
SelectionChanged="DgApps_SelectionChanged">
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="显示" Binding="{Binding IsVisible}" Width="50"/>
<DataGridTextColumn Header="名称" Binding="{Binding Name}" Width="150"/>
<DataGridTextColumn Header="路径" Binding="{Binding Path}" Width="*"/>
<DataGridTextColumn Header="位置" Binding="{Binding Position}" Width="50"/>
</DataGrid.Columns>
</DataGrid>
<!-- 操作按钮 -->
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="5">
<Button x:Name="BtnAdd" Content="添加" Padding="10,5" Margin="0,5,5,5" Click="BtnAdd_Click"
Background="#FF007ACC" Foreground="White" BorderBrush="#FF005A9B" BorderThickness="1"
Style="{StaticResource DefaultButtonStyle}"/>
<Button x:Name="BtnEdit" Content="编辑" Padding="10,5" Margin="5" Click="BtnEdit_Click"
Background="#FF6C757D" Foreground="White" BorderBrush="#FF5A6268" BorderThickness="1"
Style="{StaticResource DefaultButtonStyle}"/>
<Button x:Name="BtnDelete" Content="删除" Padding="10,5" Margin="5" Click="BtnDelete_Click"
Background="#FFDC3545" Foreground="White" BorderBrush="#FFBD2130" BorderThickness="1"
Style="{StaticResource DefaultButtonStyle}"/>
</StackPanel>
</Grid>
</Border>
</Grid>
<!-- 底部按钮 -->
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,15,0,0">
<Button x:Name="BtnSave" Content="保存设置" Padding="15,5" Click="BtnSave_Click"
Background="#FF28A745" Foreground="White" BorderBrush="#FF1E7E34" BorderThickness="1"
Style="{StaticResource DefaultButtonStyle}"/>
</StackPanel>
</Grid>
</UserControl>
@@ -1,396 +0,0 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using Ink_Canvas.Windows;
using Microsoft.Win32;
namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
{
/// <summary>
/// LauncherSettingsControl.xaml 的交互逻辑
/// </summary>
public partial class LauncherSettingsControl : UserControl
{
/// <summary>
/// 父插件
/// </summary>
private readonly SuperLauncherPlugin _plugin;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="plugin">父插件</param>
public LauncherSettingsControl(SuperLauncherPlugin plugin)
{
InitializeComponent();
_plugin = plugin;
// 设置按钮位置
RbtnLeft.IsChecked = _plugin.Config.ButtonPosition == LauncherButtonPosition.Left;
RbtnRight.IsChecked = _plugin.Config.ButtonPosition == LauncherButtonPosition.Right;
// 绑定应用列表
DgApps.ItemsSource = _plugin.LauncherItems;
// 初始化按钮状态
UpdateButtonStates();
}
/// <summary>
/// 更新按钮状态
/// </summary>
private void UpdateButtonStates()
{
bool hasSelection = DgApps.SelectedItem != null;
BtnEdit.IsEnabled = hasSelection;
BtnDelete.IsEnabled = hasSelection;
}
/// <summary>
/// 位置单选按钮选择事件
/// </summary>
private void RbtnPosition_Checked(object sender, RoutedEventArgs e)
{
if (!IsLoaded) return;
LauncherButtonPosition oldPosition = _plugin.Config.ButtonPosition;
if (sender == RbtnLeft)
{
_plugin.Config.ButtonPosition = LauncherButtonPosition.Left;
}
else if (sender == RbtnRight)
{
_plugin.Config.ButtonPosition = LauncherButtonPosition.Right;
}
// 如果位置发生变化,更新按钮位置
if (oldPosition != _plugin.Config.ButtonPosition)
{
try
{
// 更新按钮位置
_plugin.UpdateButtonPosition();
// 保存配置
_plugin.SaveConfig();
LogHelper.WriteLogToFile($"启动台按钮位置已更改为: {_plugin.Config.ButtonPosition}");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新启动台按钮位置时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"更新启动台按钮位置时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
/// <summary>
/// 添加按钮点击事件
/// </summary>
private void BtnAdd_Click(object sender, RoutedEventArgs e)
{
try
{
// 创建新的启动项
LauncherItem item = new LauncherItem
{
Name = "",
Path = "",
IsVisible = true,
Position = -1 // 让插件管理器分配位置
};
// 直接显示编辑对话框
EditLauncherItem(item, true);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"添加启动项时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"添加启动项时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
/// <summary>
/// 编辑应用按钮点击事件
/// </summary>
private void BtnEdit_Click(object sender, RoutedEventArgs e)
{
if (DgApps.SelectedItem is LauncherItem item)
{
EditLauncherItem(item, false);
}
}
/// <summary>
/// 删除应用按钮点击事件
/// </summary>
private void BtnDelete_Click(object sender, RoutedEventArgs e)
{
if (DgApps.SelectedItem is LauncherItem item)
{
// 确认删除
MessageBoxResult result = MessageBox.Show(
$"确定要删除 {item.Name} 吗?",
"删除确认",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
// 从集合中移除
_plugin.LauncherItems.Remove(item);
// 保存配置
_plugin.SaveConfig();
}
}
}
/// <summary>
/// 保存设置按钮点击事件
/// </summary>
private void BtnSave_Click(object sender, RoutedEventArgs e)
{
try
{
// 保存配置
_plugin.SaveConfig();
// 如果插件已启用,重新加载启动台按钮
if (_plugin.IsEnabled)
{
_plugin.Disable();
_plugin.Enable();
}
else
{
// 如果插件未启用,则启用它
_plugin.Enable();
// 通知PluginSettingsWindow刷新插件列表
var window = Window.GetWindow(this);
if (window is PluginSettingsWindow pluginSettingsWindow)
{
// 触发刷新
pluginSettingsWindow.RefreshPluginList();
}
}
MessageBox.Show("设置已保存并应用!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存设置时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"保存设置时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
/// <summary>
/// 应用项选择变更事件
/// </summary>
private void DgApps_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
UpdateButtonStates();
}
/// <summary>
/// 编辑启动项
/// </summary>
/// <param name="item">启动项</param>
/// <param name="isNew">是否为新建</param>
private void EditLauncherItem(LauncherItem item, bool isNew)
{
// 创建简单的编辑窗口
Window editWindow = new Window
{
Title = isNew ? "添加" : "编辑应用",
Width = 400,
Height = 200,
WindowStartupLocation = WindowStartupLocation.CenterScreen,
ResizeMode = ResizeMode.NoResize
};
// 创建编辑表单
Grid grid = new Grid
{
Margin = new Thickness(20)
};
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(80) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
// 名称输入框
TextBlock nameLabel = new TextBlock
{
Text = "名称:",
VerticalAlignment = VerticalAlignment.Center
};
TextBox nameTextBox = new TextBox
{
Text = item.Name,
Margin = new Thickness(0, 5, 0, 5)
};
Grid.SetRow(nameLabel, 0);
Grid.SetColumn(nameLabel, 0);
Grid.SetRow(nameTextBox, 0);
Grid.SetColumn(nameTextBox, 1);
grid.Children.Add(nameLabel);
grid.Children.Add(nameTextBox);
// 路径输入框
TextBlock pathLabel = new TextBlock
{
Text = "路径:",
VerticalAlignment = VerticalAlignment.Center
};
Grid pathGrid = new Grid();
pathGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
pathGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength() });
TextBox pathTextBox = new TextBox
{
Text = item.Path,
Margin = new Thickness(0, 5, 5, 5)
};
Button browseButton = new Button
{
Content = "浏览",
Padding = new Thickness(5, 0, 5, 0),
Margin = new Thickness(0, 5, 0, 5)
};
browseButton.Click += (s, e) =>
{
OpenFileDialog dialog = new OpenFileDialog
{
Title = "选择应用程序",
Filter = "应用程序 (*.exe)|*.exe|所有文件 (*.*)|*.*",
Multiselect = false,
FileName = pathTextBox.Text
};
if (dialog.ShowDialog() == true)
{
pathTextBox.Text = dialog.FileName;
// 如果选择的是.exe文件,自动获取文件名填入名称字段
if (Path.GetExtension(dialog.FileName).ToLower() == ".exe")
{
string fileName = Path.GetFileNameWithoutExtension(dialog.FileName);
// 只有在名称字段为空或者是新建项目时才自动填入
if (string.IsNullOrWhiteSpace(nameTextBox.Text) || isNew)
{
nameTextBox.Text = fileName;
}
}
}
};
Grid.SetColumn(pathTextBox, 0);
Grid.SetColumn(browseButton, 1);
pathGrid.Children.Add(pathTextBox);
pathGrid.Children.Add(browseButton);
Grid.SetRow(pathLabel, 1);
Grid.SetColumn(pathLabel, 0);
Grid.SetRow(pathGrid, 1);
Grid.SetColumn(pathGrid, 1);
grid.Children.Add(pathLabel);
grid.Children.Add(pathGrid);
// 确认和取消按钮
StackPanel buttonPanel = new StackPanel
{
Orientation = Orientation.Horizontal,
HorizontalAlignment = HorizontalAlignment.Right,
Margin = new Thickness(0, 10, 0, 0)
};
Button okButton = new Button
{
Content = "确定",
Padding = new Thickness(15, 5, 15, 5),
Margin = new Thickness(0, 0, 10, 0),
IsDefault = true
};
Button cancelButton = new Button
{
Content = "取消",
Padding = new Thickness(15, 5, 15, 5),
IsCancel = true
};
okButton.Click += (s, e) =>
{
// 验证输入
if (string.IsNullOrWhiteSpace(nameTextBox.Text))
{
MessageBox.Show("请输入应用名称!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (string.IsNullOrWhiteSpace(pathTextBox.Text))
{
MessageBox.Show("请输入应用路径!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
// 更新项目
item.Name = nameTextBox.Text;
item.Path = pathTextBox.Text;
// 如果是新建,添加到集合
if (isNew)
{
_plugin.AddLauncherItem(item);
}
else
{
// 触发属性变更通知,刷新DataGrid
if (DgApps.ItemsSource is ICollectionView view)
{
view.Refresh();
}
// 保存配置
_plugin.SaveConfig();
}
editWindow.DialogResult = true;
editWindow.Close();
};
cancelButton.Click += (s, e) =>
{
editWindow.DialogResult = false;
editWindow.Close();
};
buttonPanel.Children.Add(okButton);
buttonPanel.Children.Add(cancelButton);
Grid.SetRow(buttonPanel, 2);
Grid.SetColumnSpan(buttonPanel, 2);
grid.Children.Add(buttonPanel);
// 设置窗口内容
editWindow.Content = grid;
// 显示窗口
editWindow.ShowDialog();
}
}
}
@@ -1,91 +0,0 @@
<Window x:Class="Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher.LauncherWindow"
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"
xmlns:local="clr-namespace:Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher"
mc:Ignorable="d"
Title="启动台"
Width="400"
Height="300"
WindowStyle="None"
AllowsTransparency="True"
Background="#80000000"
ResizeMode="NoResize"
Topmost="True"
Deactivated="Window_Deactivated"
ShowInTaskbar="False">
<Window.Resources>
<!-- 应用项样式 -->
<Style x:Key="LauncherItemStyle" TargetType="Button">
<Setter Property="Width" Value="80"/>
<Setter Property="Height" Value="80"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="Background" Value="#40FFFFFF"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="8">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Grid.Row="0" Source="{Binding Icon}" Width="32" Height="32" Margin="0,10,0,5"/>
<TextBlock Grid.Row="1" Text="{Binding Name}" TextWrapping="Wrap" TextAlignment="Center"
Margin="2,0,2,8" FontSize="11" Foreground="White"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#80FFFFFF"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#C0FFFFFF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Border CornerRadius="15" Background="#80000000" BorderThickness="1" BorderBrush="#40FFFFFF">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 标题栏 -->
<Grid Grid.Row="0" Height="40">
<TextBlock Text="启动台" Foreground="White" FontSize="18" FontWeight="Bold"
VerticalAlignment="Center" Margin="15,0,0,0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
<Button x:Name="BtnFixMode" Click="BtnFixMode_Click" Width="30" Height="30"
Margin="5,0" Background="Transparent" BorderThickness="0"
ToolTip="切换固定模式">
<Path x:Name="FixModeIcon" Data="M7,2V13H10V22L17,10H13L17,2H7Z" Fill="White" Stretch="Uniform" Width="16" Height="16"/>
</Button>
<Button x:Name="BtnClose" Click="BtnClose_Click" Width="30" Height="30"
Background="Transparent" BorderThickness="0"
ToolTip="关闭">
<Path Data="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"
Fill="White" Stretch="Uniform" Width="16" Height="16"/>
</Button>
</StackPanel>
</Grid>
<!-- 应用网格 -->
<ScrollViewer Grid.Row="1" Margin="10" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<WrapPanel x:Name="AppPanel" Orientation="Horizontal" HorizontalAlignment="Center"/>
</ScrollViewer>
</Grid>
</Border>
</Window>
@@ -1,466 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
{
/// <summary>
/// LauncherWindow.xaml 的交互逻辑
/// </summary>
public partial class LauncherWindow : Window
{
/// <summary>
/// 父插件
/// </summary>
private readonly SuperLauncherPlugin _plugin;
/// <summary>
/// 是否处于固定模式
/// </summary>
private bool _isFixMode;
/// <summary>
/// 应用项按钮列表
/// </summary>
private readonly Dictionary<Button, LauncherItem> _appButtons = new Dictionary<Button, LauncherItem>();
/// <summary>
/// 拖拽中的按钮
/// </summary>
private Button _draggingButton;
/// <summary>
/// 拖拽开始位置
/// </summary>
private Point _dragStartPoint;
/// <summary>
/// 构造函数
/// </summary>
public LauncherWindow(SuperLauncherPlugin plugin)
{
InitializeComponent();
_plugin = plugin;
// 加载应用项
LoadLauncherItems();
// 添加鼠标按下事件(用于拖动窗口)
MouseDown += (s, e) =>
{
if (e.ChangedButton == MouseButton.Left && e.ButtonState == MouseButtonState.Pressed)
{
DragMove();
}
};
// 根据应用数量调整窗口大小
AdjustWindowSize();
}
/// <summary>
/// 加载启动台应用项
/// </summary>
private void LoadLauncherItems()
{
// 清空现有应用项
AppPanel.Children.Clear();
_appButtons.Clear();
// 获取显示的应用项
var visibleItems = _plugin.LauncherItems
.Where(item => item.IsVisible)
.OrderBy(item => item.Position)
.ToList();
foreach (var item in visibleItems)
{
// 创建应用按钮
Button appButton = new Button
{
Style = (Style)FindResource("LauncherItemStyle"),
DataContext = item,
Tag = item.Position
};
// 添加点击事件
appButton.Click += AppButton_Click;
// 在固定模式下,添加拖拽事件
appButton.PreviewMouseDown += AppButton_PreviewMouseDown;
appButton.PreviewMouseMove += AppButton_PreviewMouseMove;
appButton.PreviewMouseUp += AppButton_PreviewMouseUp;
// 记录按钮和项目的对应关系
_appButtons.Add(appButton, item);
// 添加到面板
AppPanel.Children.Add(appButton);
}
}
/// <summary>
/// 根据应用数量调整窗口大小
/// </summary>
private void AdjustWindowSize()
{
try
{
// 每行最多显示4个应用
const int appsPerRow = 4;
// 计算行数
int visibleCount = _appButtons.Count;
int rowCount = (int)Math.Ceiling(visibleCount / (double)appsPerRow);
// 设置窗口宽度(每个应用90像素宽 = 80 + 5*2
Width = Math.Min(appsPerRow * 90 + 40, 400); // 最大宽度400
// 设置窗口高度(每个应用90像素高 = 80 + 5*2
Height = Math.Min(rowCount * 90 + 60, 600); // 最大高度600,标题栏40 + 边距20
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"调整启动台窗口大小时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 应用按钮点击事件
/// </summary>
private void AppButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (_isFixMode) return; // 在固定模式下,不响应点击事件
if (sender is Button button && _appButtons.TryGetValue(button, out LauncherItem item))
{
// 获取应用路径和名称,用于后续启动
string appPath = item.Path;
string appName = item.Name;
LogHelper.WriteLogToFile($"点击启动应用: {appName}, 路径: {appPath}");
// 首先标记窗口正在关闭
IsClosing = true;
// 创建一个应用启动任务
var launchTask = new Task(() =>
{
try
{
// 等待一段时间,确保窗口关闭流程已经开始
Thread.Sleep(200);
// 使用UI线程启动应用
Application.Current.Dispatcher.Invoke(() =>
{
try
{
// 检查应用路径是否存在
if (File.Exists(appPath) || !appPath.Contains(":\\"))
{
// 创建进程启动信息
var psi = new ProcessStartInfo
{
FileName = appPath,
UseShellExecute = true,
};
// 启动应用程序
var process = Process.Start(psi);
LogHelper.WriteLogToFile($"应用程序 {appName} 已启动");
}
else
{
LogHelper.WriteLogToFile($"应用路径不存在: {appPath}", LogHelper.LogType.Error);
MessageBox.Show($"找不到应用程序: {appPath}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"启动应用程序失败: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"启动应用程序失败: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"应用启动任务出错: {ex.Message}", LogHelper.LogType.Error);
}
});
// 关闭窗口
try
{
Dispatcher.BeginInvoke(new Action(() =>
{
try { Close(); } catch { }
// 启动应用程序任务
launchTask.Start();
}), DispatcherPriority.Background);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"关闭窗口或启动任务时出错: {ex.Message}", LogHelper.LogType.Error);
// 如果无法通过UI关闭窗口,直接启动任务
launchTask.Start();
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"应用按钮点击事件出错: {ex.Message}", LogHelper.LogType.Error);
try { IsClosing = true; Close(); } catch { }
}
}
#region
/// <summary>
/// 应用按钮鼠标按下事件
/// </summary>
private void AppButton_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (!_isFixMode) return;
if (e.ChangedButton == MouseButton.Left && sender is Button button)
{
_draggingButton = button;
_dragStartPoint = e.GetPosition(AppPanel);
button.CaptureMouse();
button.Opacity = 0.7;
// 阻止事件冒泡,以避免触发按钮点击
e.Handled = true;
}
}
/// <summary>
/// 应用按钮鼠标移动事件
/// </summary>
private void AppButton_PreviewMouseMove(object sender, MouseEventArgs e)
{
if (!_isFixMode || _draggingButton == null) return;
if (e.LeftButton == MouseButtonState.Pressed)
{
Point currentPosition = e.GetPosition(AppPanel);
// 移动按钮
System.Windows.Controls.Canvas.SetLeft(_draggingButton, currentPosition.X - _draggingButton.ActualWidth / 2);
System.Windows.Controls.Canvas.SetTop(_draggingButton, currentPosition.Y - _draggingButton.ActualHeight / 2);
// 将按钮移到最上层
Panel.SetZIndex(_draggingButton, 100);
// 阻止事件冒泡
e.Handled = true;
}
}
/// <summary>
/// 应用按钮鼠标释放事件
/// </summary>
private void AppButton_PreviewMouseUp(object sender, MouseButtonEventArgs e)
{
if (!_isFixMode || _draggingButton == null) return;
// 释放鼠标捕获
_draggingButton.ReleaseMouseCapture();
// 计算新位置
Point releasePoint = e.GetPosition(AppPanel);
int newPosition = CalculateGridPosition(releasePoint);
// 获取当前项目
LauncherItem currentItem = _appButtons[_draggingButton];
// 重新排序
ReorderItems(currentItem, newPosition);
// 重新加载应用项
LoadLauncherItems();
// 保存配置
_plugin.SaveConfig();
// 清除拖拽状态
_draggingButton.Opacity = 1;
Panel.SetZIndex(_draggingButton, 0);
_draggingButton = null;
// 阻止事件冒泡
e.Handled = true;
}
/// <summary>
/// 计算网格位置
/// </summary>
private int CalculateGridPosition(Point point)
{
// 计算行和列
int columnCount = 4; // 每行最多4个应用
int columnWidth = 90; // 应用宽度(包括边距)
int rowHeight = 90; // 应用高度(包括边距)
int column = (int)(point.X / columnWidth);
int row = (int)(point.Y / rowHeight);
// 确保在有效范围内
column = Math.Max(0, Math.Min(column, columnCount - 1));
row = Math.Max(0, row);
// 计算位置索引
return row * columnCount + column;
}
/// <summary>
/// 重新排序应用项
/// </summary>
private void ReorderItems(LauncherItem item, int newPosition)
{
try
{
// 设置项目为固定位置
item.IsPositionFixed = true;
// 如果位置相同,无需调整
if (item.Position == newPosition)
{
return;
}
// 获取所有可见项目
var visibleItems = _plugin.LauncherItems
.Where(i => i.IsVisible)
.OrderBy(i => i.Position)
.ToList();
// 移除当前项目
visibleItems.Remove(item);
// 查找插入位置
int insertIndex = 0;
for (int i = 0; i < visibleItems.Count; i++)
{
if (visibleItems[i].Position >= newPosition)
{
insertIndex = i;
break;
}
insertIndex = i + 1;
}
// 插入项目
visibleItems.Insert(insertIndex, item);
// 重新分配位置
for (int i = 0; i < visibleItems.Count; i++)
{
visibleItems[i].Position = i;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"重新排序应用项时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
#endregion
#region
/// <summary>
/// 窗口失去焦点事件
/// </summary>
private void Window_Deactivated(object sender, EventArgs e)
{
try
{
// 只有在非固定模式、窗口已加载、未处于关闭状态且IsLoaded=true时关闭窗口
if (!_isFixMode && IsLoaded && !IsClosing)
{
// 标记为正在关闭
IsClosing = true;
// 使用Dispatcher.BeginInvoke而不是直接调用Close,避免冲突
Dispatcher.BeginInvoke(new Action(() =>
{
try
{
// 再次检查窗口状态
if (IsLoaded && !IsClosing)
{
Close();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"延迟关闭窗口时出错: {ex.Message}", LogHelper.LogType.Error);
}
}), DispatcherPriority.Background);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"窗口失去焦点关闭时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 窗口是否正在关闭
/// </summary>
private bool IsClosing { get; set; }
/// <summary>
/// 重写OnClosing方法,标记窗口正在关闭
/// </summary>
protected override void OnClosing(CancelEventArgs e)
{
IsClosing = true;
base.OnClosing(e);
}
/// <summary>
/// 关闭按钮点击事件
/// </summary>
private void BtnClose_Click(object sender, RoutedEventArgs e)
{
Close();
}
/// <summary>
/// 固定模式按钮点击事件
/// </summary>
private void BtnFixMode_Click(object sender, RoutedEventArgs e)
{
// 切换固定模式
_isFixMode = !_isFixMode;
// 更新固定模式按钮图标颜色
FixModeIcon.Fill = _isFixMode ? Brushes.Yellow : Brushes.White;
// 显示提示
if (_isFixMode)
{
MessageBox.Show("已进入固定模式,您可以拖动应用图标调整位置。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
#endregion
}
}
@@ -1,589 +0,0 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher;
using Newtonsoft.Json;
namespace Ink_Canvas.Helpers.Plugins.BuiltIn
{
/// <summary>
/// 超级启动台插件
/// </summary>
public class SuperLauncherPlugin : PluginBase
{
#region
public override string Name => "超级启动台";
public override string Description => "在浮动栏添加一个启动台按钮,可快速启动常用应用程序。";
public override Version Version => new Version(1, 0, 1);
public override string Author => "ICC CE 团队";
public override bool IsBuiltIn => true;
#endregion
#region
/// <summary>
/// 启动台配置
/// </summary>
public LauncherConfig Config { get; private set; }
/// <summary>
/// 启动台应用程序列表
/// </summary>
public ObservableCollection<LauncherItem> LauncherItems { get; private set; }
/// <summary>
/// 启动台按钮
/// </summary>
private LauncherButton _launcherButton;
/// <summary>
/// 启动台窗口
/// </summary>
private LauncherWindow _launcherWindow;
/// <summary>
/// 配置文件路径
/// </summary>
private readonly string _configPath = Path.Combine(App.RootPath, "PluginConfigs", "SuperLauncher.json");
/// <summary>
/// 标记是否已添加到浮动栏
/// </summary>
private bool _isAddedToFloatingBar;
#endregion
#region
public override void Initialize()
{
try
{
base.Initialize();
// 创建配置目录
string configDir = Path.Combine(App.RootPath, "PluginConfigs");
if (!Directory.Exists(configDir))
{
Directory.CreateDirectory(configDir);
}
// 加载配置
LoadConfig();
LogHelper.WriteLogToFile("超级启动台插件已初始化");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"初始化超级启动台插件时出错: {ex.Message}", LogHelper.LogType.Error);
LogHelper.NewLog(ex);
}
}
public override void Enable()
{
try
{
if (IsEnabled) return; // 防止重复启用
// 创建启动台按钮
if (_launcherButton == null)
{
_launcherButton = new LauncherButton(this);
LogHelper.WriteLogToFile("超级启动台按钮已创建");
}
// 添加启动台按钮到浮动栏
AddLauncherButtonToFloatingBar();
// 设置启用状态
base.Enable();
// 保存插件配置
SavePluginSettings();
LogHelper.WriteLogToFile("超级启动台插件已启用");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"启用超级启动台插件时出错: {ex.Message}", LogHelper.LogType.Error);
LogHelper.NewLog(ex);
}
}
public override void Disable()
{
try
{
if (!IsEnabled) return; // 防止重复禁用
// 从浮动栏移除启动台按钮
RemoveLauncherButtonFromFloatingBar();
// 如果启动台窗口打开,则关闭
if (_launcherWindow != null && _launcherWindow.IsVisible)
{
_launcherWindow.Close();
_launcherWindow = null;
}
// 设置禁用状态
base.Disable();
// 保存插件配置
SavePluginSettings();
LogHelper.WriteLogToFile("超级启动台插件已禁用");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"禁用超级启动台插件时出错: {ex.Message}", LogHelper.LogType.Error);
LogHelper.NewLog(ex);
}
}
public override UserControl GetSettingsView()
{
return new LauncherSettingsControl(this);
}
public override void Cleanup()
{
// 保存配置
SaveConfig();
// 从浮动栏移除启动台按钮
RemoveLauncherButtonFromFloatingBar();
// 如果启动台窗口打开,则关闭
if (_launcherWindow != null && _launcherWindow.IsVisible)
{
_launcherWindow.Close();
_launcherWindow = null;
}
base.Cleanup();
}
/// <summary>
/// 保存插件设置
/// </summary>
public override void SavePluginSettings()
{
try
{
// 确保配置已加载
if (Config == null)
{
LoadConfig();
}
// 更新其他设置,但不更改插件启用状态
// 保存配置
SaveConfig();
LogHelper.WriteLogToFile("超级启动台插件设置已保存");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存超级启动台插件设置时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
#endregion
#region
/// <summary>
/// 加载配置
/// </summary>
private void LoadConfig()
{
try
{
if (File.Exists(_configPath))
{
string json = File.ReadAllText(_configPath);
Config = JsonConvert.DeserializeObject<LauncherConfig>(json) ?? CreateDefaultConfig();
LauncherItems = new ObservableCollection<LauncherItem>(Config.Items ?? new List<LauncherItem>());
// 注意:不再根据配置更改插件启用状态
// 插件状态由PluginManager统一管理
}
else
{
Config = CreateDefaultConfig();
LauncherItems = new ObservableCollection<LauncherItem>(Config.Items);
SaveConfig();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"加载超级启动台配置时出错: {ex.Message}", LogHelper.LogType.Error);
Config = CreateDefaultConfig();
LauncherItems = new ObservableCollection<LauncherItem>(Config.Items);
}
}
/// <summary>
/// 保存配置
/// </summary>
public void SaveConfig()
{
try
{
// 同步LauncherItems到Config
Config.Items = new List<LauncherItem>(LauncherItems);
// 序列化并保存配置
string json = JsonConvert.SerializeObject(Config, Formatting.Indented);
File.WriteAllText(_configPath, json);
LogHelper.WriteLogToFile("超级启动台配置已保存");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存超级启动台配置时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 创建默认配置
/// </summary>
private LauncherConfig CreateDefaultConfig()
{
var config = new LauncherConfig
{
ButtonPosition = LauncherButtonPosition.Right,
// 不再使用IsEnabled,插件状态由PluginManager管理
Items = new List<LauncherItem>
{
new LauncherItem
{
Name = "资源管理器",
Path = @"C:\Windows\explorer.exe",
IsVisible = true,
Position = 0
}
}
};
return config;
}
#endregion
#region
/// <summary>
/// 将启动台按钮添加到浮动栏
/// </summary>
private void AddLauncherButtonToFloatingBar()
{
try
{
// 如果已经添加,先移除
if (_isAddedToFloatingBar)
{
RemoveLauncherButtonFromFloatingBar();
_isAddedToFloatingBar = false;
}
// 获取主窗口实例
var mainWindow = Application.Current.MainWindow;
if (mainWindow == null)
{
LogHelper.WriteLogToFile("未找到主窗口实例,无法添加启动台按钮", LogHelper.LogType.Error);
return;
}
// 创建启动台按钮
_launcherButton = new LauncherButton(this);
var buttonElement = _launcherButton.Element;
// 查找浮动栏
var floatingBar = mainWindow.FindName("StackPanelFloatingBar") as Panel;
if (floatingBar == null)
{
// 如果直接查找失败,则尝试遍历可视树查找
Panel floatingBarPanelFromTree = null;
FindStackPanelFloatingBar(mainWindow, ref floatingBarPanelFromTree);
floatingBar = floatingBarPanelFromTree;
}
if (floatingBar == null)
{
LogHelper.WriteLogToFile("未找到浮动栏,无法添加启动台按钮", LogHelper.LogType.Error);
return;
}
// 添加启动台按钮到浮动栏
if (Config.ButtonPosition == LauncherButtonPosition.Left)
{
floatingBar.Children.Insert(0, buttonElement);
LogHelper.WriteLogToFile("启动台按钮已添加到浮动栏左侧");
}
else
{
floatingBar.Children.Add(buttonElement);
LogHelper.WriteLogToFile("启动台按钮已添加到浮动栏右侧");
}
_isAddedToFloatingBar = true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"添加启动台按钮到浮动栏时出错: {ex.Message}", LogHelper.LogType.Error);
LogHelper.NewLog(ex);
}
}
/// <summary>
/// 递归查找StackPanelFloatingBar
/// </summary>
private void FindStackPanelFloatingBar(DependencyObject parent, ref Panel result)
{
if (parent == null || result != null) return;
try
{
// 检查当前对象是否为我们要找的面板
if (parent is Panel panel && panel.Name == "StackPanelFloatingBar")
{
result = panel;
return;
}
// 获取子元素数量
int childCount = VisualTreeHelper.GetChildrenCount(parent);
// 遍历所有子元素
for (int i = 0; i < childCount; i++)
{
DependencyObject child = VisualTreeHelper.GetChild(parent, i);
FindStackPanelFloatingBar(child, ref result);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"查找StackPanelFloatingBar时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 从浮动栏移除启动台按钮
/// </summary>
private void RemoveLauncherButtonFromFloatingBar()
{
try
{
if (!_isAddedToFloatingBar || _launcherButton == null)
{
return;
}
// 获取主窗口实例
var mainWindow = Application.Current.MainWindow;
if (mainWindow == null)
{
LogHelper.WriteLogToFile("未找到主窗口实例,无法移除启动台按钮", LogHelper.LogType.Error);
return;
}
// 获取按钮元素
var buttonElement = _launcherButton.Element;
// 查找浮动栏
var floatingBar = mainWindow.FindName("StackPanelFloatingBar") as Panel;
if (floatingBar == null)
{
// 如果直接查找失败,则尝试遍历可视树查找
Panel floatingBarPanelFromTree = null;
FindStackPanelFloatingBar(mainWindow, ref floatingBarPanelFromTree);
floatingBar = floatingBarPanelFromTree;
}
if (floatingBar == null)
{
LogHelper.WriteLogToFile("未找到浮动栏,无法移除启动台按钮", LogHelper.LogType.Error);
return;
}
// 从浮动栏移除启动台按钮
if (floatingBar.Children.Contains(buttonElement))
{
floatingBar.Children.Remove(buttonElement);
LogHelper.WriteLogToFile("启动台按钮已从浮动栏移除");
}
_isAddedToFloatingBar = false;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"移除启动台按钮时出错: {ex.Message}", LogHelper.LogType.Error);
LogHelper.NewLog(ex);
}
}
/// <summary>
/// 更新启动台按钮位置
/// </summary>
public void UpdateButtonPosition()
{
try
{
// 如果按钮已添加到浮动栏,重新添加以更新位置
if (_isAddedToFloatingBar)
{
RemoveLauncherButtonFromFloatingBar();
AddLauncherButtonToFloatingBar();
LogHelper.WriteLogToFile($"启动台按钮位置已更新为: {Config.ButtonPosition}");
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"更新启动台按钮位置时出错: {ex.Message}", LogHelper.LogType.Error);
LogHelper.NewLog(ex);
}
}
#endregion
#region
/// <summary>
/// 显示启动台窗口
/// </summary>
/// <param name="buttonPosition">按钮在屏幕上的位置</param>
public void ShowLauncherWindow(Point buttonPosition)
{
try
{
// 如果窗口已存在,关闭它
if (_launcherWindow != null && _launcherWindow.IsVisible)
{
_launcherWindow.Close();
_launcherWindow = null;
return;
}
// 创建新的启动台窗口
_launcherWindow = new LauncherWindow(this);
// 计算窗口位置,使其位于按钮上方
PositionLauncherWindow(_launcherWindow, buttonPosition);
// 显示窗口
_launcherWindow.Show();
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"显示启动台窗口时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 设置启动台窗口位置
/// </summary>
/// <param name="window">启动台窗口</param>
/// <param name="buttonPosition">按钮在屏幕上的位置</param>
private void PositionLauncherWindow(LauncherWindow window, Point buttonPosition)
{
// 确保窗口已加载
if (window.ActualWidth == 0 || window.ActualHeight == 0)
{
window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
// 设置窗口加载完成后的位置
window.Loaded += (s, e) =>
{
// 窗口位于按钮上方居中
double left = buttonPosition.X - (window.ActualWidth / 2);
double top = buttonPosition.Y - window.ActualHeight - 10; // 在按钮上方留出一些间距
// 确保窗口在屏幕内
left = Math.Max(0, Math.Min(left, SystemParameters.WorkArea.Width - window.ActualWidth));
top = Math.Max(0, Math.Min(top, SystemParameters.WorkArea.Height - window.ActualHeight));
window.Left = left;
window.Top = top;
};
}
else
{
// 窗口位于按钮上方居中
double left = buttonPosition.X - (window.ActualWidth / 2);
double top = buttonPosition.Y - window.ActualHeight - 10; // 在按钮上方留出一些间距
// 确保窗口在屏幕内
left = Math.Max(0, Math.Min(left, SystemParameters.WorkArea.Width - window.ActualWidth));
top = Math.Max(0, Math.Min(top, SystemParameters.WorkArea.Height - window.ActualHeight));
window.Left = left;
window.Top = top;
}
}
/// <summary>
/// 添加应用到启动台
/// </summary>
/// <param name="item">启动台项</param>
public void AddLauncherItem(LauncherItem item)
{
// 如果项目数量已达上限,则不添加
if (LauncherItems.Count >= 40)
{
MessageBox.Show("启动台项目数量已达上限(40个)!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
// 寻找合适的位置
if (item.Position < 0)
{
item.Position = FindNextAvailablePosition();
}
// 添加项目并保存配置
LauncherItems.Add(item);
SaveConfig();
}
/// <summary>
/// 查找下一个可用位置
/// </summary>
private int FindNextAvailablePosition()
{
// 获取已使用的位置列表
var usedPositions = new HashSet<int>();
foreach (var item in LauncherItems)
{
usedPositions.Add(item.Position);
}
// 查找第一个可用位置
for (int i = 0; i < 40; i++)
{
if (!usedPositions.Contains(i))
{
return i;
}
}
// 如果所有位置都已使用,则返回0
return 0;
}
#endregion
}
}
@@ -1,178 +0,0 @@
using System;
using System.IO;
namespace Ink_Canvas.Helpers.Plugins
{
/// <summary>
/// ICCPP 插件适配器,用于加载和管理 .iccpp 格式的插件
/// </summary>
public class ICCPPPluginAdapter : PluginBase
{
private readonly byte[] _pluginData;
private readonly string _pluginPath;
private readonly string _pluginName;
private readonly Version _pluginVersion;
private bool _isInitialized;
/// <summary>
/// 创建 ICCPP 插件适配器
/// </summary>
/// <param name="pluginPath">插件文件路径</param>
/// <param name="pluginData">插件文件数据</param>
public ICCPPPluginAdapter(string pluginPath, byte[] pluginData)
{
_pluginPath = pluginPath;
_pluginData = pluginData;
PluginPath = pluginPath;
// 从文件名获取插件名称
_pluginName = Path.GetFileNameWithoutExtension(pluginPath);
_pluginVersion = new Version(1, 0, 0); // 默认版本
// 尝试从插件数据中读取更多信息
TryReadPluginMetadata();
}
public ICCPPPluginAdapter()
{
_pluginPath = string.Empty;
_pluginData = new byte[0];
PluginPath = string.Empty;
_pluginName = "ICCPPPlugin";
_pluginVersion = new Version(1, 0, 0);
// 可选:初始化其他字段
}
/// <summary>
/// 尝试从插件数据中读取元数据
/// </summary>
private void TryReadPluginMetadata()
{
try
{
// 这里可以根据 .iccpp 文件的实际格式解析元数据
// 例如,如果文件有特定的头部结构,可以在这里解析
// 示例:如果前100字节包含元数据
if (_pluginData.Length > 100)
{
// 解析元数据的代码...
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"解析插件 {_pluginName} 元数据时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
#region IPlugin
/// <summary>
/// 插件名称
/// </summary>
public override string Name => _pluginName;
/// <summary>
/// 插件描述
/// </summary>
public override string Description => $"{_pluginName} (ICCPP 格式插件)";
/// <summary>
/// 插件版本
/// </summary>
public override Version Version => _pluginVersion;
/// <summary>
/// 插件作者
/// </summary>
public override string Author => "未知";
/// <summary>
/// 是否为内置插件
/// </summary>
public override bool IsBuiltIn => false;
/// <summary>
/// 初始化插件
/// </summary>
public override void Initialize()
{
if (_isInitialized) return;
try
{
// 这里可以添加 .iccpp 插件的初始化逻辑
// 例如,根据文件格式加载特定资源
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已初始化");
_isInitialized = true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"初始化 ICCPP 插件 {Name} 时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 启用插件
/// </summary>
public override void Enable()
{
if (IsEnabled) return;
try
{
// 这里可以添加 .iccpp 插件的启用逻辑
// 例如,加载动态库、注册事件等
base.Enable(); // 设置启用状态并触发事件
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已启用");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"启用 ICCPP 插件 {Name} 时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 禁用插件
/// </summary>
public override void Disable()
{
if (!IsEnabled) return;
try
{
// 这里可以添加 .iccpp 插件的禁用逻辑
// 例如,卸载动态库、注销事件等
base.Disable(); // 设置禁用状态并触发事件
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已禁用");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"禁用 ICCPP 插件 {Name} 时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 清理插件资源
/// </summary>
public override void Cleanup()
{
try
{
// 这里可以添加 .iccpp 插件的清理逻辑
// 例如,释放资源等
LogHelper.WriteLogToFile($"ICCPP 插件 {Name} 已清理资源");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理 ICCPP 插件 {Name} 资源时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
#endregion
}
}
-67
View File
@@ -1,67 +0,0 @@
using System;
using System.Windows.Controls;
namespace Ink_Canvas.Helpers.Plugins
{
/// <summary>
/// 定义插件的基本接口
/// </summary>
public interface IPlugin
{
/// <summary>
/// 插件名称
/// </summary>
string Name { get; }
/// <summary>
/// 插件描述
/// </summary>
string Description { get; }
/// <summary>
/// 插件版本
/// </summary>
Version Version { get; }
/// <summary>
/// 插件作者
/// </summary>
string Author { get; }
/// <summary>
/// 是否为内置插件
/// </summary>
bool IsBuiltIn { get; }
/// <summary>
/// 初始化插件
/// 此方法在插件加载时被调用,用于执行一些初始化工作
/// </summary>
void Initialize();
/// <summary>
/// 启用插件
/// 此方法在插件被用户或系统启用时调用,激活插件功能
/// </summary>
void Enable();
/// <summary>
/// 禁用插件
/// 此方法在插件被用户或系统禁用时调用,停用插件功能
/// </summary>
void Disable();
/// <summary>
/// 获取插件设置界面
/// 此方法返回插件的设置界面控件,用于展示在设置窗口
/// </summary>
/// <returns>插件设置界面</returns>
UserControl GetSettingsView();
/// <summary>
/// 插件卸载时的清理工作
/// 此方法在插件被卸载前调用,用于释放资源和执行清理
/// </summary>
void Cleanup();
}
}
-161
View File
@@ -1,161 +0,0 @@
using System;
using System.Windows.Controls;
namespace Ink_Canvas.Helpers.Plugins
{
/// <summary>
/// 插件基类,提供基本实现
/// </summary>
public abstract class PluginBase : IPlugin
{
/// <summary>
/// 插件状态(私有字段)
/// </summary>
private bool _isEnabled;
/// <summary>
/// 插件状态(公共属性)
/// </summary>
public bool IsEnabled
{
get => _isEnabled;
protected set
{
if (_isEnabled != value)
{
_isEnabled = value;
OnEnabledStateChanged(value);
}
}
}
/// <summary>
/// 插件ID
/// </summary>
public string Id { get; protected set; }
/// <summary>
/// 插件路径
/// </summary>
public string PluginPath { get; set; }
/// <summary>
/// 插件名称
/// </summary>
public abstract string Name { get; }
/// <summary>
/// 插件描述
/// </summary>
public abstract string Description { get; }
/// <summary>
/// 插件版本
/// </summary>
public abstract Version Version { get; }
/// <summary>
/// 插件作者
/// </summary>
public abstract string Author { get; }
/// <summary>
/// 是否为内置插件
/// </summary>
public virtual bool IsBuiltIn => false;
/// <summary>
/// 状态变更事件
/// </summary>
public event EventHandler<bool> EnabledStateChanged;
/// <summary>
/// 初始化插件
/// </summary>
public virtual void Initialize()
{
Id = GetType().FullName;
// 添加日志,记录插件名称
try
{
string name = Name;
LogHelper.WriteLogToFile($"初始化插件: ID={Id}, 名称={name ?? ""}");
if (string.IsNullOrEmpty(name))
{
LogHelper.WriteLogToFile($"警告: 插件 {Id} 的名称为空", LogHelper.LogType.Warning);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"获取插件名称时出错: {ex.Message}", LogHelper.LogType.Error);
}
LogHelper.WriteLogToFile($"插件 {Name} 已初始化");
}
/// <summary>
/// 启用插件
/// </summary>
public virtual void Enable()
{
if (!IsEnabled)
{
IsEnabled = true;
LogHelper.WriteLogToFile($"插件 {Name} 已启用");
}
}
/// <summary>
/// 禁用插件
/// </summary>
public virtual void Disable()
{
if (IsEnabled)
{
IsEnabled = false;
LogHelper.WriteLogToFile($"插件 {Name} 已禁用");
}
}
/// <summary>
/// 获取插件设置界面
/// </summary>
/// <returns>插件设置界面</returns>
public virtual UserControl GetSettingsView()
{
// 默认返回空设置页面
return new UserControl();
}
/// <summary>
/// 插件卸载时的清理工作
/// </summary>
public virtual void Cleanup()
{
LogHelper.WriteLogToFile($"插件 {Name} 已卸载");
}
/// <summary>
/// 保存插件自身的设置
/// 注意:此方法仅用于保存插件的特定设置,不应影响插件启用/禁用状态
/// 插件启用状态由PluginManager统一管理
/// </summary>
public virtual void SavePluginSettings()
{
// 默认实现不做任何事情
// 子类可以重写此方法,将自身设置保存到配置文件中
LogHelper.WriteLogToFile($"插件 {Name} 设置已保存", LogHelper.LogType.Event);
}
/// <summary>
/// 触发状态变更事件
/// </summary>
/// <param name="isEnabled">是否启用</param>
protected virtual void OnEnabledStateChanged(bool isEnabled)
{
EnabledStateChanged?.Invoke(this, isEnabled);
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,276 +0,0 @@
using System;
using System.Windows;
using System.Windows.Controls;
namespace Ink_Canvas.Helpers.Plugins
{
/// <summary>
/// 插件模板,用于开发者参考
/// 注意:实际开发时,请将此类移到单独的程序集中
/// </summary>
public class PluginTemplate : PluginBase
{
#region
/// <summary>
/// 插件名称
/// </summary>
public override string Name => "插件模板";
/// <summary>
/// 插件描述
/// </summary>
public override string Description => "这是一个插件开发模板,用于开发者参考。";
/// <summary>
/// 插件版本
/// </summary>
public override Version Version => new Version(1, 0, 0);
/// <summary>
/// 插件作者
/// </summary>
public override string Author => "Your Name";
/// <summary>
/// 是否为内置插件(外部插件请返回false)
/// </summary>
public override bool IsBuiltIn => false;
#endregion
#region
/// <summary>
/// 插件初始化
/// 在这里进行插件的初始化工作,如加载配置、注册事件等
/// </summary>
public override void Initialize()
{
// 先调用基类方法,这样会设置插件ID和记录日志
base.Initialize();
// TODO: 在这里进行插件初始化工作
// 示例:记录初始化信息
LogHelper.WriteLogToFile($"插件 {Name} 开始初始化");
// 示例:加载配置
LoadConfig();
// 示例:注册自定义事件
// MainWindow.Instance.SomeEvent += OnSomeEvent;
LogHelper.WriteLogToFile($"插件 {Name} 初始化完成");
}
/// <summary>
/// 启用插件
/// 在这里激活插件功能
/// </summary>
public override void Enable()
{
// 先调用基类方法,这样会设置插件状态和记录日志
base.Enable();
// TODO: 在这里启用插件功能
LogHelper.WriteLogToFile($"插件 {Name} 已启用");
}
/// <summary>
/// 禁用插件
/// 在这里停用插件功能
/// </summary>
public override void Disable()
{
// 先调用基类方法,这样会设置插件状态和记录日志
base.Disable();
// TODO: 在这里禁用插件功能
LogHelper.WriteLogToFile($"插件 {Name} 已禁用");
}
/// <summary>
/// 清理资源
/// 在插件卸载时调用,清理资源
/// </summary>
public override void Cleanup()
{
// TODO: 在这里清理插件资源
// 示例:取消注册事件
// MainWindow.Instance.SomeEvent -= OnSomeEvent;
// 示例:保存配置
SaveConfig();
// 最后调用基类方法
base.Cleanup();
}
#endregion
#region
/// <summary>
/// 加载插件配置
/// </summary>
private void LoadConfig()
{
try
{
// TODO: 从文件或其他位置加载配置
// 示例:
// string configPath = Path.Combine(App.RootPath, "PluginConfigs", "YourPluginName.json");
// if (File.Exists(configPath))
// {
// string json = File.ReadAllText(configPath);
// YourConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<YourConfigClass>(json);
// }
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"加载插件配置时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 保存插件配置
/// </summary>
private void SaveConfig()
{
try
{
// TODO: 保存配置到文件或其他位置
// 示例:
// string configDir = Path.Combine(App.RootPath, "PluginConfigs");
// if (!Directory.Exists(configDir))
// {
// Directory.CreateDirectory(configDir);
// }
// string configPath = Path.Combine(configDir, "YourPluginName.json");
// string json = Newtonsoft.Json.JsonConvert.SerializeObject(YourConfig, Newtonsoft.Json.Formatting.Indented);
// File.WriteAllText(configPath, json);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存插件配置时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
#endregion
#region
/// <summary>
/// 获取插件设置界面
/// </summary>
/// <returns>插件设置界面</returns>
public override UserControl GetSettingsView()
{
// 创建插件设置界面
return new PluginTemplateSettingsControl();
}
#endregion
#region
// TODO: 在这里添加插件的具体功能方法
/// <summary>
/// 示例方法:执行一些功能
/// </summary>
public void DoSomething()
{
if (!IsEnabled) return;
try
{
// TODO: 实现你的功能
MessageBox.Show("插件功能执行示例", "插件模板", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"执行插件功能时出错: {ex.Message}", LogHelper.LogType.Error);
}
}
#endregion
}
/// <summary>
/// 插件设置控件
/// </summary>
public class PluginTemplateSettingsControl : UserControl
{
public PluginTemplateSettingsControl()
{
// 创建设置界面布局
var panel = new StackPanel
{
Margin = new Thickness(10)
};
// 添加标题
panel.Children.Add(new TextBlock
{
Text = "插件模板设置",
FontSize = 16,
FontWeight = FontWeights.Bold,
Margin = new Thickness(0, 0, 0, 10)
});
// 添加说明文字
panel.Children.Add(new TextBlock
{
Text = "这是一个示例设置界面,你可以在这里添加自己的设置控件。",
TextWrapping = TextWrapping.Wrap,
Margin = new Thickness(0, 0, 0, 15)
});
// 添加示例设置选项
var checkBox = new CheckBox
{
Content = "启用某项功能",
Margin = new Thickness(0, 0, 0, 10)
};
panel.Children.Add(checkBox);
// 添加文本输入框
panel.Children.Add(new TextBlock
{
Text = "设置项:",
Margin = new Thickness(0, 5, 0, 5)
});
panel.Children.Add(new TextBox
{
Margin = new Thickness(0, 0, 0, 10),
Width = 200,
HorizontalAlignment = HorizontalAlignment.Left
});
// 添加按钮
var button = new Button
{
Content = "保存设置",
Padding = new Thickness(10, 5, 10, 5),
Margin = new Thickness(0, 10, 0, 0),
HorizontalAlignment = HorizontalAlignment.Left
};
button.Click += (sender, e) =>
{
MessageBox.Show("设置已保存!", "插件模板", MessageBoxButton.OK, MessageBoxImage.Information);
};
panel.Children.Add(button);
// 设置控件内容
Content = panel;
}
}
}
-51
View File
@@ -1,51 +0,0 @@
using System.IO;
namespace Ink_Canvas.Helpers
{
public static class StartupCount
{
private static readonly string CountFilePath = Path.Combine(App.RootPath, "startup-count");
private static readonly object fileLock = new object();
public static int GetCount()
{
try
{
if (File.Exists(CountFilePath))
{
var text = File.ReadAllText(CountFilePath).Trim();
if (int.TryParse(text, out int count))
return count;
}
}
catch { }
return 0;
}
public static void Increment()
{
lock (fileLock)
{
int count = GetCount() + 1;
try
{
File.WriteAllText(CountFilePath, count.ToString());
}
catch { }
}
}
public static void Reset()
{
lock (fileLock)
{
try
{
if (File.Exists(CountFilePath))
File.Delete(CountFilePath);
}
catch { }
}
}
}
}
-575
View File
@@ -1,575 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<RuntimeIdentifiers>win;win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<OutputType>WinExe</OutputType>
<RootNamespace>Ink_Canvas</RootNamespace>
<AssemblyName>InkCanvasForClass</AssemblyName>
<TargetFramework>net472</TargetFramework>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>2.0.2.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>false</BootstrapperEnabled>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<UseWPF>true</UseWPF>
<Configurations>Debug;Release;x86 Debug</Configurations>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>embedded</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|AnyCPU'">
<DebugType>embedded</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>embedded</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\icc.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|x86'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>pdbonly</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Title>InkCanvasForClass</Title>
<Version>5.0.4</Version>
<Authors>Dubi906w</Authors>
<Product>InkCanvasForClass</Product>
<Copyright>© Copyright HARKOTEK Studio 2024-now</Copyright>
<PackageProjectUrl>https://icc.bliemhax.com</PackageProjectUrl>
<FileVersion>bundled</FileVersion>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|ARM64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>pdbonly</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|x64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>pdbonly</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="IACore">
<HintPath>.\IACore.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="IALoader">
<HintPath>.\IALoader.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="IAWinFX">
<HintPath>.\IAWinFX.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="netstandard" />
<Reference Include="System.Windows.Forms" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml" />
<Reference Include="UIAutomationClient" />
<Reference Include="UIAutomationTypes" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<None Include="app.manifest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.9.27" />
<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" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NHotkey.Wpf" Version="3.0.0" />
<PackageReference Include="OSVersionExt" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="stdole">
<Guid>{00020430-0000-0000-C000-000000000046}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="VBIDE">
<Guid>{0002E157-0000-0000-C000-000000000046}</Guid>
<VersionMajor>5</VersionMajor>
<VersionMinor>3</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\TimerDownNotice.wav" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\IACore\IACore.dll" />
<EmbeddedResource Include="Resources\IACore\IALoader.dll" />
<EmbeddedResource Include="Resources\IACore\IAWinFX.dll" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Cursors\Cursor.cur" />
<Resource Include="Resources\Cursors\Pen.cur" />
<Resource Include="Resources\DeveloperAvatars\aaaaaaccd.jpg" />
<Resource Include="Resources\DeveloperAvatars\Alan-CRL.png" />
<Resource Include="Resources\DeveloperAvatars\NetheriteBowl.png" />
<Resource Include="Resources\DeveloperAvatars\NotYoojun.png" />
<Resource Include="Resources\DeveloperAvatars\RaspberryKan.jpg" />
<Resource Include="Resources\DeveloperAvatars\wwei.png" />
<Resource Include="Resources\DeveloperAvatars\yuwenhui2020.png" />
<Resource Include="Resources\icc.ico" />
<Resource Include="Resources\Icons-png\AdmoxBooth.png" />
<Resource Include="Resources\Icons-png\AdmoxWhiteboard.png" />
<Resource Include="Resources\Icons-png\check-box-background.png" />
<Resource Include="Resources\Icons-png\Donview.png" />
<Resource Include="Resources\Icons-png\EasiNote3.png" />
<Resource Include="Resources\Icons-png\eraser-line.png" />
<Resource Include="Resources\Icons-png\eraser-outline.png" />
<Resource Include="Resources\Icons-png\HiteLightBoard.png" />
<Resource Include="Resources\Icons-png\ica.png" />
<Resource Include="Resources\Icons-png\icc-transparent-dark-small.png" />
<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\InkCanvas.png" />
<Resource Include="Resources\Icons-png\kuanciya.png" />
<Resource Include="Resources\Icons-png\kuandogeyuanliangwo.png" />
<Resource Include="Resources\Icons-png\kuandoujiyanhuaji.png" />
<Resource Include="Resources\Icons-png\kuanneikuhuaji.png" />
<Resource Include="Resources\Icons-png\kuanshounvhuaji.png" />
<Resource Include="Resources\Icons-png\MaxHubWhiteboard.png" />
<Resource Include="Resources\Icons-png\playCircle.png" />
<Resource Include="Resources\Icons-png\redo.png" />
<Resource Include="Resources\Icons-png\Seewo2Annotation.png" />
<Resource Include="Resources\Icons-png\setting.png" />
<Resource Include="Resources\Icons-png\tiebahuaji.png" />
<Resource Include="Resources\Icons-png\transparent-grid.png" />
<Resource Include="Resources\Icons-png\undo.png" />
<Resource Include="Resources\Icons-png\minimize.png" />
<Resource Include="Resources\Icons-png\penUpright.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\twoFingelMove-Blue.png" />
<Resource Include="Resources\Icons-png\twoFingelMove.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\close-circle.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\DeveloperAvatars\ChangSakura.png" />
<Resource Include="Resources\DeveloperAvatars\clover-yan.png" />
<Resource Include="Resources\DeveloperAvatars\CN-Ironegg.jpg" />
<Resource Include="Resources\DeveloperAvatars\jiajiaxd.jpg" />
<Resource Include="Resources\DeveloperAvatars\kengwang.png" />
<Resource Include="Resources\DeveloperAvatars\STBBRD.png" />
<Resource Include="Resources\DeveloperAvatars\WXRIW.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\down.png" />
<Resource Include="Resources\Icons-png\up.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\EasiCamera.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\Desmos.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_cursor_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_lasso_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_settings_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_whiteboard_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_dark_theme_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_dual_screen_span_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_timer_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_delete_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_cursorWITHdelete_24_regular.png" />
</ItemGroup>
<ItemGroup>
<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_sunny_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_signature_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_save_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_camera_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_copy_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_copy_add_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_add_circle_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_flip_horizontal_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_flip_vertical_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_edit_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_folder_open_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_people_money_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_person_money_24_regular.png" />
</ItemGroup>
<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" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_scales_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_arrow_clockwise_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_calendar_sync_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_dismiss_circle_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_drag_24_regular.png" />
<Resource Include="Resources\Icons-Fluent\ic_fluent_shapes_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_power_24_regular.png" />
</ItemGroup>
<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>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_control_button_24_regular.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\ic_fluent_people_24_regular.png" />
<Resource Include="Resources\Icons-png\VComYouJiao.png" />
<Resource Include="Resources\Icons-png\WenXiang.png" />
<Resource Include="Resources\Icons-png\YiYunVisualPresenter.png" />
<Resource Include="Resources\Icons-png\YiYunWhiteboard.png" />
<Resource Include="Resources\new-icons\chevron-left.png" />
<Resource Include="Resources\new-icons\end-slides-show.png">
<CopyToOutputDirectory></CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\new-icons\eye.png" />
<Resource Include="Resources\new-icons\hand-move.png" />
<Resource Include="Resources\new-icons\highlighter-white.png" />
<Resource Include="Resources\new-icons\multi-touch.png" />
<Resource Include="Resources\new-icons\osu-lazer-triangles.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\pen-lined.png" />
<Resource Include="Resources\new-icons\pen-solid.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\cursor-lined.png" />
<Resource Include="Resources\new-icons\cursor-solid.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\eraser-lined.png" />
<Resource Include="Resources\new-icons\eraser-solid.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\circle-eraser-lined.png" />
<Resource Include="Resources\new-icons\circle-eraser-solid.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\lasso-select-lined.png" />
<Resource Include="Resources\new-icons\lasso-select-solid.png" />
<Resource Include="Resources\new-icons\pen-white.png" />
<Resource Include="Resources\new-icons\rotate.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\trash.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\shapes.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\eye-off.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\grid.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\blackboard.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\cursor-clear.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\DeveloperAvatars\dubi906w.jpg" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\gesture.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\gesture-enabled.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\close-white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\checked-white.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\checked-black.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\pressdown-background.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\arrow.png" />
<Resource Include="Resources\Icons-png\geo-icons\dashed-line.png" />
<Resource Include="Resources\Icons-png\geo-icons\dotted-line.png" />
<Resource Include="Resources\Icons-png\geo-icons\line.png" />
<Resource Include="Resources\Icons-png\geo-icons\paralle-lines.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\centered-square.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\centered-circle.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\centered-circle-dashed.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\centered-oval.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\square.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\cylinder.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\cone.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\geo-icons\cube.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\EasiNote.png" />
<Resource Include="Resources\Icons-png\EasiNote3C.png" />
<Resource Include="Resources\Icons-png\EasiNote5C.png" />
<Resource Include="Resources\Icons-png\SeewoPinco.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\HiteBoard.png" />
<Resource Include="Resources\Icons-png\HiteCamera.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\Whiteboard.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\Powerpoint.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\PPTTools.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\WPS.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\hatsune-miku1.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-Fluent\party.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\redo.png" />
<Resource Include="Resources\new-icons\undo.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\new-icons\unfold-chevron.png" />
<Resource Include="Resources\new-icons\zoom.png" />
</ItemGroup>
<ItemGroup>
<Compile Remove="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="MainWindow.xaml~RF6c3144.TMP" />
<None Remove="Resources\Cursors\Cursor.cur" />
<None Remove="Resources\Cursors\Pen.cur" />
<None Remove="Resources\DeveloperAvatars\aaaaaaccd.jpg" />
<None Remove="Resources\DeveloperAvatars\Alan-CRL.png" />
<None Remove="Resources\DeveloperAvatars\NetheriteBowl.png" />
<None Remove="Resources\DeveloperAvatars\NotYoojun.png" />
<None Remove="Resources\DeveloperAvatars\RaspberryKan.jpg" />
<None Remove="Resources\DeveloperAvatars\wwei.png" />
<None Remove="Resources\DeveloperAvatars\yuwenhui2020.png" />
<None Remove="Resources\icc.ico" />
<None Remove="Resources\Icons-png\AdmoxBooth.png" />
<None Remove="Resources\Icons-png\AdmoxWhiteboard.png" />
<None Remove="Resources\Icons-png\Donview.png" />
<None Remove="Resources\Icons-png\EasiNote3.png" />
<None Remove="Resources\Icons-png\HiteAnnotation.png" />
<None Remove="Resources\Icons-png\HiteLightBoard.png" />
<None Remove="Resources\Icons-png\ica.png" />
<None Remove="Resources\Icons-png\icc-transparent-dark-small.png" />
<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\idt.png" />
<None Remove="Resources\Icons-png\InkCanvas.png" />
<None Remove="Resources\Icons-png\kuanciya.png" />
<None Remove="Resources\Icons-png\kuandogeyuanliangwo.png" />
<None Remove="Resources\Icons-png\kuandoujiyanhuaji.png" />
<None Remove="Resources\Icons-png\kuanneikuhuaji.png" />
<None Remove="Resources\Icons-png\kuanshounvhuaji.png" />
<None Remove="Resources\Icons-png\MaxHubWhiteboard.png" />
<None Remove="Resources\Icons-png\Seewo2Annotation.png" />
<None Remove="Resources\Icons-png\tiebahuaji.png" />
<None Remove="Resources\Icons-png\transparent-grid.png" />
<None Remove="Resources\Icons-png\VComYouJiao.png" />
<None Remove="Resources\Icons-png\WenXiang.png" />
<None Remove="Resources\Icons-png\YiYunVisualPresenter.png" />
<None Remove="Resources\Icons-png\YiYunWhiteboard.png" />
<None Remove="Resources\new-icons\chevron-left.png" />
<None Remove="Resources\new-icons\end-slides-show.png" />
<None Remove="Resources\new-icons\eye.png" />
<None Remove="Resources\new-icons\hand-move.png" />
<None Remove="Resources\new-icons\highlighter-white.png" />
<None Remove="Resources\new-icons\multi-touch.png" />
<None Remove="Resources\new-icons\osu-lazer-triangles.png" />
<None Remove="Resources\new-icons\pen-white.png" />
<None Remove="Resources\new-icons\rotate.png" />
<None Remove="Resources\new-icons\unfold-chevron.png" />
<None Remove="Resources\new-icons\zoom.png" />
<None Remove="Resources\PresentationExample\bottombar-dark.png" />
<None Remove="Resources\PresentationExample\bottombar-white.png" />
<None Remove="Resources\PresentationExample\page.jpg" />
<None Remove="Resources\PresentationExample\sidebar-dark.png" />
<None Remove="Resources\PresentationExample\sidebar-white.png" />
<None Remove="Resources\PresentationExample\toolbar.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\idt.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons-png\HiteAnnotation.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" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>
-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>
@@ -1,449 +0,0 @@
<Project>
<PropertyGroup>
<AssemblyName>InkCanvasForClass</AssemblyName>
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<MSBuildProjectExtensionsPath>C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\</MSBuildProjectExtensionsPath>
<_TargetAssemblyProjectName>InkCanvasForClass</_TargetAssemblyProjectName>
<RootNamespace>Ink_Canvas</RootNamespace>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.WindowsDesktop" />
<PropertyGroup>
<RuntimeIdentifiers>win;win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<OutputType>WinExe</OutputType>
<RootNamespace>Ink_Canvas</RootNamespace>
<TargetFramework>net472</TargetFramework>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>2.0.2.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>false</BootstrapperEnabled>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<UseWPF>true</UseWPF>
<Configurations>Debug;Release;x86 Debug</Configurations>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>embedded</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|AnyCPU'">
<DebugType>embedded</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>embedded</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\icc.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|x86'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>pdbonly</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Title>InkCanvasForClass</Title>
<Version>5.0.4</Version>
<Authors>Dubi906w</Authors>
<Product>InkCanvasForClass</Product>
<Copyright>© Copyright HARKOTEK Studio 2024-now</Copyright>
<PackageProjectUrl>https://icc.bliemhax.com</PackageProjectUrl>
<FileVersion>bundled</FileVersion>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|ARM64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>pdbonly</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|x64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>full</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<DebugType>pdbonly</DebugType>
<LangVersion>7.3</LangVersion>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<None Include="app.manifest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.9.27" />
<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" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NHotkey.Wpf" Version="3.0.0" />
<PackageReference Include="OSVersionExt" Version="3.0.0" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="stdole">
<Guid>{00020430-0000-0000-C000-000000000046}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="VBIDE">
<Guid>{0002E157-0000-0000-C000-000000000046}</Guid>
<VersionMajor>5</VersionMajor>
<VersionMinor>3</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\TimerDownNotice.wav" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<Compile Remove="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="MainWindow.xaml~RF6c3144.TMP" />
<None Remove="Resources\Cursors\Cursor.cur" />
<None Remove="Resources\Cursors\Pen.cur" />
<None Remove="Resources\DeveloperAvatars\aaaaaaccd.jpg" />
<None Remove="Resources\DeveloperAvatars\Alan-CRL.png" />
<None Remove="Resources\DeveloperAvatars\NetheriteBowl.png" />
<None Remove="Resources\DeveloperAvatars\NotYoojun.png" />
<None Remove="Resources\DeveloperAvatars\RaspberryKan.jpg" />
<None Remove="Resources\DeveloperAvatars\wwei.png" />
<None Remove="Resources\DeveloperAvatars\yuwenhui2020.png" />
<None Remove="Resources\icc.ico" />
<None Remove="Resources\Icons-png\AdmoxBooth.png" />
<None Remove="Resources\Icons-png\AdmoxWhiteboard.png" />
<None Remove="Resources\Icons-png\Donview.png" />
<None Remove="Resources\Icons-png\EasiNote3.png" />
<None Remove="Resources\Icons-png\HiteAnnotation.png" />
<None Remove="Resources\Icons-png\HiteLightBoard.png" />
<None Remove="Resources\Icons-png\ica.png" />
<None Remove="Resources\Icons-png\icc-transparent-dark-small.png" />
<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\idt.png" />
<None Remove="Resources\Icons-png\InkCanvas.png" />
<None Remove="Resources\Icons-png\kuanciya.png" />
<None Remove="Resources\Icons-png\kuandogeyuanliangwo.png" />
<None Remove="Resources\Icons-png\kuandoujiyanhuaji.png" />
<None Remove="Resources\Icons-png\kuanneikuhuaji.png" />
<None Remove="Resources\Icons-png\kuanshounvhuaji.png" />
<None Remove="Resources\Icons-png\MaxHubWhiteboard.png" />
<None Remove="Resources\Icons-png\Seewo2Annotation.png" />
<None Remove="Resources\Icons-png\tiebahuaji.png" />
<None Remove="Resources\Icons-png\transparent-grid.png" />
<None Remove="Resources\Icons-png\VComYouJiao.png" />
<None Remove="Resources\Icons-png\WenXiang.png" />
<None Remove="Resources\Icons-png\YiYunVisualPresenter.png" />
<None Remove="Resources\Icons-png\YiYunWhiteboard.png" />
<None Remove="Resources\new-icons\chevron-left.png" />
<None Remove="Resources\new-icons\end-slides-show.png" />
<None Remove="Resources\new-icons\eye.png" />
<None Remove="Resources\new-icons\hand-move.png" />
<None Remove="Resources\new-icons\highlighter-white.png" />
<None Remove="Resources\new-icons\multi-touch.png" />
<None Remove="Resources\new-icons\osu-lazer-triangles.png" />
<None Remove="Resources\new-icons\pen-white.png" />
<None Remove="Resources\new-icons\rotate.png" />
<None Remove="Resources\new-icons\unfold-chevron.png" />
<None Remove="Resources\new-icons\zoom.png" />
<None Remove="Resources\PresentationExample\bottombar-dark.png" />
<None Remove="Resources\PresentationExample\bottombar-white.png" />
<None Remove="Resources\PresentationExample\page.jpg" />
<None Remove="Resources\PresentationExample\sidebar-dark.png" />
<None Remove="Resources\PresentationExample\sidebar-white.png" />
<None Remove="Resources\PresentationExample\toolbar.png" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\hardcodet.notifyicon.wpf\1.1.0\lib\net472\Hardcodet.NotifyIcon.Wpf.dll" />
<ReferencePath Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\IACore.dll" />
<ReferencePath Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\IALoader.dll" />
<ReferencePath Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\IAWinFX.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\avalonedit\6.3.0.90\lib\net462\ICSharpCode.AvalonEdit.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\inkore.ui.wpf.modern\0.9.27\lib\net452\iNKORE.UI.WPF.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\inkore.ui.wpf.modern\0.9.27\lib\net452\iNKORE.UI.WPF.Modern.Controls.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\inkore.ui.wpf.modern\0.9.27\lib\net452\iNKORE.UI.WPF.Modern.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mdxaml\1.27.0\lib\net462\MdXaml.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mdxaml.plugins\1.27.0\lib\net462\MdXaml.Plugins.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Microsoft.CSharp.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\microsoft.office.interop.powerpoint\15.0.4420.1018\lib\net20\Microsoft.Office.Interop.PowerPoint.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Microsoft.VisualBasic.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\netstandard.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\newtonsoft.json\13.0.3\lib\net45\Newtonsoft.Json.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\nhotkey\3.0.0\lib\net462\NHotkey.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\nhotkey.wpf\3.0.0\lib\net462\NHotkey.Wpf.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\microsoftofficecore\15.0.0\lib\net35\Office.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\osversionext\3.0.0\lib\net462\OSVersionExt.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\PresentationCore.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\PresentationFramework.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.DataSetExtensions.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Drawing.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Net.Http.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Numerics.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.Serialization.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\system.valuetuple\4.5.0\ref\net47\System.ValueTuple.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Windows.Controls.Ribbon.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Windows.Forms.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xaml.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.Linq.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\UIAutomationClient.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\UIAutomationClientsideProviders.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\UIAutomationProvider.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\UIAutomationTypes.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\WindowsBase.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\WindowsFormsIntegration.dll" />
<ReferencePath Include="C:\Windows\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll">
<EmbedInteropTypes>True</EmbedInteropTypes>
</ReferencePath>
<ReferencePath Include="C:\Windows\assembly\GAC_MSIL\Microsoft.Vbe.Interop\15.0.0.0__71e9bce111e9429c\Microsoft.Vbe.Interop.dll">
<EmbedInteropTypes>True</EmbedInteropTypes>
</ReferencePath>
<ReferencePath Include="obj\Debug\net472\Interop.IWshRuntimeLibrary.dll">
<EmbedInteropTypes>True</EmbedInteropTypes>
</ReferencePath>
</ItemGroup>
<ItemGroup>
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\MainWindow.g.cs" />
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\Windows\CountdownTimerWindow.g.cs" />
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\Windows\CycleProcessBar.g.cs" />
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\Windows\HasNewUpdateWindow.g.cs" />
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\Windows\NamesInputWindow.g.cs" />
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\Windows\OperatingGuideWindow.g.cs" />
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\Windows\RandWindow.g.cs" />
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\Windows\YesOrNoNotificationWindow.g.cs" />
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\App.g.cs" />
<Compile Include="C:\Users\Administrator\Desktop\ICC CE\ICC CE main\community\Ink Canvas\obj\Debug\net472\GeneratedInternalTypeHelper.g.cs" />
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk.WindowsDesktop" />
</Project>
File diff suppressed because it is too large Load Diff
-6
View File
@@ -1,6 +0,0 @@
namespace Ink_Canvas
{
internal class ConfigHelper
{
}
}
@@ -1,308 +0,0 @@
using Ink_Canvas.Helpers;
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Ink;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Controls;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
namespace Ink_Canvas {
public partial class MainWindow : Window {
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 void SaveStrokes(bool isBackupMain = false) {
// 确保画布上的所有UI元素都被保存到时间机器历史记录中
var currentHistory = timeMachine.ExportTimeMachineHistory();
var elementsInHistory = new HashSet<UIElement>();
// 收集已经在历史记录中的元素
if (currentHistory != null) {
foreach (var h in currentHistory) {
if (h.CommitType == TimeMachineHistoryType.ElementInsert &&
h.InsertedElement != null &&
!h.StrokeHasBeenCleared) {
elementsInHistory.Add(h.InsertedElement);
}
}
}
// 检查画布上的所有UI元素,确保它们都在历史记录中
var missingElements = 0;
foreach (UIElement child in inkCanvas.Children) {
if (child is Image || child is MediaElement) {
if (!elementsInHistory.Contains(child)) {
timeMachine.CommitElementInsertHistory(child);
missingElements++;
}
}
}
// 确保画布上的所有墨迹都被保存
if (inkCanvas.Strokes.Count > 0) {
// 检查是否有墨迹没有在时间机器历史记录中
var strokesInHistory = new HashSet<Stroke>();
if (currentHistory != null) {
foreach (var h in currentHistory) {
if (h.CommitType == TimeMachineHistoryType.UserInput &&
h.CurrentStroke != null &&
!h.StrokeHasBeenCleared) {
foreach (Stroke stroke in h.CurrentStroke) {
strokesInHistory.Add(stroke);
}
}
}
}
// 收集没有在历史记录中的墨迹
var missingStrokes = new StrokeCollection();
foreach (Stroke stroke in inkCanvas.Strokes) {
if (!strokesInHistory.Contains(stroke)) {
missingStrokes.Add(stroke);
}
}
if (missingStrokes.Count > 0) {
timeMachine.CommitStrokeUserInputHistory(missingStrokes);
}
}
if (isBackupMain) {
var timeMachineHistory = timeMachine.ExportTimeMachineHistory();
TimeMachineHistories[0] = timeMachineHistory;
timeMachine.ClearStrokeHistory();
} else {
var timeMachineHistory = timeMachine.ExportTimeMachineHistory();
TimeMachineHistories[CurrentWhiteboardIndex] = timeMachineHistory;
timeMachine.ClearStrokeHistory();
}
}
private void ClearStrokes(bool isErasedByCode) {
_currentCommitType = CommitReason.ClearingCanvas;
if (isErasedByCode) _currentCommitType = CommitReason.CodeInput;
// 取消任何UI元素的选择,隐藏拉伸控件
DeselectUIElement();
// 只清除笔画,不清除图片元素
// 图片元素的清除由调用方决定
inkCanvas.Strokes.Clear();
_currentCommitType = CommitReason.UserInput;
}
// 恢复每页白板图片信息
private void RestoreStrokes(bool isBackupMain = false) {
try {
var targetIndex = isBackupMain ? 0 : CurrentWhiteboardIndex;
// 先清空当前画布的墨迹
inkCanvas.Strokes.Clear();
// 清空当前画布的所有内容(墨迹和图片)
// 这里必须清除图片,因为页面切换时需要完全重置画布状态
inkCanvas.Children.Clear();
// 如果历史记录为空,直接返回(新页面或空页面)
if (TimeMachineHistories[targetIndex] == null) {
timeMachine.ClearStrokeHistory();
return;
}
if (isBackupMain) {
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[0]);
foreach (var item in TimeMachineHistories[0]) ApplyHistoryToCanvas(item);
} else {
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[CurrentWhiteboardIndex]);
// 通过时间机器历史恢复所有内容(墨迹和图片)
foreach (var item in TimeMachineHistories[CurrentWhiteboardIndex]) ApplyHistoryToCanvas(item);
}
// 确保选中状态被清除,因为我们切换了页面
if (selectedUIElement != null) {
DeselectUIElement();
}
}
catch {
// ignored
}
}
private async void BtnWhiteBoardPageIndex_Click(object sender, EventArgs e) {
if (sender == BtnLeftPageListWB) {
if (BoardBorderLeftPageListView.Visibility == Visibility.Visible) {
AnimationsHelper.HideWithSlideAndFade(BoardBorderLeftPageListView);
} else {
AnimationsHelper.HideWithSlideAndFade(BoardBorderRightPageListView);
RefreshBlackBoardSidePageListView();
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardBorderLeftPageListView);
await Task.Delay(1);
ScrollViewToVerticalTop(
(ListViewItem)BlackBoardLeftSidePageListView.ItemContainerGenerator.ContainerFromIndex(
CurrentWhiteboardIndex - 1), BlackBoardLeftSidePageListScrollViewer);
}
} else if (sender == BtnRightPageListWB)
{
if (BoardBorderRightPageListView.Visibility == Visibility.Visible) {
AnimationsHelper.HideWithSlideAndFade(BoardBorderRightPageListView);
} else {
AnimationsHelper.HideWithSlideAndFade(BoardBorderLeftPageListView);
RefreshBlackBoardSidePageListView();
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardBorderRightPageListView);
await Task.Delay(1);
ScrollViewToVerticalTop(
(ListViewItem)BlackBoardRightSidePageListView.ItemContainerGenerator.ContainerFromIndex(
CurrentWhiteboardIndex - 1), BlackBoardRightSidePageListScrollViewer);
}
}
}
private void BtnWhiteBoardSwitchPrevious_Click(object sender, EventArgs e) {
if (CurrentWhiteboardIndex <= 1) return;
// 取消任何UI元素的选择
DeselectUIElement();
SaveStrokes();
ClearStrokes(true);
CurrentWhiteboardIndex--;
RestoreStrokes();
UpdateIndexInfoDisplay();
}
private void BtnWhiteBoardSwitchNext_Click(object sender, EventArgs e) {
Trace.WriteLine("113223234");
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true);
if (CurrentWhiteboardIndex >= WhiteboardTotalCount) {
// 在最后一页时,点击“新页面”按钮直接新增一页
BtnWhiteBoardAdd_Click(sender, e);
return;
}
// 取消任何UI元素的选择
DeselectUIElement();
SaveStrokes();
ClearStrokes(true);
CurrentWhiteboardIndex++;
RestoreStrokes();
UpdateIndexInfoDisplay();
}
private void BtnWhiteBoardAdd_Click(object sender, EventArgs e) {
if (WhiteboardTotalCount >= 99) return;
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true);
// 取消任何UI元素的选择
DeselectUIElement();
SaveStrokes();
ClearStrokes(true);
WhiteboardTotalCount++;
CurrentWhiteboardIndex++;
if (CurrentWhiteboardIndex != WhiteboardTotalCount)
for (var i = WhiteboardTotalCount; i > CurrentWhiteboardIndex; i--)
TimeMachineHistories[i] = TimeMachineHistories[i - 1];
// 确保新页面的历史记录为空
TimeMachineHistories[CurrentWhiteboardIndex] = null;
// 恢复新页面(这会清空画布,因为历史记录为null)
RestoreStrokes();
UpdateIndexInfoDisplay();
if (WhiteboardTotalCount >= 99) BtnWhiteBoardAdd.IsEnabled = false;
if (BlackBoardLeftSidePageListView.Visibility == Visibility.Visible) {
RefreshBlackBoardSidePageListView();
}
}
private void BtnWhiteBoardDelete_Click(object sender, RoutedEventArgs e) {
ClearStrokes(true);
if (CurrentWhiteboardIndex != WhiteboardTotalCount)
for (var i = CurrentWhiteboardIndex; i <= WhiteboardTotalCount; i++)
TimeMachineHistories[i] = TimeMachineHistories[i + 1];
else
CurrentWhiteboardIndex--;
WhiteboardTotalCount--;
RestoreStrokes();
UpdateIndexInfoDisplay();
if (WhiteboardTotalCount < 99) BtnWhiteBoardAdd.IsEnabled = true;
}
private void UpdateIndexInfoDisplay() {
TextBlockWhiteBoardIndexInfo.Text =
$"{CurrentWhiteboardIndex}/{WhiteboardTotalCount}";
bool isLastPage = CurrentWhiteboardIndex == WhiteboardTotalCount;
bool isMaxPage = WhiteboardTotalCount >= 99;
// 设置按钮文本
BtnLeftWhiteBoardSwitchNextLabel.Text = isLastPage ? "新页面" : "下一页";
BtnRightWhiteBoardSwitchNextLabel.Text = isLastPage ? "新页面" : "下一页";
// 始终允许点击“下一页/新页面”按钮(除非已达最大页数)
BtnWhiteBoardSwitchNext.IsEnabled = !isMaxPage;
// 保持按钮常亮(高亮)
BtnLeftWhiteBoardSwitchNextGeometry.Brush = new SolidColorBrush(Color.FromArgb(255, 24, 24, 27));
BtnLeftWhiteBoardSwitchNextLabel.Opacity = 1;
BtnRightWhiteBoardSwitchNextGeometry.Brush = new SolidColorBrush(Color.FromArgb(255, 24, 24, 27));
BtnRightWhiteBoardSwitchNextLabel.Opacity = 1;
BtnWhiteBoardSwitchPrevious.IsEnabled = true;
if (CurrentWhiteboardIndex == 1) {
BtnWhiteBoardSwitchPrevious.IsEnabled = false;
BtnLeftWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(127, 24, 24, 27));
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));
BtnLeftWhiteBoardSwitchPreviousLabel.Opacity = 1;
BtnRightWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(255, 24, 24, 27));
BtnRightWhiteBoardSwitchPreviousLabel.Opacity = 1;
}
BtnWhiteBoardDelete.IsEnabled = WhiteboardTotalCount != 1;
}
}
}
-833
View File
@@ -1,833 +0,0 @@
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Ink_Canvas.Helpers;
namespace Ink_Canvas {
public partial class MainWindow : Window {
private void BoardChangeBackgroundColorBtn_MouseUp(object sender, RoutedEventArgs e) {
if (!isLoaded) return;
// 创建背景选项面板(如果不存在)
if (BackgroundPalette == null)
{
CreateBackgroundPalette();
}
// 显示或隐藏背景选项面板
if (BackgroundPalette != null)
{
if (BackgroundPalette.Visibility == Visibility.Visible)
{
// 如果面板已经显示,则隐藏它
AnimationsHelper.HideWithSlideAndFade(BackgroundPalette);
}
else
{
// 隐藏其他可能显示的面板
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(PenPalette);
AnimationsHelper.HideWithSlideAndFade(BoardPenPalette);
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
// 显示背景选项面板
AnimationsHelper.ShowWithSlideFromBottomAndFade(BackgroundPalette);
}
return;
}
// 原有的背景切换代码
Settings.Canvas.UsingWhiteboard = !Settings.Canvas.UsingWhiteboard;
SaveSettingsToFile();
if (Settings.Canvas.UsingWhiteboard) {
if (inkColor == 5) lastBoardInkColor = 0;
ICCWaterMarkDark.Visibility = Visibility.Visible;
ICCWaterMarkWhite.Visibility = Visibility.Collapsed;
// 设置为白板默认背景色
Color defaultWhiteboardColor = Color.FromRgb(234, 235, 237);
if (currentMode == 1) // 白板模式
{
// 设置背景为默认白板背景色
GridBackgroundCover.Background = new SolidColorBrush(defaultWhiteboardColor);
// 更新RGB滑块的值为默认白板背景色
if (BackgroundPalette != null && BackgroundPalette.Visibility == Visibility.Visible)
{
UpdateRGBSliders(defaultWhiteboardColor);
}
// 更新自定义背景色为默认白板背景色
CustomBackgroundColor = defaultWhiteboardColor;
// 保存到设置
string colorHex = $"#{defaultWhiteboardColor.R:X2}{defaultWhiteboardColor.G:X2}{defaultWhiteboardColor.B:X2}";
Settings.Canvas.CustomBackgroundColor = colorHex;
SaveSettingsToFile();
}
// 设置墨迹颜色为黑色
CheckLastColor(0);
forceEraser = false;
}
else {
if (inkColor == 0) lastBoardInkColor = 5;
ICCWaterMarkWhite.Visibility = Visibility.Visible;
ICCWaterMarkDark.Visibility = Visibility.Collapsed;
// 设置为黑板默认背景色
Color defaultBlackboardColor = Color.FromRgb(22, 41, 36);
if (currentMode == 1) // 黑板模式
{
// 设置背景为默认黑板背景色
GridBackgroundCover.Background = new SolidColorBrush(defaultBlackboardColor);
// 更新RGB滑块的值为默认黑板背景色
if (BackgroundPalette != null && BackgroundPalette.Visibility == Visibility.Visible)
{
UpdateRGBSliders(defaultBlackboardColor);
}
// 更新自定义背景色为默认黑板背景色
CustomBackgroundColor = defaultBlackboardColor;
// 保存到设置
string colorHex = $"#{defaultBlackboardColor.R:X2}{defaultBlackboardColor.G:X2}{defaultBlackboardColor.B:X2}";
Settings.Canvas.CustomBackgroundColor = colorHex;
SaveSettingsToFile();
}
// 设置墨迹颜色为白色
CheckLastColor(5);
forceEraser = false;
}
CheckColorTheme(true);
}
// 创建背景选项面板
private void CreateBackgroundPalette()
{
// 确保加载自定义背景色
LoadCustomBackgroundColor();
// 创建一个类似于PenPalette的面板
BackgroundPalette = new Border
{
Name = "BackgroundPalette",
Visibility = Visibility.Collapsed,
Background = new SolidColorBrush(Colors.White),
Opacity = 1,
BorderBrush = new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)),
BorderThickness = new Thickness(1),
CornerRadius = new CornerRadius(8),
Width = 300,
MaxHeight = 400
};
// 确保面板显示在顶层
Panel.SetZIndex(BackgroundPalette, 1000);
// 创建面板内容
var stackPanel = new StackPanel();
// 创建标题栏
var titleBorder = new Border
{
BorderBrush = new SolidColorBrush(Color.FromRgb(0x1e, 0x3a, 0x8a)),
Height = 32,
BorderThickness = new Thickness(0, 0, 0, 1),
CornerRadius = new CornerRadius(8, 8, 0, 0),
Background = new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)),
Margin = new Thickness(-1, -1, -1, 0),
Padding = new Thickness(1, 1, 1, 0)
};
var titleCanvas = new System.Windows.Controls.Canvas { Height = 24, ClipToBounds = true };
var titleText = new TextBlock
{
Text = "背景设置",
Foreground = new SolidColorBrush(Colors.White),
Padding = new Thickness(0, 5, 0, 0),
FontSize = 11,
FontWeight = FontWeights.Bold,
TextAlignment = TextAlignment.Center
};
System.Windows.Controls.Canvas.SetLeft(titleText, 8);
titleCanvas.Children.Add(titleText);
// 关闭按钮
var closeImage = new Image
{
Source = new BitmapImage(new Uri("/Resources/new-icons/close-white.png", UriKind.Relative)),
Height = 16,
Width = 16
};
RenderOptions.SetBitmapScalingMode(closeImage, BitmapScalingMode.HighQuality);
closeImage.MouseUp += CloseBordertools_MouseUp;
System.Windows.Controls.Canvas.SetRight(closeImage, 8);
System.Windows.Controls.Canvas.SetTop(closeImage, 4);
titleCanvas.Children.Add(closeImage);
titleBorder.Child = titleCanvas;
stackPanel.Children.Add(titleBorder);
// 创建背景选项内容区域
var contentPanel = new StackPanel { Margin = new Thickness(8) };
// 黑板/白板选择
var modeTitle = new TextBlock
{
Text = "白板模式",
Foreground = new SolidColorBrush(Color.FromRgb(0x17, 0x25, 0x54)),
FontSize = 10,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
Margin = new Thickness(0, 4, 0, 8)
};
contentPanel.Children.Add(modeTitle);
var modePanel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center };
// 白板按钮
var whiteboardButton = new Border
{
Width = 60,
Height = 30,
Background = Settings.Canvas.UsingWhiteboard ? new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)) : new SolidColorBrush(Colors.LightGray),
CornerRadius = new CornerRadius(4),
Margin = new Thickness(0, 0, 8, 0)
};
var whiteboardText = new TextBlock
{
Text = "白板",
Foreground = Settings.Canvas.UsingWhiteboard ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
whiteboardButton.Child = whiteboardText;
whiteboardButton.MouseUp += (s, args) => {
Settings.Canvas.UsingWhiteboard = true;
SaveSettingsToFile();
ICCWaterMarkDark.Visibility = Visibility.Visible;
ICCWaterMarkWhite.Visibility = Visibility.Collapsed;
// 设置为白板默认背景色
Color defaultWhiteboardColor = Color.FromRgb(234, 235, 237);
if (currentMode == 1) // 白板模式
{
// 设置背景为默认白板背景色
GridBackgroundCover.Background = new SolidColorBrush(defaultWhiteboardColor);
// 更新RGB滑块的值为默认白板背景色
UpdateRGBSliders(defaultWhiteboardColor);
// 更新自定义背景色为默认白板背景色
CustomBackgroundColor = defaultWhiteboardColor;
// 保存到设置
string colorHex = $"#{defaultWhiteboardColor.R:X2}{defaultWhiteboardColor.G:X2}{defaultWhiteboardColor.B:X2}";
Settings.Canvas.CustomBackgroundColor = colorHex;
SaveSettingsToFile();
}
// 设置墨迹颜色为黑色
CheckLastColor(0);
forceEraser = false;
CheckColorTheme(true);
UpdateBackgroundButtonsState();
};
modePanel.Children.Add(whiteboardButton);
// 黑板按钮
var blackboardButton = new Border
{
Width = 60,
Height = 30,
Background = !Settings.Canvas.UsingWhiteboard ? new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)) : new SolidColorBrush(Colors.LightGray),
CornerRadius = new CornerRadius(4)
};
var blackboardText = new TextBlock
{
Text = "黑板",
Foreground = !Settings.Canvas.UsingWhiteboard ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
blackboardButton.Child = blackboardText;
blackboardButton.MouseUp += (s, args) => {
Settings.Canvas.UsingWhiteboard = false;
SaveSettingsToFile();
ICCWaterMarkWhite.Visibility = Visibility.Visible;
ICCWaterMarkDark.Visibility = Visibility.Collapsed;
// 设置为黑板默认背景色
Color defaultBlackboardColor = Color.FromRgb(22, 41, 36);
if (currentMode == 1) // 黑板模式
{
// 设置背景为默认黑板背景色
GridBackgroundCover.Background = new SolidColorBrush(defaultBlackboardColor);
// 更新RGB滑块的值为默认黑板背景色
UpdateRGBSliders(defaultBlackboardColor);
// 更新自定义背景色为默认黑板背景色
CustomBackgroundColor = defaultBlackboardColor;
// 保存到设置
string colorHex = $"#{defaultBlackboardColor.R:X2}{defaultBlackboardColor.G:X2}{defaultBlackboardColor.B:X2}";
Settings.Canvas.CustomBackgroundColor = colorHex;
SaveSettingsToFile();
}
// 设置墨迹颜色为白色
CheckLastColor(5);
forceEraser = false;
CheckColorTheme(true);
UpdateBackgroundButtonsState();
};
modePanel.Children.Add(blackboardButton);
contentPanel.Children.Add(modePanel);
// 添加一条分隔线
var separator = new Border
{
Height = 1,
Background = new SolidColorBrush(Color.FromRgb(0xd4, 0xd4, 0xd8)),
Margin = new Thickness(0, 12, 0, 12)
};
contentPanel.Children.Add(separator);
// 添加RGB颜色选择器部分
var colorTitle = new TextBlock
{
Text = "背景颜色",
Foreground = new SolidColorBrush(Color.FromRgb(0x17, 0x25, 0x54)),
FontSize = 10,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center,
Margin = new Thickness(0, 4, 0, 8)
};
contentPanel.Children.Add(colorTitle);
// 创建颜色预览
Border colorPreview = new Border
{
Width = 100,
Height = 40,
BorderThickness = new Thickness(1),
BorderBrush = new SolidColorBrush(Color.FromRgb(0xd4, 0xd4, 0xd8)),
Background = new SolidColorBrush(Colors.White),
CornerRadius = new CornerRadius(4),
Margin = new Thickness(0, 0, 0, 10),
HorizontalAlignment = HorizontalAlignment.Center
};
contentPanel.Children.Add(colorPreview);
// 获取当前背景颜色
Color currentBackgroundColor;
if (currentMode == 1) // 白板或黑板模式
{
if (GridBackgroundCover.Background is SolidColorBrush brush)
{
currentBackgroundColor = brush.Color;
}
else
{
// 默认颜色
currentBackgroundColor = Settings.Canvas.UsingWhiteboard ?
Color.FromRgb(234, 235, 237) : // 白板默认颜色
Color.FromRgb(22, 41, 36); // 黑板默认颜色
}
}
else
{
// 默认白色
currentBackgroundColor = Colors.White;
}
// 更新颜色预览
colorPreview.Background = new SolidColorBrush(currentBackgroundColor);
// 先创建所有滑块控件
// 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 rSlider = new Slider
{
Minimum = 0,
Maximum = 255,
Value = currentBackgroundColor.R,
Width = 150,
Margin = new Thickness(5, 0, 5, 0),
VerticalAlignment = VerticalAlignment.Center
};
var rValueText = new TextBlock
{
Text = currentBackgroundColor.R.ToString(),
Width = 30,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Right
};
// 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 gSlider = new Slider
{
Minimum = 0,
Maximum = 255,
Value = currentBackgroundColor.G,
Width = 150,
Margin = new Thickness(5, 0, 5, 0),
VerticalAlignment = VerticalAlignment.Center
};
var gValueText = new TextBlock
{
Text = currentBackgroundColor.G.ToString(),
Width = 30,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Right
};
// 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 bSlider = new Slider
{
Minimum = 0,
Maximum = 255,
Value = currentBackgroundColor.B,
Width = 150,
Margin = new Thickness(5, 0, 5, 0),
VerticalAlignment = VerticalAlignment.Center
};
var bValueText = new TextBlock
{
Text = currentBackgroundColor.B.ToString(),
Width = 30,
VerticalAlignment = VerticalAlignment.Center,
TextAlignment = TextAlignment.Right
};
// 现在添加事件处理程序
rSlider.ValueChanged += (s, e) => {
int value = (int)e.NewValue;
rValueText.Text = value.ToString();
UpdateColorPreview(colorPreview, rSlider, gSlider, bSlider);
};
gSlider.ValueChanged += (s, e) => {
int value = (int)e.NewValue;
gValueText.Text = value.ToString();
UpdateColorPreview(colorPreview, rSlider, gSlider, bSlider);
};
bSlider.ValueChanged += (s, e) => {
int value = (int)e.NewValue;
bValueText.Text = value.ToString();
UpdateColorPreview(colorPreview, rSlider, gSlider, bSlider);
};
// 添加控件到面板
rPanel.Children.Add(rLabel);
rPanel.Children.Add(rSlider);
rPanel.Children.Add(rValueText);
contentPanel.Children.Add(rPanel);
gPanel.Children.Add(gLabel);
gPanel.Children.Add(gSlider);
gPanel.Children.Add(gValueText);
contentPanel.Children.Add(gPanel);
bPanel.Children.Add(bLabel);
bPanel.Children.Add(bSlider);
bPanel.Children.Add(bValueText);
contentPanel.Children.Add(bPanel);
// 应用按钮
var applyButton = new Button
{
Content = "应用颜色",
Margin = new Thickness(0, 10, 0, 0),
Padding = new Thickness(10, 5, 10, 5),
Background = new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)),
Foreground = new SolidColorBrush(Colors.White),
BorderThickness = new Thickness(0),
HorizontalAlignment = HorizontalAlignment.Center
};
applyButton.Click += (s, e) => {
Color selectedColor = Color.FromRgb(
(byte)rSlider.Value,
(byte)gSlider.Value,
(byte)bSlider.Value
);
ApplyCustomBackgroundColor(selectedColor);
};
contentPanel.Children.Add(applyButton);
stackPanel.Children.Add(contentPanel);
// 将面板添加到父容器
BackgroundPalette.Child = stackPanel;
// 获取主窗口中的根网格,确保面板添加到顶层
Grid mainGrid = FindName("Main_Grid") as Grid;
if (mainGrid != null)
{
// 删除可能已存在的BackgroundPalette
foreach (UIElement element in mainGrid.Children)
{
if (element is Border border && border.Name == "BackgroundPalette")
{
mainGrid.Children.Remove(border);
break;
}
}
// 重新定位面板
BackgroundPalette.HorizontalAlignment = HorizontalAlignment.Center;
BackgroundPalette.VerticalAlignment = VerticalAlignment.Center;
BackgroundPalette.Margin = new Thickness(0, 0, 0, 0);
// 添加到主网格
mainGrid.Children.Add(BackgroundPalette);
// 设置面板位置
var clickElement = FindName("BoardChangeBackgroundColorBtn") as FrameworkElement;
if (clickElement != null)
{
Point position = clickElement.TranslatePoint(new Point(0, 0), mainGrid);
BackgroundPalette.Margin = new Thickness(
position.X - 150,
position.Y + clickElement.ActualHeight + 5,
0, 0);
BackgroundPalette.HorizontalAlignment = HorizontalAlignment.Left;
BackgroundPalette.VerticalAlignment = VerticalAlignment.Top;
}
}
}
// 更新背景按钮状态
private void UpdateBackgroundButtonsState()
{
if (BackgroundPalette != null && BackgroundPalette.Child is StackPanel stackPanel)
{
if (stackPanel.Children.Count > 1 && stackPanel.Children[1] is StackPanel contentPanel)
{
if (contentPanel.Children.Count > 1 && contentPanel.Children[1] is StackPanel modePanel)
{
if (modePanel.Children.Count > 1)
{
var whiteboardButton = modePanel.Children[0] as Border;
var blackboardButton = modePanel.Children[1] as Border;
if (whiteboardButton != null && whiteboardButton.Child is TextBlock whiteboardText)
{
whiteboardButton.Background = Settings.Canvas.UsingWhiteboard ?
new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)) :
new SolidColorBrush(Colors.LightGray);
whiteboardText.Foreground = Settings.Canvas.UsingWhiteboard ?
new SolidColorBrush(Colors.White) :
new SolidColorBrush(Colors.Black);
}
if (blackboardButton != null && blackboardButton.Child is TextBlock blackboardText)
{
blackboardButton.Background = !Settings.Canvas.UsingWhiteboard ?
new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)) :
new SolidColorBrush(Colors.LightGray);
blackboardText.Foreground = !Settings.Canvas.UsingWhiteboard ?
new SolidColorBrush(Colors.White) :
new SolidColorBrush(Colors.Black);
}
}
}
}
}
}
// 添加成员变量保存背景面板引用
private Border BackgroundPalette { get; set; }
// 添加成员变量保存当前自定义背景色
private Color? CustomBackgroundColor { get; set; }
/// <summary>
/// 更新颜色预览框的颜色
/// </summary>
private void UpdateColorPreview(Border colorPreview, Slider rSlider, Slider gSlider, Slider bSlider)
{
Color previewColor = Color.FromRgb(
(byte)rSlider.Value,
(byte)gSlider.Value,
(byte)bSlider.Value
);
colorPreview.Background = new SolidColorBrush(previewColor);
}
/// <summary>
/// 应用自定义背景颜色
/// </summary>
private void ApplyCustomBackgroundColor(Color color)
{
// 保存当前选择的颜色
CustomBackgroundColor = color;
// 将颜色转换为十六进制字符串并保存到设置中
string colorHex = $"#{color.R:X2}{color.G:X2}{color.B:X2}";
Settings.Canvas.CustomBackgroundColor = colorHex;
// 只在白板或黑板模式下应用自定义背景色
if (currentMode == 1) // 白板或黑板模式
{
// 设置白板/黑板模式下的背景
GridBackgroundCover.Background = new SolidColorBrush(color);
}
// 保存设置
SaveSettingsToFile();
// 立即更新界面
if (BackgroundPalette != null)
{
UpdateBackgroundButtonsState();
UpdateRGBSliders(color); // 更新RGB滑块的值
}
// 显示提示信息
ShowNotification($"已应用自定义背景色: {colorHex}");
}
/// <summary>
/// 从设置中加载自定义背景色
/// </summary>
private void LoadCustomBackgroundColor()
{
if (!string.IsNullOrEmpty(Settings.Canvas.CustomBackgroundColor))
{
try
{
// 解析颜色字符串
string colorHex = Settings.Canvas.CustomBackgroundColor;
if (colorHex.StartsWith("#") && colorHex.Length == 7) // #RRGGBB 格式
{
byte r = Convert.ToByte(colorHex.Substring(1, 2), 16);
byte g = Convert.ToByte(colorHex.Substring(3, 2), 16);
byte b = Convert.ToByte(colorHex.Substring(5, 2), 16);
// 保存到内存中
CustomBackgroundColor = Color.FromRgb(r, g, b);
}
}
catch (Exception ex)
{
// 解析失败,根据当前模式设置默认颜色
if (!Settings.Canvas.UsingWhiteboard)
{
// 黑板模式默认颜色
CustomBackgroundColor = Color.FromRgb(22, 41, 36);
}
else
{
// 白板模式默认颜色
CustomBackgroundColor = Color.FromRgb(234, 235, 237);
}
// 可以在这里记录日志
Console.WriteLine($"解析自定义背景色失败: {ex.Message}");
}
}
else
{
// 如果没有设置自定义背景色,根据当前模式设置默认颜色
if (!Settings.Canvas.UsingWhiteboard)
{
// 黑板模式默认颜色
CustomBackgroundColor = Color.FromRgb(22, 41, 36);
}
else
{
// 白板模式默认颜色
CustomBackgroundColor = Color.FromRgb(234, 235, 237);
}
}
// 只在白板或黑板模式下应用自定义背景色
if (currentMode == 1 && CustomBackgroundColor.HasValue) // 白板或黑板模式
{
// 设置白板/黑板模式下的背景
GridBackgroundCover.Background = new SolidColorBrush(CustomBackgroundColor.Value);
// 更新RGB滑块的值(如果调色板已经创建)
if (BackgroundPalette != null && BackgroundPalette.Visibility == Visibility.Visible)
{
UpdateRGBSliders(CustomBackgroundColor.Value);
}
}
}
private void BoardLassoIcon_Click(object sender, RoutedEventArgs e) {
forceEraser = false;
forcePointEraser = false;
drawingShapeMode = 0;
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
SetCursorBasedOnEditingMode(inkCanvas);
}
private void BoardEraserIconByStrokes_Click(object sender, RoutedEventArgs e) {
//if (BoardEraserByStrokes.Background.ToString() == "#FF679CF4") {
// AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardDeleteIcon);
//}
//else {
// 禁用高级橡皮擦系统
DisableAdvancedEraserSystem();
forceEraser = true;
forcePointEraser = false;
inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
drawingShapeMode = 0;
// 修复:切换到线擦时,确保重置笔的状态
penType = 0;
drawingAttributes.IsHighlighter = false;
drawingAttributes.StylusTip = StylusTip.Ellipse;
inkCanvas_EditingModeChanged(inkCanvas, null);
CancelSingleFingerDragMode();
HideSubPanels("eraserByStrokes");
//}
}
private void BoardSymbolIconDelete_MouseUp(object sender, RoutedEventArgs e) {
PenIcon_Click(null, null);
SymbolIconDelete_MouseUp(null, null);
// 根据设置决定是否清空图片
if (Settings.Canvas.ClearCanvasAlsoClearImages) {
// 如果设置为清空图片,则直接清空所有子元素
Debug.WriteLine("BoardSymbolIconDelete: Clearing all children including images");
inkCanvas.Children.Clear();
} else {
// 保存非笔画元素(如图片)
Debug.WriteLine("BoardSymbolIconDelete: Preserving non-stroke elements (images)");
var preservedElements = PreserveNonStrokeElements();
Debug.WriteLine($"BoardSymbolIconDelete: Preserved elements count: {preservedElements.Count}");
inkCanvas.Children.Clear();
// 恢复非笔画元素
RestoreNonStrokeElements(preservedElements);
Debug.WriteLine($"BoardSymbolIconDelete: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
}
}
private void BoardSymbolIconDeleteInkAndHistories_MouseUp(object sender, RoutedEventArgs e)
{
PenIcon_Click(null, null);
SymbolIconDelete_MouseUp(null, null);
if (Settings.Canvas.ClearCanvasAndClearTimeMachine == false) timeMachine.ClearStrokeHistory();
// 根据设置决定是否清空图片
if (Settings.Canvas.ClearCanvasAlsoClearImages) {
// 如果设置为清空图片,则直接清空所有子元素
Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Clearing all children including images");
inkCanvas.Children.Clear();
} else {
// 保存非笔画元素(如图片)
Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Preserving non-stroke elements (images)");
var preservedElements = PreserveNonStrokeElements();
Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: Preserved elements count: {preservedElements.Count}");
inkCanvas.Children.Clear();
// 恢复非笔画元素
RestoreNonStrokeElements(preservedElements);
Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
}
}
private void BoardLaunchEasiCamera_MouseUp(object sender, MouseButtonEventArgs e) {
ImageBlackboard_MouseUp(null, null);
SoftwareLauncher.LaunchEasiCamera("希沃视频展台");
}
private void BoardLaunchDesmos_MouseUp(object sender, MouseButtonEventArgs e) {
HideSubPanelsImmediately();
ImageBlackboard_MouseUp(null, null);
Process.Start("https://www.desmos.com/calculator?lang=zh-CN");
}
/// <summary>
/// 根据当前背景颜色更新RGB滑块的值
/// </summary>
private void UpdateRGBSliders(Color color)
{
if (BackgroundPalette != null && BackgroundPalette.Child is StackPanel stackPanel)
{
if (stackPanel.Children.Count > 1 && stackPanel.Children[1] is StackPanel contentPanel)
{
// 查找RGB滑块
Slider rSlider = null;
Slider gSlider = null;
Slider bSlider = null;
// 遍历面板查找RGB滑块
foreach (var child in contentPanel.Children)
{
if (child is StackPanel panel && panel.Orientation == Orientation.Horizontal)
{
foreach (var panelChild in panel.Children)
{
if (panelChild is Slider slider)
{
if (panel.Children.Count > 0 && panel.Children[0] is TextBlock label)
{
if (label.Text == "R:")
{
rSlider = slider;
}
else if (label.Text == "G:")
{
gSlider = slider;
}
else if (label.Text == "B:")
{
bSlider = slider;
}
}
}
}
}
}
// 更新滑块值
if (rSlider != null && gSlider != null && bSlider != null)
{
rSlider.Value = color.R;
gSlider.Value = color.G;
bSlider.Value = color.B;
}
}
}
}
}
}
@@ -1,267 +0,0 @@
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using Ink_Canvas.Helpers;
namespace Ink_Canvas
{
public partial class MainWindow : Window
{
private bool isClipboardMonitoringEnabled = false;
private BitmapSource lastClipboardImage = null;
// 初始化剪贴板监控
private void InitializeClipboardMonitoring()
{
try
{
// 监听剪贴板变化
ClipboardNotification.ClipboardUpdate += OnClipboardUpdate;
isClipboardMonitoringEnabled = true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"初始化剪贴板监控失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 剪贴板内容变化事件处理
private void OnClipboardUpdate()
{
try
{
if (Clipboard.ContainsImage())
{
var clipboardImage = Clipboard.GetImage();
if (clipboardImage != null && clipboardImage != lastClipboardImage)
{
lastClipboardImage = clipboardImage;
// 在白板模式下显示粘贴提示
if (currentMode == 1) // 白板模式
{
ShowPasteNotification();
}
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理剪贴板更新失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 显示粘贴提示
private void ShowPasteNotification()
{
try
{
Dispatcher.Invoke(() =>
{
ShowNotification("检测到剪贴板中有图片,右键点击白板可粘贴");
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"显示粘贴提示失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 处理右键菜单显示
private void ShowPasteContextMenu(Point position)
{
try
{
if (!Clipboard.ContainsImage()) return;
// 创建右键菜单
var contextMenu = new ContextMenu();
var pasteMenuItem = new MenuItem
{
Header = "粘贴图片"
};
pasteMenuItem.Click += async (s, e) => await PasteImageFromClipboard(position);
contextMenu.Items.Add(pasteMenuItem);
// 显示菜单
contextMenu.IsOpen = true;
contextMenu.PlacementTarget = inkCanvas;
contextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"显示粘贴菜单失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 从剪贴板粘贴图片
private async Task PasteImageFromClipboard(Point? position = null)
{
try
{
if (!Clipboard.ContainsImage())
{
ShowNotification("剪贴板中没有图片");
return;
}
var clipboardImage = Clipboard.GetImage();
if (clipboardImage == null)
{
ShowNotification("无法获取剪贴板图片");
return;
}
// 创建Image控件
var image = new Image
{
Source = clipboardImage,
Width = clipboardImage.PixelWidth,
Height = clipboardImage.PixelHeight,
Stretch = System.Windows.Media.Stretch.Fill
};
// 生成唯一名称
string timestamp = "img_clipboard_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss_fff");
image.Name = timestamp;
// 设置位置
if (position.HasValue)
{
// 在指定位置居中显示
InkCanvas.SetLeft(image, position.Value.X - image.Width / 2);
InkCanvas.SetTop(image, position.Value.Y - image.Height / 2);
}
else
{
// 使用与文件选择相同的居中和缩放逻辑
CenterAndScaleElement(image);
}
// 添加到画布
inkCanvas.Children.Add(image);
// 添加鼠标事件处理
image.MouseDown += UIElement_MouseDown;
image.IsManipulationEnabled = true;
// 提交到历史记录
timeMachine.CommitElementInsertHistory(image);
ShowNotification("图片已从剪贴板粘贴");
}
catch (Exception ex)
{
ShowNotification($"粘贴图片失败: {ex.Message}");
LogHelper.WriteLogToFile($"粘贴图片失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 处理白板右键事件
private void InkCanvas_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
try
{
// 只在白板模式下处理
if (currentMode != 1) return;
// 检查是否有图片在剪贴板中
if (Clipboard.ContainsImage())
{
var position = e.GetPosition(inkCanvas);
ShowPasteContextMenu(position);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理右键事件失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 处理全局粘贴快捷键
private async void HandleGlobalPaste(object sender, ExecutedRoutedEventArgs e)
{
try
{
// 只在白板模式下处理
if (currentMode != 1) return;
if (Clipboard.ContainsImage())
{
await PasteImageFromClipboard();
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"处理全局粘贴失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 清理剪贴板监控
private void CleanupClipboardMonitoring()
{
try
{
if (isClipboardMonitoringEnabled)
{
ClipboardNotification.ClipboardUpdate -= OnClipboardUpdate;
isClipboardMonitoringEnabled = false;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理剪贴板监控失败: {ex.Message}", LogHelper.LogType.Error);
}
}
}
// 剪贴板通知类
public static class ClipboardNotification
{
public static event Action ClipboardUpdate;
private static System.Windows.Forms.Timer clipboardTimer;
private static string lastClipboardText = "";
private static bool lastHadImage = false;
static ClipboardNotification()
{
clipboardTimer = new System.Windows.Forms.Timer();
clipboardTimer.Interval = 500; // 每500ms检查一次
clipboardTimer.Tick += CheckClipboard;
clipboardTimer.Start();
}
private static void CheckClipboard(object sender, EventArgs e)
{
try
{
bool currentHasImage = Clipboard.ContainsImage();
string currentText = Clipboard.ContainsText() ? Clipboard.GetText() : "";
if (currentHasImage != lastHadImage || currentText != lastClipboardText)
{
lastHadImage = currentHasImage;
lastClipboardText = currentText;
ClipboardUpdate?.Invoke();
}
}
catch
{
// 忽略剪贴板访问错误
}
}
public static void Stop()
{
clipboardTimer?.Stop();
clipboardTimer?.Dispose();
}
}
}
@@ -1,430 +0,0 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Ink_Canvas.Helpers;
using Microsoft.Win32;
namespace Ink_Canvas
{
public partial class MainWindow : Window
{
#region Image
private async void BtnImageInsert_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Image files (*.jpg; *.jpeg; *.png; *.bmp)|*.jpg;*.jpeg;*.png;*.bmp";
if (openFileDialog.ShowDialog() == true)
{
string filePath = openFileDialog.FileName;
Image image = await CreateAndCompressImageAsync(filePath);
if (image != null)
{
string timestamp = "img_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss_fff");
image.Name = timestamp;
CenterAndScaleElement(image);
inkCanvas.Children.Add(image);
// 添加鼠标事件处理,使图片可以被选择
image.MouseDown += UIElement_MouseDown;
image.IsManipulationEnabled = true;
timeMachine.CommitElementInsertHistory(image);
}
}
}
private async Task<Image> CreateAndCompressImageAsync(string filePath)
{
string savePath = Path.Combine(Settings.Automation.AutoSavedStrokesLocation, "File Dependency");
if (!Directory.Exists(savePath))
{
Directory.CreateDirectory(savePath);
}
string fileExtension = Path.GetExtension(filePath);
string timestamp = "img_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss_fff");
string newFilePath = Path.Combine(savePath, timestamp + fileExtension);
await Task.Run(() => File.Copy(filePath, newFilePath, true));
return await Dispatcher.InvokeAsync(() =>
{
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.UriSource = new Uri(newFilePath);
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
int width = bitmapImage.PixelWidth;
int height = bitmapImage.PixelHeight;
Image image = new Image();
// 设置拉伸模式为Fill,支持任意比例缩放
image.Stretch = Stretch.Fill;
if (isLoaded && Settings.Canvas.IsCompressPicturesUploaded && (width > 1920 || height > 1080))
{
double scaleX = 1920.0 / width;
double scaleY = 1080.0 / height;
double scale = Math.Min(scaleX, scaleY);
TransformedBitmap transformedBitmap = new TransformedBitmap(bitmapImage, new ScaleTransform(scale, scale));
image.Source = transformedBitmap;
image.Width = transformedBitmap.PixelWidth;
image.Height = transformedBitmap.PixelHeight;
}
else
{
image.Source = bitmapImage;
image.Width = width;
image.Height = height;
}
return image;
});
}
#endregion
#region Media
private async void BtnMediaInsert_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Media files (*.mp4; *.avi; *.wmv)|*.mp4;*.avi;*.wmv";
if (openFileDialog.ShowDialog() == true)
{
string filePath = openFileDialog.FileName;
byte[] mediaBytes = await Task.Run(() => File.ReadAllBytes(filePath));
MediaElement mediaElement = await CreateMediaElementAsync(filePath);
if (mediaElement != null)
{
CenterAndScaleElement(mediaElement);
InkCanvas.SetLeft(mediaElement, 0);
InkCanvas.SetTop(mediaElement, 0);
inkCanvas.Children.Add(mediaElement);
// 添加鼠标事件处理,使媒体元素可以被选择
mediaElement.MouseDown += UIElement_MouseDown;
mediaElement.IsManipulationEnabled = true;
mediaElement.LoadedBehavior = MediaState.Manual;
mediaElement.UnloadedBehavior = MediaState.Manual;
mediaElement.Loaded += async (_, args) =>
{
mediaElement.Play();
await Task.Delay(100);
mediaElement.Pause();
};
timeMachine.CommitElementInsertHistory(mediaElement);
}
}
}
private async Task<MediaElement> CreateMediaElementAsync(string filePath)
{
string savePath = Path.Combine(Settings.Automation.AutoSavedStrokesLocation, "File Dependency");
if (!Directory.Exists(savePath))
{
Directory.CreateDirectory(savePath);
}
return await Dispatcher.InvokeAsync(() =>
{
MediaElement mediaElement = new MediaElement();
mediaElement.Source = new Uri(filePath);
string timestamp = "media_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss_fff");
mediaElement.Name = timestamp;
mediaElement.LoadedBehavior = MediaState.Manual;
mediaElement.UnloadedBehavior = MediaState.Manual;
mediaElement.Width = 256;
mediaElement.Height = 256;
string fileExtension = Path.GetExtension(filePath);
string newFilePath = Path.Combine(savePath, mediaElement.Name + fileExtension);
File.Copy(filePath, newFilePath, true);
mediaElement.Source = new Uri(newFilePath);
return mediaElement;
});
}
#endregion
#region Image Operations
/// <summary>
/// 旋转图片
/// </summary>
/// <param name="image">要旋转的图片</param>
/// <param name="angle">旋转角度(正数为顺时针,负数为逆时针)</param>
private void RotateImage(Image image, double angle)
{
if (image == null) return;
try
{
// 获取当前的变换
var transformGroup = image.RenderTransform as TransformGroup ?? new TransformGroup();
// 查找现有的旋转变换
RotateTransform rotateTransform = null;
foreach (Transform transform in transformGroup.Children)
{
if (transform is RotateTransform rt)
{
rotateTransform = rt;
break;
}
}
// 如果没有旋转变换,创建一个新的
if (rotateTransform == null)
{
rotateTransform = new RotateTransform();
transformGroup.Children.Add(rotateTransform);
}
// 设置旋转中心为图片中心
rotateTransform.CenterX = image.ActualWidth / 2;
rotateTransform.CenterY = image.ActualHeight / 2;
// 累加旋转角度
rotateTransform.Angle = (rotateTransform.Angle + angle) % 360;
// 应用变换
image.RenderTransform = transformGroup;
// 提交到时间机器以支持撤销
// 注意:旋转操作目前不支持撤销,因为需要更复杂的历史记录机制
}
catch (Exception ex)
{
// 记录错误但不中断程序
System.Diagnostics.Debug.WriteLine($"旋转图片时发生错误: {ex.Message}");
}
}
/// <summary>
/// 克隆图片
/// </summary>
/// <param name="image">要克隆的图片</param>
private void CloneImage(Image image)
{
if (image == null) return;
try
{
// 创建图片的副本
var clonedImage = new Image
{
Source = image.Source,
Width = image.Width,
Height = image.Height,
Stretch = image.Stretch,
RenderTransform = image.RenderTransform?.Clone() as Transform
};
// 设置位置,稍微偏移以避免重叠
InkCanvas.SetLeft(clonedImage, InkCanvas.GetLeft(image) + 20);
InkCanvas.SetTop(clonedImage, InkCanvas.GetTop(image) + 20);
// 添加鼠标事件处理,使图片可以被选择
clonedImage.MouseDown += UIElement_MouseDown;
clonedImage.IsManipulationEnabled = true;
// 添加到画布
inkCanvas.Children.Add(clonedImage);
// 选择新克隆的图片
DeselectUIElement();
SelectUIElement(clonedImage);
// 提交到时间机器以支持撤销
timeMachine.CommitElementInsertHistory(clonedImage);
}
catch (Exception ex)
{
// 记录错误但不中断程序
System.Diagnostics.Debug.WriteLine($"克隆图片时发生错误: {ex.Message}");
}
}
/// <summary>
/// 克隆图片到新页面
/// </summary>
/// <param name="image">要克隆的图片</param>
private void CloneImageToNewBoard(Image image)
{
if (image == null) return;
try
{
// 创建图片的副本
var clonedImage = new Image
{
Source = image.Source,
Width = image.Width,
Height = image.Height,
Stretch = image.Stretch,
RenderTransform = image.RenderTransform?.Clone() as Transform
};
// 设置位置,稍微偏移以避免重叠
InkCanvas.SetLeft(clonedImage, InkCanvas.GetLeft(image) + 20);
InkCanvas.SetTop(clonedImage, InkCanvas.GetTop(image) + 20);
// 添加鼠标事件处理,使图片可以被选择
clonedImage.MouseDown += UIElement_MouseDown;
clonedImage.IsManipulationEnabled = true;
// 创建新页面
BtnWhiteBoardAdd_Click(null, null);
// 添加到新页面的画布
inkCanvas.Children.Add(clonedImage);
// 选择新克隆的图片
DeselectUIElement();
SelectUIElement(clonedImage);
// 提交到时间机器以支持撤销
timeMachine.CommitElementInsertHistory(clonedImage);
}
catch (Exception ex)
{
// 记录错误但不中断程序
System.Diagnostics.Debug.WriteLine($"克隆图片到新页面时发生错误: {ex.Message}");
}
}
/// <summary>
/// 缩放图片
/// </summary>
/// <param name="image">要缩放的图片</param>
/// <param name="scaleFactor">缩放因子(大于1为放大,小于1为缩小)</param>
private void ScaleImage(Image image, double scaleFactor)
{
if (image == null) return;
try
{
// 获取当前的变换
var transformGroup = image.RenderTransform as TransformGroup ?? new TransformGroup();
// 查找现有的缩放变换
ScaleTransform scaleTransform = null;
foreach (Transform transform in transformGroup.Children)
{
if (transform is ScaleTransform st)
{
scaleTransform = st;
break;
}
}
// 如果没有缩放变换,创建一个新的
if (scaleTransform == null)
{
scaleTransform = new ScaleTransform();
transformGroup.Children.Add(scaleTransform);
}
// 设置缩放中心为图片中心
scaleTransform.CenterX = image.ActualWidth / 2;
scaleTransform.CenterY = image.ActualHeight / 2;
// 应用缩放因子
scaleTransform.ScaleX *= scaleFactor;
scaleTransform.ScaleY *= scaleFactor;
// 应用变换
image.RenderTransform = transformGroup;
// 提交到时间机器以支持撤销
// 注意:缩放操作目前不支持撤销,因为需要更复杂的历史记录机制
}
catch (Exception ex)
{
// 记录错误但不中断程序
System.Diagnostics.Debug.WriteLine($"缩放图片时发生错误: {ex.Message}");
}
}
/// <summary>
/// 删除图片
/// </summary>
/// <param name="image">要删除的图片</param>
private void DeleteImage(Image image)
{
if (image == null) return;
try
{
// 从画布中移除图片
if (inkCanvas.Children.Contains(image))
{
inkCanvas.Children.Remove(image);
// 取消选择
DeselectUIElement();
// 提交到时间机器以支持撤销
timeMachine.CommitElementRemoveHistory(image);
}
}
catch (Exception ex)
{
// 记录错误但不中断程序
System.Diagnostics.Debug.WriteLine($"删除图片时发生错误: {ex.Message}");
}
}
#endregion
private void CenterAndScaleElement(FrameworkElement element)
{
double maxWidth = SystemParameters.PrimaryScreenWidth / 2;
double maxHeight = SystemParameters.PrimaryScreenHeight / 2;
double scaleX = maxWidth / element.Width;
double scaleY = maxHeight / element.Height;
double scale = Math.Min(scaleX, scaleY);
// 直接设置元素的大小,而不使用RenderTransform
double newWidth = element.Width * scale;
double newHeight = element.Height * scale;
element.Width = newWidth;
element.Height = newHeight;
// 计算居中位置
double canvasWidth = inkCanvas.ActualWidth;
double canvasHeight = inkCanvas.ActualHeight;
double centerX = (canvasWidth - newWidth) / 2;
double centerY = (canvasHeight - newHeight) / 2;
// 直接设置位置,而不使用RenderTransform
InkCanvas.SetLeft(element, centerX);
InkCanvas.SetTop(element, centerY);
// 清除任何现有的RenderTransform
element.RenderTransform = Transform.Identity;
}
}
}
-735
View File
@@ -1,735 +0,0 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using Ink_Canvas.Helpers;
namespace Ink_Canvas {
public partial class MainWindow : Window {
// 新橡皮擦系统的核心变量
public bool isUsingAdvancedEraser;
private IncrementalStrokeHitTester advancedHitTester;
// 橡皮擦配置
public double currentEraserSize = 64;
public bool isCurrentEraserCircle;
public bool isUsingStrokeEraser;
// 视觉反馈相关
private Matrix eraserTransformMatrix;
private Point lastEraserPosition;
private bool isEraserVisible;
// 性能优化相关
private DateTime lastEraserUpdate = DateTime.Now;
private const double ERASER_UPDATE_INTERVAL = 16.67; // 约60FPS
// 锁定笔画的GUID(如果不存在则创建一个默认值)
private static readonly Guid IsLockGuid = new Guid("12345678-1234-1234-1234-123456789ABC");
// 橡皮擦视觉反馈控件
private DrawingVisual eraserVisual = new DrawingVisual();
private VisualCanvas eraserOverlayCanvas = null;
private Border eraserVisualBorder; // 用于显示橡皮擦视觉反馈的Border
// 兼容性属性:模拟原有的EraserOverlay_DrawingVisual
private VisualCanvas EraserOverlay_DrawingVisual => eraserOverlayCanvas;
// 兼容性保持
[Obsolete("使用 isUsingAdvancedEraser 替代")]
public bool isUsingGeometryEraser
{
get => isUsingAdvancedEraser;
set => isUsingAdvancedEraser = value;
}
[Obsolete("使用 currentEraserSize 替代")]
public double eraserWidth
{
get => currentEraserSize;
set => currentEraserSize = value;
}
[Obsolete("使用 isCurrentEraserCircle 替代")]
public bool isEraserCircleShape
{
get => isCurrentEraserCircle;
set => isCurrentEraserCircle = value;
}
[Obsolete("使用 isUsingStrokeEraser 替代")]
public bool isUsingStrokesEraser
{
get => isUsingStrokeEraser;
set => isUsingStrokeEraser = value;
}
[Obsolete("使用 eraserTransformMatrix 替代")]
private Matrix scaleMatrix
{
get => eraserTransformMatrix;
set => eraserTransformMatrix = value;
}
/// <summary>
/// 新橡皮擦覆盖层加载事件处理
/// </summary>
private void EraserOverlay_Loaded(object sender, RoutedEventArgs e) {
var border = (Border)sender;
// 初始化覆盖层
InitializeEraserOverlay(border);
Trace.WriteLine("Advanced Eraser: Overlay loaded and initialized");
}
/// <summary>
/// 开始高级橡皮擦操作
/// </summary>
private void StartAdvancedEraserOperation(object sender) {
if (isUsingAdvancedEraser) return;
// 设置操作状态
isUsingAdvancedEraser = true;
isEraserVisible = true;
// 更新橡皮擦尺寸
UpdateEraserSize();
// 获取inkCanvas引用
var inkCanvas = FindName("inkCanvas") as InkCanvas;
if (inkCanvas == null) return;
// 根据橡皮擦形状创建碰撞检测器
StylusShape eraserShape = CreateEraserShape();
advancedHitTester = inkCanvas.Strokes.GetIncrementalStrokeHitTester(eraserShape);
advancedHitTester.StrokeHit += OnAdvancedEraserStrokeHit;
// 初始化变换矩阵
InitializeEraserTransform();
}
/// <summary>
/// 创建橡皮擦形状
/// </summary>
private StylusShape CreateEraserShape()
{
if (isCurrentEraserCircle) {
return new EllipseStylusShape(currentEraserSize, currentEraserSize);
}
// 矩形橡皮擦,使用与原来相同的逻辑
return new RectangleStylusShape(currentEraserSize, currentEraserSize / 0.6);
}
/// <summary>
/// 初始化橡皮擦变换矩阵
/// </summary>
private void InitializeEraserTransform() {
eraserTransformMatrix = new Matrix();
if (isCurrentEraserCircle) {
// 圆形橡皮擦:等比例缩放
var scale = currentEraserSize / 56.0; // 基于56x56的基准尺寸
eraserTransformMatrix.ScaleAt(scale, scale, 0, 0);
} else {
// 矩形橡皮擦:保持传统比例
var scaleX = currentEraserSize / 38.0;
var scaleY = (currentEraserSize * 56 / 38) / 56.0;
eraserTransformMatrix.ScaleAt(scaleX, scaleY, 0, 0);
}
}
/// <summary>
/// 更新橡皮擦尺寸
/// </summary>
private void UpdateEraserSize() {
// 使用与原来相同的逻辑计算橡皮擦尺寸
double k = 1.0;
switch (Settings.Canvas.EraserSize) {
case 0: k = Settings.Canvas.EraserShapeType == 0 ? 0.5 : 0.7; break;
case 1: k = Settings.Canvas.EraserShapeType == 0 ? 0.8 : 0.9; break;
case 2: k = 1.0; break;
case 3: k = Settings.Canvas.EraserShapeType == 0 ? 1.25 : 1.2; break;
case 4: k = Settings.Canvas.EraserShapeType == 0 ? 1.5 : 1.3; break;
}
// 更新形状类型
isCurrentEraserCircle = (Settings.Canvas.EraserShapeType == 0);
// 根据形状类型设置尺寸
if (isCurrentEraserCircle) {
currentEraserSize = k * 90; // 圆形橡皮擦
} else {
currentEraserSize = k * 90 * 0.6; // 矩形橡皮擦宽度
}
}
/// <summary>
/// 结束高级橡皮擦操作
/// </summary>
private void EndAdvancedEraserOperation(object sender) {
if (!isUsingAdvancedEraser) return;
// 重置操作状态
isUsingAdvancedEraser = false;
isEraserVisible = false;
// 释放鼠标捕获
if (sender is Border border) {
border.ReleaseMouseCapture();
}
// 隐藏橡皮擦视觉反馈
HideEraserFeedback();
// 结束碰撞检测
if (advancedHitTester != null) {
advancedHitTester.EndHitTesting();
advancedHitTester = null;
}
// 提交橡皮擦历史记录
CommitEraserHistory();
}
/// <summary>
/// 隐藏橡皮擦视觉反馈
/// </summary>
private void HideEraserFeedback() {
try {
if (eraserVisualBorder != null) {
eraserVisualBorder.Visibility = Visibility.Collapsed;
}
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error hiding feedback - {ex.Message}");
}
}
/// <summary>
/// 提交橡皮擦历史记录
/// </summary>
private void CommitEraserHistory() {
try {
if (ReplacedStroke != null || AddedStroke != null) {
timeMachine.CommitStrokeEraseHistory(ReplacedStroke, AddedStroke);
AddedStroke = null;
ReplacedStroke = null;
}
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error committing history - {ex.Message}");
}
}
/// <summary>
/// 高级橡皮擦笔画碰撞事件处理
/// </summary>
private void OnAdvancedEraserStrokeHit(object sender, StrokeHitEventArgs args) {
try {
var inkCanvas = FindName("inkCanvas") as InkCanvas;
if (inkCanvas == null) return;
var eraseResult = args.GetPointEraseResults();
var strokeToReplace = new StrokeCollection { args.HitStroke };
// 过滤锁定的笔画
var filteredToReplace = strokeToReplace.Where(stroke => !stroke.ContainsPropertyData(IsLockGuid));
var filteredToReplaceArray = filteredToReplace as Stroke[] ?? filteredToReplace.ToArray();
if (!filteredToReplaceArray.Any()) return;
var filteredResult = eraseResult.Where(stroke => !stroke.ContainsPropertyData(IsLockGuid));
var filteredResultArray = filteredResult as Stroke[] ?? filteredResult.ToArray();
// 执行笔画替换或删除
if (filteredResultArray.Any()) {
inkCanvas.Strokes.Replace(
new StrokeCollection(filteredToReplaceArray),
new StrokeCollection(filteredResultArray)
);
} else {
inkCanvas.Strokes.Remove(new StrokeCollection(filteredToReplaceArray));
}
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error in stroke hit - {ex.Message}");
}
}
/// <summary>
/// 更新高级橡皮擦位置
/// </summary>
private void UpdateAdvancedEraserPosition(object sender, Point position) {
// 移除isUsingAdvancedEraser检查,让视觉反馈始终更新
// if (!isUsingAdvancedEraser) return;
// 性能优化:限制更新频率
var now = DateTime.Now;
if ((now - lastEraserUpdate).TotalMilliseconds < ERASER_UPDATE_INTERVAL) {
return;
}
lastEraserUpdate = now;
// 更新位置
lastEraserPosition = position;
// 更新视觉反馈(始终执行)
UpdateEraserVisualFeedback(position);
// 只有在实际使用橡皮擦时才处理擦除
if (isUsingAdvancedEraser) {
// 处理不同的橡皮擦模式
if (isUsingStrokeEraser) {
ProcessStrokeEraserAtPosition(position);
} else {
ProcessGeometryEraserAtPosition(position);
}
}
}
/// <summary>
/// 在指定位置处理笔画橡皮擦
/// </summary>
private void ProcessStrokeEraserAtPosition(Point position) {
try {
var inkCanvas = FindName("inkCanvas") as InkCanvas;
if (inkCanvas == null) return;
var hitStrokes = inkCanvas.Strokes.HitTest(position)
.Where(stroke => !stroke.ContainsPropertyData(IsLockGuid));
var strokesArray = hitStrokes as Stroke[] ?? hitStrokes.ToArray();
if (strokesArray.Any()) {
inkCanvas.Strokes.Remove(new StrokeCollection(strokesArray));
}
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error in stroke eraser - {ex.Message}");
}
}
/// <summary>
/// 在指定位置处理几何橡皮擦
/// </summary>
private void ProcessGeometryEraserAtPosition(Point position) {
try {
if (advancedHitTester != null) {
advancedHitTester.AddPoint(position);
}
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error in geometry eraser - {ex.Message}");
}
}
/// <summary>
/// 更新橡皮擦视觉反馈
/// </summary>
private void UpdateEraserVisualFeedback(Point position) {
try {
// 获取或创建橡皮擦视觉反馈Border
if (eraserVisualBorder == null) {
eraserVisualBorder = new Border {
Background = new SolidColorBrush(Colors.Transparent),
BorderBrush = new SolidColorBrush(Colors.Transparent),
BorderThickness = new Thickness(0),
IsHitTestVisible = false,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top,
Opacity = 1
};
Panel.SetZIndex(eraserVisualBorder, 1001);
// 将Border添加到InkCanvasGridForInkReplay中
var inkCanvasGrid = FindName("InkCanvasGridForInkReplay") as Grid;
if (inkCanvasGrid != null) {
inkCanvasGrid.Children.Add(eraserVisualBorder);
Trace.WriteLine("Advanced Eraser: Visual feedback border added to grid");
} else {
Trace.WriteLine("Advanced Eraser: Failed to find InkCanvasGridForInkReplay");
return; // 如果找不到Grid,直接返回
}
}
if (eraserVisualBorder != null) {
// 创建橡皮擦视觉反馈
var eraserImage = CreateEraserVisualImage();
// 清除Border的内容并添加新的图像
eraserVisualBorder.Child = eraserImage;
// 更新橡皮擦位置和大小
if (isCurrentEraserCircle) {
var radius = currentEraserSize / 2;
eraserVisualBorder.Width = currentEraserSize;
eraserVisualBorder.Height = currentEraserSize;
// 使用Margin来定位,因为Border在Grid中
eraserVisualBorder.Margin = new Thickness(
position.X - radius,
position.Y - radius,
0, 0);
} else {
// 矩形橡皮擦,使用与原来相同的逻辑
var height = currentEraserSize / 0.6;
eraserVisualBorder.Width = currentEraserSize;
eraserVisualBorder.Height = height;
// 使用Margin来定位,因为Border在Grid中
eraserVisualBorder.Margin = new Thickness(
position.X - currentEraserSize / 2,
position.Y - height / 2,
0, 0);
}
eraserVisualBorder.Visibility = Visibility.Visible;
Trace.WriteLine($"Advanced Eraser: Visual feedback updated to ({position.X:F1}, {position.Y:F1})");
}
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error updating visual feedback - {ex.Message}");
}
}
/// <summary>
/// 创建橡皮擦视觉图像
/// </summary>
private Image CreateEraserVisualImage() {
try {
// 根据橡皮擦形状选择对应的DrawingGroup资源
string resourceKey = isCurrentEraserCircle ? "EraserCircleDrawingGroup" : "EraserDrawingGroup";
// 尝试从资源字典中获取DrawingGroup
var drawingGroup = TryFindResource(resourceKey) as DrawingGroup;
if (drawingGroup == null) {
// 如果找不到资源,创建默认的橡皮擦图像
return CreateDefaultEraserImage();
}
// 创建变换后的DrawingGroup
var transformedGroup = new DrawingGroup();
transformedGroup.Children.Add(drawingGroup);
// 应用缩放变换
var transform = new ScaleTransform();
if (isCurrentEraserCircle) {
var scale = currentEraserSize / 56.0; // 基于56x56的基准尺寸
transform.ScaleX = scale;
transform.ScaleY = scale;
} else {
var scaleX = currentEraserSize / 38.0;
var scaleY = (currentEraserSize / 0.6) / 56.0;
transform.ScaleX = scaleX;
transform.ScaleY = scaleY;
}
transformedGroup.Transform = transform;
// 创建DrawingImage
var drawingImage = new DrawingImage(transformedGroup);
// 创建Image控件
var image = new Image {
Source = drawingImage,
Stretch = Stretch.None
};
RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.HighQuality);
return image;
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error creating eraser visual image - {ex.Message}");
return CreateDefaultEraserImage();
}
}
/// <summary>
/// 创建默认的橡皮擦图像(当资源不可用时)
/// </summary>
private Image CreateDefaultEraserImage() {
try {
// 创建一个简单的几何图形作为默认橡皮擦
Geometry geometry;
if (isCurrentEraserCircle) {
geometry = new EllipseGeometry(new Point(28, 28), 28, 28);
} else {
geometry = new RectangleGeometry(new Rect(0, 0, 38, 56));
}
var brush = new SolidColorBrush(Colors.LightGray);
var pen = new Pen(new SolidColorBrush(Colors.DarkGray), 1);
var geometryDrawing = new GeometryDrawing(brush, pen, geometry);
var drawingGroup = new DrawingGroup();
drawingGroup.Children.Add(geometryDrawing);
// 应用缩放变换
var transform = new ScaleTransform();
if (isCurrentEraserCircle) {
var scale = currentEraserSize / 56.0;
transform.ScaleX = scale;
transform.ScaleY = scale;
} else {
var scaleX = currentEraserSize / 38.0;
var scaleY = (currentEraserSize / 0.6) / 56.0;
transform.ScaleX = scaleX;
transform.ScaleY = scaleY;
}
drawingGroup.Transform = transform;
var drawingImage = new DrawingImage(drawingGroup);
var image = new Image {
Source = drawingImage,
Stretch = Stretch.None
};
return image;
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error creating default eraser image - {ex.Message}");
return null;
}
}
/// <summary>
/// 兼容性方法:旧版橡皮擦几何碰撞处理
/// </summary>
[Obsolete("使用 OnAdvancedEraserStrokeHit 替代")]
private void EraserGeometry_StrokeHit(object sender, StrokeHitEventArgs args) {
OnAdvancedEraserStrokeHit(sender, args);
}
/// <summary>
/// 兼容性方法:旧版橡皮擦移动处理
/// </summary>
[Obsolete("使用 UpdateAdvancedEraserPosition 替代")]
private void EraserOverlay_PointerMove(object sender, Point pt) {
UpdateAdvancedEraserPosition(sender, pt);
}
/// <summary>
/// 兼容性方法:旧版橡皮擦按下处理
/// </summary>
[Obsolete("使用 StartAdvancedEraserOperation 替代")]
private void EraserOverlay_PointerDown(object sender) {
StartAdvancedEraserOperation(sender);
}
/// <summary>
/// 兼容性方法:旧版橡皮擦抬起处理
/// </summary>
[Obsolete("使用 EndAdvancedEraserOperation 替代")]
private void EraserOverlay_PointerUp(object sender) {
EndAdvancedEraserOperation(sender);
}
/// <summary>
/// 获取当前橡皮擦状态信息(用于调试)
/// </summary>
public string GetEraserStatusInfo() {
return "Advanced Eraser Status:\n" +
$"- Active: {isUsingAdvancedEraser}\n" +
$"- Size: {currentEraserSize:F1}\n" +
$"- Shape: {(isCurrentEraserCircle ? "Circle" : "Rectangle")}\n" +
$"- Mode: {(isUsingStrokeEraser ? "Stroke" : "Geometry")}\n" +
$"- Visible: {isEraserVisible}\n" +
$"- Last Position: ({lastEraserPosition.X:F1}, {lastEraserPosition.Y:F1})";
}
/// <summary>
/// 重置橡皮擦状态
/// </summary>
public void ResetEraserState() {
isUsingAdvancedEraser = false;
isEraserVisible = false;
lastEraserPosition = new Point();
if (advancedHitTester != null) {
advancedHitTester.EndHitTesting();
advancedHitTester = null;
}
HideEraserFeedback();
// 清理视觉反馈Border
if (eraserVisualBorder != null) {
var inkCanvasGrid = FindName("InkCanvasGridForInkReplay") as Grid;
if (inkCanvasGrid != null) {
inkCanvasGrid.Children.Remove(eraserVisualBorder);
}
eraserVisualBorder = null;
}
}
/// <summary>
/// 应用高级橡皮擦形状到InkCanvas
/// </summary>
public void ApplyAdvancedEraserShape() {
try {
var inkCanvas = FindName("inkCanvas") as InkCanvas;
if (inkCanvas == null) return;
// 更新橡皮擦尺寸和形状
UpdateEraserSize();
// 创建橡皮擦形状
StylusShape eraserShape = CreateEraserShape();
// 应用到InkCanvas
inkCanvas.EraserShape = eraserShape;
Trace.WriteLine($"Advanced Eraser: Applied shape - Size: {currentEraserSize}, Circle: {isCurrentEraserCircle}");
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error applying shape - {ex.Message}");
// 回退到传统方法
try {
ApplyCurrentEraserShape();
} catch (Exception fallbackEx) {
Trace.WriteLine($"Advanced Eraser: Fallback also failed - {fallbackEx.Message}");
}
}
}
/// <summary>
/// 启用高级橡皮擦系统
/// </summary>
public void EnableAdvancedEraserSystem() {
try {
// 获取橡皮擦覆盖层
var eraserOverlay = FindName("AdvancedEraserOverlay") as Border;
if (eraserOverlay != null) {
// 启用覆盖层的交互
eraserOverlay.IsHitTestVisible = true;
// 确保覆盖层在橡皮擦模式下启用
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
eraserOverlay.IsHitTestVisible = true;
Trace.WriteLine("Advanced Eraser: Overlay enabled for eraser mode");
}
// 设置覆盖层的大小以覆盖整个InkCanvas
var inkCanvasControl = FindName("inkCanvas") as InkCanvas;
if (inkCanvasControl != null) {
eraserOverlay.Width = inkCanvasControl.ActualWidth;
eraserOverlay.Height = inkCanvasControl.ActualHeight;
Trace.WriteLine($"Advanced Eraser: Overlay size set to {eraserOverlay.Width}x{eraserOverlay.Height}");
}
Trace.WriteLine("Advanced Eraser: System enabled successfully");
} else {
Trace.WriteLine("Advanced Eraser: Failed to find eraser overlay");
}
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error enabling system - {ex.Message}");
}
}
/// <summary>
/// 初始化橡皮擦覆盖层
/// </summary>
private void InitializeEraserOverlay(Border overlay) {
try {
// 设置覆盖层的基本属性
overlay.Background = new SolidColorBrush(Colors.Transparent);
overlay.IsHitTestVisible = false; // 默认禁用,只在橡皮擦模式下启用
// 绑定事件处理
overlay.MouseDown += (sender, e) => {
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
overlay.CaptureMouse();
StartAdvancedEraserOperation(sender);
}
};
overlay.MouseUp += (sender, e) => {
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
overlay.ReleaseMouseCapture();
EndAdvancedEraserOperation(sender);
}
};
overlay.MouseMove += (sender, e) => {
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
var position = e.GetPosition((UIElement)FindName("inkCanvas"));
Trace.WriteLine($"Advanced Eraser: Mouse move event triggered at ({position.X:F1}, {position.Y:F1})");
UpdateAdvancedEraserPosition(sender, position);
} else {
Trace.WriteLine($"Advanced Eraser: Mouse move ignored - not in eraser mode, current mode: {inkCanvas.EditingMode}");
}
};
// 触控笔事件
overlay.StylusDown += (sender, e) => {
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
e.Handled = true;
if (e.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) {
overlay.CaptureStylus();
}
StartAdvancedEraserOperation(sender);
}
};
overlay.StylusUp += (sender, e) => {
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
e.Handled = true;
if (e.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) {
overlay.ReleaseStylusCapture();
}
EndAdvancedEraserOperation(sender);
}
};
overlay.StylusMove += (sender, e) => {
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
e.Handled = true;
var position = e.GetPosition((UIElement)FindName("inkCanvas"));
UpdateAdvancedEraserPosition(sender, position);
Trace.WriteLine($"Advanced Eraser: Stylus move at ({position.X:F1}, {position.Y:F1})");
}
};
Trace.WriteLine("Advanced Eraser: Overlay initialized successfully");
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error initializing overlay - {ex.Message}");
}
}
/// <summary>
/// 禁用高级橡皮擦系统
/// </summary>
public void DisableAdvancedEraserSystem() {
try {
// 重置橡皮擦状态
ResetEraserState();
// 获取橡皮擦覆盖层并禁用
var eraserOverlay = FindName("AdvancedEraserOverlay") as Border;
if (eraserOverlay != null) {
eraserOverlay.IsHitTestVisible = false;
}
// 确保视觉反馈被隐藏
HideEraserFeedback();
Trace.WriteLine("Advanced Eraser: System disabled successfully");
} catch (Exception ex) {
Trace.WriteLine($"Advanced Eraser: Error disabling system - {ex.Message}");
}
}
/// <summary>
/// 切换橡皮擦形状(圆形/矩形)
/// </summary>
public void ToggleEraserShape() {
isCurrentEraserCircle = !isCurrentEraserCircle;
// 更新设置
Settings.Canvas.EraserShapeType = isCurrentEraserCircle ? 0 : 1;
// 应用新形状
ApplyAdvancedEraserShape();
Trace.WriteLine($"Advanced Eraser: Toggled to {(isCurrentEraserCircle ? "Circle" : "Rectangle")}");
}
}
}
-39
View File
@@ -1,39 +0,0 @@
namespace Ink_Canvas {
public static class XamlGraphicsIconGeometries {
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 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";
public static string SolidPenIcon =
"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";
public static string LinedEraserStrokeIcon =
"F1 M24,24z M0,0z M19.0625,7.99501C19.2863,7.99501 19.4861,8.06695 19.662,8.21083 19.8538,8.35471 19.9897,8.53856 20.0696,8.76237 20.4054,9.94539 20.7011,11.2563 20.9569,12.6951 21.1967,14.0859 21.3646,15.4368 21.4605,16.7477L21.4845,17.2993C21.5005,17.5551 21.5084,17.9068 21.5084,18.3544 21.5084,19.2017 21.2926,19.8412 20.861,20.2728 20.4453,20.7044 19.7099,21.0482 18.6548,21.3039 18.3191,21.3679 17.7836,20.4327 17.0482,18.4983 16.5845,20.8643 16.1129,22.0313 15.6333,21.9994 13.9227,21.9674 12.468,21.8954 11.269,21.7835L10.8134,21.7356C9.83817,21.6077 8.86297,21.4398 7.88778,21.232 7.1524,21.0721 6.32109,20.8563 5.39386,20.5845 4.61051,20.3447 3.97904,20.089 3.49944,19.8172 3.01984,19.5454 2.70809,19.2337 2.56421,18.882 2.40434,18.4823 2.50827,18.0746 2.87596,17.659L3.09176,17.3952 3.18769,17.2273 3.23565,17.1074 3.37954,16.8197 3.47544,16.5559 3.6433,15.9324 3.73923,15.6207 3.85912,15.1411 4.17088,13.5824 4.57853,11.1844 4.98621,9.05013C5.03417,8.79435 5.16203,8.55455 5.36986,8.33073 5.59367,8.10692 5.8255,7.99501 6.0653,7.99501L19.0625,7.99501z M14.4823,2C14.7861,2 15.0418,2.08793 15.2496,2.26378 15.4575,2.43963 15.5614,2.64746 15.5614,2.88726L15.5614,4.99751 19.0625,4.99751C19.3343,4.99751 19.5661,5.10142 19.7579,5.30925 19.9498,5.50109 20.0457,5.73289 20.0457,6.00467 20.0457,6.27644 19.9498,6.51624 19.7579,6.72407 19.5661,6.91591 19.3343,7.01183 19.0625,7.01183L6.0653,7.01183C5.79352,7.01183 5.55372,6.91591 5.34589,6.72407 5.15405,6.51624 5.05814,6.27644 5.05814,6.00467 5.05814,5.73289 5.15405,5.50109 5.34589,5.30925 5.55372,5.10142 5.79352,4.99751 6.0653,4.99751L9.56638,4.99751 9.56638,2.88726C9.56638,2.66345 9.65432,2.47161 9.83017,2.31174 10.022,2.15187 10.2538,2.05595 10.5256,2.02398L10.6455,2 14.4823,2z";
public static string SolidEraserStrokeIcon =
"F1 M24,24z M0,0z M19.0625,7.99501C19.2863,7.99501 19.4861,8.06695 19.662,8.21083 19.8538,8.35471 19.9897,8.53856 20.0696,8.76237 20.4054,9.94539 20.7011,11.2563 20.9569,12.6951 21.1967,14.0859 21.3646,15.4368 21.4605,16.7477L21.4845,17.2993C21.5005,17.5551 21.5084,17.9068 21.5084,18.3544 21.5084,19.2017 21.2926,19.8412 20.861,20.2728 20.4453,20.7044 19.7099,21.0482 18.6548,21.3039 18.3191,21.3679 17.7836,20.4327 17.0482,18.4983 16.5845,20.8643 16.1129,22.0313 15.6333,21.9994 13.9227,21.9674 12.468,21.8954 11.269,21.7835L10.8134,21.7356C9.83817,21.6077 8.86297,21.4398 7.88778,21.232 7.1524,21.0721 6.32109,20.8563 5.39386,20.5845 4.61051,20.3447 3.97904,20.089 3.49944,19.8172 3.01984,19.5454 2.70809,19.2337 2.56421,18.882 2.40434,18.4823 2.50827,18.0746 2.87596,17.659L3.09176,17.3952 3.18769,17.2273 3.23565,17.1074 3.37954,16.8197 3.47544,16.5559 3.6433,15.9324 3.73923,15.6207 3.85912,15.1411 4.17088,13.5824 4.57853,11.1844 4.98621,9.05013C5.03417,8.79435 5.16203,8.55455 5.36986,8.33073 5.59367,8.10692 5.8255,7.99501 6.0653,7.99501L19.0625,7.99501z M14.4823,2C14.7861,2 15.0418,2.08793 15.2496,2.26378 15.4575,2.43963 15.5614,2.64746 15.5614,2.88726L15.5614,4.99751 19.0625,4.99751C19.3343,4.99751 19.5661,5.10142 19.7579,5.30925 19.9498,5.50109 20.0457,5.73289 20.0457,6.00467 20.0457,6.27644 19.9498,6.51624 19.7579,6.72407 19.5661,6.91591 19.3343,7.01183 19.0625,7.01183L6.0653,7.01183C5.79352,7.01183 5.55372,6.91591 5.34589,6.72407 5.15405,6.51624 5.05814,6.27644 5.05814,6.00467 5.05814,5.73289 5.15405,5.50109 5.34589,5.30925 5.55372,5.10142 5.79352,4.99751 6.0653,4.99751L9.56638,4.99751 9.56638,2.88726C9.56638,2.66345 9.65432,2.47161 9.83017,2.31174 10.022,2.15187 10.2538,2.05595 10.5256,2.02398L10.6455,2 14.4823,2z";
public static string LinedEraserCircleIcon =
"F1 M24,24z M0,0z M15.0665,2.29557L21.6921,8.92118C21.8892,9.11823 21.9877,9.36453 21.9877,9.6601 21.9877,9.93924 21.8892,10.1773 21.6921,10.3744L10.3621,21.6798C10.165,21.8933 9.92694,22 9.6478,22 9.36865,22 9.12235,21.8933 8.90888,21.6798L2.30789,15.0788C2.11085,14.8654 2.01233,14.619 2.01233,14.3399 2.01233,14.0608 2.11085,13.8227 2.30789,13.6256L13.6133,2.29557C13.8103,2.09852 14.0485,2 14.3276,2 14.6232,2 14.8695,2.09852 15.0665,2.29557z M8.19458,11.5813C8.09606,11.4828 7.97292,11.4335 7.82514,11.4335 7.69377,11.4335 7.57883,11.4828 7.48031,11.5813L5.28818,13.7734C5.18965,13.8719 5.14041,13.9951 5.14041,14.1429 5.14041,14.2906 5.18965,14.4138 5.28818,14.5123L9.47539,18.6995C9.59033,18.8144 9.71347,18.8719 9.84483,18.8719 9.99261,18.8719 10.1158,18.8144 10.2143,18.6995L12.4064,16.5074C12.5049,16.4089 12.5542,16.2939 12.5542,16.1626 12.5542,16.0148 12.5049,15.8916 12.4064,15.7931L8.19458,11.5813z";
public static string SolidEraserCircleIcon =
"F1 M24,24z M0,0z M15.0665,2.29557L21.6921,8.92118C21.8892,9.11823 21.9877,9.36453 21.9877,9.6601 21.9877,9.93924 21.8892,10.1773 21.6921,10.3744L10.3621,21.6798C10.165,21.8933 9.92694,22 9.6478,22 9.36865,22 9.12235,21.8933 8.90888,21.6798L2.30789,15.0788C2.11085,14.8654 2.01233,14.619 2.01233,14.3399 2.01233,14.0608 2.11085,13.8227 2.30789,13.6256L13.6133,2.29557C13.8103,2.09852 14.0485,2 14.3276,2 14.6232,2 14.8695,2.09852 15.0665,2.29557z M8.19458,11.5813C8.09606,11.4828 7.97292,11.4335 7.82514,11.4335 7.69377,11.4335 7.57883,11.4828 7.48031,11.5813L5.28818,13.7734C5.18965,13.8719 5.14041,13.9951 5.14041,14.1429 5.14041,14.2906 5.18965,14.4138 5.28818,14.5123L9.47539,18.6995C9.59033,18.8144 9.71347,18.8719 9.84483,18.8719 9.99261,18.8719 10.1158,18.8144 10.2143,18.6995L12.4064,16.5074C12.5049,16.4089 12.5542,16.2939 12.5542,16.1626 12.5542,16.0148 12.5049,15.8916 12.4064,15.7931L8.19458,11.5813z";
public static string LinedLassoSelectIcon =
"F0 M24,24z M0,0z M21.1749,3.19033C21.2959,3.31432,21.3512,3.45083,21.3512,3.62667L21.3512,15.7344 18.9141,14.0608 18.9141,5.43716 5.30084,5.43716 5.30084,19.0505 14.7641,19.0505 15.0947,21.4876 3.49029,21.4876C3.31451,21.4876 3.178,21.4323 3.05397,21.3113 2.92046,21.1636 2.86368,21.0107 2.86368,20.8334L2.86368,3.62667C2.86368,3.44751 2.92108,3.30918 3.04695,3.18331 3.17285,3.0574 3.31118,3 3.49029,3L20.697,3C20.8743,3,21.0272,3.0568,21.1749,3.19033z M15.042,13.7475L16.02,20.0637C16.0562,20.2901,16.1015,20.6026,16.1559,21.001L16.3052,21.9247C16.3234,22.0424 16.3686,22.1239 16.4411,22.1692 16.5226,22.2144 16.6086,22.2235 16.6992,22.1963 16.7897,22.1601 16.8667,22.0877 16.9301,21.979L18.2205,19.7242 20.421,22.8755C20.4663,22.9389 20.5251,22.9796 20.5976,22.9978 20.6791,23.0068 20.7515,22.9887 20.8149,22.9434L21.7522,22.2914C21.8156,22.2461 21.8518,22.1873 21.8609,22.1148 21.879,22.0333 21.8654,21.9609 21.8201,21.8975L19.7555,18.9499 22.7981,18.9499C22.9249,18.9499 23.0154,18.9137 23.0698,18.8412 23.1332,18.7597 23.1512,18.6692 23.1241,18.5696 23.0969,18.47 23.0336,18.3839 22.934,18.3115 22.0556,17.7048 20.8693,16.8898 19.3751,15.8665 17.7542,14.7708 16.509,13.9377 15.6396,13.3672 15.531,13.2947 15.4224,13.2585 15.3137,13.2585 15.205,13.2585 15.1235,13.2992 15.0692,13.3807 15.0149,13.4622 15.0058,13.5845 15.042,13.7475z";
public static string SolidLassoSelectIcon =
"F0 M24,24z M0,0z M21.1749,3.19033C21.2959,3.31432,21.3512,3.45083,21.3512,3.62667L21.3512,15.7344 18.9141,14.0608 18.9141,5.43716 5.30084,5.43716 5.30084,19.0505 14.7641,19.0505 15.0947,21.4876 3.49029,21.4876C3.31451,21.4876 3.178,21.4323 3.05397,21.3113 2.92046,21.1636 2.86368,21.0107 2.86368,20.8334L2.86368,3.62667C2.86368,3.44751 2.92108,3.30918 3.04695,3.18331 3.17285,3.0574 3.31118,3 3.49029,3L20.697,3C20.8743,3,21.0272,3.0568,21.1749,3.19033z M15.042,13.7475L16.02,20.0637C16.0562,20.2901,16.1015,20.6026,16.1559,21.001L16.3052,21.9247C16.3234,22.0424 16.3686,22.1239 16.4411,22.1692 16.5226,22.2144 16.6086,22.2235 16.6992,22.1963 16.7897,22.1601 16.8667,22.0877 16.9301,21.979L18.2205,19.7242 20.421,22.8755C20.4663,22.9389 20.5251,22.9796 20.5976,22.9978 20.6791,23.0068 20.7515,22.9887 20.8149,22.9434L21.7522,22.2914C21.8156,22.2461 21.8518,22.1873 21.8609,22.1148 21.879,22.0333 21.8654,21.9609 21.8201,21.8975L19.7555,18.9499 22.7981,18.9499C22.9249,18.9499 23.0154,18.9137 23.0698,18.8412 23.1332,18.7597 23.1512,18.6692 23.1241,18.5696 23.0969,18.47 23.0336,18.3839 22.934,18.3115 22.0556,17.7048 20.8693,16.8898 19.3751,15.8665 17.7542,14.7708 16.509,13.9377 15.6396,13.3672 15.531,13.2947 15.4224,13.2585 15.3137,13.2585 15.205,13.2585 15.1235,13.2992 15.0692,13.3807 15.0149,13.4622 15.0058,13.5845 15.042,13.7475z";
public static string DisabledGestureIcon =
"F0 M24,24z M0,0z M7.82154,10.0753L7.82154,3.74613C7.82154,3.06603 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.35737,17.6675 7.23419,15.7096 5.31756,12.2988 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 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 M18.2806,5.20935L19.1565,5.75549 20.259,4.01404 19.3831,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";
public static string EnabledGestureIcon =
"F1 M24,24z M0,0z M7.29844,9.85586L7.29844,3.52668C7.29844,2.84658 7.56636,2.1871 8.05067,1.70279 8.53498,1.21848 9.18416,0.950562 9.87456,0.950562 10.565,0.950562 11.2141,1.21848 11.6984,1.70279 12.1828,2.1871 12.4507,2.83628 12.4507,3.52668L12.4507,6.15363C12.6184,6.12002 12.7908,6.10279 12.9659,6.10279 13.6563,6.10279 14.3055,6.37071 14.7898,6.85502 14.9253,6.99055 15.0439,7.139 15.1444,7.29765 15.432,7.18971 15.7403,7.13324 16.0572,7.13324 16.7476,7.13324 17.3968,7.40116 17.8811,7.88547 18.023,8.02738 18.1464,8.18344 18.2498,8.35055 19.1625,8.04393 20.2443,8.23925 20.9416,8.93654 21.4259,9.42085 21.6938,10.0803 21.6938,10.7604L21.6938,14.2958C21.1174,13.741,20.4192,13.3118,19.6432,13.0524L19.6432,10.7604C19.6432,10.6265 19.5917,10.4925 19.4886,10.3998 19.2928,10.204 18.9528,10.204 18.757,10.3998 18.7035,10.4532 18.6603,10.5204 18.6334,10.5934L18.6334,11.255C18.6334,11.8218 18.1697,12.2855 17.6029,12.2855 17.0362,12.2855 16.5725,11.8218 16.5725,11.255L16.5725,11.0106C16.5523,10.9304 16.5415,10.8466 16.5415,10.7604 16.5415,10.6283 16.5521,10.4969 16.5725,10.3674L16.5725,9.70936C16.5725,9.5754 16.5209,9.44144 16.4179,9.3487 16.3252,9.25596 16.1912,9.19413 16.0572,9.19413 15.9233,9.19413 15.7893,9.24566 15.6966,9.3487 15.6038,9.44144 15.542,9.5754 15.542,9.70936L15.542,11.255C15.542,11.8218 15.0783,12.2855 14.5116,12.2855 13.9448,12.2855 13.4811,11.8218 13.4811,11.255L13.4811,8.67891C13.4811,8.54495 13.4296,8.41099 13.3266,8.31825 13.2338,8.22551 13.0999,8.16369 12.9659,8.16369 12.8319,8.16369 12.698,8.21521 12.6052,8.31825 12.5125,8.41099 12.4507,8.54495 12.4507,8.67891L12.4507,11.255C12.4507,11.8218 11.987,12.2855 11.4202,12.2855 10.8535,12.2855 10.3898,11.8218 10.3898,11.255L10.3898,3.52668C10.3898,3.39272 10.3383,3.25876 10.2352,3.16602 10.1425,3.07328 10.0085,3.01145 9.87456,3.01145 9.7406,3.01145 9.60664,3.06298 9.5139,3.16602 9.42116,3.25876 9.35933,3.39272 9.35933,3.52668L9.35933,12.2855C9.35933,12.6034 9.21341,12.8889 8.98523,13.0783 8.58114,13.4285 7.97109,13.4115 7.58697,13.0274L6.07221,11.5127C5.92795,11.3684 5.74247,11.286 5.54668,11.255 5.3509,11.2344 5.14481,11.2756 4.97994,11.3787 4.86659,11.4508 4.78415,11.5539 4.74293,11.6878 4.71202,11.8218 4.72232,11.9557 4.79446,12.0794 6.71109,15.4902 7.83427,17.448 8.14341,17.922L8.3495,18.2312C8.8132,18.9422 9.46238,19.5295 10.2043,19.9314 10.9565,20.3333 11.7912,20.5497 12.6362,20.5497L12.9829,20.5497C13.3696,21.3681 13.9542,22.0748 14.6748,22.608 14.6102,22.6097 14.5455,22.6106 14.4807,22.6106L12.6258,22.6106 12.6568,22.59 12.3167,22.59C11.2451,22.5384 10.1837,22.2499 9.23568,21.7347 8.18463,21.1679 7.28814,20.3436 6.62865,19.3544L6.42256,19.0452C6.08251,18.53 4.96963,16.5824 3.00148,13.0892 2.67174,12.5019 2.579,11.8218 2.75417,11.1623 2.92935,10.5131 3.34153,9.95668 3.91858,9.61663 4.48532,9.27658 5.14481,9.13232 5.79399,9.21476 6.34238,9.28439 6.86871,9.50845 7.29844,9.85586z M2.47595,6.0925L1.26003,4.43348 2.09469,3.82551C2.93965,3.20725,3.85675,2.67141,4.81507,2.24893L5.75277,1.82645 6.59774,3.71216 5.66003,4.13465C4.83567,4.50561,4.04223,4.959,3.31061,5.49484L2.47595,6.1028 2.47595,6.0925z M17.7575,4.9899L18.6334,5.53604 19.7359,3.79458 18.86,3.24845C17.5926,2.455,16.2221,1.85734,14.7795,1.46577L13.7799,1.19786 13.2441,3.18662 14.2436,3.45454C15.4802,3.78428,16.6652,4.2995,17.7575,4.9899z";
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";
}
}
@@ -1,35 +0,0 @@
using System;
using System.Linq;
using System.Threading;
using System.Windows;
using Ink_Canvas.Helpers;
namespace Ink_Canvas {
public partial class MainWindow : Window {
private int lastNotificationShowTime;
private int notificationShowTime = 2500;
public static void ShowNewMessage(string notice, bool isShowImmediately = true) {
(Application.Current?.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow)
?.ShowNotification(notice, isShowImmediately);
}
public void ShowNotification(string notice, bool isShowImmediately = true) {
try {
lastNotificationShowTime = Environment.TickCount;
TextBlockNotice.Text = notice;
AnimationsHelper.ShowWithSlideFromBottomAndFade(GridNotifications);
new Thread(() => {
Thread.Sleep(notificationShowTime + 300);
if (Environment.TickCount - lastNotificationShowTime >= notificationShowTime)
Application.Current.Dispatcher.Invoke(() => {
AnimationsHelper.HideWithSlideAndFade(GridNotifications);
});
}).Start();
}
catch { }
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,635 +0,0 @@
using Ink_Canvas.Helpers;
using System;
using System.IO;
using System.Windows;
using System.Windows.Ink;
using System.Windows.Input;
using File = System.IO.File;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
using System.Collections.Generic;
using System.Windows.Controls;
using Newtonsoft.Json;
namespace Ink_Canvas {
// 1. 定义元素信息结构
public class CanvasElementInfo
{
public string Type { get; set; } // "Image"
public string SourcePath { get; set; }
public double Left { get; set; }
public double Top { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public string Stretch { get; set; } = "Fill"; // 默认为Fill
}
public partial class MainWindow : Window {
private void SymbolIconSaveStrokes_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender || inkCanvas.Visibility != Visibility.Visible) return;
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
GridNotifications.Visibility = Visibility.Collapsed;
SaveInkCanvasStrokes(true, true);
}
private void SaveInkCanvasStrokes(bool newNotice = true, bool saveByUser = false) {
try {
var savePath = Settings.Automation.AutoSavedStrokesLocation
+ (saveByUser ? @"\User Saved - " : @"\Auto Saved - ")
+ (currentMode == 0 ? "Annotation Strokes" : "BlackBoard Strokes");
if (!Directory.Exists(savePath)) Directory.CreateDirectory(savePath);
string savePathWithName;
if (currentMode != 0) // 黑板模式下
savePathWithName = savePath + @"\" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss-fff") + " Page-" +
CurrentWhiteboardIndex + " StrokesCount-" + inkCanvas.Strokes.Count + ".icstk";
else
//savePathWithName = savePath + @"\" + DateTime.Now.ToString("u").Replace(':', '-') + ".icstk";
savePathWithName = savePath + @"\" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss-fff") + ".icstk";
if (Settings.Automation.IsSaveFullPageStrokes)
{
// 全页面保存模式 - 检查是否存在多页面墨迹
bool hasMultiplePages = false;
List<StrokeCollection> allPageStrokes = new List<StrokeCollection>();
// 检查PPT放映模式下的多页面墨迹
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible && _pptManager?.IsConnected == true)
{
hasMultiplePages = true;
// 收集PPT放映模式下的所有页面墨迹
var totalSlides = _pptManager.SlidesCount;
var currentSlide = _pptManager.GetCurrentSlideNumber();
for (int i = 1; i <= totalSlides; i++)
{
var slideStrokes = _pptInkManager?.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)
{
// 多页面墨迹保存为压缩包
string zipFileName = Path.ChangeExtension(savePathWithName, "zip");
SaveMultiPageStrokesAsZip(allPageStrokes, zipFileName, newNotice);
}
else
{
// 单页面墨迹保存为图像
SaveSinglePageStrokesAsImage(savePathWithName, newNotice);
}
}
else
{
// 常规保存模式 - 仅保存墨迹对象
var fs = new FileStream(savePathWithName, FileMode.Create);
inkCanvas.Strokes.Save(fs);
fs.Close();
// 保存元素信息
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(savePathWithName, ".elements.json"), JsonConvert.SerializeObject(elementInfos, Formatting.Indented));
if (newNotice) ShowNotification("墨迹成功保存至 " + savePathWithName);
}
}
catch (Exception ex) {
ShowNotification("墨迹保存失败");
LogHelper.WriteLogToFile("墨迹保存失败 | " + ex.ToString(), LogHelper.LogType.Error);
}
}
/// <summary>
/// 将多页面墨迹保存为压缩包
/// </summary>
private void SaveMultiPageStrokesAsZip(List<StrokeCollection> allPageStrokes, string zipFileName, bool newNotice)
{
try
{
// 创建临时目录来存放文件
string tempDir = Path.Combine(Path.GetTempPath(), $"InkCanvas_MultiPage_{DateTime.Now:yyyyMMdd_HHmmss}");
Directory.CreateDirectory(tempDir);
try
{
// 保存所有页面的文件到临时目录
for (int i = 0; i < allPageStrokes.Count; i++)
{
var strokes = allPageStrokes[i];
if (strokes.Count > 0)
{
// 保存墨迹文件
string strokeFileName = Path.Combine(tempDir, $"page_{i + 1:D4}.icstk");
using (var fs = new FileStream(strokeFileName, FileMode.Create))
{
strokes.Save(fs);
}
// 保存页面图像
string imageFileName = Path.Combine(tempDir, $"page_{i + 1:D4}.png");
using (var fs = new FileStream(imageFileName, FileMode.Create))
{
SavePageAsImage(strokes, fs);
}
}
}
// 保存元数据信息
string metadataFile = Path.Combine(tempDir, "metadata.txt");
using (var writer = new StreamWriter(metadataFile, false, System.Text.Encoding.UTF8))
{
writer.WriteLine($"保存时间: {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
writer.WriteLine($"总页数: {allPageStrokes.Count}");
writer.WriteLine($"模式: {(currentMode == 0 ? "PPT放映" : "")}");
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} 条墨迹");
}
}
// 使用.NET Framework内置的压缩功能创建ZIP文件
if (File.Exists(zipFileName))
File.Delete(zipFileName);
// 使用System.IO.Compression.FileSystem来创建ZIP
System.IO.Compression.ZipFile.CreateFromDirectory(tempDir, zipFileName);
if (newNotice) ShowNotification($"多页面墨迹成功保存至压缩包 {zipFileName}");
}
finally
{
// 清理临时目录
try
{
if (Directory.Exists(tempDir))
Directory.Delete(tempDir, true);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"清理临时目录失败: {ex.ToString()}", LogHelper.LogType.Warning);
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存多页面墨迹压缩包失败: {ex.ToString()}", LogHelper.LogType.Error);
throw;
}
}
/// <summary>
/// 将单页面墨迹保存为图像
/// </summary>
private void SaveSinglePageStrokesAsImage(string savePathWithName, bool newNotice)
{
// 全页面保存模式 - 保存整个墨迹页面的图像
var bitmap = new System.Drawing.Bitmap(
(int)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
(int)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
using (var g = System.Drawing.Graphics.FromImage(bitmap))
{
// 创建黑色或透明背景
System.Drawing.Color bgColor = Settings.Canvas.UsingWhiteboard
? System.Drawing.Color.White
: System.Drawing.Color.FromArgb(22, 41, 36); // 黑板背景色
g.Clear(bgColor);
// 将InkCanvas墨迹渲染到Visual
var visual = new DrawingVisual();
using (var dc = visual.RenderOpen())
{
// 创建一个VisualBrush,使用inkCanvas作为源
var visualBrush = new VisualBrush(inkCanvas);
// 绘制矩形并填充为inkCanvas的内容
dc.DrawRectangle(visualBrush, null, new Rect(0, 0, inkCanvas.ActualWidth, inkCanvas.ActualHeight));
}
// 创建适合墨迹画布尺寸的渲染位图
var rtb = new RenderTargetBitmap(
(int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight,
96, 96,
PixelFormats.Pbgra32);
rtb.Render(visual);
// 转换为GDI+ Bitmap并保存
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(rtb));
using (var ms = new MemoryStream())
{
encoder.Save(ms);
ms.Seek(0, SeekOrigin.Begin);
var imgBitmap = new System.Drawing.Bitmap(ms);
// 将生成的墨迹图像绘制到屏幕截图上
// 居中绘制,确保墨迹位于屏幕中央
int x = (bitmap.Width - imgBitmap.Width) / 2;
int y = (bitmap.Height - imgBitmap.Height) / 2;
g.DrawImage(imgBitmap, x, y);
// 保存为PNG
string imagePathWithName = Path.ChangeExtension(savePathWithName, "png");
bitmap.Save(imagePathWithName, System.Drawing.Imaging.ImageFormat.Png);
// 仍然保存墨迹文件以兼容旧版本
var fs = new FileStream(savePathWithName, FileMode.Create);
inkCanvas.Strokes.Save(fs);
fs.Close();
}
}
// 显示提示
if (newNotice) ShowNotification("墨迹成功全页面保存至 " + Path.ChangeExtension(savePathWithName, "png"));
}
/// <summary>
/// 将指定墨迹集合保存为图像到指定流
/// </summary>
private void SavePageAsImage(StrokeCollection strokes, Stream outputStream)
{
try
{
// 创建临时InkCanvas来渲染墨迹
var tempCanvas = new InkCanvas();
tempCanvas.Strokes = strokes;
tempCanvas.Width = inkCanvas.ActualWidth;
tempCanvas.Height = inkCanvas.ActualHeight;
// 创建渲染位图
var rtb = new RenderTargetBitmap(
(int)tempCanvas.Width, (int)tempCanvas.Height,
96, 96,
PixelFormats.Pbgra32);
rtb.Render(tempCanvas);
// 保存为PNG
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(rtb));
encoder.Save(outputStream);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"保存页面图像失败: {ex.ToString()}", LogHelper.LogType.Error);
throw;
}
}
private void SymbolIconOpenStrokes_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
var openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = Settings.Automation.AutoSavedStrokesLocation;
openFileDialog.Title = "打开墨迹文件";
openFileDialog.Filter = "Ink Canvas Strokes File (*.icstk)|*.icstk|ICC压缩包 (*.zip)|*.zip";
if (openFileDialog.ShowDialog() != true) return;
LogHelper.WriteLogToFile($"Strokes Insert: Name: {openFileDialog.FileName}",
LogHelper.LogType.Event);
try {
string fileExtension = Path.GetExtension(openFileDialog.FileName).ToLower();
if (fileExtension == ".zip") {
// 处理ICC压缩包
OpenICCZipFile(openFileDialog.FileName);
} else {
// 处理单个墨迹文件
OpenSingleStrokeFile(openFileDialog.FileName);
}
if (inkCanvas.Visibility != Visibility.Visible) SymbolIconCursor_Click(sender, null);
}
catch (Exception ex) {
ShowNotification("墨迹打开失败");
LogHelper.WriteLogToFile($"墨迹打开失败: {ex.ToString()}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 打开ICC创建的.zip压缩包
/// </summary>
private void OpenICCZipFile(string zipFilePath) {
try {
// 创建临时目录来解压文件
string tempDir = Path.Combine(Path.GetTempPath(), $"InkCanvas_Open_{DateTime.Now:yyyyMMdd_HHmmss}");
Directory.CreateDirectory(tempDir);
try {
// 解压ZIP文件
System.IO.Compression.ZipFile.ExtractToDirectory(zipFilePath, tempDir);
// 读取元数据文件
string metadataFile = Path.Combine(tempDir, "metadata.txt");
if (!File.Exists(metadataFile)) {
throw new Exception("压缩包中未找到元数据文件");
}
var metadata = ReadMetadataFile(metadataFile);
// 根据元数据信息决定恢复模式
bool isPPTMode = metadata.ContainsKey("模式") && metadata["模式"].Contains("PPT放映");
bool isWhiteboardMode = metadata.ContainsKey("模式") && metadata["模式"].Contains("白板");
// 检查当前是否处于PPT模式
bool isCurrentlyInPPTMode = BtnPPTSlideShowEnd.Visibility == Visibility.Visible && pptApplication != null;
// 检查当前是否处于白板模式
bool isCurrentlyInWhiteboardMode = currentMode != 0;
// 严格模式隔离:只在对应模式下恢复对应墨迹
if (isPPTMode && isCurrentlyInPPTMode) {
// 只在PPT放映模式下恢复PPT墨迹
RestorePPTStrokesFromZip(tempDir, metadata);
} else if (isWhiteboardMode && isCurrentlyInWhiteboardMode) {
// 只在白板模式下恢复白板墨迹
RestoreWhiteboardStrokesFromZip(tempDir, metadata);
} else {
// 模式不匹配时,显示提示信息
string savedMode = isPPTMode ? "PPT放映" : (isWhiteboardMode ? "白板" : "未知");
string currentMode = isCurrentlyInPPTMode ? "PPT放映" : (isCurrentlyInWhiteboardMode ? "白板" : "桌面");
ShowNotification($"墨迹保存模式({savedMode})与当前模式({currentMode})不匹配,无法恢复墨迹");
LogHelper.WriteLogToFile($"模式不匹配:保存模式={savedMode},当前模式={currentMode}", LogHelper.LogType.Warning);
}
ShowNotification($"成功打开ICC压缩包,共{(metadata.ContainsKey("") ? metadata[""] : "0")}页");
}
finally {
// 清理临时目录
try {
if (Directory.Exists(tempDir))
Directory.Delete(tempDir, true);
}
catch (Exception ex) {
LogHelper.WriteLogToFile($"清理临时目录失败: {ex.ToString()}", LogHelper.LogType.Warning);
}
}
}
catch (Exception ex) {
LogHelper.WriteLogToFile($"打开ICC压缩包失败: {ex.ToString()}", LogHelper.LogType.Error);
throw;
}
}
/// <summary>
/// 读取元数据文件
/// </summary>
private Dictionary<string, string> ReadMetadataFile(string metadataPath) {
var metadata = new Dictionary<string, string>();
using (var reader = new StreamReader(metadataPath, System.Text.Encoding.UTF8)) {
string line;
while ((line = reader.ReadLine()) != null) {
if (line.Contains(":")) {
var parts = line.Split(new[] { ':' }, 2);
if (parts.Length == 2) {
metadata[parts[0].Trim()] = parts[1].Trim();
}
}
}
}
return metadata;
}
/// <summary>
/// 从ZIP文件恢复PPT墨迹
/// </summary>
private void RestorePPTStrokesFromZip(string tempDir, Dictionary<string, string> metadata) {
try {
// 确保当前处于PPT放映模式
if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible || pptApplication == null) {
throw new InvalidOperationException("当前不在PPT放映模式,无法恢复PPT墨迹");
}
// 检查PPT文件路径是否匹配
if (metadata.ContainsKey("PPT文件路径"))
{
string savedPptPath = metadata["PPT文件路径"];
string currentPptPath = pptApplication.SlideShowWindows[1].Presentation.FullName;
if (!string.IsNullOrEmpty(savedPptPath) && !string.IsNullOrEmpty(currentPptPath))
{
// 使用文件路径哈希值进行比较,避免路径格式差异
string savedHash = GetFileHash(savedPptPath);
string currentHash = GetFileHash(currentPptPath);
if (savedHash != currentHash)
{
throw new InvalidOperationException($"墨迹文件与当前PPT文件不匹配。保存的PPT: {savedPptPath},当前PPT: {currentPptPath}");
}
}
}
// 清空当前墨迹
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
// 重置PPT墨迹存储
_pptInkManager?.ClearAllStrokes();
// 读取所有页面的墨迹文件
var files = Directory.GetFiles(tempDir, "page_*.icstk");
foreach (var file in files) {
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)) {
var strokes = new StrokeCollection(fs);
if (strokes.Count > 0) {
_pptInkManager?.SaveCurrentSlideStrokes(pageNumber, strokes);
}
}
}
}
// 恢复当前页面的墨迹
if (_pptManager?.IsInSlideShow == true) {
int currentSlide = _pptManager.GetCurrentSlideNumber();
var currentStrokes = _pptInkManager?.LoadSlideStrokes(currentSlide);
if (currentStrokes != null && currentStrokes.Count > 0) {
inkCanvas.Strokes.Add(currentStrokes);
}
}
LogHelper.WriteLogToFile($"成功恢复PPT墨迹,共{files.Length}页");
}
catch (Exception ex) {
LogHelper.WriteLogToFile($"恢复PPT墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
throw;
}
}
/// <summary>
/// 从ZIP文件恢复白板墨迹
/// </summary>
private void RestoreWhiteboardStrokesFromZip(string tempDir, Dictionary<string, string> metadata) {
try {
// 确保当前处于白板模式
if (currentMode == 0) {
throw new InvalidOperationException("当前不在白板模式,无法恢复白板墨迹");
}
// 清空当前墨迹
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
// 读取总页数
int totalPages = 1;
if (metadata.ContainsKey("总页数") && int.TryParse(metadata["总页数"], out int parsedPages)) {
totalPages = parsedPages;
}
// 重置白板状态
WhiteboardTotalCount = totalPages;
CurrentWhiteboardIndex = 1;
// 清空历史记录
for (int i = 0; i < TimeMachineHistories.Length; i++) {
TimeMachineHistories[i] = null;
}
// 读取所有页面的墨迹文件
var files = Directory.GetFiles(tempDir, "page_*.icstk");
foreach (var file in files) {
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)) {
var strokes = new StrokeCollection(fs);
if (strokes.Count > 0) {
// 创建历史记录
var history = new TimeMachineHistory(strokes, TimeMachineHistoryType.UserInput, false);
TimeMachineHistories[pageNumber] = new TimeMachineHistory[] { history };
}
}
}
}
// 恢复第一页的墨迹
if (TimeMachineHistories[1] != null) {
RestoreStrokes();
}
// 更新UI显示
UpdateIndexInfoDisplay();
LogHelper.WriteLogToFile($"成功恢复白板墨迹,共{totalPages}页");
}
catch (Exception ex) {
LogHelper.WriteLogToFile($"恢复白板墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
throw;
}
}
/// <summary>
/// 打开单个墨迹文件
/// </summary>
private void OpenSingleStrokeFile(string filePath) {
var fileStreamHasNoStroke = false;
using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) {
var strokes = new StrokeCollection(fs);
fileStreamHasNoStroke = strokes.Count == 0;
if (!fileStreamHasNoStroke) {
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
inkCanvas.Strokes.Add(strokes);
LogHelper.NewLog($"Strokes Insert: Strokes Count: {inkCanvas.Strokes.Count.ToString()}");
}
}
// 恢复元素信息
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);
}
}
}
if (fileStreamHasNoStroke)
using (var ms = new MemoryStream(File.ReadAllBytes(filePath))) {
ms.Seek(0, SeekOrigin.Begin);
var strokes = new StrokeCollection(ms);
ClearStrokes(true);
timeMachine.ClearStrokeHistory();
inkCanvas.Strokes.Add(strokes);
LogHelper.NewLog($"Strokes Insert (2): Strokes Count: {strokes.Count.ToString()}");
}
}
}
}
-337
View File
@@ -1,337 +0,0 @@
using System;
using System.Collections.Generic;
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;
using System.Windows.Media.Imaging;
using Ink_Canvas.Helpers;
using Ink_Canvas.Helpers;
using Application = System.Windows.Application;
using Clipboard = System.Windows.Clipboard;
using Size = System.Drawing.Size;
namespace Ink_Canvas {
// 截图结果结构体
public struct ScreenshotResult
{
public System.Drawing.Rectangle Area;
public List<System.Windows.Point> Path;
public ScreenshotResult(System.Drawing.Rectangle area, List<System.Windows.Point> path = null)
{
Area = area;
Path = path;
}
}
public partial class MainWindow : Window {
private void SaveScreenShot(bool isHideNotification, string fileName = null) {
var savePath = Settings.Automation.IsSaveScreenshotsInDateFolders
? GetDateFolderPath(fileName)
: GetDefaultFolderPath();
CaptureAndSaveScreenshot(savePath, isHideNotification);
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
SaveInkCanvasStrokes(false);
}
private void SaveScreenShotToDesktop() {
var desktopPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
$"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.png");
CaptureAndSaveScreenshot(desktopPath, false);
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
SaveInkCanvasStrokes(false);
}
// 提取公共的截图和保存逻辑
private void CaptureAndSaveScreenshot(string savePath, bool isHideNotification) {
var rc = SystemInformation.VirtualScreen;
using (var bitmap = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb))
using (var memoryGraphics = Graphics.FromImage(bitmap)) {
memoryGraphics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy);
// 确保目录存在
var directory = Path.GetDirectoryName(savePath);
if (!Directory.Exists(directory)) {
Directory.CreateDirectory(directory);
}
bitmap.Save(savePath, ImageFormat.Png);
}
if (!isHideNotification) {
ShowNotification($"截图成功保存至 {savePath}");
}
}
// 获取日期文件夹路径
private string GetDateFolderPath(string fileName) {
if (string.IsNullOrWhiteSpace(fileName)) {
fileName = DateTime.Now.ToString("HH-mm-ss");
}
var basePath = Settings.Automation.AutoSavedStrokesLocation;
var dateFolder = DateTime.Now.ToString("yyyyMMdd");
return Path.Combine(
basePath,
"Auto Saved - Screenshots",
dateFolder,
$"{fileName}.png");
}
// 获取默认文件夹路径
private string GetDefaultFolderPath() {
var basePath = Settings.Automation.AutoSavedStrokesLocation;
var screenshotsFolder = Path.Combine(basePath, "Auto Saved - Screenshots");
if (!Directory.Exists(screenshotsFolder)) {
Directory.CreateDirectory(screenshotsFolder);
}
return Path.Combine(
screenshotsFolder,
$"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.png");
}
// 截图并复制到剪贴板
private async Task CaptureScreenshotToClipboard() {
try {
// 隐藏主窗口以避免截图包含窗口本身
var originalVisibility = this.Visibility;
this.Visibility = Visibility.Hidden;
// 等待窗口隐藏
await Task.Delay(200);
// 启动区域选择截图
var screenshotResult = await ShowScreenshotSelector();
// 恢复窗口显示
this.Visibility = originalVisibility;
if (screenshotResult.HasValue && screenshotResult.Value.Area.Width > 0 && screenshotResult.Value.Area.Height > 0)
{
// 截取选定区域
using (var originalBitmap = CaptureScreenArea(screenshotResult.Value.Area))
{
if (originalBitmap != null)
{
Bitmap finalBitmap = originalBitmap;
// 如果有路径信息,应用形状遮罩
if (screenshotResult.Value.Path != null && screenshotResult.Value.Path.Count > 0)
{
finalBitmap = ApplyShapeMask(originalBitmap, screenshotResult.Value.Path, screenshotResult.Value.Area);
}
// 将截图复制到剪贴板
CopyBitmapToClipboard(finalBitmap);
// 等待窗口完全显示后自动粘贴
await Task.Delay(100);
await AutoPasteScreenshot();
}
}
}
else
{
ShowNotification("截图已取消");
}
}
catch (Exception ex) {
ShowNotification($"截图失败: {ex.Message}");
this.Visibility = Visibility.Visible;
}
}
// 显示截图区域选择器
private async Task<ScreenshotResult?> ShowScreenshotSelector()
{
ScreenshotResult? result = null;
try
{
await Application.Current.Dispatcher.InvokeAsync(() =>
{
var selectorWindow = new ScreenshotSelectorWindow();
if (selectorWindow.ShowDialog() == true)
{
result = new ScreenshotResult(
selectorWindow.SelectedArea.Value,
selectorWindow.SelectedPath
);
}
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"显示截图选择器失败: {ex.Message}", LogHelper.LogType.Error);
}
return result;
}
// 截取指定屏幕区域
private Bitmap CaptureScreenArea(System.Drawing.Rectangle area)
{
try
{
// 确保区域在有效范围内
var virtualScreen = SystemInformation.VirtualScreen;
// 调整区域边界,确保不超出屏幕范围
int x = Math.Max(area.X, virtualScreen.X);
int y = Math.Max(area.Y, virtualScreen.Y);
int right = Math.Min(area.Right, virtualScreen.Right);
int bottom = Math.Min(area.Bottom, virtualScreen.Bottom);
int width = Math.Max(1, right - x);
int height = Math.Max(1, bottom - y);
var bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
using (var graphics = Graphics.FromImage(bitmap))
{
// 设置高质量渲染
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
// 截取屏幕区域
graphics.CopyFromScreen(x, y, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
}
LogHelper.WriteLogToFile($"成功截取区域: X={x}, Y={y}, Width={width}, Height={height}", LogHelper.LogType.Info);
return bitmap;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"截取屏幕区域失败: {ex.Message}", LogHelper.LogType.Error);
return null;
}
}
// 自动粘贴截图到画布
private async Task AutoPasteScreenshot() {
try {
// 只在白板模式下自动粘贴
if (currentMode == 1) {
await PasteImageFromClipboard();
ShowNotification("截图已自动插入到画布");
} else {
ShowNotification("截图已复制到剪贴板,可在白板模式下粘贴");
}
}
catch (Exception ex) {
ShowNotification($"自动粘贴截图失败: {ex.Message}");
LogHelper.WriteLogToFile($"自动粘贴截图失败: {ex.Message}", LogHelper.LogType.Error);
}
}
// 将Bitmap复制到剪贴板
private void CopyBitmapToClipboard(Bitmap bitmap) {
try {
// 将System.Drawing.Bitmap转换为WPF BitmapSource
var bitmapSource = ConvertBitmapToBitmapSource(bitmap);
// 复制到剪贴板
Clipboard.SetImage(bitmapSource);
}
catch (Exception ex) {
ShowNotification($"复制到剪贴板失败: {ex.Message}");
}
}
// 应用形状遮罩到截图
private Bitmap ApplyShapeMask(Bitmap bitmap, List<System.Windows.Point> path, System.Drawing.Rectangle area)
{
try
{
// 获取DPI缩放比例
var dpiScale = GetDpiScale();
var virtualScreen = SystemInformation.VirtualScreen;
// 创建结果位图
var resultBitmap = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format32bppArgb);
using (var resultGraphics = Graphics.FromImage(resultBitmap))
{
// 设置高质量渲染
resultGraphics.SmoothingMode = SmoothingMode.AntiAlias;
resultGraphics.CompositingQuality = CompositingQuality.HighQuality;
// 创建路径
using (var pathGraphics = new GraphicsPath())
{
// 转换WPF坐标到GDI+坐标,考虑DPI缩放和屏幕偏移
var points = new PointF[path.Count];
for (int i = 0; i < path.Count; i++)
{
// 将WPF坐标转换为实际屏幕坐标,然后相对于截图区域计算偏移
double screenX = (path[i].X * dpiScale) + virtualScreen.Left;
double screenY = (path[i].Y * dpiScale) + virtualScreen.Top;
// 计算相对于截图区域的坐标
float relativeX = (float)(screenX - area.X);
float relativeY = (float)(screenY - area.Y);
points[i] = new PointF(relativeX, relativeY);
}
// 添加路径
pathGraphics.AddPolygon(points);
// 设置裁剪区域为路径内部
resultGraphics.SetClip(pathGraphics);
// 在裁剪区域内绘制原始图像
resultGraphics.DrawImage(bitmap, 0, 0);
}
}
return resultBitmap;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"应用形状遮罩失败: {ex.Message}", LogHelper.LogType.Error);
return bitmap; // 如果失败,返回原始图像
}
}
// 获取DPI缩放比例
private double GetDpiScale()
{
var source = PresentationSource.FromVisual(this);
if (source?.CompositionTarget != null)
{
return source.CompositionTarget.TransformToDevice.M11;
}
return 1.0; // 默认DPI
}
// 将System.Drawing.Bitmap转换为WPF BitmapSource
private BitmapSource ConvertBitmapToBitmapSource(Bitmap bitmap) {
using (var memory = new MemoryStream()) {
bitmap.Save(memory, ImageFormat.Png);
memory.Position = 0;
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = memory;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
bitmapImage.Freeze();
return bitmapImage;
}
}
}
}
@@ -1,988 +0,0 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Threading;
using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern.Controls;
using Point = System.Windows.Point;
namespace Ink_Canvas {
public partial class MainWindow : Window {
#region Floating Control
private object lastBorderMouseDownObject;
private void Border_MouseDown(object sender, MouseButtonEventArgs e) {
// 如果发送者是 RandomDrawPanel 或 SingleDrawPanel,且它们被隐藏,则不处理事件
if (sender is SimpleStackPanel panel) {
if ((panel == RandomDrawPanel || panel == SingleDrawPanel) &&
panel.Visibility != Visibility.Visible) {
return;
}
}
lastBorderMouseDownObject = sender;
}
private bool isStrokeSelectionCloneOn;
private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
if (isStrokeSelectionCloneOn) {
BorderStrokeSelectionClone.Background = Brushes.Transparent;
isStrokeSelectionCloneOn = false;
}
else {
BorderStrokeSelectionClone.Background = new SolidColorBrush(StringToColor("#FF1ED760"));
isStrokeSelectionCloneOn = true;
}
}
private void BorderStrokeSelectionCloneToNewBoard_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
var strokes = inkCanvas.GetSelectedStrokes();
inkCanvas.Select(new StrokeCollection());
strokes = strokes.Clone();
BtnWhiteBoardAdd_Click(null, null);
inkCanvas.Strokes.Add(strokes);
}
private void BorderStrokeSelectionDelete_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
SymbolIconDelete_MouseUp(sender, e);
}
private void GridPenWidthDecrease_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
ChangeStrokeThickness(0.8);
}
private void GridPenWidthIncrease_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
ChangeStrokeThickness(1.25);
}
private void ChangeStrokeThickness(double multipler) {
foreach (var stroke in inkCanvas.GetSelectedStrokes()) {
var newWidth = stroke.DrawingAttributes.Width * multipler;
var newHeight = stroke.DrawingAttributes.Height * multipler;
if (!(newWidth >= DrawingAttributes.MinWidth) || !(newWidth <= DrawingAttributes.MaxWidth)
|| !(newHeight >= DrawingAttributes.MinHeight) ||
!(newHeight <= DrawingAttributes.MaxHeight)) continue;
stroke.DrawingAttributes.Width = newWidth;
stroke.DrawingAttributes.Height = newHeight;
}
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
private void GridPenWidthRestore_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
foreach (var stroke in inkCanvas.GetSelectedStrokes()) {
stroke.DrawingAttributes.Width = inkCanvas.DefaultDrawingAttributes.Width;
stroke.DrawingAttributes.Height = inkCanvas.DefaultDrawingAttributes.Height;
}
}
private void ImageFlipHorizontal_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
var m = new Matrix();
// Find center of element and then transform to get current location of center
var fe = e.Source as FrameworkElement;
var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
// Update matrix to reflect translation/rotation
m.ScaleAt(-1, 1, center.X, center.Y); // 缩放
var targetStrokes = inkCanvas.GetSelectedStrokes();
foreach (var stroke in targetStrokes) stroke.Transform(m, false);
if (DrawingAttributesHistory.Count > 0)
{
//var collecion = new StrokeCollection();
//foreach (var item in DrawingAttributesHistory)
//{
// collecion.Add(item.Key);
//}
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
//updateBorderStrokeSelectionControlLocation();
}
private void ImageFlipVertical_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
var m = new Matrix();
// Find center of element and then transform to get current location of center
var fe = e.Source as FrameworkElement;
var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
// Update matrix to reflect translation/rotation
m.ScaleAt(1, -1, center.X, center.Y); // 缩放
var targetStrokes = inkCanvas.GetSelectedStrokes();
foreach (var stroke in targetStrokes) stroke.Transform(m, false);
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
// ... existing code ...
private void ImageRotate45_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
var m = new Matrix();
// Find center of element and then transform to get current location of center
var fe = e.Source as FrameworkElement;
var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
// Update matrix to reflect translation/rotation
m.RotateAt(45, center.X, center.Y); // 顺时针旋转45度
var targetStrokes = inkCanvas.GetSelectedStrokes();
foreach (var stroke in targetStrokes) stroke.Transform(m, false);
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
private void ImageRotate90_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
var m = new Matrix();
// Find center of element and then transform to get current location of center
var fe = e.Source as FrameworkElement;
var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
// Update matrix to reflect translation/rotation
m.RotateAt(90, center.X, center.Y); // 旋转
var targetStrokes = inkCanvas.GetSelectedStrokes();
foreach (var stroke in targetStrokes) stroke.Transform(m, false);
if (DrawingAttributesHistory.Count > 0)
{
var collecion = new StrokeCollection();
foreach (var item in DrawingAttributesHistory)
{
collecion.Add(item.Key);
}
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
#endregion
private bool isGridInkCanvasSelectionCoverMouseDown;
private StrokeCollection StrokesSelectionClone = new StrokeCollection();
private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e) {
isGridInkCanvasSelectionCoverMouseDown = true;
}
private void GridInkCanvasSelectionCover_MouseUp(object sender, MouseButtonEventArgs e) {
if (!isGridInkCanvasSelectionCoverMouseDown) return;
isGridInkCanvasSelectionCoverMouseDown = false;
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
}
private void BtnSelect_Click(object sender, RoutedEventArgs e) {
ExitMultiTouchModeIfNeeded();
forceEraser = true;
drawingShapeMode = 0;
inkCanvas.IsManipulationEnabled = false;
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select) {
if (inkCanvas.GetSelectedStrokes().Count == inkCanvas.Strokes.Count) {
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
}
else {
var selectedStrokes = new StrokeCollection();
foreach (var stroke in inkCanvas.Strokes)
if (stroke.GetBounds().Width > 0 && stroke.GetBounds().Height > 0)
selectedStrokes.Add(stroke);
inkCanvas.Select(selectedStrokes);
}
}
else {
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
}
}
private double BorderStrokeSelectionControlWidth = 490.0;
private double BorderStrokeSelectionControlHeight = 80.0;
private bool isProgramChangeStrokeSelection;
private void inkCanvas_SelectionChanged(object sender, EventArgs e) {
if (isProgramChangeStrokeSelection) return;
if (inkCanvas.GetSelectedStrokes().Count == 0) {
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
// 当没有选中笔画时,检查是否有选中的UIElement
CheckUIElementSelection();
}
else {
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
BorderStrokeSelectionClone.Background = Brushes.Transparent;
isStrokeSelectionCloneOn = false;
updateBorderStrokeSelectionControlLocation();
// 当选中笔画时,取消UIElement选择
DeselectUIElement();
}
}
private void CheckUIElementSelection()
{
// 检查InkCanvas中的UIElement是否被选中
var selectedElements = inkCanvas.GetSelectedElements();
if (selectedElements.Count > 0)
{
var element = selectedElements[0];
SelectUIElement(element);
}
else
{
DeselectUIElement();
}
}
private void updateBorderStrokeSelectionControlLocation() {
var borderLeft = (inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Right -
BorderStrokeSelectionControlWidth) / 2;
var borderTop = inkCanvas.GetSelectionBounds().Bottom + 1;
if (borderLeft < 0) borderLeft = 0;
if (borderTop < 0) borderTop = 0;
if (Width - borderLeft < BorderStrokeSelectionControlWidth || double.IsNaN(borderLeft))
borderLeft = Width - BorderStrokeSelectionControlWidth;
if (Height - borderTop < BorderStrokeSelectionControlHeight || double.IsNaN(borderTop))
borderTop = Height - BorderStrokeSelectionControlHeight;
if (borderTop > 60) borderTop -= 60;
BorderStrokeSelectionControl.Margin = new Thickness(borderLeft, borderTop, 0, 0);
}
private void GridInkCanvasSelectionCover_ManipulationStarting(object sender, ManipulationStartingEventArgs e) {
e.Mode = ManipulationModes.All;
}
private void GridInkCanvasSelectionCover_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) {
if (StrokeManipulationHistory?.Count > 0)
{
timeMachine.CommitStrokeManipulationHistory(StrokeManipulationHistory);
foreach (var item in StrokeManipulationHistory)
{
StrokeInitialHistory[item.Key] = item.Value.Item2;
}
StrokeManipulationHistory = null;
}
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
private void GridInkCanvasSelectionCover_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) {
try {
if (dec.Count >= 1) {
bool disableScale = dec.Count >= 3;
var md = e.DeltaManipulation;
var trans = md.Translation; // 获得位移矢量
var rotate = md.Rotation; // 获得旋转角度
var scale = md.Scale; // 获得缩放倍数
var m = new Matrix();
// Find center of element and then transform to get current location of center
var fe = e.Source as FrameworkElement;
var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
// Update matrix to reflect translation/rotation
m.Translate(trans.X, trans.Y); // 移动
if (!disableScale)
m.ScaleAt(scale.X, scale.Y, center.X, center.Y); // 缩放
var strokes = inkCanvas.GetSelectedStrokes();
if (StrokesSelectionClone.Count != 0)
strokes = StrokesSelectionClone;
else if (Settings.Gesture.IsEnableTwoFingerRotationOnSelection)
m.RotateAt(rotate, center.X, center.Y); // 旋转
foreach (var stroke in strokes) {
stroke.Transform(m, false);
try {
stroke.DrawingAttributes.Width *= md.Scale.X;
stroke.DrawingAttributes.Height *= md.Scale.Y;
}
catch { }
}
updateBorderStrokeSelectionControlLocation();
}
}
catch { }
}
private void GridInkCanvasSelectionCover_TouchDown(object sender, TouchEventArgs e) { }
private void GridInkCanvasSelectionCover_TouchUp(object sender, TouchEventArgs e) { }
private Point lastTouchPointOnGridInkCanvasCover = new Point(0, 0);
private void GridInkCanvasSelectionCover_PreviewTouchDown(object sender, TouchEventArgs e) {
dec.Add(e.TouchDevice.Id);
//设备1个的时候,记录中心点
if (dec.Count == 1) {
var touchPoint = e.GetTouchPoint(null);
centerPoint = touchPoint.Position;
lastTouchPointOnGridInkCanvasCover = touchPoint.Position;
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 {
// 新增:启动套索选择模式
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
inkCanvas.Select(new StrokeCollection());
}
}
}
private void GridInkCanvasSelectionCover_PreviewTouchUp(object sender, TouchEventArgs e) {
dec.Remove(e.TouchDevice.Id);
if (dec.Count >= 1) return;
isProgramChangeStrokeSelection = false;
if (lastTouchPointOnGridInkCanvasCover == e.GetTouchPoint(null).Position) {
if (!(lastTouchPointOnGridInkCanvasCover.X < inkCanvas.GetSelectionBounds().Left) &&
!(lastTouchPointOnGridInkCanvasCover.Y < inkCanvas.GetSelectionBounds().Top) &&
!(lastTouchPointOnGridInkCanvasCover.X > inkCanvas.GetSelectionBounds().Right) &&
!(lastTouchPointOnGridInkCanvasCover.Y > inkCanvas.GetSelectionBounds().Bottom)) return;
inkCanvas.Select(new StrokeCollection());
StrokesSelectionClone = new StrokeCollection();
}
else if (inkCanvas.GetSelectedStrokes().Count == 0) {
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
StrokesSelectionClone = new StrokeCollection();
}
else {
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
StrokesSelectionClone = new StrokeCollection();
}
}
private void LassoSelect_Click(object sender, RoutedEventArgs e) {
ExitMultiTouchModeIfNeeded();
forceEraser = false;
forcePointEraser = false;
drawingShapeMode = 0;
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
SetCursorBasedOnEditingMode(inkCanvas);
}
private void BtnLassoSelect_Click(object sender, RoutedEventArgs e) {
ExitMultiTouchModeIfNeeded();
forceEraser = false;
forcePointEraser = false;
drawingShapeMode = 0;
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
inkCanvas.IsManipulationEnabled = true;
SetCursorBasedOnEditingMode(inkCanvas);
}
#region UIElement Selection and Resize
private UIElement selectedUIElement;
private System.Windows.Controls.Canvas resizeHandlesCanvas;
private readonly List<Rectangle> resizeHandles = new List<Rectangle>();
private bool isResizing;
private ResizeDirection currentResizeDirection = ResizeDirection.None;
private Point resizeStartPoint;
private Rect originalElementBounds;
// 图片工具栏相关
private Border borderImageSelectionControl;
private double BorderImageSelectionControlWidth = 490.0; // 6个按钮 + 分隔线的实际宽度
private double BorderImageSelectionControlHeight = 80.0;
// 元素变化监听相关
private DispatcherTimer elementUpdateTimer;
private Rect lastElementBounds;
private enum ResizeDirection
{
None,
TopLeft,
TopCenter,
TopRight,
MiddleLeft,
MiddleRight,
BottomLeft,
BottomCenter,
BottomRight
}
private void InitializeUIElementSelection()
{
// 创建拖拽手柄画布
if (resizeHandlesCanvas == null)
{
resizeHandlesCanvas = new System.Windows.Controls.Canvas
{
Background = Brushes.Transparent,
IsHitTestVisible = true,
Visibility = Visibility.Collapsed
};
// 将手柄画布添加到主网格中,确保它在InkCanvas之上
var mainGrid = inkCanvas.Parent as Grid;
if (mainGrid != null)
{
mainGrid.Children.Add(resizeHandlesCanvas);
Panel.SetZIndex(resizeHandlesCanvas, 1000); // 确保在最上层
}
}
// 初始化图片工具栏引用
if (borderImageSelectionControl == null)
{
borderImageSelectionControl = FindName("BorderImageSelectionControl") as Border;
}
// 创建8个拖拽手柄
CreateResizeHandles();
}
private void CreateResizeHandles()
{
resizeHandles.Clear();
resizeHandlesCanvas.Children.Clear();
var directions = new[]
{
ResizeDirection.TopLeft, ResizeDirection.TopCenter, ResizeDirection.TopRight,
ResizeDirection.MiddleLeft, ResizeDirection.MiddleRight,
ResizeDirection.BottomLeft, ResizeDirection.BottomCenter, ResizeDirection.BottomRight
};
foreach (var direction in directions)
{
var handle = new Rectangle
{
Width = 12,
Height = 12,
Fill = Brushes.White,
Stroke = Brushes.DodgerBlue,
StrokeThickness = 2,
Cursor = GetCursorForDirection(direction),
Tag = direction
};
handle.MouseDown += ResizeHandle_MouseDown;
handle.MouseMove += ResizeHandle_MouseMove;
handle.MouseUp += ResizeHandle_MouseUp;
resizeHandles.Add(handle);
resizeHandlesCanvas.Children.Add(handle);
}
}
private Cursor GetCursorForDirection(ResizeDirection direction)
{
switch (direction)
{
case ResizeDirection.TopLeft:
case ResizeDirection.BottomRight:
return Cursors.SizeNWSE;
case ResizeDirection.TopRight:
case ResizeDirection.BottomLeft:
return Cursors.SizeNESW;
case ResizeDirection.TopCenter:
case ResizeDirection.BottomCenter:
return Cursors.SizeNS;
case ResizeDirection.MiddleLeft:
case ResizeDirection.MiddleRight:
return Cursors.SizeWE;
default:
return Cursors.Arrow;
}
}
private void SelectUIElement(UIElement element)
{
if (selectedUIElement == element) return;
// 取消之前的选择
DeselectUIElement();
// 清除笔画选择
if (inkCanvas.GetSelectedStrokes().Count > 0)
{
isProgramChangeStrokeSelection = true;
inkCanvas.Select(new StrokeCollection());
isProgramChangeStrokeSelection = false;
}
selectedUIElement = element;
if (element != null)
{
// 初始化选择系统(如果还没有初始化)
if (resizeHandlesCanvas == null)
{
InitializeUIElementSelection();
}
// 显示拖拽手柄(所有UI元素都需要)
ShowResizeHandles();
// 根据元素类型显示特定的工具栏
if (element is Image)
{
ShowImageToolbar();
}
// 监听元素的布局变化,以便实时更新手柄位置
StartMonitoringElementChanges(element);
}
}
private void DeselectUIElement()
{
// 停止监听之前选中元素的变化
StopMonitoringElementChanges();
selectedUIElement = null;
HideResizeHandles();
HideImageToolbar();
}
private void ShowResizeHandles()
{
if (selectedUIElement == null || resizeHandlesCanvas == null) return;
var bounds = GetUIElementBounds(selectedUIElement);
UpdateResizeHandlesPosition(bounds);
resizeHandlesCanvas.Visibility = Visibility.Visible;
}
private void HideResizeHandles()
{
if (resizeHandlesCanvas != null)
{
resizeHandlesCanvas.Visibility = Visibility.Collapsed;
}
}
private void ShowImageToolbar()
{
if (selectedUIElement == null || borderImageSelectionControl == null) return;
var bounds = GetUIElementBounds(selectedUIElement);
UpdateImageToolbarPosition(bounds);
borderImageSelectionControl.Visibility = Visibility.Visible;
}
private void HideImageToolbar()
{
if (borderImageSelectionControl != null)
{
borderImageSelectionControl.Visibility = Visibility.Collapsed;
}
}
private void UpdateImageToolbarPosition(Rect bounds)
{
if (borderImageSelectionControl == null) return;
// 计算工具栏位置,类似于墨迹选择工具栏的逻辑
var toolbarX = bounds.X + bounds.Width / 2 - BorderImageSelectionControlWidth / 2;
var toolbarY = bounds.Y + bounds.Height + 10; // 在图片下方10像素处
// 确保工具栏不会超出画布边界
if (toolbarX < 0) toolbarX = 0;
if (toolbarX + BorderImageSelectionControlWidth > inkCanvas.ActualWidth)
toolbarX = inkCanvas.ActualWidth - BorderImageSelectionControlWidth;
if (toolbarY + BorderImageSelectionControlHeight > inkCanvas.ActualHeight)
toolbarY = bounds.Y - BorderImageSelectionControlHeight - 10; // 如果下方空间不够,显示在上方
borderImageSelectionControl.Margin = new Thickness(toolbarX, toolbarY, 0, 0);
}
private Rect GetUIElementBounds(UIElement element)
{
if (element is FrameworkElement fe)
{
var left = InkCanvas.GetLeft(element);
var top = InkCanvas.GetTop(element);
if (double.IsNaN(left)) left = 0;
if (double.IsNaN(top)) top = 0;
var width = fe.ActualWidth > 0 ? fe.ActualWidth : fe.Width;
var height = fe.ActualHeight > 0 ? fe.ActualHeight : fe.Height;
// 检查是否有RenderTransform
if (fe.RenderTransform != null && fe.RenderTransform != Transform.Identity)
{
try
{
// 如果有变换,使用变换后的边界
var transform = element.TransformToAncestor(inkCanvas);
var elementBounds = new Rect(0, 0, width, height);
var transformedBounds = transform.TransformBounds(elementBounds);
return transformedBounds;
}
catch
{
// 变换失败时回退到简单计算
return new Rect(left, top, width, height);
}
}
else
{
// 没有变换时直接使用位置和大小
return new Rect(left, top, width, height);
}
}
return new Rect(0, 0, 0, 0);
}
private void UpdateResizeHandlesPosition(Rect bounds)
{
if (resizeHandles.Count != 8) return;
var handleSize = 12.0;
var halfHandle = handleSize / 2;
// 计算手柄位置
var positions = new[]
{
new Point(bounds.Left - halfHandle, bounds.Top - halfHandle), // TopLeft
new Point(bounds.Left + bounds.Width / 2 - halfHandle, bounds.Top - halfHandle), // TopCenter
new Point(bounds.Right - halfHandle, bounds.Top - halfHandle), // TopRight
new Point(bounds.Left - halfHandle, bounds.Top + bounds.Height / 2 - halfHandle), // MiddleLeft
new Point(bounds.Right - halfHandle, bounds.Top + bounds.Height / 2 - halfHandle), // MiddleRight
new Point(bounds.Left - halfHandle, bounds.Bottom - halfHandle), // BottomLeft
new Point(bounds.Left + bounds.Width / 2 - halfHandle, bounds.Bottom - halfHandle), // BottomCenter
new Point(bounds.Right - halfHandle, bounds.Bottom - halfHandle) // BottomRight
};
for (int i = 0; i < resizeHandles.Count && i < positions.Length; i++)
{
System.Windows.Controls.Canvas.SetLeft(resizeHandles[i], positions[i].X);
System.Windows.Controls.Canvas.SetTop(resizeHandles[i], positions[i].Y);
}
}
private void ResizeHandle_MouseDown(object sender, MouseButtonEventArgs e)
{
if (selectedUIElement == null) return;
var handle = sender as Rectangle;
if (handle?.Tag is ResizeDirection direction)
{
isResizing = true;
currentResizeDirection = direction;
resizeStartPoint = e.GetPosition(inkCanvas);
originalElementBounds = GetUIElementBounds(selectedUIElement);
handle.CaptureMouse();
e.Handled = true;
}
}
private void ResizeHandle_MouseMove(object sender, MouseEventArgs e)
{
if (!isResizing || selectedUIElement == null) return;
var currentPoint = e.GetPosition(inkCanvas);
var deltaX = currentPoint.X - resizeStartPoint.X;
var deltaY = currentPoint.Y - resizeStartPoint.Y;
ResizeUIElement(deltaX, deltaY);
e.Handled = true;
}
private void ResizeHandle_MouseUp(object sender, MouseButtonEventArgs e)
{
if (isResizing)
{
isResizing = false;
currentResizeDirection = ResizeDirection.None;
var handle = sender as Rectangle;
handle?.ReleaseMouseCapture();
e.Handled = true;
}
}
private void ResizeUIElement(double deltaX, double deltaY)
{
if (selectedUIElement == null) return;
var newBounds = originalElementBounds;
const double minSize = 20.0;
switch (currentResizeDirection)
{
case ResizeDirection.TopLeft:
var newWidth = originalElementBounds.Width - deltaX;
var newHeight = originalElementBounds.Height - deltaY;
if (newWidth >= minSize && newHeight >= minSize)
{
newBounds.X = originalElementBounds.X + deltaX;
newBounds.Y = originalElementBounds.Y + deltaY;
newBounds.Width = newWidth;
newBounds.Height = newHeight;
}
break;
case ResizeDirection.TopCenter:
var newHeightTC = originalElementBounds.Height - deltaY;
if (newHeightTC >= minSize)
{
newBounds.Y = originalElementBounds.Y + deltaY;
newBounds.Height = newHeightTC;
}
break;
case ResizeDirection.TopRight:
var newWidthTR = originalElementBounds.Width + deltaX;
var newHeightTR = originalElementBounds.Height - deltaY;
if (newWidthTR >= minSize && newHeightTR >= minSize)
{
newBounds.Y = originalElementBounds.Y + deltaY;
newBounds.Width = newWidthTR;
newBounds.Height = newHeightTR;
}
break;
case ResizeDirection.MiddleLeft:
var newWidthML = originalElementBounds.Width - deltaX;
if (newWidthML >= minSize)
{
newBounds.X = originalElementBounds.X + deltaX;
newBounds.Width = newWidthML;
}
break;
case ResizeDirection.MiddleRight:
var newWidthMR = originalElementBounds.Width + deltaX;
if (newWidthMR >= minSize)
{
newBounds.Width = newWidthMR;
}
break;
case ResizeDirection.BottomLeft:
var newWidthBL = originalElementBounds.Width - deltaX;
var newHeightBL = originalElementBounds.Height + deltaY;
if (newWidthBL >= minSize && newHeightBL >= minSize)
{
newBounds.X = originalElementBounds.X + deltaX;
newBounds.Width = newWidthBL;
newBounds.Height = newHeightBL;
}
break;
case ResizeDirection.BottomCenter:
var newHeightBC = originalElementBounds.Height + deltaY;
if (newHeightBC >= minSize)
{
newBounds.Height = newHeightBC;
}
break;
case ResizeDirection.BottomRight:
var newWidthBR = originalElementBounds.Width + deltaX;
var newHeightBR = originalElementBounds.Height + deltaY;
if (newWidthBR >= minSize && newHeightBR >= minSize)
{
newBounds.Width = newWidthBR;
newBounds.Height = newHeightBR;
}
break;
}
// 应用新的尺寸和位置
ApplyUIElementBounds(selectedUIElement, newBounds);
// 更新手柄位置
UpdateResizeHandlesPosition(newBounds);
// 如果是图片,也更新工具栏位置
if (selectedUIElement is Image)
{
UpdateImageToolbarPosition(newBounds);
}
}
private void ApplyUIElementBounds(UIElement element, Rect bounds)
{
if (element is FrameworkElement fe)
{
// 清除RenderTransform,避免与直接设置Width/Height冲突
fe.RenderTransform = Transform.Identity;
// 直接设置位置和大小
InkCanvas.SetLeft(element, bounds.X);
InkCanvas.SetTop(element, bounds.Y);
fe.Width = bounds.Width;
fe.Height = bounds.Height;
}
}
private void UIElement_MouseDown(object sender, MouseButtonEventArgs e)
{
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
{
var element = sender as UIElement;
if (element != null)
{
// 切换到选择模式并选择这个元素
inkCanvas.Select(new[] { element });
SelectUIElement(element);
e.Handled = true;
}
}
}
private void StartMonitoringElementChanges(UIElement element)
{
// 停止之前的监听
StopMonitoringElementChanges();
if (element == null) return;
// 记录初始边界
lastElementBounds = GetUIElementBounds(element);
// 创建定时器,定期检查元素边界变化
elementUpdateTimer = new DispatcherTimer
{
Interval = TimeSpan.FromMilliseconds(16) // 约60FPS的更新频率
};
elementUpdateTimer.Tick += (sender, e) =>
{
if (selectedUIElement == null)
{
StopMonitoringElementChanges();
return;
}
var currentBounds = GetUIElementBounds(selectedUIElement);
// 检查边界是否发生变化
if (!AreRectsEqual(lastElementBounds, currentBounds))
{
lastElementBounds = currentBounds;
// 更新手柄位置
UpdateResizeHandlesPosition(currentBounds);
// 如果是图片,也更新工具栏位置
if (selectedUIElement is Image)
{
UpdateImageToolbarPosition(currentBounds);
}
}
};
elementUpdateTimer.Start();
}
private void StopMonitoringElementChanges()
{
if (elementUpdateTimer != null)
{
elementUpdateTimer.Stop();
elementUpdateTimer = null;
}
}
private bool AreRectsEqual(Rect rect1, Rect rect2)
{
const double tolerance = 0.1; // 允许的误差范围
return Math.Abs(rect1.X - rect2.X) < tolerance &&
Math.Abs(rect1.Y - rect2.Y) < tolerance &&
Math.Abs(rect1.Width - rect2.Width) < tolerance &&
Math.Abs(rect1.Height - rect2.Height) < tolerance;
}
#endregion
}
}
File diff suppressed because it is too large Load Diff
-557
View File
@@ -1,557 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using Ink_Canvas.Helpers;
using Point = System.Windows.Point;
namespace Ink_Canvas {
public partial class MainWindow : Window {
#region Multi-Touch
private bool isInMultiTouchMode;
private List<int> dec = new List<int>();
private bool isSingleFingerDragMode;
private Point centerPoint = new Point(0, 0);
private InkCanvasEditingMode lastInkCanvasEditingMode = InkCanvasEditingMode.Ink;
/// <summary>
/// 保存画布上的非笔画元素(如图片、媒体元素等)
/// </summary>
private List<UIElement> PreserveNonStrokeElements()
{
var preservedElements = new List<UIElement>();
// 遍历inkCanvas的所有子元素
for (int i = inkCanvas.Children.Count - 1; i >= 0; i--)
{
var child = inkCanvas.Children[i];
// 保存图片、媒体元素等非笔画相关的UI元素
if (child is Image || child is MediaElement ||
(child is Border border && border.Name != "AdvancedEraserOverlay"))
{
preservedElements.Add(child);
}
}
return preservedElements;
}
/// <summary>
/// 恢复之前保存的非笔画元素到画布
/// </summary>
private void RestoreNonStrokeElements(List<UIElement> preservedElements)
{
if (preservedElements == null) return;
foreach (var element in preservedElements)
{
// 确保元素没有父容器再添加到inkCanvas
if (element is FrameworkElement fe && fe.Parent == null)
{
inkCanvas.Children.Add(element);
}
}
}
private void BorderMultiTouchMode_MouseUp(object sender, MouseButtonEventArgs e) {
if (isInMultiTouchMode) {
inkCanvas.StylusDown -= MainWindow_StylusDown;
inkCanvas.StylusMove -= MainWindow_StylusMove;
inkCanvas.StylusUp -= MainWindow_StylusUp;
inkCanvas.TouchDown -= MainWindow_TouchDown;
inkCanvas.TouchDown += Main_Grid_TouchDown;
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
}
// 保存非笔画元素(如图片)
var preservedElements = PreserveNonStrokeElements();
inkCanvas.Children.Clear();
// 恢复非笔画元素
RestoreNonStrokeElements(preservedElements);
isInMultiTouchMode = false;
}
else {
inkCanvas.StylusDown += MainWindow_StylusDown;
inkCanvas.StylusMove += MainWindow_StylusMove;
inkCanvas.StylusUp += MainWindow_StylusUp;
inkCanvas.TouchDown += MainWindow_TouchDown;
inkCanvas.TouchDown -= Main_Grid_TouchDown;
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
inkCanvas.EditingMode = InkCanvasEditingMode.None;
}
// 保存非笔画元素(如图片)
var preservedElements = PreserveNonStrokeElements();
inkCanvas.Children.Clear();
// 恢复非笔画元素
RestoreNonStrokeElements(preservedElements);
isInMultiTouchMode = true;
}
}
private void MainWindow_TouchDown(object sender, TouchEventArgs e) {
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint
|| inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke
|| inkCanvas.EditingMode == InkCanvasEditingMode.Select) return;
if (!isHidingSubPanelsWhenInking) {
isHidingSubPanelsWhenInking = true;
HideSubPanels(); // 书写时自动隐藏二级菜单
}
// 只保留普通橡皮逻辑
TouchDownPointsList[e.TouchDevice.Id] = InkCanvasEditingMode.None;
inkCanvas.EraserShape = new EllipseStylusShape(50, 50);
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
inkCanvas.EditingMode = InkCanvasEditingMode.None;
}
}
private void MainWindow_StylusDown(object sender, StylusDownEventArgs e) {
SetCursorBasedOnEditingMode(inkCanvas);
inkCanvas.CaptureStylus();
ViewboxFloatingBar.IsHitTestVisible = false;
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
// 确保手写笔模式下显示光标
if (Settings.Canvas.IsShowCursor) {
inkCanvas.ForceCursor = true;
inkCanvas.UseCustomCursor = true;
// 根据当前编辑模式设置不同的光标
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
inkCanvas.Cursor = Cursors.Cross;
} else if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink) {
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
if (sri != null)
inkCanvas.Cursor = new Cursor(sri.Stream);
}
// 强制显示光标
System.Windows.Forms.Cursor.Show();
}
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint
|| inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke
|| inkCanvas.EditingMode == InkCanvasEditingMode.Select) return;
TouchDownPointsList[e.StylusDevice.Id] = InkCanvasEditingMode.None;
}
private async void MainWindow_StylusUp(object sender, StylusEventArgs e) {
try {
inkCanvas.Strokes.Add(GetStrokeVisual(e.StylusDevice.Id).Stroke);
await Task.Delay(5); // 避免渲染墨迹完成前预览墨迹被删除导致墨迹闪烁
inkCanvas.Children.Remove(GetVisualCanvas(e.StylusDevice.Id));
inkCanvas_StrokeCollected(inkCanvas,
new InkCanvasStrokeCollectedEventArgs(GetStrokeVisual(e.StylusDevice.Id).Stroke));
}
catch (Exception ex) {
Label.Content = ex.ToString();
}
try {
StrokeVisualList.Remove(e.StylusDevice.Id);
VisualCanvasList.Remove(e.StylusDevice.Id);
TouchDownPointsList.Remove(e.StylusDevice.Id);
if (StrokeVisualList.Count == 0 || VisualCanvasList.Count == 0 || TouchDownPointsList.Count == 0) {
// 只清除手写笔预览相关的Canvas,不清除所有子元素
foreach (var canvas in VisualCanvasList.Values.ToList()) {
if (inkCanvas.Children.Contains(canvas)) {
inkCanvas.Children.Remove(canvas);
}
}
StrokeVisualList.Clear();
VisualCanvasList.Clear();
TouchDownPointsList.Clear();
}
}
catch { }
inkCanvas.ReleaseStylusCapture();
ViewboxFloatingBar.IsHitTestVisible = true;
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
}
private void MainWindow_StylusMove(object sender, StylusEventArgs e) {
try {
if (GetTouchDownPointsList(e.StylusDevice.Id) != InkCanvasEditingMode.None) return;
try {
if (e.StylusDevice.StylusButtons[1].StylusButtonState == StylusButtonState.Down) return;
}
catch { }
// 确保手写笔移动时光标保持可见
if (Settings.Canvas.IsShowCursor) {
inkCanvas.ForceCursor = true;
inkCanvas.UseCustomCursor = true;
System.Windows.Forms.Cursor.Show();
}
var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
var stylusPointCollection = e.GetStylusPoints(this);
foreach (var stylusPoint in stylusPointCollection)
strokeVisual.Add(new StylusPoint(stylusPoint.X, stylusPoint.Y, stylusPoint.PressureFactor));
strokeVisual.Redraw();
}
catch { }
}
private StrokeVisual GetStrokeVisual(int id) {
if (StrokeVisualList.TryGetValue(id, out var visual)) return visual;
var strokeVisual = new StrokeVisual(inkCanvas.DefaultDrawingAttributes.Clone());
StrokeVisualList[id] = strokeVisual;
StrokeVisualList[id] = strokeVisual;
var visualCanvas = new VisualCanvas(strokeVisual);
VisualCanvasList[id] = visualCanvas;
inkCanvas.Children.Add(visualCanvas);
return strokeVisual;
}
private VisualCanvas GetVisualCanvas(int id) {
return VisualCanvasList.TryGetValue(id, out var visualCanvas) ? visualCanvas : null;
}
private InkCanvasEditingMode GetTouchDownPointsList(int id) {
return TouchDownPointsList.TryGetValue(id, out var inkCanvasEditingMode) ? inkCanvasEditingMode : inkCanvas.EditingMode;
}
private Dictionary<int, InkCanvasEditingMode> TouchDownPointsList { get; } =
new Dictionary<int, InkCanvasEditingMode>();
private Dictionary<int, StrokeVisual> StrokeVisualList { get; } = new Dictionary<int, StrokeVisual>();
private Dictionary<int, VisualCanvas> VisualCanvasList { get; } = new Dictionary<int, VisualCanvas>();
#endregion
private int lastTouchDownTime = 0, lastTouchUpTime = 0;
private Point iniP = new Point(0, 0);
private void Main_Grid_TouchDown(object sender, TouchEventArgs e) {
SetCursorBasedOnEditingMode(inkCanvas);
inkCanvas.CaptureTouch(e.TouchDevice);
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
// 橡皮状态下只return,保证橡皮状态可保持
return;
}
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select) {
// 套索选状态下只return,保证套索选可用
return;
}
if (drawingShapeMode == 9) {
if (isFirstTouchCuboid) {
CuboidFrontRectIniP = e.GetTouchPoint(inkCanvas).Position;
}
// 允许MouseTouchMove在TouchMove时处理
return;
}
if (drawingShapeMode != 0) {
return;
}
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink) {
return;
}
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
}
}
// 手掌擦相关变量
private bool isPalmEraserActive;
private InkCanvasEditingMode palmEraserLastEditingMode = InkCanvasEditingMode.Ink;
private bool palmEraserLastIsHighlighter;
private bool palmEraserWasEnabledBeforeMultiTouch;
private void inkCanvas_PreviewTouchDown(object sender, TouchEventArgs e) {
// 橡皮状态下不做任何切换,直接return,保证橡皮可持续
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
return;
}
SetCursorBasedOnEditingMode(inkCanvas);
inkCanvas.CaptureTouch(e.TouchDevice);
ViewboxFloatingBar.IsHitTestVisible = false;
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
dec.Add(e.TouchDevice.Id);
// Palm Eraser 逻辑
if (Settings.Canvas.EnablePalmEraser && dec.Count >= 2 && !isPalmEraserActive) {
var bounds = e.GetTouchPoint(inkCanvas).Bounds;
double palmThreshold = 40; // 触摸面积阈值,可根据实际调整
if (bounds.Width >= palmThreshold || bounds.Height >= palmThreshold) {
// 记录当前编辑模式和高光状态
palmEraserLastEditingMode = inkCanvas.EditingMode;
palmEraserLastIsHighlighter = drawingAttributes.IsHighlighter;
// 切换为橡皮擦
EraserIcon_Click(null, null);
isPalmEraserActive = true;
}
}
//设备1个的时候,记录中心点
if (dec.Count == 1) {
var touchPoint = e.GetTouchPoint(inkCanvas);
centerPoint = touchPoint.Position;
// 新增:几何绘制模式下,记录初始点
if (drawingShapeMode != 0) {
iniP = touchPoint.Position;
}
//记录第一根手指点击时的 StrokeCollection
lastTouchDownStrokeCollection = inkCanvas.Strokes.Clone();
}
//设备两个及两个以上,将画笔功能关闭
if (dec.Count > 1 || isSingleFingerDragMode || !Settings.Gesture.IsEnableTwoFingerGesture) {
if (isInMultiTouchMode || !Settings.Gesture.IsEnableTwoFingerGesture) return;
if (inkCanvas.EditingMode == InkCanvasEditingMode.None ||
inkCanvas.EditingMode == InkCanvasEditingMode.Select) return;
lastInkCanvasEditingMode = inkCanvas.EditingMode;
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
inkCanvas.EditingMode = InkCanvasEditingMode.None;
}
}
}
private void inkCanvas_PreviewTouchUp(object sender, TouchEventArgs e) {
// 橡皮状态下不做任何切换,直接return,保证橡皮可持续
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint && !isPalmEraserActive) {
return;
}
inkCanvas.ReleaseAllTouchCaptures();
ViewboxFloatingBar.IsHitTestVisible = true;
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
// Palm Eraser 逻辑:所有点抬起后恢复原编辑模式
dec.Remove(e.TouchDevice.Id);
if (isPalmEraserActive && dec.Count == 0) {
// 恢复高光状态
drawingAttributes.IsHighlighter = palmEraserLastIsHighlighter;
// 恢复编辑模式
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
if (palmEraserLastEditingMode == InkCanvasEditingMode.Ink) {
PenIcon_Click(null, null);
} else if (palmEraserLastEditingMode == InkCanvasEditingMode.Select) {
SymbolIconSelect_MouseUp(null, null);
} else {
inkCanvas.EditingMode = palmEraserLastEditingMode;
}
}
isPalmEraserActive = false;
}
// 新增:几何绘制模式下,触摸抬手时自动落笔
if (drawingShapeMode != 0) {
var mouseArgs = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left)
{
RoutedEvent = MouseLeftButtonUpEvent,
Source = inkCanvas
};
inkCanvas_MouseUp(inkCanvas, mouseArgs);
}
//手势完成后切回之前的状态
// 修复:改进多指手势恢复逻辑,确保从橡皮擦切换到笔时多指手势能正确恢复
if (dec.Count > 1) {
if (inkCanvas.EditingMode == InkCanvasEditingMode.None) {
if (lastInkCanvasEditingMode != InkCanvasEditingMode.EraseByPoint) {
inkCanvas.EditingMode = lastInkCanvasEditingMode;
}
}
} else if (dec.Count == 0) {
// 当所有触摸点都抬起时,确保正确恢复编辑模式
// 这对于从橡皮擦切换到笔后恢复多指手势功能很重要
if (inkCanvas.EditingMode == InkCanvasEditingMode.None &&
lastInkCanvasEditingMode != InkCanvasEditingMode.None &&
lastInkCanvasEditingMode != InkCanvasEditingMode.EraseByPoint) {
inkCanvas.EditingMode = lastInkCanvasEditingMode;
}
}
inkCanvas.Opacity = 1;
if (dec.Count == 0)
if (lastTouchDownStrokeCollection.Count() != inkCanvas.Strokes.Count() &&
!(drawingShapeMode == 9 && !isFirstTouchCuboid)) {
var whiteboardIndex = CurrentWhiteboardIndex;
if (currentMode == 0) whiteboardIndex = 0;
strokeCollections[whiteboardIndex] = lastTouchDownStrokeCollection;
}
}
private void inkCanvas_ManipulationStarting(object sender, ManipulationStartingEventArgs e) {
e.Mode = ManipulationModes.All;
}
private void inkCanvas_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e) { }
private void Main_Grid_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) {
if (e.Manipulators.Count() != 0) return;
if (drawingShapeMode == 0 && inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
// 修复:确保多指手势完成后正确更新lastInkCanvasEditingMode
lastInkCanvasEditingMode = InkCanvasEditingMode.Ink;
}
}
private void Main_Grid_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) {
// 手掌擦时禁止移动/缩放
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
return;
// 三指及以上禁止缩放
bool disableScale = dec.Count >= 3;
if (isInMultiTouchMode || !Settings.Gesture.IsEnableTwoFingerGesture) return;
if ((dec.Count >= 2 && (Settings.PowerPointSettings.IsEnableTwoFingerGestureInPresentationMode ||
StackPanelPPTControls.Visibility != Visibility.Visible ||
StackPanelPPTButtons.Visibility == Visibility.Collapsed)) ||
isSingleFingerDragMode) {
var md = e.DeltaManipulation;
var trans = md.Translation; // 获得位移矢量
var m = new Matrix();
if (Settings.Gesture.IsEnableTwoFingerTranslate)
m.Translate(trans.X, trans.Y); // 移动
if (Settings.Gesture.IsEnableTwoFingerGestureTranslateOrRotation) {
var rotate = md.Rotation; // 获得旋转角度
var scale = md.Scale; // 获得缩放倍数
// Find center of element and then transform to get current location of center
var fe = e.Source as FrameworkElement;
var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
if (Settings.Gesture.IsEnableTwoFingerRotation)
m.RotateAt(rotate, center.X, center.Y); // 旋转
if (Settings.Gesture.IsEnableTwoFingerZoom && !disableScale)
m.ScaleAt(scale.X, scale.Y, center.X, center.Y); // 缩放
}
var strokes = inkCanvas.GetSelectedStrokes();
if (strokes.Count != 0) {
foreach (var stroke in strokes) {
stroke.Transform(m, false);
foreach (var circle in circles)
if (stroke == circle.Stroke) {
circle.R = GetDistance(circle.Stroke.StylusPoints[0].ToPoint(),
circle.Stroke.StylusPoints[circle.Stroke.StylusPoints.Count / 2].ToPoint()) / 2;
circle.Centroid = new Point(
(circle.Stroke.StylusPoints[0].X +
circle.Stroke.StylusPoints[circle.Stroke.StylusPoints.Count / 2].X) / 2,
(circle.Stroke.StylusPoints[0].Y +
circle.Stroke.StylusPoints[circle.Stroke.StylusPoints.Count / 2].Y) / 2);
break;
}
if (!Settings.Gesture.IsEnableTwoFingerZoom) continue;
try {
stroke.DrawingAttributes.Width *= md.Scale.X;
stroke.DrawingAttributes.Height *= md.Scale.Y;
}
catch { }
}
}
else {
if (Settings.Gesture.IsEnableTwoFingerZoom) {
foreach (var stroke in inkCanvas.Strokes) {
stroke.Transform(m, false);
try {
stroke.DrawingAttributes.Width *= md.Scale.X;
stroke.DrawingAttributes.Height *= md.Scale.Y;
}
catch { }
}
;
}
else {
foreach (var stroke in inkCanvas.Strokes) stroke.Transform(m, false);
;
}
foreach (var circle in circles) {
circle.R = GetDistance(circle.Stroke.StylusPoints[0].ToPoint(),
circle.Stroke.StylusPoints[circle.Stroke.StylusPoints.Count / 2].ToPoint()) / 2;
circle.Centroid = new Point(
(circle.Stroke.StylusPoints[0].X +
circle.Stroke.StylusPoints[circle.Stroke.StylusPoints.Count / 2].X) / 2,
(circle.Stroke.StylusPoints[0].Y +
circle.Stroke.StylusPoints[circle.Stroke.StylusPoints.Count / 2].Y) / 2
);
}
}
}
}
// 退出多指书写模式,恢复InkCanvas的TouchDown事件绑定
private void ExitMultiTouchModeIfNeeded()
{
if (isInMultiTouchMode)
{
inkCanvas.StylusDown -= MainWindow_StylusDown;
inkCanvas.StylusMove -= MainWindow_StylusMove;
inkCanvas.StylusUp -= MainWindow_StylusUp;
inkCanvas.TouchDown -= MainWindow_TouchDown;
inkCanvas.TouchDown += Main_Grid_TouchDown;
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint)
{
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
}
// 保存非笔画元素(如图片)
var preservedElements = PreserveNonStrokeElements();
inkCanvas.Children.Clear();
// 恢复非笔画元素
RestoreNonStrokeElements(preservedElements);
isInMultiTouchMode = false;
// 关闭多指书写时,恢复手掌擦开关
if (palmEraserWasEnabledBeforeMultiTouch) {
Settings.Canvas.EnablePalmEraser = true;
if (ToggleSwitchEnablePalmEraser != null)
ToggleSwitchEnablePalmEraser.IsOn = true;
}
}
}
// 进入多指书写模式,绑定Main_Grid_TouchDown
private void EnterMultiTouchModeIfNeeded()
{
if (!isInMultiTouchMode)
{
inkCanvas.StylusDown += MainWindow_StylusDown;
inkCanvas.StylusMove += MainWindow_StylusMove;
inkCanvas.StylusUp += MainWindow_StylusUp;
inkCanvas.TouchDown += MainWindow_TouchDown;
inkCanvas.TouchDown -= Main_Grid_TouchDown;
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint)
{
inkCanvas.EditingMode = InkCanvasEditingMode.None;
}
// 保存非笔画元素(如图片)
var preservedElements = PreserveNonStrokeElements();
inkCanvas.Children.Clear();
// 恢复非笔画元素
RestoreNonStrokeElements(preservedElements);
isInMultiTouchMode = true;
// 启用多指书写时,自动禁用手掌擦
palmEraserWasEnabledBeforeMultiTouch = Settings.Canvas.EnablePalmEraser;
Settings.Canvas.EnablePalmEraser = false;
if (ToggleSwitchEnablePalmEraser != null)
ToggleSwitchEnablePalmEraser.IsOn = false;
}
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

@@ -1,44 +0,0 @@
<Window x:Class="Ink_Canvas.AddCustomIconWindow"
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"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:local="clr-namespace:Ink_Canvas"
mc:Ignorable="d"
Title="添加自定义图标" Height="500" Width="750" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="添加自定义浮动栏图标" FontSize="18" FontWeight="Bold" Margin="0,0,0,15" Grid.Row="0"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,0,0,20">
<TextBlock Text="选择图标文件:" VerticalAlignment="Center" FontSize="14"/>
<TextBox Name="IconPathTextBox" Width="220" IsReadOnly="True" Margin="10,0" Height="25"/>
<Button Content="浏览..." Click="BrowseButton_Click" Width="80" Height="45"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,0,0,20">
<TextBlock Text="图标名称:" VerticalAlignment="Center" FontSize="14"/>
<TextBox Name="IconNameTextBox" Width="280" Margin="28,0,0,0" Height="25"/>
</StackPanel>
<TextBlock Grid.Row="3" Text="预览:" Margin="0,0,0,8" FontSize="14"/>
<Border Grid.Row="4" BorderBrush="#CCCCCC" BorderThickness="1" Padding="8" HorizontalAlignment="Left" VerticalAlignment="Top">
<Image Name="IconPreviewImage" Width="72" Height="72" Stretch="Uniform"/>
</Border>
<StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,25,0,0">
<Button Content="取消" Width="100" Height="30" Click="CancelButton_Click" Margin="0,0,15,0"/>
<Button Name="SaveButton" Content="保存" Width="100" Height="30" Click="SaveButton_Click" IsEnabled="False"/>
</StackPanel>
</Grid>
</Window>
@@ -1,120 +0,0 @@
using System;
using System.IO;
using System.Windows;
using System.Windows.Media.Imaging;
using Microsoft.Win32;
namespace Ink_Canvas
{
/// <summary>
/// AddCustomIconWindow.xaml 的交互逻辑
/// </summary>
public partial class AddCustomIconWindow : Window
{
private MainWindow mainWindow;
private string selectedFilePath;
public bool IsSuccess { get; private set; }
public AddCustomIconWindow(MainWindow owner)
{
InitializeComponent();
mainWindow = owner;
IsSuccess = false;
// 添加TextBox内容变化事件以检查是否可以保存
IconNameTextBox.TextChanged += (s, e) => ValidateSaveButton();
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "图像文件|*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.ico",
Title = "选择一个图标文件"
};
if (openFileDialog.ShowDialog() == true)
{
selectedFilePath = openFileDialog.FileName;
IconPathTextBox.Text = selectedFilePath;
// 显示预览
try
{
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(selectedFilePath);
bitmap.EndInit();
IconPreviewImage.Source = bitmap;
}
catch (Exception ex)
{
MessageBox.Show($"无法加载图像: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
// 自动填充名称建议(文件名,不包括扩展名)
string suggestedName = Path.GetFileNameWithoutExtension(selectedFilePath);
IconNameTextBox.Text = suggestedName;
ValidateSaveButton();
}
}
private void ValidateSaveButton()
{
SaveButton.IsEnabled = !string.IsNullOrWhiteSpace(IconNameTextBox.Text) && !string.IsNullOrEmpty(selectedFilePath);
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void SaveButton_Click(object sender, RoutedEventArgs e)
{
try
{
// 创建pictures/icons文件夹结构(如果不存在)
string picturesFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "pictures");
string iconsFolder = Path.Combine(picturesFolder, "icons");
if (!Directory.Exists(picturesFolder))
{
Directory.CreateDirectory(picturesFolder);
}
if (!Directory.Exists(iconsFolder))
{
Directory.CreateDirectory(iconsFolder);
}
// 生成一个唯一的文件名(使用GUID)
string extension = Path.GetExtension(selectedFilePath);
string newFileName = $"{Guid.NewGuid()}{extension}";
string destPath = Path.Combine(iconsFolder, newFileName);
// 复制文件到pictures/icons文件夹
File.Copy(selectedFilePath, destPath);
// 创建新的自定义图标对象
var customIcon = new CustomFloatingBarIcon(IconNameTextBox.Text, destPath);
// 添加到主窗口的设置中
MainWindow.Settings.Appearance.CustomFloatingBarImgs.Add(customIcon);
// 更新ComboBox
mainWindow.UpdateCustomIconsInComboBox();
// 保存设置
MainWindow.SaveSettingsToFile();
IsSuccess = true;
Close();
}
catch (Exception ex)
{
MessageBox.Show($"保存图标时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
@@ -1,48 +0,0 @@
<Window x:Class="Ink_Canvas.AddPickNameBackgroundWindow"
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"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:local="clr-namespace:Ink_Canvas"
mc:Ignorable="d"
Title="添加自定义点名背景" Height="550" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="添加自定义点名背景" FontSize="20" FontWeight="Bold" Margin="0,0,0,20" Grid.Row="0"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,0,0,20">
<TextBlock Text="选择背景图片:" VerticalAlignment="Center" FontSize="14"/>
<TextBox Name="BackgroundPathTextBox" Width="400" IsReadOnly="True" Margin="10,0" Height="25"/>
<Button Content="浏览..." Click="BrowseButton_Click" Width="100" Height="45"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,0,0,20">
<TextBlock Text="背景名称:" VerticalAlignment="Center" FontSize="14"/>
<TextBox Name="BackgroundNameTextBox" Width="400" Margin="28,0,0,0" Height="25"/>
</StackPanel>
<TextBlock Grid.Row="3" Text="预览:" Margin="0,0,0,10" FontSize="14"/>
<Border Grid.Row="4" BorderBrush="#CCCCCC" BorderThickness="1" Padding="8">
<Grid>
<Image Name="BackgroundPreviewImage" Stretch="Uniform" MaxHeight="250"/>
<TextBlock Text="未选择图片" HorizontalAlignment="Center" VerticalAlignment="Center"
Foreground="Gray" FontSize="16" Name="NoImageText"/>
</Grid>
</Border>
<StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,25,0,0">
<Button Content="取消" Width="120" Height="40" Click="CancelButton_Click" Margin="0,0,15,0"/>
<Button Name="SaveButton" Content="保存" Width="120" Height="40" Click="SaveButton_Click" IsEnabled="False"/>
</StackPanel>
</Grid>
</Window>
@@ -1,121 +0,0 @@
using System;
using System.IO;
using System.Windows;
using System.Windows.Media.Imaging;
using Microsoft.Win32;
namespace Ink_Canvas
{
/// <summary>
/// AddPickNameBackgroundWindow.xaml 的交互逻辑
/// </summary>
public partial class AddPickNameBackgroundWindow : Window
{
private MainWindow mainWindow;
private string selectedFilePath;
public bool IsSuccess { get; private set; }
public AddPickNameBackgroundWindow(MainWindow owner)
{
InitializeComponent();
mainWindow = owner;
IsSuccess = false;
// 添加TextBox内容变化事件以检查是否可以保存
BackgroundNameTextBox.TextChanged += (s, e) => ValidateSaveButton();
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "图像文件|*.png;*.jpg;*.jpeg;*.bmp;*.gif",
Title = "选择一个背景图片"
};
if (openFileDialog.ShowDialog() == true)
{
selectedFilePath = openFileDialog.FileName;
BackgroundPathTextBox.Text = selectedFilePath;
// 显示预览
try
{
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(selectedFilePath);
bitmap.EndInit();
BackgroundPreviewImage.Source = bitmap;
NoImageText.Visibility = Visibility.Collapsed;
}
catch (Exception ex)
{
MessageBox.Show($"无法加载图像: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
// 自动填充名称建议(文件名,不包括扩展名)
string suggestedName = Path.GetFileNameWithoutExtension(selectedFilePath);
BackgroundNameTextBox.Text = suggestedName;
ValidateSaveButton();
}
}
private void ValidateSaveButton()
{
SaveButton.IsEnabled = !string.IsNullOrWhiteSpace(BackgroundNameTextBox.Text) && !string.IsNullOrEmpty(selectedFilePath);
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void SaveButton_Click(object sender, RoutedEventArgs e)
{
try
{
// 创建pictures/picknamebackgrounds文件夹结构(如果不存在)
string picturesFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "pictures");
string backgroundsFolder = Path.Combine(picturesFolder, "picknamebackgrounds");
if (!Directory.Exists(picturesFolder))
{
Directory.CreateDirectory(picturesFolder);
}
if (!Directory.Exists(backgroundsFolder))
{
Directory.CreateDirectory(backgroundsFolder);
}
// 生成一个唯一的文件名(使用GUID)
string extension = Path.GetExtension(selectedFilePath);
string newFileName = $"{Guid.NewGuid()}{extension}";
string destPath = Path.Combine(backgroundsFolder, newFileName);
// 复制文件到pictures/picknamebackgrounds文件夹
File.Copy(selectedFilePath, destPath);
// 创建新的自定义背景对象
var customBackground = new CustomPickNameBackground(BackgroundNameTextBox.Text, destPath);
// 添加到主窗口的设置中
MainWindow.Settings.RandSettings.CustomPickNameBackgrounds.Add(customBackground);
// 更新ComboBox
mainWindow.UpdatePickNameBackgroundsInComboBox();
// 保存设置
MainWindow.SaveSettingsToFile();
IsSuccess = true;
Close();
}
catch (Exception ex)
{
MessageBox.Show($"保存背景时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
-45
View File
@@ -1,45 +0,0 @@
<Window x:Class="Ink_Canvas.CustomIconWindow"
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"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:local="clr-namespace:Ink_Canvas"
mc:Ignorable="d"
Title="自定义浮动栏图标" Height="450" Width="500" WindowStartupLocation="CenterScreen">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="自定义浮动栏图标管理" FontSize="20" FontWeight="Bold" Margin="0,0,0,15"/>
<ListView Grid.Row="1" Name="CustomIconsListView" BorderBrush="#CCCCCC" BorderThickness="1">
<ListView.View>
<GridView>
<GridViewColumn Header="预览" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding FilePath}" Width="32" Height="32"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="名称" Width="200" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Header="操作" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Content="删除" Click="DeleteCustomIcon_Click" Tag="{Binding}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,15,0,0">
<Button Content="关闭" Width="80" Click="CloseButton_Click"/>
</StackPanel>
</Grid>
</Window>
@@ -1,61 +0,0 @@
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
namespace Ink_Canvas
{
/// <summary>
/// CustomIconWindow.xaml 的交互逻辑
/// </summary>
public partial class CustomIconWindow : Window
{
private MainWindow mainWindow;
public ObservableCollection<CustomFloatingBarIcon> CustomIcons { get; set; }
public CustomIconWindow(MainWindow owner)
{
InitializeComponent();
mainWindow = owner;
// 从主窗口的设置获取自定义图标列表
CustomIcons = new ObservableCollection<CustomFloatingBarIcon>(MainWindow.Settings.Appearance.CustomFloatingBarImgs);
CustomIconsListView.ItemsSource = CustomIcons;
}
private void DeleteCustomIcon_Click(object sender, RoutedEventArgs e)
{
if (sender is Button button && button.Tag is CustomFloatingBarIcon icon)
{
// 从列表中移除图标
CustomIcons.Remove(icon);
// 更新主窗口的设置
MainWindow.Settings.Appearance.CustomFloatingBarImgs.Clear();
foreach (var customIcon in CustomIcons)
{
MainWindow.Settings.Appearance.CustomFloatingBarImgs.Add(customIcon);
}
// 如果当前选中的是被删除的图标,重置为默认图标
if (MainWindow.Settings.Appearance.FloatingBarImg >= 8 &&
MainWindow.Settings.Appearance.FloatingBarImg - 8 >= MainWindow.Settings.Appearance.CustomFloatingBarImgs.Count)
{
MainWindow.Settings.Appearance.FloatingBarImg = 0;
mainWindow.ComboBoxFloatingBarImg.SelectedIndex = 0;
mainWindow.UpdateFloatingBarIcon();
}
// 更新ComboBox
mainWindow.UpdateCustomIconsInComboBox();
// 保存设置
MainWindow.SaveSettingsToFile();
}
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}
@@ -1,90 +0,0 @@
<Window x:Class="Ink_Canvas.HasNewUpdateWindow"
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"
xmlns:local="clr-namespace:Ink_Canvas"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
mc:Ignorable="d"
ui:WindowHelper.UseModernWindowStyle = "True"
ui:WindowHelper.SystemBackdropType="Mica"
ui:TitleBar.Height="36"
Title="InkCanvasForClass CE有新版本可用" Height="600" Width="850" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<Grid Background="#fafafa" Margin="0,0,0,30">
<ui:SimpleStackPanel VerticalAlignment="Stretch" Spacing="0">
<!-- 标题栏 -->
<ui:SimpleStackPanel Orientation="Horizontal" Background="#2563eb" Margin="0,0,0,0">
<ui:SimpleStackPanel Orientation="Vertical" Width="735" Margin="24,18,0,12" Spacing="2">
<TextBlock Text="InkCanvasForClass CE新版本来了!" FontSize="24" FontWeight="Bold" Foreground="White" TextAlignment="Left"/>
<TextBlock Text="希望您能喜欢我们的新版本 :-)" FontSize="20" TextAlignment="Left" Foreground="White"/>
</ui:SimpleStackPanel>
<Image Source="/Resources/Icons-fluent/party.png" Width="72" Height="72"/>
</ui:SimpleStackPanel>
<!-- 更新内容 -->
<Border BorderBrush="#3f3f46" Background="White" BorderThickness="1" CornerRadius="4" Margin="24,16,24,0">
<ui:ScrollViewerEx Margin="0" VerticalScrollBarVisibility="Auto" Height="180" PanningMode="VerticalOnly">
<mdxam:MarkdownScrollViewer x:Name="markdownContent" xml:space="preserve" Foreground="Black" MarkdownStyleName="GithubLike">
# InkCanvasForClass v5.0.2更新
你好,旅行者们,本次InkCanvasForClass Community Edition更新带来了如下新功能供您探索:
1. 全新设计的UI界面,包括浮动工具栏和白板页面均经过重新设计,更加现代化的UI让您在使用的过程中更加舒适。
2. 带来了实时修改橡皮大小和橡皮形状的菜单。您可以选择使用圆形橡皮,方形橡皮,和类似希沃白板的真实黑板擦(矩形)橡皮。
3. 白板页面支持显示当前时间和日期
4. 自动收纳新增对希沃轻白板、智绘教、鸿合屏幕书写等软件的支持,自动查杀新增对鸿合屏幕书写、希沃轻白板等软件的支持。
5. 为设置界面重写了全新的UI。
6. 重写了随机抽选模块,现在支持更丰富的抽选机制和自定义选项。
7. 修复了部分小Bug,提升了整体的用户体验。
8. 带来了基于FitToCurve的笔迹平滑,基于贝塞尔曲线平滑,让墨迹线条更加优美好看。
</mdxam:MarkdownScrollViewer>
</ui:ScrollViewerEx>
</Border>
<!-- 版本信息 -->
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="16" Margin="0,16,0,0">
<TextBlock x:Name="updateVersionInfo" Text="本次更新: 4.9.1 -> 5.9.1" FontWeight="Bold" FontSize="15" TextAlignment="Center"/>
<TextBlock x:Name="updateDateInfo" Text="2024年8月4日发布更新" FontSize="15" TextAlignment="Center"/>
</ui:SimpleStackPanel>
<!-- 更新按钮组 -->
<Border Background="#f1f5f9" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="4" Margin="24,16,24,20">
<ui:SimpleStackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="14" Margin="0,16,0,16">
<TextBlock Text="请选择更新方式" FontWeight="Bold" FontSize="16" HorizontalAlignment="Center" Margin="0,0,0,6"/>
<!-- 立即更新按钮 -->
<Button x:Name="UpdateNowButton" Content="立刻下载并安装" Foreground="White" FontSize="15" FontWeight="SemiBold"
Padding="20,10" Width="360" Height="48" HorizontalAlignment="Center"
Click="UpdateNowButton_Click" ToolTip="立即下载更新并在完成后安装" Visibility="Visible" IsEnabled="True">
<Button.Resources>
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundKey}" Color="#15803d"/>
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPointerOverKey}" Color="#15803d"/>
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPressedKey}" Color="#166534"/>
</Button.Resources>
</Button>
<!-- 稍后更新按钮 -->
<Button x:Name="UpdateLaterButton" Content="下载并在软件关闭时安装" Foreground="Black" FontSize="15"
Padding="20,10" Width="360" Height="48" HorizontalAlignment="Center"
Click="UpdateLaterButton_Click" Background="#e2e8f0" BorderBrush="#cbd5e1"
ToolTip="后台下载更新,在软件关闭时自动安装" Visibility="Visible" IsEnabled="True"/>
<!-- 跳过版本按钮 -->
<Button x:Name="SkipVersionButton" Content="跳过该版本" HorizontalAlignment="Center" Foreground="#71717a"
FontSize="15" Padding="20,10" Width="360" Height="48" Click="SkipVersionButton_Click"
Background="#f8fafc" BorderBrush="#cbd5e1" ToolTip="跳过此版本更新" Visibility="Visible" IsEnabled="True"/>
</ui:SimpleStackPanel>
</Border>
<!-- 下载进度条和状态 -->
<StackPanel x:Name="DownloadProgressPanel" Orientation="Vertical" HorizontalAlignment="Center" Margin="0,10,0,0" Visibility="Collapsed">
<ProgressBar x:Name="DownloadProgressBar" Width="360" Height="18" Minimum="0" Maximum="100" Value="0"/>
<TextBlock x:Name="DownloadProgressText" Text="正在下载..." FontSize="14" Foreground="#2563eb" HorizontalAlignment="Center" Margin="0,6,0,0"/>
</StackPanel>
</ui:SimpleStackPanel>
</Grid>
</ScrollViewer>
</Window>
@@ -1,350 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using System.Windows.Media;
using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern.Controls;
using MdXaml;
namespace Ink_Canvas
{
/// <summary>
/// HasNewUpdateWindow.xaml 的交互逻辑
/// </summary>
///
public partial class HasNewUpdateWindow : Window
{
[DllImport("dwmapi.dll")]
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
private static bool UseImmersiveDarkMode(IntPtr handle, bool enabled)
{
if (IsWindows10OrGreater(17763))
{
var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
if (IsWindows10OrGreater(18985))
{
attribute = DWMWA_USE_IMMERSIVE_DARK_MODE;
}
int useImmersiveDarkMode = enabled ? 1 : 0;
return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0;
}
return false;
}
private static bool IsWindows10OrGreater(int build = -1)
{
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build;
}
// 存储更新版本信息
public string CurrentVersion { get; set; }
public string NewVersion { get; set; }
public string ReleaseDate { get; set; }
public string ReleaseNotes { get; set; }
// 更新按钮结果
public enum UpdateResult
{
UpdateNow,
UpdateLater,
SkipVersion
}
public UpdateResult Result { get; private set; } = UpdateResult.UpdateLater;
public HasNewUpdateWindow(string currentVersion, string newVersion, string releaseDate, string releaseNotes = null)
{
InitializeComponent();
// 设置版本信息
CurrentVersion = currentVersion;
NewVersion = newVersion;
ReleaseDate = releaseDate;
ReleaseNotes = releaseNotes;
// 更新UI
updateVersionInfo.Text = $"本次更新: {CurrentVersion} -> {NewVersion}";
updateDateInfo.Text = $"{ReleaseDate}发布更新";
// 如果有发布说明,设置到Markdown内容中
if (!string.IsNullOrEmpty(ReleaseNotes))
{
markdownContent.Markdown = ReleaseNotes;
}
// 自动更新和静默更新设置已移至设置界面,此处不再需要
// 确保按钮可见且可用
EnsureButtonsVisibility();
// 显示窗口动画
AnimationsHelper.ShowWithFadeIn(this, 0.25);
// 设置深色模式
UseImmersiveDarkMode(new WindowInteropHelper(this).Handle, true);
// 窗口加载完成后再次确保按钮可见
Loaded += HasNewUpdateWindow_Loaded;
}
private void HasNewUpdateWindow_Loaded(object sender, RoutedEventArgs e)
{
// 窗口加载完成后再次确保按钮可见
EnsureButtonsVisibility();
// 调整窗口大小以适应屏幕分辨率
AdjustWindowSizeForScreenResolution();
}
// 确保按钮可见并启用
private void EnsureButtonsVisibility()
{
// 确保立即更新按钮可见
UpdateNowButton.Visibility = Visibility.Visible;
UpdateNowButton.IsEnabled = true;
// 确保稍后更新按钮可见
UpdateLaterButton.Visibility = Visibility.Visible;
UpdateLaterButton.IsEnabled = true;
// 确保跳过版本按钮可见
SkipVersionButton.Visibility = Visibility.Visible;
SkipVersionButton.IsEnabled = true;
// 强制刷新UI
UpdateLayout();
// 记录日志
LogHelper.WriteLogToFile("AutoUpdate | Update dialog buttons visibility ensured");
}
private async void UpdateNowButton_Click(object sender, RoutedEventArgs e)
{
LogHelper.WriteLogToFile("AutoUpdate | Update Now button clicked");
// 禁用按钮,显示进度条
UpdateNowButton.IsEnabled = false;
UpdateLaterButton.IsEnabled = false;
SkipVersionButton.IsEnabled = false;
DownloadProgressPanel.Visibility = Visibility.Visible;
DownloadProgressBar.Value = 0;
DownloadProgressText.Text = "正在准备下载...";
// 启动多线路下载
bool downloadSuccess = false;
try
{
// 获取当前通道的所有线路组
var groups = AutoUpdateHelper.ChannelLineGroups[MainWindow.Settings.Startup.UpdateChannel];
downloadSuccess = await AutoUpdateHelper.DownloadSetupFileWithFallback(NewVersion, groups, (percent, text) =>
{
Dispatcher.Invoke(() => {
DownloadProgressBar.Value = percent;
DownloadProgressText.Text = text;
});
});
if (downloadSuccess)
{
// 下载完成后自动安装
await DownloadAndInstallVersion(NewVersion, null, CancellationToken.None);
}
}
catch (Exception ex)
{
DownloadProgressText.Text = $"下载失败: {ex.Message}";
LogHelper.WriteLogToFile($"AutoUpdate | 下载异常: {ex.Message}", LogHelper.LogType.Error);
}
if (downloadSuccess)
{
DownloadProgressBar.Value = 100;
DownloadProgressText.Text = "下载完成,准备安装...";
await Task.Delay(800);
// 设置结果为立即更新
Result = UpdateResult.UpdateNow;
DialogResult = true;
Close();
}
else
{
DownloadProgressText.Text = "下载失败,请检查网络后重试。";
UpdateNowButton.IsEnabled = true;
UpdateLaterButton.IsEnabled = true;
SkipVersionButton.IsEnabled = true;
}
}
private void UpdateLaterButton_Click(object sender, RoutedEventArgs e)
{
LogHelper.WriteLogToFile("AutoUpdate | Update Later button clicked");
// 设置结果为稍后更新
Result = UpdateResult.UpdateLater;
// 关闭窗口
DialogResult = true;
Close();
}
private void SkipVersionButton_Click(object sender, RoutedEventArgs e)
{
LogHelper.WriteLogToFile("AutoUpdate | Skip Version button clicked");
// 设置结果为跳过该版本
Result = UpdateResult.SkipVersion;
// 关闭窗口
DialogResult = true;
Close();
}
// 根据屏幕分辨率调整窗口大小
private void AdjustWindowSizeForScreenResolution()
{
try
{
// 获取主屏幕分辨率
double screenWidth = SystemParameters.PrimaryScreenWidth;
double screenHeight = SystemParameters.PrimaryScreenHeight;
LogHelper.WriteLogToFile($"AutoUpdate | Screen resolution: {screenWidth}x{screenHeight}");
// 始终确保窗口不超过屏幕大小的85%
double maxHeight = screenHeight * 0.85;
double maxWidth = screenWidth * 0.85;
bool needsAdjustment = false;
// 如果窗口高度超过最大允许高度,调整窗口高度
if (Height > maxHeight)
{
Height = maxHeight;
needsAdjustment = true;
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window height to: {Height}");
}
// 如果窗口宽度超过最大允许宽度,调整窗口宽度
if (Width > maxWidth)
{
Width = maxWidth;
needsAdjustment = true;
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window width to: {Width}");
}
// 如果屏幕分辨率较低,调整更多UI元素
if (screenHeight < 768 || screenWidth < 1024 || needsAdjustment)
{
// 查找相关控件并调整大小
var markdownViewer = FindName("markdownContent") as MarkdownScrollViewer;
var updateNowButton = FindName("UpdateNowButton") as Button;
var updateLaterButton = FindName("UpdateLaterButton") as Button;
var skipVersionButton = FindName("SkipVersionButton") as Button;
// 查找包含ScrollViewer的边框控件,减小其高度
var contentBorders = FindVisualChildren<Border>().ToList();
foreach (var border in contentBorders)
{
if (border.Child is ScrollViewer || border.Child is ScrollViewerEx)
{
// 减小内容显示区域的高度
if (border.Height > 180)
{
border.Height = 160;
LogHelper.WriteLogToFile("AutoUpdate | Reduced content area height");
}
else if (border.Child is ScrollViewerEx scrollViewer && scrollViewer.Height > 160)
{
scrollViewer.Height = 160;
LogHelper.WriteLogToFile("AutoUpdate | Reduced scroll viewer height");
}
}
}
// 调整按钮大小
if (updateNowButton != null && updateLaterButton != null && skipVersionButton != null)
{
updateNowButton.Height = 42;
updateLaterButton.Height = 42;
skipVersionButton.Height = 42;
updateNowButton.Padding = new Thickness(15, 8, 15, 8);
updateLaterButton.Padding = new Thickness(15, 8, 15, 8);
skipVersionButton.Padding = new Thickness(15, 8, 15, 8);
LogHelper.WriteLogToFile("AutoUpdate | Reduced button sizes for small screen");
}
}
// 确保窗口在屏幕范围内
if (Left < 0) Left = 0;
if (Top < 0) Top = 0;
if (Left + Width > screenWidth) Left = screenWidth - Width;
if (Top + Height > screenHeight) Top = screenHeight - Height;
LogHelper.WriteLogToFile($"AutoUpdate | Final window size: {Width}x{Height}");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"AutoUpdate | Error adjusting window size: {ex.Message}", LogHelper.LogType.Error);
}
}
// 递归查找指定类型的所有子控件
private IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj = null) where T : DependencyObject
{
if (depObj == null)
depObj = this;
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
yield return (T)child;
}
foreach (T childOfChild in FindVisualChildren<T>(child))
{
yield return childOfChild;
}
}
}
}
// 多线程分块下载并自动安装
private async Task<bool> DownloadAndInstallVersion(string version, string downloadUrl, CancellationToken token)
{
if (string.IsNullOrEmpty(downloadUrl))
{
// 自动更新场景下,downloadUrl为null,直接用主下载目录
string updatesFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate");
downloadUrl = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.{version}.zip");
}
LogHelper.WriteLogToFile($"AutoUpdate | 开始安装版本: {version}");
AutoUpdateHelper.InstallNewVersionApp(version, false);
App.IsAppExitByUser = true;
Application.Current.Dispatcher.Invoke(() => {
Application.Current.Shutdown();
});
return true;
}
}
}
@@ -1,24 +0,0 @@
<Window x:Class="Ink_Canvas.HistoryRollbackWindow"
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"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
mc:Ignorable="d"
Title="历史版本回滚" Height="600" Width="850" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid Background="#fafafa">
<ui:SimpleStackPanel VerticalAlignment="Stretch" Spacing="0">
<TextBlock Text="选择历史版本进行回滚" FontSize="24" FontWeight="Bold" Foreground="#2563eb" Margin="24,24,0,12"/>
<ComboBox x:Name="VersionComboBox" Width="400" Height="36" Margin="24,0,0,0" DisplayMemberPath="Version" SelectionChanged="VersionComboBox_SelectionChanged"/>
<Border BorderBrush="#3f3f46" Background="White" BorderThickness="1" CornerRadius="4" Margin="24,16,24,0" Height="180">
<mdxam:MarkdownScrollViewer x:Name="ReleaseNotesViewer" Foreground="Black" MarkdownStyleName="GithubLike"/>
</Border>
<Button x:Name="RollbackButton" Content="回滚到此版本" Width="360" Height="48" Margin="24,24,0,0" Click="RollbackButton_Click"/>
<StackPanel x:Name="DownloadProgressPanel" Orientation="Vertical" HorizontalAlignment="Center" Margin="0,10,0,0" Visibility="Collapsed">
<ProgressBar x:Name="DownloadProgressBar" Width="360" Height="18" Minimum="0" Maximum="100" Value="0"/>
<TextBlock x:Name="DownloadProgressText" Text="正在下载..." FontSize="14" Foreground="#2563eb" HorizontalAlignment="Center" Margin="0,6,0,0"/>
</StackPanel>
</ui:SimpleStackPanel>
</Grid>
</Window>
@@ -1,142 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Ink_Canvas.Helpers;
// Added for OrderByDescending
namespace Ink_Canvas
{
public partial class HistoryRollbackWindow : Window
{
private class VersionItem
{
public string Version { get; set; }
public string DownloadUrl { get; set; }
public string ReleaseNotes { get; set; }
}
private List<VersionItem> versionList = new List<VersionItem>();
private VersionItem selectedItem;
private UpdateChannel channel = UpdateChannel.Release;
private CancellationTokenSource downloadCts = null;
public HistoryRollbackWindow(UpdateChannel channel = UpdateChannel.Release)
{
InitializeComponent();
this.channel = channel;
LoadVersions();
}
private async void LoadVersions()
{
LogHelper.WriteLogToFile($"HistoryRollback | 开始加载历史版本,通道: {channel}");
RollbackButton.IsEnabled = false;
VersionComboBox.Items.Clear();
DownloadProgressPanel.Visibility = Visibility.Collapsed;
DownloadProgressBar.Value = 0;
DownloadProgressText.Text = "";
ReleaseNotesViewer.Markdown = "正在获取历史版本...";
var releases = await AutoUpdateHelper.GetAllGithubReleases(channel);
versionList.Clear();
foreach (var (version, url, notes) in releases)
{
versionList.Add(new VersionItem { Version = version, DownloadUrl = url, ReleaseNotes = notes });
}
// 按版本号数字降序排列
versionList = versionList.OrderByDescending(v => ParseVersionForSort(v.Version)).ToList();
VersionComboBox.ItemsSource = versionList;
if (versionList.Count > 0)
{
VersionComboBox.SelectedIndex = 0;
RollbackButton.IsEnabled = true;
LogHelper.WriteLogToFile($"HistoryRollback | 加载到 {versionList.Count} 个历史版本");
}
else
{
ReleaseNotesViewer.Markdown = "未获取到历史版本信息。";
LogHelper.WriteLogToFile("HistoryRollback | 未获取到历史版本信息", LogHelper.LogType.Warning);
}
}
// 辅助方法:解析版本号用于排序
private Version ParseVersionForSort(string version)
{
var v = version.TrimStart('v', 'V');
Version result;
if (Version.TryParse(v, out result))
return result;
return new Version(0, 0, 0, 0);
}
private void VersionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
selectedItem = VersionComboBox.SelectedItem as VersionItem;
if (selectedItem != null)
{
ReleaseNotesViewer.Markdown = selectedItem.ReleaseNotes ?? "无更新日志";
LogHelper.WriteLogToFile($"HistoryRollback | 用户选择版本: {selectedItem.Version}");
}
// 取消聚焦,防止父级自动滚动
Keyboard.ClearFocus();
}
private async void RollbackButton_Click(object sender, RoutedEventArgs e)
{
if (selectedItem == null) return;
LogHelper.WriteLogToFile($"HistoryRollback | 用户点击回滚,目标版本: {selectedItem.Version}");
RollbackButton.IsEnabled = false;
VersionComboBox.IsEnabled = false;
DownloadProgressPanel.Visibility = Visibility.Visible;
DownloadProgressBar.Value = 0;
DownloadProgressText.Text = "正在准备下载...";
bool downloadSuccess = false;
try
{
downloadSuccess = await AutoUpdateHelper.StartManualDownloadAndInstall(
selectedItem.Version,
channel,
(percent, text) =>
{
Dispatcher.Invoke(() => {
DownloadProgressBar.Value = percent;
DownloadProgressText.Text = text;
});
}
);
}
catch (Exception ex)
{
DownloadProgressText.Text = $"下载失败: {ex.Message}";
LogHelper.WriteLogToFile($"HistoryRollback | 下载异常: {ex.Message}", LogHelper.LogType.Error);
}
if (downloadSuccess)
{
DownloadProgressBar.Value = 100;
DownloadProgressText.Text = "下载完成,准备安装...";
await Task.Delay(800);
DialogResult = true;
Close();
}
else
{
DownloadProgressText.Text = "下载失败,请检查网络后重试。";
RollbackButton.IsEnabled = true;
VersionComboBox.IsEnabled = true;
}
}
protected override void OnClosing(CancelEventArgs e)
{
downloadCts?.Cancel();
base.OnClosing(e);
}
}
}
@@ -1,50 +0,0 @@
<Window x:Class="Ink_Canvas.ManagePickNameBackgroundsWindow"
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"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:local="clr-namespace:Ink_Canvas"
mc:Ignorable="d"
Title="管理点名背景" Height="500" Width="750" WindowStartupLocation="CenterScreen">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="管理自定义点名背景" FontSize="20" FontWeight="Bold" Margin="0,0,0,15"/>
<ListView Grid.Row="1" Name="BackgroundsListView" BorderBrush="#CCCCCC" BorderThickness="1">
<ListView.View>
<GridView>
<GridViewColumn Header="预览" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Border BorderThickness="1" BorderBrush="#CCCCCC">
<Image Source="{Binding FilePath}" Width="140" Height="80" Stretch="Uniform"/>
</Border>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="名称" Width="300" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Header="操作" Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="设为当前" Width="90" Margin="0,0,5,0" Click="SetAsCurrentButton_Click" Tag="{Binding}"/>
<Button Content="删除" Width="70" Click="DeleteBackgroundButton_Click" Tag="{Binding}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,15,0,0">
<Button Content="关闭" Width="120" Height="40" Click="CloseButton_Click"/>
</StackPanel>
</Grid>
</Window>
@@ -1,98 +0,0 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Windows;
using System.Windows.Controls;
namespace Ink_Canvas
{
/// <summary>
/// ManagePickNameBackgroundsWindow.xaml 的交互逻辑
/// </summary>
public partial class ManagePickNameBackgroundsWindow : Window
{
private MainWindow mainWindow;
public ObservableCollection<CustomPickNameBackground> Backgrounds { get; set; }
public ManagePickNameBackgroundsWindow(MainWindow owner)
{
InitializeComponent();
mainWindow = owner;
// 从主窗口的设置获取自定义背景列表
Backgrounds = new ObservableCollection<CustomPickNameBackground>(MainWindow.Settings.RandSettings.CustomPickNameBackgrounds);
BackgroundsListView.ItemsSource = Backgrounds;
}
private void SetAsCurrentButton_Click(object sender, RoutedEventArgs e)
{
if (sender is Button button && button.Tag is CustomPickNameBackground background)
{
// 找到背景在列表中的索引(加8,因为前8个是默认值)
int index = Backgrounds.IndexOf(background) + 1; // 增加1因为索引0将是"默认"
// 更新设置
MainWindow.Settings.RandSettings.SelectedBackgroundIndex = index;
// 更新UI
mainWindow.UpdatePickNameBackgroundDisplay();
// 保存设置
MainWindow.SaveSettingsToFile();
MessageBox.Show($"已将\"{background.Name}\"设置为当前点名背景", "设置成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
private void DeleteBackgroundButton_Click(object sender, RoutedEventArgs e)
{
if (sender is Button button && button.Tag is CustomPickNameBackground background)
{
if (MessageBox.Show($"确定要删除背景\"{background.Name}\"吗?", "确认删除", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
try
{
// 尝试删除文件
if (File.Exists(background.FilePath))
{
File.Delete(background.FilePath);
}
// 从列表中移除背景
Backgrounds.Remove(background);
// 更新主窗口的设置
MainWindow.Settings.RandSettings.CustomPickNameBackgrounds.Clear();
foreach (var bg in Backgrounds)
{
MainWindow.Settings.RandSettings.CustomPickNameBackgrounds.Add(bg);
}
// 如果当前选中的是被删除的背景,重置为默认背景
int selectedIndex = MainWindow.Settings.RandSettings.SelectedBackgroundIndex;
if (selectedIndex > 0 && selectedIndex - 1 >= MainWindow.Settings.RandSettings.CustomPickNameBackgrounds.Count)
{
MainWindow.Settings.RandSettings.SelectedBackgroundIndex = 0;
mainWindow.UpdatePickNameBackgroundDisplay();
}
// 更新ComboBox
mainWindow.UpdatePickNameBackgroundsInComboBox();
// 保存设置
MainWindow.SaveSettingsToFile();
}
catch (Exception ex)
{
MessageBox.Show($"删除背景时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}
@@ -1,154 +0,0 @@
<Window x:Class="Ink_Canvas.Windows.PluginSettingsWindow"
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"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:local="clr-namespace:Ink_Canvas.Windows"
mc:Ignorable="d"
Title="插件管理" Height="550" Width="800"
WindowStartupLocation="CenterScreen"
ResizeMode="CanResize"
Background="#F9F9F9">
<Window.Resources>
<!-- 定义必要的资源 -->
<SolidColorBrush x:Key="BorderBrush" Color="#DDDDDD"/>
<SolidColorBrush x:Key="SystemAccentColorLight1" Color="#3B82F6"/>
<SolidColorBrush x:Key="SystemAccentColor" Color="#2563EB"/>
<SolidColorBrush x:Key="SystemControlBackgroundChromeMediumBrush" Color="#F0F0F0"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 标题栏 -->
<Border Grid.Row="0" Background="{DynamicResource SystemAccentColorLight1}" Height="60">
<Grid>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="20,0,0,0">
<TextBlock Text="插件管理" FontSize="22" FontWeight="SemiBold" Foreground="White" VerticalAlignment="Center"/>
</StackPanel>
<Button x:Name="BtnClose" Content="&#xE8BB;" FontFamily="Segoe MDL2 Assets"
HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0"
Background="Transparent" BorderThickness="0" FontSize="16" Foreground="White"
Click="BtnClose_Click"/>
</Grid>
</Border>
<!-- 主内容区 -->
<Grid Grid.Row="1" Margin="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 左侧插件列表 -->
<Border Grid.Column="0" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Margin="0,0,10,0" CornerRadius="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="插件列表" Margin="10,10,0,5" FontSize="16" FontWeight="SemiBold" Foreground="Black"/>
<ListView Grid.Row="1" x:Name="PluginListView" BorderThickness="0" Margin="0,5,0,0"
SelectionChanged="PluginListView_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" Grid.Column="0" VerticalAlignment="Center"
Foreground="Black" FontWeight="Normal" FontSize="14"/>
<ui:ToggleSwitch Grid.Column="1" IsOn="{Binding IsEnabled}"
Toggled="PluginToggleSwitch_Toggled"
Tag="{Binding}" MinWidth="40"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Border>
<!-- 右侧插件详情和设置 -->
<ScrollViewer Grid.Column="1" Margin="10,0,0,0" VerticalScrollBarVisibility="Auto">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 插件详情 -->
<Border Grid.Row="0" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Padding="15" CornerRadius="5">
<Grid x:Name="PluginDetailGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="名称:" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="Black"/>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Name}" Margin="0,0,0,5" Foreground="Black"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="版本:" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="Black"/>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Version}" Margin="0,0,0,5" Foreground="Black"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="作者:" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="Black"/>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Author}" Margin="0,0,0,5" Foreground="Black"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="描述:" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="Black"/>
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding Description}" TextWrapping="Wrap" Margin="0,0,0,5" Foreground="Black"/>
<Button Grid.Row="3" Grid.Column="2" x:Name="BtnDeletePlugin" Content="删除插件"
Visibility="Collapsed" Click="BtnDeletePlugin_Click"
Margin="10,0,0,0" Padding="8,3" HorizontalAlignment="Right"
Background="#FFEE5555" Foreground="White"/>
</Grid>
</Border>
<!-- 插件设置区域 -->
<Border Grid.Row="1" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Margin="0,10,0,0" Padding="15" CornerRadius="5">
<StackPanel>
<TextBlock Text="插件设置" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,10" Foreground="Black"/>
<ContentControl x:Name="PluginSettingsContainer" MinHeight="50"/>
</StackPanel>
</Border>
<!-- 插件配置内容区 -->
<Border Grid.Row="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Margin="0,10,0,0" Padding="0" CornerRadius="5">
<ContentControl x:Name="PluginContentContainer" Margin="0"/>
</Border>
</Grid>
</ScrollViewer>
</Grid>
<!-- 底部操作栏 -->
<Border Grid.Row="2" Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}" Height="60">
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="20,0,0,0">
<Button x:Name="BtnLoadPlugin" Content="加载本地插件" Click="BtnLoadPlugin_Click"
Padding="15,5" Background="{DynamicResource SystemAccentColor}" Foreground="White"/>
<Button x:Name="BtnSaveConfig" Content="保存状态" Click="BtnSaveConfig_Click"
Padding="15,5" Margin="10,0,0,0" Background="{DynamicResource SystemAccentColor}" Foreground="White"
ToolTip="手动保存当前所有插件的启用/禁用状态到配置文件"/>
<Button x:Name="BtnExportPlugin" Content="导出插件" Click="BtnExportPlugin_Click"
Padding="15,5" Margin="10,0,0,0" Background="{DynamicResource SystemAccentColor}" Foreground="White"/>
</StackPanel>
</Grid>
</Border>
</Grid>
</Window>
@@ -1,716 +0,0 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using Ink_Canvas.Helpers;
using Ink_Canvas.Helpers.Plugins;
using Ink_Canvas.Helpers.Plugins.BuiltIn;
using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher;
using iNKORE.UI.WPF.Modern.Controls;
using Microsoft.Win32;
using MessageBox = System.Windows.MessageBox;
namespace Ink_Canvas.Windows
{
/// <summary>
/// PluginSettingsWindow.xaml 的交互逻辑
/// </summary>
public partial class PluginSettingsWindow : Window, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 刷新插件列表
/// </summary>
public void RefreshPluginList()
{
LoadPlugins();
// 如果当前选中的插件仍然存在,保持其选中状态
if (SelectedPlugin != null)
{
var matchingPlugin = Plugins.FirstOrDefault(p => p.Plugin.GetType().FullName == SelectedPlugin.GetType().FullName);
if (matchingPlugin != null)
{
PluginListView.SelectedItem = matchingPlugin;
}
}
OnPropertyChanged(nameof(SelectedPlugin));
LogHelper.WriteLogToFile("插件列表已刷新");
}
private IPlugin _selectedPlugin;
/// <summary>
/// 当前选中的插件
/// </summary>
public IPlugin SelectedPlugin
{
get => _selectedPlugin;
set
{
if (_selectedPlugin != value)
{
_selectedPlugin = value;
OnPropertyChanged(nameof(SelectedPlugin));
OnPropertyChanged(nameof(Name));
OnPropertyChanged(nameof(Version));
OnPropertyChanged(nameof(Author));
OnPropertyChanged(nameof(Description));
OnPropertyChanged(nameof(IsEnabled));
OnPropertyChanged(nameof(IsBuiltIn));
}
}
}
public string Name => SelectedPlugin?.Name ?? string.Empty;
public string Version => SelectedPlugin?.Version?.ToString() ?? string.Empty;
public string Author => SelectedPlugin?.Author ?? string.Empty;
public string Description => SelectedPlugin?.Description ?? string.Empty;
public bool IsEnabled => SelectedPlugin is PluginBase plugin && plugin.IsEnabled;
public bool IsBuiltIn => SelectedPlugin?.IsBuiltIn ?? false;
/// <summary>
/// 插件列表
/// </summary>
public ObservableCollection<PluginViewModel> Plugins { get; } = new ObservableCollection<PluginViewModel>();
public PluginSettingsWindow()
{
InitializeComponent();
// 设置数据上下文
PluginDetailGrid.DataContext = this;
// 设置导出按钮初始状态
BtnExportPlugin.IsEnabled = false;
BtnExportPlugin.ToolTip = "请先选择要导出的插件";
// 加载插件列表
LoadPlugins();
// 注册窗口关闭事件
Closing += PluginSettingsWindow_Closing;
}
/// <summary>
/// 窗口关闭事件处理
/// </summary>
private void PluginSettingsWindow_Closing(object sender, CancelEventArgs e)
{
try
{
// 保存插件配置
LogHelper.WriteLogToFile("插件管理窗口关闭,保存插件配置...");
PluginManager.Instance.SaveConfig();
LogHelper.WriteLogToFile("插件配置已保存");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"关闭窗口时保存插件配置出错: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 加载插件列表
/// </summary>
private void LoadPlugins()
{
Plugins.Clear();
LogHelper.WriteLogToFile($"开始加载插件列表到UI,插件总数: {PluginManager.Instance.Plugins.Count}");
// 添加所有已加载的插件
foreach (var plugin in PluginManager.Instance.Plugins)
{
bool isEnabled = false;
// 从插件实例获取启用状态
if (plugin is PluginBase pluginBase)
{
isEnabled = pluginBase.IsEnabled;
}
// 记录插件详细信息
LogHelper.WriteLogToFile($"正在加载插件到UI: 类型={plugin.GetType().FullName}, 名称={plugin.Name ?? ""}, 状态={isEnabled}");
// 创建视图模型并添加到集合
var viewModel = new PluginViewModel(plugin)
{
IsEnabled = isEnabled
};
Plugins.Add(viewModel);
LogHelper.WriteLogToFile($"已加载插件到UI列表: {plugin.Name},状态: {(isEnabled ? "" : "")}");
}
// 绑定到ListView
LogHelper.WriteLogToFile($"绑定 {Plugins.Count} 个插件到ListView");
PluginListView.ItemsSource = Plugins;
// 如果有插件,选择第一个
if (Plugins.Count > 0)
{
LogHelper.WriteLogToFile($"选择第一个插件: {Plugins[0].Name}");
PluginListView.SelectedIndex = 0;
}
else
{
LogHelper.WriteLogToFile("没有找到任何插件", LogHelper.LogType.Warning);
}
}
/// <summary>
/// 更新属性变更通知
/// </summary>
/// <param name="propertyName">属性名称</param>
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
/// <summary>
/// 插件列表选择变更事件
/// </summary>
private void PluginListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (PluginListView.SelectedItem is PluginViewModel viewModel)
{
// 设置当前选中的插件
SelectedPlugin = viewModel.Plugin;
// 加载插件设置界面
PluginSettingsContainer.Content = SelectedPlugin.GetSettingsView();
// 设置删除按钮的可见性
BtnDeletePlugin.Visibility = !SelectedPlugin.IsBuiltIn ? Visibility.Visible : Visibility.Collapsed;
// 设置导出按钮的可用状态
BtnExportPlugin.IsEnabled = !SelectedPlugin.IsBuiltIn;
if (SelectedPlugin.IsBuiltIn)
{
BtnExportPlugin.ToolTip = "内置插件无法导出";
}
else
{
BtnExportPlugin.ToolTip = "将插件导出为.iccpp文件";
}
}
else
{
SelectedPlugin = null;
PluginSettingsContainer.Content = null;
BtnDeletePlugin.Visibility = Visibility.Collapsed;
BtnExportPlugin.IsEnabled = false;
BtnExportPlugin.ToolTip = "请先选择要导出的插件";
}
}
/// <summary>
/// 加载本地插件按钮点击事件
/// </summary>
private void BtnLoadPlugin_Click(object sender, RoutedEventArgs e)
{
try
{
// 创建文件对话框
OpenFileDialog dialog = new OpenFileDialog
{
Filter = "ICC插件文件(*.iccpp)|*.iccpp",
Title = "选择要加载的插件文件"
};
// 显示对话框
if (dialog.ShowDialog() == true)
{
// 获取插件文件路径
string pluginPath = dialog.FileName;
// 检查是否在Plugins目录下
string pluginsDirectory = Path.Combine(App.RootPath, "Plugins");
string targetPath = Path.Combine(pluginsDirectory, Path.GetFileName(pluginPath));
// 确保Plugins目录存在
if (!Directory.Exists(pluginsDirectory))
{
Directory.CreateDirectory(pluginsDirectory);
}
// 如果插件不在Plugins目录下,复制过去
if (!string.Equals(pluginPath, targetPath, StringComparison.OrdinalIgnoreCase))
{
File.Copy(pluginPath, targetPath, true);
pluginPath = targetPath;
}
// 加载插件
IPlugin plugin = PluginManager.Instance.LoadExternalPlugin(pluginPath);
if (plugin != null)
{
// 刷新插件列表
LoadPlugins();
// 选择新加载的插件
foreach (var item in Plugins)
{
if (item.Plugin == plugin)
{
PluginListView.SelectedItem = item;
break;
}
}
MessageBox.Show($"插件 {plugin.Name} v{plugin.Version} 已成功加载!", "成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
MessageBox.Show("插件加载失败,请检查文件是否有效。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
catch (Exception ex)
{
MessageBox.Show($"加载插件时发生错误:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
/// <summary>
/// 删除插件按钮点击事件
/// </summary>
private void BtnDeletePlugin_Click(object sender, RoutedEventArgs e)
{
if (SelectedPlugin == null) return;
// 不能删除内置插件
if (SelectedPlugin.IsBuiltIn)
{
MessageBox.Show("内置插件无法删除。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
// 保存插件名称,以便在删除后使用
string pluginName = SelectedPlugin.Name;
// 确认删除
MessageBoxResult result = MessageBox.Show(
$"确定要删除插件 {pluginName} 吗?\n此操作将永久删除插件文件,无法恢复。",
"删除确认",
MessageBoxButton.YesNo,
MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
{
// 删除插件
bool success = PluginManager.Instance.DeletePlugin(SelectedPlugin);
if (success)
{
// 刷新插件列表
LoadPlugins();
// 如果还有插件,选择第一个
if (Plugins.Count > 0)
{
PluginListView.SelectedIndex = 0;
}
MessageBox.Show($"插件 {pluginName} 已成功删除。", "成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
MessageBox.Show($"删除插件 {pluginName} 失败,请稍后重试。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
/// <summary>
/// 导出插件按钮点击事件
/// </summary>
private void BtnExportPlugin_Click(object sender, RoutedEventArgs e)
{
try
{
// 检查是否有选中的插件
if (SelectedPlugin == null)
{
MessageBox.Show("请先选择要导出的插件", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
// 检查是否为内置插件
if (SelectedPlugin.IsBuiltIn)
{
MessageBox.Show("内置插件无法导出", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
// 检查插件文件是否存在
string pluginPath = null;
if (SelectedPlugin is PluginBase pluginBase)
{
pluginPath = pluginBase.PluginPath;
}
if (string.IsNullOrEmpty(pluginPath) || !File.Exists(pluginPath))
{
MessageBox.Show("插件文件不存在或无法访问", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
// 创建保存文件对话框
SaveFileDialog dialog = new SaveFileDialog
{
Filter = "ICC插件文件(*.iccpp)|*.iccpp",
Title = "导出插件",
FileName = Path.GetFileName(pluginPath)
};
// 显示对话框
if (dialog.ShowDialog() == true)
{
// 获取目标路径
string targetPath = dialog.FileName;
// 如果目标文件已存在,询问是否覆盖
if (File.Exists(targetPath) && !string.Equals(pluginPath, targetPath, StringComparison.OrdinalIgnoreCase))
{
MessageBoxResult result = MessageBox.Show("目标文件已存在,是否覆盖?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result != MessageBoxResult.Yes)
{
return;
}
}
// 复制插件文件到目标路径
if (!string.Equals(pluginPath, targetPath, StringComparison.OrdinalIgnoreCase))
{
File.Copy(pluginPath, targetPath, true);
}
LogHelper.WriteLogToFile($"插件 {SelectedPlugin.Name} 已成功导出到: {targetPath}");
MessageBox.Show($"插件 {SelectedPlugin.Name} 已成功导出!", "成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"导出插件时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"导出插件时发生错误: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
/// <summary>
/// 插件开关切换事件
/// </summary>
private void PluginToggleSwitch_Toggled(object sender, RoutedEventArgs e)
{
try
{
if (sender is ToggleSwitch toggleSwitch &&
toggleSwitch.Tag is IPlugin plugin)
{
// 记录当前开关状态
bool targetState = toggleSwitch.IsOn;
// 记录插件类型名称和名称,用于稍后查找重载后的插件
string pluginTypeName = plugin.GetType().FullName;
string pluginName = plugin.Name;
bool wasBuiltIn = plugin.IsBuiltIn;
LogHelper.WriteLogToFile($"UI开关切换: {pluginName}, 目标状态: {(targetState ? "" : "")}");
// 切换插件状态
PluginManager.Instance.TogglePlugin(plugin, targetState);
// 立即同步保存配置到文件(确保状态被立即持久化)
PluginManager.Instance.SaveConfig();
LogHelper.WriteLogToFile("插件状态已立即保存到配置文件");
// 延迟一下再检查状态,确保变更已应用
Dispatcher.BeginInvoke(new Action(() =>
{
try
{
// 查找最新的插件实例
IPlugin currentPlugin = null;
foreach (var p in PluginManager.Instance.Plugins)
{
if (p.GetType().FullName == pluginTypeName || p.Name == pluginName)
{
currentPlugin = p;
break;
}
}
if (currentPlugin == null)
{
LogHelper.WriteLogToFile($"无法找到插件: {pluginName}UI状态可能不准确", LogHelper.LogType.Warning);
return;
}
// 检查实际状态
bool actualState = currentPlugin is PluginBase pb && pb.IsEnabled;
LogHelper.WriteLogToFile($"插件 {pluginName} 实际状态: {(actualState ? "" : "")}");
// 更新视图模型
PluginViewModel viewModel = null;
if (toggleSwitch.DataContext is PluginViewModel vm)
{
viewModel = vm;
}
else
{
viewModel = Plugins.FirstOrDefault(p => p.Plugin == currentPlugin);
}
if (viewModel != null)
{
// 确保视图模型状态与实际状态一致
if (viewModel.IsEnabled != actualState)
{
LogHelper.WriteLogToFile($"同步视图模型状态: {(actualState ? "" : "")}");
viewModel.IsEnabled = actualState;
}
// 确保UI开关状态与实际状态一致
if (toggleSwitch.IsOn != actualState)
{
LogHelper.WriteLogToFile($"同步UI开关状态: {(actualState ? "" : "")}");
toggleSwitch.IsOn = actualState;
}
}
// 如果是当前选中的插件,更新属性
if (currentPlugin == SelectedPlugin)
{
OnPropertyChanged(nameof(IsEnabled));
}
// 对于内置插件,特别处理
if (wasBuiltIn)
{
// 特殊插件刷新逻辑,如果是超级启动台插件,立即刷新UI
if (currentPlugin is SuperLauncherPlugin &&
PluginSettingsContainer.Content is LauncherSettingsControl)
{
// 重新获取设置界面
PluginSettingsContainer.Content = currentPlugin.GetSettingsView();
}
}
LogHelper.WriteLogToFile($"插件 {pluginName} UI状态同步完成");
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"同步UI状态时出错: {ex.Message}", LogHelper.LogType.Error);
}
}), DispatcherPriority.Background);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"切换插件状态时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"切换插件状态时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
/// <summary>
/// 保存插件状态按钮点击事件
/// </summary>
private void BtnSaveConfig_Click(object sender, RoutedEventArgs e)
{
try
{
int syncCount = 0;
// 遍历界面上所有插件视图模型,获取开关状态
foreach (var viewModel in Plugins)
{
try
{
if (viewModel.Plugin != null)
{
// 获取UI中开关的当前状态(从界面控件读取)
bool uiState = viewModel.IsEnabled;
// 获取插件类型名,用于查找配置
string pluginTypeName = viewModel.Plugin.GetType().FullName;
// 查找实际的插件实例(可能与viewModel.Plugin不同,因为可能已经重新加载)
IPlugin actualPlugin = null;
foreach (var p in PluginManager.Instance.Plugins)
{
if (p.GetType().FullName == pluginTypeName)
{
actualPlugin = p;
break;
}
}
// 如果找不到对应的实际插件实例,跳过
if (actualPlugin == null)
{
LogHelper.WriteLogToFile($"手动保存:无法找到与UI对应的插件实例:{viewModel.Name}", LogHelper.LogType.Warning);
continue;
}
// 获取插件实际状态
bool pluginState = false;
if (actualPlugin is PluginBase pluginBase)
{
pluginState = pluginBase.IsEnabled;
}
// 如果界面状态与插件实际状态不一致,应用界面状态
if (uiState != pluginState)
{
// 应用界面的状态到插件
PluginManager.Instance.TogglePlugin(actualPlugin, uiState);
LogHelper.WriteLogToFile($"手动保存:同步插件 {actualPlugin.Name} 状态 {pluginState} -> {uiState}");
syncCount++;
}
// 确保配置中的状态也与界面一致
if (PluginManager.Instance.PluginStates.TryGetValue(pluginTypeName, out bool configState) && configState != uiState)
{
PluginManager.Instance.PluginStates[pluginTypeName] = uiState;
LogHelper.WriteLogToFile($"手动保存:更新配置中插件 {actualPlugin.Name} 状态 {configState} -> {uiState}");
syncCount++;
}
}
}
catch (Exception pluginEx)
{
// 单个插件处理失败不应该影响其他插件
LogHelper.WriteLogToFile($"手动保存:处理插件 {viewModel.Name} 时出错: {pluginEx.Message}", LogHelper.LogType.Error);
}
}
// 保存插件状态配置
PluginManager.Instance.SaveConfig();
// 记录日志
LogHelper.WriteLogToFile($"用户手动保存插件状态配置,同步了 {syncCount} 个状态变更");
// 刷新插件列表,确保UI与最新状态同步
RefreshPluginList();
// 显示保存成功提示
string message = syncCount > 0
? $"插件状态已成功保存,同步了 {syncCount} 个状态变更"
: "插件状态已成功保存,所有插件状态已是最新";
MessageBox.Show(message, "保存成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
// 记录错误日志
LogHelper.WriteLogToFile($"手动保存插件状态时出错: {ex.Message}", LogHelper.LogType.Error);
// 显示错误信息
MessageBox.Show($"保存插件状态时发生错误: {ex.Message}", "保存失败", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
/// <summary>
/// 关闭按钮点击事件
/// </summary>
private void BtnClose_Click(object sender, RoutedEventArgs e)
{
// 直接关闭窗口,窗口关闭事件会处理配置保存
Close();
}
}
/// <summary>
/// 插件视图模型
/// </summary>
public class PluginViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 插件实例
/// </summary>
public IPlugin Plugin { get; }
/// <summary>
/// 插件名称
/// </summary>
public string Name
{
get
{
string name = Plugin?.Name ?? "未命名插件";
LogHelper.WriteLogToFile($"获取插件名称: {name},类型: {Plugin?.GetType().FullName ?? ""}");
return name;
}
}
/// <summary>
/// 插件是否启用
/// </summary>
private bool _isEnabled;
public bool IsEnabled
{
get => _isEnabled;
set
{
if (_isEnabled != value)
{
_isEnabled = value;
OnPropertyChanged(nameof(IsEnabled));
}
}
}
public PluginViewModel(IPlugin plugin)
{
Plugin = plugin;
// 获取实际状态
_isEnabled = plugin is PluginBase pluginBase && pluginBase.IsEnabled;
// 记录日志
LogHelper.WriteLogToFile($"创建插件视图模型: {plugin?.GetType().FullName ?? ""}, 名称: {plugin?.Name ?? ""}");
// 注册插件状态变更事件
if (plugin is PluginBase pb)
{
pb.EnabledStateChanged += Plugin_EnabledStateChanged;
}
}
/// <summary>
/// 处理插件状态变更事件
/// </summary>
private void Plugin_EnabledStateChanged(object sender, bool isEnabled)
{
// 在UI线程上更新状态
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
IsEnabled = isEnabled;
// 确保配置立即保存
if (sender is IPlugin plugin)
{
LogHelper.WriteLogToFile($"视图模型捕获到插件 {plugin.Name} 状态变更: {(isEnabled ? "" : "")}");
PluginManager.Instance.SaveConfig();
LogHelper.WriteLogToFile("视图模型已触发配置保存");
}
}));
}
/// <summary>
/// 属性变更通知
/// </summary>
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

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