ningshuxia
2025-04-03 4917fb959e2befec07a693e72d7010c09494ec7c
02-desktop/WinFrmUI/IStation.WinFrmUI.Basic/PumpCurveMgr/PumpCurveTreeListCtrl.cs
@@ -15,10 +15,10 @@
        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; ;
        }
@@ -27,36 +27,36 @@
            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; }
@@ -70,10 +70,10 @@
            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;
                }
            }
        }
@@ -99,7 +99,7 @@
        /// </summary>
        public void SetBindingData()
        {
            this.stationTreeListLookUpEdit1.SetBindingData();
            stationTreeListLookUpEdit1.SetBindingData();
        }
        /// <summary>
@@ -108,15 +108,15 @@
        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);
        }
@@ -157,13 +157,13 @@
            }
            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();
        }
@@ -173,11 +173,11 @@
        /// </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>
@@ -185,7 +185,7 @@
        /// </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();
@@ -194,7 +194,7 @@
                existWorkPumpCurve.Reset(false);
            }
            row.Reset(true);
            this.treeList1.RefreshDataSource();
            treeList1.RefreshDataSource();
        }
        /// <summary>
@@ -202,9 +202,9 @@
        /// </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();
@@ -215,7 +215,7 @@
                        _allBindingList.Remove(item);
                    }
                }
                this.treeList1.RefreshDataSource();
                treeList1.RefreshDataSource();
            }
        }
@@ -226,7 +226,7 @@
        //聚焦前
        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)
@@ -238,10 +238,10 @@
        //聚焦改变
        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);
        }
        //鼠标点击
@@ -249,8 +249,8 @@
        {
            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)
@@ -312,7 +312,7 @@
                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();
@@ -347,7 +347,7 @@
                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();
@@ -382,7 +382,7 @@
                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();
@@ -417,7 +417,7 @@
                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();
@@ -442,22 +442,22 @@
        //全部展开
        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();
        }
@@ -468,7 +468,7 @@
        {
            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);
@@ -486,7 +486,7 @@
                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");