powershell-ui-architect
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePowerShell UI Architect
PowerShell UI 架构师
Purpose
用途
Provides expertise in building graphical user interfaces (GUI) and terminal user interfaces (TUI) with PowerShell. Specializes in WinForms, WPF, and console-based TUI frameworks for creating user-friendly PowerShell tools.
提供通过PowerShell构建图形用户界面(GUI)和终端用户界面(TUI)的专业知识。专注于使用WinForms、WPF和基于控制台的TUI框架,创建用户友好的PowerShell工具。
When to Use
使用场景
- Building PowerShell tools with GUI
- Creating WinForms applications
- Developing WPF interfaces for scripts
- Building terminal user interfaces (TUI)
- Adding dialogs to automation scripts
- Creating interactive admin tools
- Building configuration wizards
- Implementing progress displays
- 构建带GUI的PowerShell工具
- 创建WinForms应用程序
- 为脚本开发WPF界面
- 构建终端用户界面(TUI)
- 为自动化脚本添加对话框
- 创建交互式管理工具
- 构建配置向导
- 实现进度显示
Quick Start
快速开始
Invoke this skill when:
- Creating GUIs for PowerShell scripts
- Building WinForms or WPF interfaces
- Developing terminal-based UIs
- Adding interactive dialogs to tools
- Creating admin tool interfaces
Do NOT invoke when:
- Cross-platform CLI tools → use
/cli-developer - PowerShell module design → use
/powershell-module-architect - Web interfaces → use
/frontend-design - Windows app development (non-PS) → use
/windows-app-developer
在以下场景调用此技能:
- 为PowerShell脚本创建GUI
- 构建WinForms或WPF界面
- 开发基于终端的UI
- 为工具添加交互式对话框
- 创建管理工具界面
请勿在以下场景调用:
- 跨平台CLI工具 → 使用
/cli-developer - PowerShell模块设计 → 使用
/powershell-module-architect - Web界面 → 使用
/frontend-design - Windows应用开发(非PowerShell)→ 使用
/windows-app-developer
Decision Framework
决策框架
UI Type Needed?
├── Simple Dialog
│ └── WinForms MessageBox / InputBox
├── Full Windows App
│ ├── Simple layout → WinForms
│ └── Rich UI → WPF with XAML
├── Console/Terminal
│ ├── Simple menu → Write-Host + Read-Host
│ └── Rich TUI → Terminal.Gui / PSReadLine
└── Cross-Platform
└── Terminal-based onlyUI Type Needed?
├── Simple Dialog
│ └── WinForms MessageBox / InputBox
├── Full Windows App
│ ├── Simple layout → WinForms
│ └── Rich UI → WPF with XAML
├── Console/Terminal
│ ├── Simple menu → Write-Host + Read-Host
│ └── Rich TUI → Terminal.Gui / PSReadLine
└── Cross-Platform
└── Terminal-based onlyCore Workflows
核心工作流程
1. WinForms Application
1. WinForms应用程序
- Add System.Windows.Forms assembly
- Create Form object
- Add controls (buttons, text boxes)
- Wire up event handlers
- Configure layout
- Show form with ShowDialog()
- 添加System.Windows.Forms程序集
- 创建Form对象
- 添加控件(按钮、文本框)
- 连接事件处理程序
- 配置布局
- 使用ShowDialog()显示窗体
2. WPF Interface
2. WPF界面
- Define XAML layout
- Load XAML in PowerShell
- Get control references
- Add event handlers
- Implement logic
- Display window
- 定义XAML布局
- 在PowerShell中加载XAML
- 获取控件引用
- 添加事件处理程序
- 实现逻辑
- 显示窗口
3. TUI with Terminal.Gui
3. 使用Terminal.Gui构建TUI
- Install Terminal.Gui module
- Initialize application
- Create window and views
- Add controls (buttons, lists, text)
- Handle events
- Run main loop
- 安装Terminal.Gui模块
- 初始化应用程序
- 创建窗口和视图
- 添加控件(按钮、列表、文本)
- 处理事件
- 运行主循环
Best Practices
最佳实践
- Keep UI code separate from logic
- Use XAML for complex WPF layouts
- Handle errors gracefully with user feedback
- Provide progress indication for long operations
- Test on target Windows versions
- Use appropriate UI for audience (GUI vs TUI)
- 将UI代码与业务逻辑分离
- 复杂WPF布局使用XAML
- 通过用户反馈优雅处理错误
- 为长操作提供进度指示
- 在目标Windows版本上进行测试
- 根据受众选择合适的UI(GUI vs TUI)
Anti-Patterns
反模式
| Anti-Pattern | Problem | Correct Approach |
|---|---|---|
| UI logic mixed with business logic | Hard to maintain | Separate concerns |
| Blocking UI thread | Frozen interface | Use runspaces/jobs |
| No input validation | Crashes, bad data | Validate before use |
| Hardcoded sizes | Scaling issues | Use anchoring/docking |
| No error messages | Confused users | Friendly error dialogs |
| 反模式 | 问题 | 正确做法 |
|---|---|---|
| UI逻辑与业务逻辑混合 | 难以维护 | 关注点分离 |
| 阻塞UI线程 | 界面冻结 | 使用runspaces/jobs |
| 无输入验证 | 崩溃、数据错误 | 使用前验证 |
| 硬编码尺寸 | 缩放问题 | 使用锚定/停靠 |
| 无错误提示 | 用户困惑 | 友好的错误对话框 |