| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 允许修改 |
| | | /// </summary> |
| | | public bool AllowEdit { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 绑定对象 |
| | | /// </summary> |
| | | public HydroVisualViewModel SelectedObject |
| | |
| | | } |
| | | set |
| | | { |
| | | this.barBtnChangeLink.Visibility = value is HydroLinkViewModel ? BarItemVisibility.Always : BarItemVisibility.Never; |
| | | this.barBtnMatchingDb.Visibility = value == null ? BarItemVisibility.Never : BarItemVisibility.Always; |
| | | this.barBtnView.Visibility = value == null ? BarItemVisibility.Never : BarItemVisibility.Always; |
| | | if (value != null) |
| | | { |
| | | if (value is HydroReservoirViewModel) |
| | | { |
| | | this.barBtnMatchingDb.Visibility = BarItemVisibility.Never; |
| | | } |
| | | else if (value is HydroJunctionViewModel) |
| | | { |
| | | this.barBtnMatchingDb.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; |
| | | case Yw.Hydro.ePropStatus.Matching: |
| | | { |
| | | e.Appearance.ForeColor = Color.Purple; |
| | | } |
| | | 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; |