| | |
| | | /// <summary> |
| | | /// 匹配db事件 |
| | | /// 第一个参数为匹配Db的ViewModel |
| | | /// 第二个参数为是否匹配成功 |
| | | /// </summary> |
| | | public event Func<HydroVisualViewModel, bool> MatchingDbEvent; |
| | | public event Action<HydroVisualViewModel> MatchingDbEvent; |
| | | /// <summary> |
| | | /// 设置曲线事件 |
| | | /// 第一个参数为设置曲线的ViewModel |
| | | /// 第二个参数为曲线类型 |
| | | /// 第三个参数为是否设置成功 |
| | | /// 第二个参数为曲线 (HydroCurve) |
| | | /// 第三个参数为曲线类型(HydroCurveType) |
| | | /// </summary> |
| | | public event Func<HydroVisualViewModel, string, string, bool> SetCurveEvent; |
| | | /// <summary> |
| | | /// 设置模式事件 |
| | | /// 第一个参数为设置模式事的ViewModel |
| | | /// 第二个参数为模式事类型 |
| | | /// 第三个参数为是否设置成功 |
| | | /// </summary> |
| | | public event Func<HydroVisualViewModel, string, bool> SetPatternEvent; |
| | | public event Action<HydroVisualViewModel, string, string> SetCurveEvent; |
| | | /// <summary> |
| | | /// 属性值发生改变事件 |
| | | /// </summary> |
| | | public event Action<HydroVisualViewModel> PropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 标注属性值改变事件 |
| | | /// </summary> |
| | | public event Action<HydroVisualViewModel> MarkPropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 分级属性值改变事件 |
| | | /// </summary> |
| | | public event Action<HydroVisualViewModel> GradingPropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 水流动画属性值改变事件 |
| | | /// </summary> |
| | | public event Action<HydroVisualViewModel> FlowEffectPropertyValueChangedEvent; |
| | | |
| | | /// <summary> |
| | | /// 强调连接节点事件 |
| | | /// 第一个参数为本身Code |
| | | /// 第二个参数为连接节点Code |
| | | /// </summary> |
| | | public event Action<HydroLinkViewModel, string> BlinkLinkNodeEvent; |
| | | |
| | | /// <summary> |
| | | /// 查看构件事件 |
| | | /// </summary> |
| | | public event Action<HydroVisualViewModel> HydroViewEvent; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 允许修改 |
| | | /// </summary> |
| | | public bool AllowEdit { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 绑定对象 |
| | |
| | | } |
| | | set |
| | | { |
| | | this.barBtnChangeLink.Visibility = value is HydroLinkViewModel ? BarItemVisibility.Always : BarItemVisibility.Never; |
| | | this.barBtnDb.Visibility = value == null ? BarItemVisibility.Never : BarItemVisibility.Always; |
| | | this.barBtnView.Visibility = value == null ? BarItemVisibility.Never : BarItemVisibility.Always; |
| | | if (value != null) |
| | | { |
| | | if (value is HydroReservoirViewModel) |
| | | { |
| | | this.barBtnDb.Visibility = BarItemVisibility.Never; |
| | | } |
| | | else if (value is HydroJunctionViewModel) |
| | | { |
| | | this.barBtnDb.Visibility = BarItemVisibility.Never; |
| | | } |
| | | } |
| | | this.propertyGridControl1.SelectedObject = value; |
| | | SetSelectedObject(value); |
| | | } |
| | | } |
| | | |
| | | //设置选择对象 |
| | | private void SetSelectedObject(HydroVisualViewModel vm) |
| | | { |
| | | if (this.AllowEdit) |
| | | { |
| | | this.barBtnChangeLink.Visibility = vm is HydroLinkViewModel ? BarItemVisibility.Always : BarItemVisibility.Never; |
| | | this.barBtnMatchingDb.Visibility = vm == null ? BarItemVisibility.Never : BarItemVisibility.Always; |
| | | } |
| | | else |
| | | { |
| | | this.barBtnMatchingDb.Visibility = BarItemVisibility.Never; |
| | | this.barBtnChangeLink.Visibility = BarItemVisibility.Never; |
| | | } |
| | | this.barBtnView.Visibility = vm == null ? BarItemVisibility.Never : BarItemVisibility.Always; |
| | | var selectObj = this.propertyGridControl1.SelectedObject as HydroVisualViewModel; |
| | | this.propertyGridControl1.SelectedObject = vm; |
| | | if (selectObj == vm) |
| | | { |
| | | this.propertyGridControl1.UpdateRows(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | return; |
| | | } |
| | | var realFieldName = fieldName; |
| | | //属性描述器 |
| | | var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row); |
| | | if (descriptor != null) |
| | | { |
| | | //真实属性名称 |
| | | var realPropAttri = (HydroRealProAttribute)descriptor.Attributes[typeof(HydroRealProAttribute)]; |
| | | if (realPropAttri != null) |
| | | { |
| | | realFieldName = realPropAttri.RealPropName; |
| | | } |
| | | //名称 |
| | | var displayNameAttri = (DisplayNameAttribute)descriptor.Attributes[typeof(DisplayNameAttribute)]; |
| | | if (displayNameAttri != null && !string.IsNullOrEmpty(displayNameAttri.DisplayName)) |
| | |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | if (vm != null) |
| | | { |
| | | var propStatus = vm.GetPropStatus(fieldName); |
| | | var propStatus = vm.GetPropStatus(realFieldName); |
| | | if (propStatus != null) |
| | | { |
| | | switch (propStatus.PropStatus) |
| | | { |
| | | case Yw.Hydro.ePropStatus.Error: |
| | | { |
| | | e.Appearance.ForeColor = Color.Red; |
| | | } |
| | | break; |
| | | case Yw.Hydro.ePropStatus.Normal: |
| | | { |
| | | e.Appearance.ForeColor = Color.Black; |
| | | } |
| | | break; |
| | | case Yw.Hydro.ePropStatus.Lack: |
| | | { |
| | | e.Appearance.ForeColor = Color.Green; |
| | | } |
| | | break; |
| | | case Yw.Hydro.ePropStatus.Abnormal: |
| | | { |
| | | e.Appearance.ForeColor = Color.Orange; |
| | | } |
| | | break; |
| | | default: break; |
| | | } |
| | | e.Appearance.ForeColor = HydroPropStatusHelper.GetColor(propStatus.PropStatus); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | var descriptor = this.propertyGridControl1.GetPropertyDescriptor(this.propertyGridControl1.FocusedRow); |
| | | var showEditor = (ShowEditorAttribute)descriptor.Attributes[typeof(ShowEditorAttribute)]; |
| | | if (showEditor != null) |
| | | |
| | | if (this.AllowEdit) |
| | | { |
| | | if (!showEditor.ShowEditor) |
| | | var showEditor = (ShowEditorAttribute)descriptor.Attributes[typeof(ShowEditorAttribute)]; |
| | | if (showEditor != null) |
| | | { |
| | | if (!showEditor.ShowEditor) |
| | | { |
| | | e.Cancel = true; |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var showEditorInView = (ShowEditorInViewAttribute)descriptor.Attributes[typeof(ShowEditorInViewAttribute)]; |
| | | if (showEditorInView == null) |
| | | { |
| | | e.Cancel = true; |
| | | return; |
| | | } |
| | | if (!showEditorInView.ShowEditor) |
| | | { |
| | | e.Cancel = true; |
| | | return; |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 型号 |
| | | |
| | | var modelTypeAttri = (HydroModelTypeProAttribute)descriptor.Attributes[typeof(HydroModelTypeProAttribute)]; |
| | | if (modelTypeAttri != null) |
| | | { |
| | | var buttonEdit = new RepositoryItemButtonEdit(); |
| | | buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor; |
| | | buttonEdit.ButtonClick += delegate |
| | | { |
| | | if (this.MatchingDbEvent == null) |
| | | { |
| | | return; |
| | | } |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var bol = this.MatchingDbEvent.Invoke(vm); |
| | | if (bol) |
| | | { |
| | | UpdateRows(); |
| | | } |
| | | }; |
| | | e.RepositoryItem = buttonEdit; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 曲线 |
| | | |
| | | var curvePropAttri = (HydroCurveProAttribute)descriptor.Attributes[typeof(HydroCurveProAttribute)]; |
| | |
| | | { |
| | | return; |
| | | } |
| | | if (this.SetCurveEvent == null || !this.SetCurveEvent.Invoke(vm, curvePropAttri.Curve, curvePropAttri.CurveType)) |
| | | { |
| | | var curveCode = e.Row.Properties.Value?.ToString(); |
| | | var curveInfo = vm.HydroInfo.Curves?.Find(x => x.Code == curveCode); |
| | | var dlg = new SetHydroCurveDlg(); |
| | | dlg.SetBindingData(vm.HydroInfo, curveInfo, curvePropAttri.Curve, curvePropAttri.CurveType); |
| | | dlg.ReloadDataEvent += (curveInfoRhs) => |
| | | { |
| | | if (vm.HydroInfo.Curves == null) |
| | | { |
| | | vm.HydroInfo.Curves = new List<Model.HydroCurveInfo>(); |
| | | } |
| | | if (curveInfo != null) |
| | | { |
| | | vm.HydroInfo.Curves.Remove(curveInfo); |
| | | } |
| | | vm.HydroInfo.Curves.Add(curveInfo); |
| | | e.Row.Properties.Value = curveInfo.Code; |
| | | vm.UpdateVmoProperty(); |
| | | UpdateRows(); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | this.SetCurveEvent?.Invoke(vm, curvePropAttri.Curve, curvePropAttri.CurveType); |
| | | }; |
| | | e.RepositoryItem = buttonEdit; |
| | | } |
| | |
| | | buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor; |
| | | buttonEdit.ButtonClick += delegate |
| | | { |
| | | var vm = GetPropertyViewModel(e.Row); |
| | | switch (patternProAttri.PatternType) |
| | | { |
| | | case HydroPattern.Head: |
| | | { |
| | | if (this.SetPatternEvent == null || !this.SetPatternEvent.Invoke(vm, HydroPattern.Head)) |
| | | { |
| | | //缺省的设置方法 |
| | | } |
| | | } |
| | | break; |
| | | case HydroPattern.Demand: |
| | | { |
| | | if (this.SetPatternEvent == null || !this.SetPatternEvent.Invoke(vm, HydroPattern.Demand)) |
| | | { |
| | | //缺省的设置方法 |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | }; |
| | | e.RepositoryItem = buttonEdit; |
| | | } |
| | |
| | | { |
| | | vm.Vmo.Flags = flags; |
| | | vm.Flags = Yw.Untity.FlagsHelper.ToString(flags); |
| | | UpdateRows(); |
| | | this.propertyGridControl1.UpdateRows(); |
| | | this.propertyGridControl1.RefreshEditor(); |
| | | this.PropertyValueChangedEvent?.Invoke(vm); |
| | | }; |
| | | dlg.ShowDialog(); |
| | |
| | | } |
| | | } |
| | | |
| | | //选择 |
| | | private void barBtnDb_ItemClick(object sender, ItemClickEventArgs e) |
| | | //Db匹配 |
| | | private void barBtnMatchingDb_ItemClick(object sender, ItemClickEventArgs e) |
| | | { |
| | | var vm = this.SelectedObject; |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | if (this.MatchingDbEvent != null) |
| | | { |
| | | |
| | | } |
| | | this.MatchingDbEvent?.Invoke(vm); |
| | | } |
| | | |
| | | //改变连接节点 |