| | |
| | | using DevExpress.XtraBars; |
| | | using DevExpress.Data.ExpressionEditor; |
| | | using DevExpress.Utils; |
| | | using DevExpress.XtraBars; |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraEditors.Controls; |
| | | using DevExpress.XtraEditors.Repository; |
| | | using DevExpress.XtraLayout.Utils; |
| | | using DevExpress.XtraVerticalGrid.Events; |
| | | using NetTaste; |
| | | using System.Windows.Forms.VisualStyles; |
| | | using Yw.EPAnet; |
| | | |
| | | namespace Yw.WinFrmUI |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取水力信息事件 |
| | | /// </summary> |
| | | public event Func<Yw.Model.HydroModelInfo> GetHydroInfoEvent; |
| | | /// <summary> |
| | | /// 选择曲线事件 |
| | | /// </summary> |
| | | public event Func<HydroParterPropertyViewModel, string, bool> SelectCurveEvent; |
| | | /// <summary> |
| | | /// 选择模式事件 |
| | | /// </summary> |
| | | public event Func<HydroParterPropertyViewModel, string, bool> SelectPatternEvent; |
| | | /// <summary> |
| | | /// 属性值正在改变事件 |
| | | /// </summary> |
| | | public Action<HydroParterPropertyViewModel> PropertyValueChangingEvent; |
| | | |
| | | public event Func<HydroParterPropertyViewModel, bool> PropertyValueChangingEvent; |
| | | /// <summary> |
| | | /// 属性值发生改变事件 |
| | | /// </summary> |
| | | public Action<HydroParterPropertyViewModel> PropertyValueChangedEvent; |
| | | public event Func<HydroParterPropertyViewModel, bool> PropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 绑定对象 |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 绑定对象列表 |
| | | /// </summary> |
| | | public List<HydroParterPropertyViewModel> SelectedObjects |
| | | { |
| | | get { return this.propertyGridControl1.SelectedObjects?.Select(x => x as HydroParterPropertyViewModel).ToList(); } |
| | | set |
| | | { |
| | | this.propertyGridControl1.SelectedObjects = value?.ToArray(); |
| | | OnChanged(); |
| | | } |
| | | } |
| | | |
| | | |
| | | //改变触发 |
| | | protected virtual void OnChanged() |
| | | { |
| | | if (this.SelectedObject == null) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | return row.ParentRow.Properties.Value as HydroParterPropertyViewModel; |
| | | } |
| | | return GetView(row.ParentRow); |
| | | return GetPropertyViewModel(row.ParentRow); |
| | | } |
| | | |
| | | //设置描述控件的可见性 |
| | |
| | | private void propertyGridControl1_CustomDrawRowValueCell(object sender, CustomDrawRowValueCellEventArgs e) |
| | | { |
| | | var rowTypeFullName = e.Row.Properties.RowType.FullName; |
| | | |
| | | if (rowTypeFullName == typeof(DateTime).FullName) |
| | | { |
| | | e.CellText = ((DateTime)e.Properties.Value).ToString("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | { |
| | | if (e.Properties.Value != null) |
| | | { |
| | | e.CellText = e.Properties.Value.ToString() + displayUnit.Unit; |
| | | e.CellText = e.Properties.Value.ToString() + " " + displayUnit.Unit; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //自定义属性描述 |
| | | private void propertyGridControl1_CustomPropertyDescriptors(object sender, CustomPropertyDescriptorsEventArgs e) |
| | | { |
| | | |
| | | } |
| | | |
| | | //属性编辑框的显示与取消 |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 曲线 |
| | | |
| | | var curvePro = (IsHydroCurveProAttribute)descriptor.Attributes[typeof(IsHydroCurveProAttribute)]; |
| | | if (curvePro != null) |
| | | { |
| | | var buttonEdit = new RepositoryItemButtonEdit(); |
| | | buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor; |
| | | buttonEdit.ButtonClick += delegate |
| | | { |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | if (this.SelectCurveEvent == null || !this.SelectCurveEvent.Invoke(vm, curvePro.CurveType)) |
| | | { |
| | | var hydroInfo = GetHydroInfoEvent?.Invoke(); |
| | | if (hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | switch (curvePro.CurveType) |
| | | { |
| | | case HydroCurve.Pump: |
| | | { |
| | | |
| | | } |
| | | break; |
| | | case HydroCurve.PumpQH: |
| | | { |
| | | var vmPump = vm as HydroPumpPropertyViewModel; |
| | | var curveQh = hydroInfo.Curves?.Find(x => x.Code == vmPump.CurveQH); |
| | | var dlg = new SetHydroCurveDlg(); |
| | | dlg.ReloadDataEvent += (curveInfo) => |
| | | { |
| | | if (hydroInfo.Curves == null) |
| | | { |
| | | hydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | } |
| | | if (curveQh != null) |
| | | { |
| | | hydroInfo.Curves.Remove(curveQh); |
| | | } |
| | | hydroInfo.Curves.Add(curveInfo); |
| | | vmPump.CurveQH = curveInfo.Code; |
| | | UpdateRows(); |
| | | }; |
| | | dlg.SetBindingData(hydroInfo, curveQh, curvePro.CurveType); |
| | | dlg.ShowDialog(); |
| | | } |
| | | break; |
| | | case HydroCurve.PumpQP: |
| | | { |
| | | var vmPump = vm as HydroPumpPropertyViewModel; |
| | | var curveQp = hydroInfo.Curves?.Find(x => x.Code == vmPump.CurveQP); |
| | | var dlg = new SetHydroCurveDlg(); |
| | | dlg.ReloadDataEvent += (curveInfo) => |
| | | { |
| | | if (hydroInfo.Curves == null) |
| | | { |
| | | hydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | } |
| | | if (curveQp != null) |
| | | { |
| | | hydroInfo.Curves.Remove(curveQp); |
| | | } |
| | | hydroInfo.Curves.Add(curveInfo); |
| | | vmPump.CurveQP = curveInfo.Code; |
| | | UpdateRows(); |
| | | }; |
| | | dlg.SetBindingData(hydroInfo, curveQp, curvePro.CurveType); |
| | | dlg.ShowDialog(); |
| | | } |
| | | break; |
| | | case HydroCurve.PumpQE: |
| | | { |
| | | var vmPump = vm as HydroPumpPropertyViewModel; |
| | | var curveQe = hydroInfo.Curves?.Find(x => x.Code == vmPump.CurveQE); |
| | | var dlg = new SetHydroCurveDlg(); |
| | | dlg.ReloadDataEvent += (curveInfo) => |
| | | { |
| | | if (hydroInfo.Curves == null) |
| | | { |
| | | hydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | } |
| | | if (curveQe != null) |
| | | { |
| | | hydroInfo.Curves.Remove(curveQe); |
| | | } |
| | | hydroInfo.Curves.Add(curveInfo); |
| | | vmPump.CurveQE = curveInfo.Code; |
| | | UpdateRows(); |
| | | }; |
| | | dlg.SetBindingData(hydroInfo, curveQe, curvePro.CurveType); |
| | | dlg.ShowDialog(); |
| | | } |
| | | break; |
| | | case HydroCurve.Valve: |
| | | { |
| | | |
| | | } |
| | | break; |
| | | case HydroCurve.ValveQL: |
| | | { |
| | | |
| | | } |
| | | break; |
| | | default: break; |
| | | } |
| | | } |
| | | }; |
| | | e.RepositoryItem = buttonEdit; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 模式 |
| | | |
| | | var patternPro = (IsHydroPatternProAttribute)descriptor.Attributes[typeof(IsHydroPatternProAttribute)]; |
| | | if (patternPro != null) |
| | | { |
| | | var buttonEdit = new RepositoryItemButtonEdit(); |
| | | buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor; |
| | | buttonEdit.ButtonClick += delegate |
| | | { |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | this.SelectPatternEvent?.Invoke(vm, patternPro.PatternType); |
| | | }; |
| | | e.RepositoryItem = buttonEdit; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 标签 |
| | | |
| | | var flagsPro = (IsHydroFlagsProAttribute)descriptor.Attributes[typeof(IsHydroFlagsProAttribute)]; |
| | | if (flagsPro != null) |
| | | { |
| | | var buttonEdit = new RepositoryItemButtonEdit(); |
| | | buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor; |
| | | buttonEdit.ButtonClick += async delegate |
| | | { |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | var flagVmoList = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(Yw.Hydro.DataType.HydroParter); |
| | | var dbFlagList = flagVmoList?.Select(x => x.Name).Distinct().ToList(); |
| | | var dlg = new SetFlagsDlg(); |
| | | dlg.SetBindingData(dbFlagList, Yw.Untity.FlagsHelper.ToList(vm.Flags)); |
| | | dlg.ReloadDataEvent += (flags) => |
| | | { |
| | | vm.Flags = Yw.Untity.FlagsHelper.ToString(flags); |
| | | UpdateRows(); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | }; |
| | | e.RepositoryItem = buttonEdit; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | |
| | |
| | | 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 = GetHydroInfoEvent?.Invoke(); |
| | | if (hydroInfo == null) |
| | | { |
| | | return; |
| | | } |
| | | var allParterList = hydroInfo.GetAllParters(); |
| | | var parter = allParterList?.Find(x => x.ID == propertyViewModel.ID); |
| | | if (parter == null) |
| | | { |
| | | return; |
| | | } |
| | | parter.UpdateProperty(allParterList, propertyViewModel); |
| | | } |
| | | UpdateRows(); |
| | | } |
| | | |
| | |
| | | this.propertyGridControl1.CollapseAllRows(); |
| | | } |
| | | |
| | | private void propertyGridControl1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) |
| | | { |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |