| | |
| | | { |
| | | InitializeComponent(); |
| | | this.layoutControl1.SetupLayoutControl(); |
| | | this.barBtnChangeLink.Visibility = BarItemVisibility.Never; |
| | | this.barBtnView.Visibility = BarItemVisibility.Never; |
| | | SetDescriptionVisible(false);//默认设置属性描述面板不显示 |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | public event Func<HydroParterViewModel, string, bool> SetPatternEvent; |
| | | /// <summary> |
| | | /// 属性值正在改变事件 |
| | | /// </summary> |
| | | public event Func<HydroParterViewModel, bool> PropertyValueChangingEvent; |
| | | /// <summary> |
| | | /// 属性值发生改变事件 |
| | | /// </summary> |
| | | public event Func<HydroParterViewModel, bool> PropertyValueChangedEvent; |
| | | public event Action<HydroParterViewModel> PropertyValueChangedEvent; |
| | | /// <summary> |
| | | /// 强调连接组件事件 |
| | | /// 第一个参数为本身Code |
| | |
| | | /// </summary> |
| | | public event Action<string, string> BlinkLinkParterEvent; |
| | | |
| | | |
| | | //获取水力信息方法 |
| | | private Func<Yw.Model.HydroModelInfo> _hydroInfoFunc = null; |
| | | |
| | | /// <summary> |
| | | /// 初始化数据 |
| | | /// 查看构件事件 |
| | | /// </summary> |
| | | public void InitialData(Func<Yw.Model.HydroModelInfo> hydroInfoFunc) |
| | | { |
| | | _hydroInfoFunc = hydroInfoFunc; |
| | | } |
| | | public event Action<HydroParterViewModel> ViewParterEvent; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 绑定对象 |
| | |
| | | { |
| | | get |
| | | { |
| | | return this.propertyGridControl1.SelectedObject as HydroParterViewModel; |
| | | var vm = this.propertyGridControl1.SelectedObject as HydroParterViewModel; |
| | | return vm; |
| | | } |
| | | set |
| | | { |
| | | this.barBtnChangeLink.Visibility = value is HydroLinkViewModel ? BarItemVisibility.Always : BarItemVisibility.Never; |
| | | this.barBtnView.Visibility = value == null ? BarItemVisibility.Never : BarItemVisibility.Always; |
| | | this.propertyGridControl1.SelectedObject = value; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | //获取行的视图对象 |
| | | private HydroParterViewModel GetPropertyViewModel(DevExpress.XtraVerticalGrid.Rows.BaseRow row) |
| | | { |
| | | if (row == null) |
| | | { |
| | | return default; |
| | | } |
| | | if (row.Level <= 1) |
| | | { |
| | | return this.SelectedObject; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | //属性编辑框的显示与取消 |
| | | private void propertyGridControl1_ShowingEditor(object sender, CancelEventArgs e) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | //行标题,描述,编辑框 |
| | | //编辑框 |
| | | private void propertyGridControl1_CustomRecordCellEdit(object sender, GetCustomRowCellEditEventArgs e) |
| | | { |
| | | var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last(); |
| | | if (string.IsNullOrEmpty(fieldName)) |
| | | { |
| | | return; |
| | | } |
| | | var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row); |
| | | var rowTypeFullName = e.Row.Properties.RowType.FullName; |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | #region bool |
| | | |
| | |
| | | { |
| | | return; |
| | | } |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | if (vm == null) |
| | | { |
| | |
| | | buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor; |
| | | buttonEdit.ButtonClick += delegate |
| | | { |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | switch (curvePropAttri.CurveType) |
| | | { |
| | | case HydroCurve.Tank: |
| | |
| | | if (this.SetCurveEvent == null || !this.SetCurveEvent.Invoke(vm, HydroCurve.PumpQH)) |
| | | { |
| | | var pumpViewModel = vm as HydroPumpViewModel; |
| | | var curveQh = hydroInfo.Curves?.Find(x => x.Code == pumpViewModel.CurveQH); |
| | | var curveQh = vm.HydroInfo.Curves?.Find(x => x.Code == pumpViewModel.CurveQH); |
| | | var dlg = new SetHydroCurveDlg(); |
| | | dlg.ReloadDataEvent += (curveInfo) => |
| | | { |
| | | if (hydroInfo.Curves == null) |
| | | if (vm.HydroInfo.Curves == null) |
| | | { |
| | | hydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | vm.HydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | } |
| | | if (curveQh != null) |
| | | { |
| | | hydroInfo.Curves.Remove(curveQh); |
| | | vm.HydroInfo.Curves.Remove(curveQh); |
| | | } |
| | | hydroInfo.Curves.Add(curveInfo); |
| | | vm.HydroInfo.Curves.Add(curveInfo); |
| | | pumpViewModel.CurveQH = curveInfo.Code; |
| | | UpdateRows(); |
| | | }; |
| | | dlg.SetBindingData(hydroInfo, curveQh, curvePropAttri.CurveType); |
| | | dlg.SetBindingData(vm.HydroInfo, curveQh, curvePropAttri.CurveType); |
| | | dlg.ShowDialog(); |
| | | } |
| | | } |
| | |
| | | if (this.SetCurveEvent == null || !this.SetCurveEvent.Invoke(vm, curvePropAttri.CurveType)) |
| | | { |
| | | var pumpViewModel = vm as HydroPumpViewModel; |
| | | var curveQp = hydroInfo.Curves?.Find(x => x.Code == pumpViewModel.CurveQP); |
| | | var curveQp = vm.HydroInfo.Curves?.Find(x => x.Code == pumpViewModel.CurveQP); |
| | | var dlg = new SetHydroCurveDlg(); |
| | | dlg.ReloadDataEvent += (curveInfo) => |
| | | { |
| | | if (hydroInfo.Curves == null) |
| | | if (vm.HydroInfo.Curves == null) |
| | | { |
| | | hydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | vm.HydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | } |
| | | if (curveQp != null) |
| | | { |
| | | hydroInfo.Curves.Remove(curveQp); |
| | | vm.HydroInfo.Curves.Remove(curveQp); |
| | | } |
| | | hydroInfo.Curves.Add(curveInfo); |
| | | vm.HydroInfo.Curves.Add(curveInfo); |
| | | pumpViewModel.CurveQP = curveInfo.Code; |
| | | UpdateRows(); |
| | | }; |
| | | dlg.SetBindingData(hydroInfo, curveQp, curvePropAttri.CurveType); |
| | | dlg.SetBindingData(vm.HydroInfo, curveQp, curvePropAttri.CurveType); |
| | | dlg.ShowDialog(); |
| | | } |
| | | } |
| | |
| | | case HydroCurve.PumpQE: |
| | | { |
| | | var pumpViewModel = vm as HydroPumpViewModel; |
| | | var curveQe = hydroInfo.Curves?.Find(x => x.Code == pumpViewModel.CurveQE); |
| | | var curveQe = vm.HydroInfo.Curves?.Find(x => x.Code == pumpViewModel.CurveQE); |
| | | var dlg = new SetHydroCurveDlg(); |
| | | dlg.ReloadDataEvent += (curveInfo) => |
| | | { |
| | | if (hydroInfo.Curves == null) |
| | | if (vm.HydroInfo.Curves == null) |
| | | { |
| | | hydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | vm.HydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | } |
| | | if (curveQe != null) |
| | | { |
| | | hydroInfo.Curves.Remove(curveQe); |
| | | vm.HydroInfo.Curves.Remove(curveQe); |
| | | } |
| | | hydroInfo.Curves.Add(curveInfo); |
| | | vm.HydroInfo.Curves.Add(curveInfo); |
| | | pumpViewModel.CurveQE = curveInfo.Code; |
| | | UpdateRows(); |
| | | }; |
| | | dlg.SetBindingData(hydroInfo, curveQe, curvePropAttri.CurveType); |
| | | dlg.SetBindingData(vm.HydroInfo, curveQe, curvePropAttri.CurveType); |
| | | dlg.ShowDialog(); |
| | | } |
| | | break; |
| | |
| | | buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor; |
| | | buttonEdit.ButtonClick += delegate |
| | | { |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | switch (patternProAttri.PatternType) |
| | | { |
| | |
| | | buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor; |
| | | buttonEdit.ButtonClick += delegate |
| | | { |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | this.BlinkLinkParterEvent?.Invoke(vm.Code, e.Row.Properties.Value.ToString()); |
| | | }; |
| | |
| | | |
| | | } |
| | | |
| | | //属性值正在改变 |
| | | void propertyGridControl1_CellValueChanging(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e) |
| | | { |
| | | var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last(); |
| | | var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row); |
| | | var propertyViewModel = GetPropertyViewModel(e.Row); |
| | | this.PropertyValueChangingEvent?.Invoke(propertyViewModel); |
| | | } |
| | | |
| | | //属性值改变 |
| | | void propertyGridControl1_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e) |
| | | private void propertyGridControl1_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e) |
| | | { |
| | | var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last(); |
| | | var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row); |
| | | var propertyViewModel = GetPropertyViewModel(e.Row); |
| | | this.PropertyValueChangedEvent?.Invoke(propertyViewModel); |
| | | if (this.PropertyValueChangedEvent == null || !this.PropertyValueChangedEvent.Invoke(propertyViewModel)) |
| | | { |
| | | var hydroInfo = _hydroInfoFunc?.Invoke(); |
| | | if (hydroInfo == null) |
| | | if (string.IsNullOrEmpty(fieldName)) |
| | | { |
| | | return; |
| | | } |
| | | var allParterList = hydroInfo.GetAllParters(); |
| | | var parter = allParterList?.Find(x => x.ID == propertyViewModel.ID); |
| | | if (parter == null) |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | parter.UpdateProperty(allParterList, propertyViewModel); |
| | | } |
| | | UpdateRows(); |
| | | vm.UpdateVmoProperty(); |
| | | this.PropertyValueChangedEvent?.Invoke(vm); |
| | | } |
| | | |
| | | // 描述 |
| | | private void barBtnHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | //改变连接节点 |
| | | private void barBtnChangeLink_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | var visible = this.splitterItem1.Visibility == LayoutVisibility.Always ? false : true; |
| | | SetDescriptionVisible(visible); |
| | | var link = this.SelectedObject as HydroLinkViewModel; |
| | | if (link != null) |
| | | { |
| | | var tempCode = link.StartCode; |
| | | link.StartCode = link.EndCode; |
| | | link.EndCode = tempCode; |
| | | link.UpdateVmoProperty(); |
| | | this.propertyGridControl1.UpdateRows(); |
| | | } |
| | | } |
| | | |
| | | //全部展开 |
| | |
| | | this.propertyGridControl1.CollapseAllRows(); |
| | | } |
| | | |
| | | //查看 |
| | | private void barBtnView_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | var vm = this.SelectedObject; |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | this.ViewParterEvent?.Invoke(vm); |
| | | } |
| | | |
| | | // 描述 |
| | | private void barBtnHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var visible = this.splitterItem1.Visibility == LayoutVisibility.Always ? false : true; |
| | | SetDescriptionVisible(visible); |
| | | } |
| | | |
| | | //聚焦行改变 |
| | | private void propertyGridControl1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) |
| | | { |
| | | //e.Row.AppearanceHeader.BackColor = Color.FromArgb(0, 122, 204); |
| | | // e.Row.AppearanceHeader.ForeColor = Color.White; |
| | | if (e.Row == null) |
| | | { |
| | | return; |
| | | } |
| | | //字段名称 |
| | | var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last(); |
| | | if (string.IsNullOrEmpty(fieldName)) |
| | | { |
| | | return; |
| | | } |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | string caption = string.Empty; |
| | | string descrition = string.Empty; |
| | | |
| | | |
| | | |
| | | //属性描述器 |
| | | var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row); |
| | | if (descriptor != null) |
| | | { |
| | | //名称 |
| | | var displayNameAttri = (DisplayNameAttribute)descriptor.Attributes[typeof(DisplayNameAttribute)]; |
| | | if (displayNameAttri != null && !string.IsNullOrEmpty(displayNameAttri.DisplayName)) |
| | | { |
| | | caption = displayNameAttri.DisplayName; |
| | | } |
| | | |
| | | //描述 |
| | | var descritionAttri = (DescriptionAttribute)descriptor.Attributes[typeof(DescriptionAttribute)]; |
| | | if (descritionAttri != null) |
| | | { |
| | | descrition = descritionAttri.Description; |
| | | } |
| | | } |
| | | |
| | | var propStatus = vm.GetPropStatus(fieldName); |
| | | this.hydroParterPropertyDescriptionCtrl1.SetBindingData(caption, descrition, propStatus); |
| | | |
| | | } |
| | | |