摘要: 使用场景 图形界面库:在图形界面开发中,UI 元素(按钮、文本框等)和容器元素(面板、窗口等)可以使用组合模式来构建复杂的用户界面。这样,可以统一处理单个元素和组合元素,使得客户端代码更简洁 文件系统和目录结构:文件系统是一个经典的组合模式应用场景。文件夹可以包含文件和其他文件夹,形成一个树形结构。 阅读全文
posted @ 2024-03-24 16:30 木狼 阅读(38) 评论(0) 推荐(0) 编辑
摘要: using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Windows.Forms; namespace drmaple { class HotKey { / 阅读全文
posted @ 2024-03-24 14:07 木狼 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 命令模式命令模式将一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化;对请求排队或记录请求日志,以及支持可撤销的操作。 示例假定要实现一个绘图系统,要求支持撤销功能,下面就用命令模式来实现这一需求。首先定义一个抽象的命令接口 public interface IGraphCommand 阅读全文
posted @ 2024-03-24 13:14 木狼 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 新建wpf项目,新建Undoable.cs(操作记录),main.xaml(页面) using System; using System.Collections.Generic; namespace WpfApp1 { /// <summary> /// 撤销重做对象 /// ceate by xi 阅读全文
posted @ 2024-03-24 12:45 木狼 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 新建项目IPlugin类库,里面新增IPlugin.cs(插件接口),PluginManager.cs(插件管理),FileListenerServer.cs(文件夹监控),依次如下 using System; using System.Collections.Generic; using Syst 阅读全文
posted @ 2024-03-24 00:48 木狼 阅读(7) 评论(0) 推荐(0) 编辑