using DevExpress.XtraEditors; using DevExpress.XtraTreeList; using System.ComponentModel; using System.Windows.Forms; namespace IStation.WinFrmUI.Monitor { public partial class EquipmentMonitorMappingMgr : DocumentPage { public EquipmentMonitorMappingMgr() { InitializeComponent(); this.PageTitle.Caption = "测点关联"; this.treeList1.InitialMultiColSettings(); this.treeList1.OptionsBehavior.Editable = false; this.treeList1.OptionsBehavior.ReadOnly = true; this.treeList1.OptionsView.CheckBoxStyle = DevExpress.XtraTreeList.DefaultNodeCheckBoxStyle.Check; } public class CurrentViewModel { public CurrentViewModel() { } public CurrentViewModel(Model.EquipmentMonitorMapping rhs) { this.ID = rhs.ID; /* this.ParentID = rhs.ParentID; this.Name = rhs.Name; this.SortCode = rhs.SortCode; this.Description = rhs.Description; this.Model = rhs; this.Checked = rhs.Have;*/ } public long ID { get; set; } public long ParentID { get; set; } public string Name { get; set; } public int SortCode { get; set; } public string Description { get; set; } public int ImageIndex { get; set; } public object Model { get; set; } public bool? Checked { get; set; } } private BLL.EquipmentMonitorMapping _bll = new BLL.EquipmentMonitorMapping(); private BindingList _allBindingList = null;//所有列表 /// /// 初始化数据 /// public override void InitialDataSource() { } public void SetBindingData() { Set(0, ""); } //绑定数据 public void Set(long corpId, string objectType) { if (corpId < 1) return; if (string.IsNullOrEmpty(objectType)) return; WaitFrmHelper.ShowWaitForm("正在加载数据..."); _allBindingList = new BindingList(); if (corpId > 0 && !string.IsNullOrEmpty(objectType)) { XtraMessageBox.Show("接口待修改!"); return; /*var list = await _bll.GetAuthorizeHaveTreeList(corpId, objectType); SetBindingData(list);*/ } this.treeList1.DataSource = _allBindingList; this.treeList1.ForceInitialize(); this.treeList1.ExpandAll(); this.treeList1.BestFitColumns(); WaitFrmHelper.HideWaitForm(); } /// /// 刷新数据 /// public override void RefreshDataSource() { //SetBindingData(_corp); } //选中节点后 private void treeList1_AfterCheckNode(object sender, NodeEventArgs e) { SetCheckedChildNodes(e.Node, e.Node.CheckState); } /// 设置子节点的状态 private void SetCheckedChildNodes(DevExpress.XtraTreeList.Nodes.TreeListNode node, CheckState check) { for (int i = 0; i < node.Nodes.Count; i++) { node.Nodes[i].CheckState = check; SetCheckedChildNodes(node.Nodes[i], check); } } } }