Files
MeloongCore/.agents/Wpf/架构分析.md
T
2026-07-20 15:58:55 +08:00

52 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MeloongCore.Wpf 项目架构
[返回 MeloongCore 仓库指示](../仓库指示.md)
## 1. 项目定位
`MeloongCore/Wpf/MeloongCore.Wpf.csproj` 是 MeloongCore 的 WPF/Windows 适配层,面向 .NET Framework 4.8,依赖 `MeloongCore`。
它的存在使 Shared 项目无需引用 WPF,同时让多个上层 WPF 应用复用窗口、对话框、转换器与 Windows API 封装。
## 2. 源码组成
| 文件 | 职责 |
| --- | --- |
| `Main.cs` | WPF 层初始化 |
| `Controls/ModernTooltipService.cs` | 现代化 ToolTip 行为 |
| `Extensions/WpfExtensions.cs` | WPF 对象和控件扩展 |
| `General/Dialogs.cs` | 文件、文件夹和消息对话框封装 |
| `General/ValueConverters.cs` | WPF Binding 值转换器 |
| `Utils/WindowsUtils.cs` | Windows 权限、窗口和系统相关工具 |
## 3. 依赖
- `MeloongCore`;
- WPF 的 `PresentationCore`、`PresentationFramework`、`System.Xaml`;
- `System.Windows.Forms`,用于部分 Windows UI 互操作;
- `Ookii.Dialogs.Wpf`;
- `Newtonsoft.Json` 与 PolySharp。
## 4. 架构边界
此项目适合承载“可被多个 WPF 应用复用”的平台代码,例如:
- WPF 控件扩展和附加行为;
- 通用值转换器;
- Windows 窗口与权限操作;
- 文件夹选择等系统对话框。
它不适合承载:
- 特定上层应用的控件外观或页面逻辑;
- 具体应用的领域业务;
- 只被一个调用点使用的小型包装;
- 可以留在 Shared 的纯 .NET 逻辑。
## 5. 维护关注点
- 本项目承载 Windows/WPF 特有能力,而 Shared 仍需考虑 macOS;平台 API 必须留在本项目或明确受保护的代码路径中。
- `System.Windows.Forms` 与 WPF 混用时要注意 DPI、窗口句柄和线程模型。
- 该项目由多个上层应用和 Tests 引用,公共 API 变更影响面较大。
- 应避免把具体上层应用的全局日志、设置或窗口实例反向引入本项目。