From ba67a904276b104f2c9f35c3bba0fb4928a6bae0 Mon Sep 17 00:00:00 2001 From: Shuxia Ning <NingShuxia0927@outlook.com> Date: 星期四, 19 十二月 2024 20:22:40 +0800 Subject: [PATCH] 冲突 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/05-property/HydroVisualPropertyCtrl.cs | 104 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 60 insertions(+), 44 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/05-property/HydroVisualPropertyCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/05-property/HydroVisualPropertyCtrl.cs index a490c8a..5623be1 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/05-property/HydroVisualPropertyCtrl.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/05-property/HydroVisualPropertyCtrl.cs @@ -59,6 +59,11 @@ /// <summary> + /// 鍏佽淇敼 + /// </summary> + public bool AllowEdit { get; set; } + + /// <summary> /// 缁戝畾瀵硅薄 /// </summary> public HydroVisualViewModel SelectedObject @@ -70,21 +75,29 @@ } 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(); } } @@ -148,10 +161,17 @@ { 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)) @@ -170,33 +190,10 @@ 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); } } } @@ -256,10 +253,28 @@ } 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; @@ -381,7 +396,8 @@ { vm.Vmo.Flags = flags; vm.Flags = Yw.Untity.FlagsHelper.ToString(flags); - UpdateRows(); + this.propertyGridControl1.UpdateRows(); + this.propertyGridControl1.RefreshEditor(); this.PropertyValueChangedEvent?.Invoke(vm); }; dlg.ShowDialog(); -- Gitblit v1.9.3