实用设计模式-桥接模式
来源:互联网 发布:淘宝拍a发b平台赚钱 编辑:程序博客网 时间:2024/04/30 09:41
树形条组件Check访问方式(未完成),具有基本的筛选方法,其他方法待续
#region 树控件操作接口
/// <summary>
/// 树控件操作接口
/// </summary>
public interface IOperation<T>
{
/* 特殊树节点遍历 */
void ErgodicNodes(T tn);
/* 特殊树节点递归 */
void ErgodicCirculate(T tn);
/* 特殊树访问状态 */
void SetChecked(T tn);
}
#endregion
#region 使用接口
/// <summary>
/// 使用接口
/// </summary>
/// <typeparam name="T"></typeparam>
public interface ITreeNode<T>
{
void ErgodicNodes(T t);
}
#endregion
#region 树控件操作类
/// <summary>
/// 一般树节点操作类
/// </summary>
public class OperationGeneralTreeNode : IOperation<TreeNode>
{
private TreeNode _TreeNode;
public OperationGeneralTreeNode()
{
}
public OperationGeneralTreeNode(TreeNode UltraTreeNode)
{
this._TreeNode = UltraTreeNode;
}
/// <summary>
/// 同级节点
/// </summary>
/// <param name="tn"></param>
public void ErgodicNodes(TreeNode tn)
{
if (tn == null)
return;
SetChecked(tn);
if (tn.NextNode != null)
ErgodicNodes(tn.NextNode);
if (tn.FirstNode != null)
ErgodicCirculate(tn.FirstNode);
}
/// <summary>
/// 子节点
/// </summary>
/// <param name="tn"></param>
public void ErgodicCirculate(TreeNode tn)
{
SetChecked(tn);
if (tn.FirstNode != null)
ErgodicCirculate(tn.FirstNode);
if (tn.NextNode != null)
ErgodicCirculate(tn.NextNode);
}
/// <summary>
/// 访问控制
/// </summary>
/// <param name="tn"></param>
public void SetChecked(TreeNode tn)
{
if (tn != null)
if (tn.Checked == true)
tn.Checked = false;
else
tn.Checked = true;
}
}
/// <summary>
/// 第三方控件树节点操作类
/// </summary>
public class OperationUltraTreeNode : IOperation<UltraTreeNode>
{
private UltraTreeNode _UltraTreeNode;
public OperationUltraTreeNode()
{
}
public OperationUltraTreeNode(UltraTreeNode UltraTreeNode)
{
this._UltraTreeNode = UltraTreeNode;
}
/// <summary>
/// 同级节点
/// </summary>
/// <param name="tn"></param>
public void ErgodicNodes(UltraTreeNode tn)
{
if (tn == null)
return;
SetChecked(tn);
if (tn.GetSibling(NodePosition.Next) != null)
ErgodicNodes(tn.GetSibling(NodePosition.Next));
if (tn.GetSibling(NodePosition.First) != null)
ErgodicCirculate(tn.GetSibling(NodePosition.First));
}
/// <summary>
/// 子节点
/// </summary>
/// <param name="tn"></param>
public void ErgodicCirculate(UltraTreeNode tn)
{
SetChecked(tn);
if (tn.GetSibling(NodePosition.First) != null)
ErgodicCirculate(tn.GetSibling(NodePosition.First));
if (tn.GetSibling(NodePosition.Next) != null)
ErgodicCirculate(tn.GetSibling(NodePosition.Next));
}
/// <summary>
/// 访问控制
/// </summary>
/// <param name="tn"></param>
public void SetChecked(UltraTreeNode tn)
{
if (tn != null)
if (tn.CheckedState == CheckState.Checked)
tn.CheckedState = CheckState.Unchecked;
else
tn.CheckedState = CheckState.Checked;
}
}
/// <summary>
/// 使用一般操作方法
/// </summary>
public class UseGTreeNode : ITreeNode<TreeNode>
{
private IOperation<TreeNode> _Operation;
public UseGTreeNode(IOperation<TreeNode> Operation)
{
this._Operation = Operation;
}
public void ErgodicNodes(TreeNode t)
{
_Operation.ErgodicNodes(t);
}
}
/// <summary>
/// 使用控件方操作方法
/// </summary>
public class UseUTreeNode : ITreeNode<UltraTreeNode>
{
private IOperation<UltraTreeNode> _Operation;
public UseUTreeNode(IOperation<UltraTreeNode> Operation)
{
this._Operation = Operation;
}
public void ErgodicNodes(UltraTreeNode t)
{
_Operation.ErgodicNodes(t);
}
}
#endregion
- 实用设计模式-桥接模式
- 实用设计模式之状态模式
- 实用设计模式之单例模式
- 实用设计模式之观察者模式
- 实用设计模式之单例模式
- 设计模式----桥接模式
- 设计模式---桥接模式
- 设计模式:桥接模式
- 设计模式 桥接模式
- 设计模式 - 桥接模式
- 设计模式--桥接模式
- 设计模式--桥接模式
- 设计模式 - 桥接模式
- 设计模式-桥接模式
- 设计模式 - 桥接模式
- 设计模式 - 桥接模式
- 【设计模式-桥接模式】
- 设计模式:桥接模式
- 进程与线程的选择与比较
- kruskal算法
- QTableWidget 用法大全(持续更新)
- 提高Android Support Library 的稳定性
- 安卓代码混淆的方法
- 实用设计模式-桥接模式
- 12. 结构
- Python学习笔记一
- JIN_目录简介
- MYSQL导入导出.sql文件
- Oracle存储结构
- STM32 printf重定向
- linux下查看监听端口对应的进程
- Leetcode-Restore IP Addresses