| | |
| | | public PumpCurveTreeListCtrl() |
| | | { |
| | | InitializeComponent(); |
| | | this.treeList1.InitialDefaultSettings(); |
| | | this.treeList1.SelectImageList = ImageLib.Lib; |
| | | this.layoutControl1.SetupLayoutControl(); |
| | | this.stationTreeListLookUpEdit1.SelectedChangedEvent += StationTreeListLookUpEdit1_SelectedChangedEvent; ; |
| | | treeList1.InitialDefaultSettings(); |
| | | treeList1.SelectImageList = ImageLib.Lib; |
| | | layoutControl1.SetupLayoutControl(); |
| | | stationTreeListLookUpEdit1.SelectedChangedEvent += StationTreeListLookUpEdit1_SelectedChangedEvent; ; |
| | | } |
| | | |
| | | |
| | |
| | | public CurrentViewModel() { } |
| | | public CurrentViewModel(Model.Equipment equipment) |
| | | { |
| | | this.ID = equipment.ID.ToString(); |
| | | this.Name = equipment.Name; |
| | | this.ParentID = equipment.BelongID.ToString(); |
| | | this.ObjectType = IStation.ObjectType.Equipment; |
| | | this.Model = equipment; |
| | | this.IsGroup = true; |
| | | this.ImageIndex = ImageLib.Pump; |
| | | ID = equipment.ID.ToString(); |
| | | Name = equipment.Name; |
| | | ParentID = equipment.BelongID.ToString(); |
| | | ObjectType = IStation.ObjectType.Equipment; |
| | | Model = equipment; |
| | | IsGroup = true; |
| | | ImageIndex = ImageLib.Pump; |
| | | } |
| | | |
| | | public CurrentViewModel(Model.PumpCurveMapping mapping) |
| | | { |
| | | this.ID = $"{mapping.CurveID}-{mapping.ID}"; |
| | | this.Name = mapping.OtherName; |
| | | this.ParentID = mapping.PumpID.ToString(); |
| | | this.ObjectType = IStation.ObjectType.PumpCurveMapping; |
| | | this.Model = mapping; |
| | | this.IsGroup = false; |
| | | this.IsWorkCurve = mapping.IsWorking; |
| | | this.Reset(this.IsWorkCurve); |
| | | ID = $"{mapping.CurveID}-{mapping.ID}"; |
| | | Name = mapping.OtherName; |
| | | ParentID = mapping.PumpID.ToString(); |
| | | ObjectType = IStation.ObjectType.PumpCurveMapping; |
| | | Model = mapping; |
| | | IsGroup = false; |
| | | IsWorkCurve = mapping.IsWorking; |
| | | Reset(IsWorkCurve); |
| | | } |
| | | |
| | | public CurrentViewModel(long mappingId, Model.PumpSpeedCurve curve) |
| | | { |
| | | this.ID = curve.ID.ToString(); |
| | | this.Name = curve.HZ + "hz"; |
| | | this.ParentID = $"{curve.PumpCurveID}-{mappingId}"; |
| | | this.ObjectType = IStation.ObjectType.PumpSpeedCurve; |
| | | this.Model = curve; |
| | | this.IsGroup = false; |
| | | this.ImageIndex = ImageLib.PumpSpeedCurve; |
| | | ID = curve.ID.ToString(); |
| | | Name = curve.HZ + "hz"; |
| | | ParentID = $"{curve.PumpCurveID}-{mappingId}"; |
| | | ObjectType = IStation.ObjectType.PumpSpeedCurve; |
| | | Model = curve; |
| | | IsGroup = false; |
| | | ImageIndex = ImageLib.PumpSpeedCurve; |
| | | } |
| | | |
| | | public string ID { get; set; } |
| | |
| | | |
| | | public void Reset(bool isWorking) |
| | | { |
| | | if (this.ObjectType == IStation.ObjectType.PumpCurveMapping) |
| | | if (ObjectType == IStation.ObjectType.PumpCurveMapping) |
| | | { |
| | | this.IsWorkCurve = isWorking; |
| | | this.ImageIndex = this.IsWorkCurve ? ImageLib.WorkPumpCurve : ImageLib.PumpCurve; |
| | | IsWorkCurve = isWorking; |
| | | ImageIndex = IsWorkCurve ? ImageLib.WorkPumpCurve : ImageLib.PumpCurve; |
| | | } |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | public void SetBindingData() |
| | | { |
| | | this.stationTreeListLookUpEdit1.SetBindingData(); |
| | | stationTreeListLookUpEdit1.SetBindingData(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public void Clear() |
| | | { |
| | | _allBindingList = new BindingList<CurrentViewModel>(); |
| | | this.treeList1.DataSource = _allBindingList; |
| | | this.FocusedChangedEvent?.Invoke(string.Empty, null); |
| | | treeList1.DataSource = _allBindingList; |
| | | FocusedChangedEvent?.Invoke(string.Empty, null); |
| | | } |
| | | |
| | | //泵站变换 |
| | | private void StationTreeListLookUpEdit1_SelectedChangedEvent(Model.Station obj) |
| | | { |
| | | _station = obj; |
| | | this.StationChangedEvent?.Invoke(obj); |
| | | StationChangedEvent?.Invoke(obj); |
| | | SetBindingData(obj); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | this.treeList1.DataSource = _allBindingList; |
| | | this.treeList1.RefreshDataSource(); |
| | | treeList1.DataSource = _allBindingList; |
| | | treeList1.RefreshDataSource(); |
| | | |
| | | var firstNode = _allBindingList.Where(x => !x.IsGroup).FirstOrDefault(); |
| | | if (firstNode != null) |
| | | { |
| | | this.treeList1.FocusedNode = this.treeList1.FindNodeByKeyID(firstNode.ID); |
| | | treeList1.FocusedNode = treeList1.FindNodeByKeyID(firstNode.ID); |
| | | } |
| | | WaitFrmHelper.HideWaitForm(); |
| | | } |
| | |
| | | /// </summary> |
| | | public void UpdateOtherName(string name) |
| | | { |
| | | var row = this.treeList1.GetCurrentViewModel(_allBindingList); |
| | | var row = treeList1.GetCurrentViewModel(_allBindingList); |
| | | if (row == null) |
| | | return; |
| | | row.Name = name; |
| | | this.treeList1.RefreshNode(this.treeList1.FocusedNode); |
| | | treeList1.RefreshNode(treeList1.FocusedNode); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void UpdateWorkingCurve() |
| | | { |
| | | var row = this.treeList1.GetCurrentViewModel(_allBindingList); |
| | | var row = treeList1.GetCurrentViewModel(_allBindingList); |
| | | if (row == null) |
| | | return; |
| | | var existWorkPumpCurve = _allBindingList.Where(x => x.ParentID == row.ParentID && x.ID != row.ID && x.IsWorkCurve).FirstOrDefault(); |
| | |
| | | existWorkPumpCurve.Reset(false); |
| | | } |
| | | row.Reset(true); |
| | | this.treeList1.RefreshDataSource(); |
| | | treeList1.RefreshDataSource(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public void DeletePumpMapping(long id, long mappingId) |
| | | { |
| | | var node = this.treeList1.FindNodeByKeyID($"{id}-{mappingId}"); |
| | | var node = treeList1.FindNodeByKeyID($"{id}-{mappingId}"); |
| | | if (node == null) return; |
| | | if (this.treeList1.GetDataRecordByNode(node) is CurrentViewModel vm) |
| | | if (treeList1.GetDataRecordByNode(node) is CurrentViewModel vm) |
| | | { |
| | | _allBindingList.Remove(vm); |
| | | var children = _allBindingList.Where(x => x.ParentID == vm.ID).ToList(); |
| | |
| | | _allBindingList.Remove(item); |
| | | } |
| | | } |
| | | this.treeList1.RefreshDataSource(); |
| | | treeList1.RefreshDataSource(); |
| | | } |
| | | } |
| | | |
| | |
| | | //聚焦前 |
| | | private void treeList1_BeforeFocusNode(object sender, DevExpress.XtraTreeList.BeforeFocusNodeEventArgs e) |
| | | { |
| | | var vm = this.treeList1.GetDataRecordByNode(e.Node) as CurrentViewModel; |
| | | var vm = treeList1.GetDataRecordByNode(e.Node) as CurrentViewModel; |
| | | if (vm == null) |
| | | return; |
| | | if (vm.IsGroup) |
| | |
| | | //聚焦改变 |
| | | private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) |
| | | { |
| | | var vm = this.treeList1.GetCurrentViewModel(_allBindingList); |
| | | var vm = treeList1.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null || vm.IsGroup) |
| | | return; |
| | | this.FocusedChangedEvent?.Invoke(vm.ObjectType, vm.Model); |
| | | FocusedChangedEvent?.Invoke(vm.ObjectType, vm.Model); |
| | | } |
| | | |
| | | //鼠标点击 |
| | |
| | | { |
| | | if (e.Button == System.Windows.Forms.MouseButtons.Right) |
| | | { |
| | | var hitInfo = this.treeList1.CalcHitInfo(e.Location); |
| | | _rightClickVm = this.treeList1.GetDataRecordByNode(hitInfo.Node) as CurrentViewModel; |
| | | var hitInfo = treeList1.CalcHitInfo(e.Location); |
| | | _rightClickVm = treeList1.GetDataRecordByNode(hitInfo.Node) as CurrentViewModel; |
| | | if (_rightClickVm == null) |
| | | return; |
| | | if (_rightClickVm.IsGroup) |
| | |
| | | var mapping = new BLL.PumpCurveMapping().GetByID(mappingId); |
| | | |
| | | _allBindingList.Add(new CurrentViewModel(mapping)); |
| | | this.treeList1.FocusedNode = this.treeList1.FocusedNode; |
| | | treeList1.FocusedNode = treeList1.FocusedNode; |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | var mapping = new BLL.PumpCurveMapping().GetByID(mappingId); |
| | | |
| | | _allBindingList.Add(new CurrentViewModel(mapping)); |
| | | this.treeList1.FocusedNode = this.treeList1.FocusedNode; |
| | | treeList1.FocusedNode = treeList1.FocusedNode; |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | var mapping = new BLL.PumpCurveMapping().GetByID(mappingId); |
| | | |
| | | _allBindingList.Add(new CurrentViewModel(mapping)); |
| | | this.treeList1.FocusedNode = this.treeList1.FocusedNode; |
| | | treeList1.FocusedNode = treeList1.FocusedNode; |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | var mapping = new BLL.PumpCurveMapping().GetByID(mappingId); |
| | | |
| | | _allBindingList.Add(new CurrentViewModel(mapping)); |
| | | this.treeList1.FocusedNode = this.treeList1.FocusedNode; |
| | | treeList1.FocusedNode = treeList1.FocusedNode; |
| | | return true; |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | //全部展开 |
| | | private void barBtnExpandAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | this.treeList1.ExpandAll(); |
| | | treeList1.ExpandAll(); |
| | | } |
| | | |
| | | //全部折叠 |
| | | private void barBtnCollapseAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | this.treeList1.CollapseAll(); |
| | | treeList1.CollapseAll(); |
| | | } |
| | | |
| | | //检索 |
| | | private void barCkSearch_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | if (this.barCkSearch.Checked) |
| | | this.treeList1.ShowFindPanel(); |
| | | if (barCkSearch.Checked) |
| | | treeList1.ShowFindPanel(); |
| | | else |
| | | this.treeList1.HideFindPanel(); |
| | | treeList1.HideFindPanel(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | if (_station == null) |
| | | return; |
| | | var path = Path.Combine(Settings.File.RootDirectory, "陈行", _station.Name + "_inp"); |
| | | var path = Path.Combine(SettingsD.File.RootDirectory, "陈行", _station.Name + "_inp"); |
| | | if (!Directory.Exists(path)) |
| | | { |
| | | Directory.CreateDirectory(path); |
| | |
| | | var curveQE = curve.CurveInfo.CurveQE; |
| | | var filePath = path + "\\" + pump.Name + ".crv"; |
| | | // ExportInpHelper.INPDefaultFile(filePath, pump.Name + "-" + curve.SourceFrom.GetDisplayText(), curveQH, curveQE); |
| | | ExportCurveHelper.INPFile(filePath, curveQH, curveQE,100); |
| | | ExportCurveHelper.INPFile(filePath, curveQH, curveQE, 100); |
| | | } |
| | | |
| | | XtraMessageBox.Show("over"); |