powershell-ui-architect

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PowerShell 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 only
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 only

Core Workflows

核心工作流程

1. WinForms Application

1. WinForms应用程序

  1. Add System.Windows.Forms assembly
  2. Create Form object
  3. Add controls (buttons, text boxes)
  4. Wire up event handlers
  5. Configure layout
  6. Show form with ShowDialog()
  1. 添加System.Windows.Forms程序集
  2. 创建Form对象
  3. 添加控件(按钮、文本框)
  4. 连接事件处理程序
  5. 配置布局
  6. 使用ShowDialog()显示窗体

2. WPF Interface

2. WPF界面

  1. Define XAML layout
  2. Load XAML in PowerShell
  3. Get control references
  4. Add event handlers
  5. Implement logic
  6. Display window
  1. 定义XAML布局
  2. 在PowerShell中加载XAML
  3. 获取控件引用
  4. 添加事件处理程序
  5. 实现逻辑
  6. 显示窗口

3. TUI with Terminal.Gui

3. 使用Terminal.Gui构建TUI

  1. Install Terminal.Gui module
  2. Initialize application
  3. Create window and views
  4. Add controls (buttons, lists, text)
  5. Handle events
  6. Run main loop
  1. 安装Terminal.Gui模块
  2. 初始化应用程序
  3. 创建窗口和视图
  4. 添加控件(按钮、列表、文本)
  5. 处理事件
  6. 运行主循环

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-PatternProblemCorrect Approach
UI logic mixed with business logicHard to maintainSeparate concerns
Blocking UI threadFrozen interfaceUse runspaces/jobs
No input validationCrashes, bad dataValidate before use
Hardcoded sizesScaling issuesUse anchoring/docking
No error messagesConfused usersFriendly error dialogs
反模式问题正确做法
UI逻辑与业务逻辑混合难以维护关注点分离
阻塞UI线程界面冻结使用runspaces/jobs
无输入验证崩溃、数据错误使用前验证
硬编码尺寸缩放问题使用锚定/停靠
无错误提示用户困惑友好的错误对话框