using DevExpress.XtraBars;
|
using DevExpress.XtraEditors;
|
using DevExpress.XtraEditors.Controls;
|
using DevExpress.XtraEditors.Repository;
|
using DevExpress.XtraLayout.Utils;
|
using DevExpress.XtraVerticalGrid.Events;
|
|
namespace Yw.WinFrmUI
|
{
|
|
public partial class HydroVisualPropertyCtrl : XtraUserControl
|
{
|
public HydroVisualPropertyCtrl()
|
{
|
InitializeComponent();
|
this.layoutControl1.SetupLayoutControl();
|
SetDescriptionVisible(false);
|
}
|
|
/// <summary>
|
/// 匹配db事件
|
/// 第一个参数为匹配Db的ViewModel
|
/// </summary>
|
public event Action<HydroVisualViewModel> MatchingDbEvent;
|
/// <summary>
|
/// 设置曲线事件
|
/// 第一个参数为设置曲线的ViewModel
|
/// 第二个参数为曲线 (HydroCurve)
|
/// 第三个参数为曲线类型(HydroCurveType)
|
/// </summary>
|
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> FlowDirectionPropertyValueChangedEvent;
|
|
|
/// <summary>
|
/// 强调连接节点事件
|
/// 第一个参数为本身Code
|
/// 第二个参数为连接节点Code
|
/// </summary>
|
public event Action<HydroLinkViewModel, string> BlinkLinkNodeEvent;
|
/// <summary>
|
/// 查看构件事件
|
/// </summary>
|
public event Action<HydroVisualViewModel> HydroViewEvent;
|
|
private HydroChangeHelper _changeHelper = null;//改变辅助类
|
private HydroPropStatusHelper _propStatusHelper = null;//属性状态辅助类
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public void InitialData
|
(
|
HydroChangeHelper changeHelper,
|
HydroPropStatusHelper propStatusHelper
|
)
|
{
|
_changeHelper = changeHelper;
|
_propStatusHelper = propStatusHelper;
|
}
|
|
/// <summary>
|
/// 允许修改
|
/// </summary>
|
public bool AllowEdit { get; set; }
|
|
/// <summary>
|
/// 绑定对象
|
/// </summary>
|
public HydroVisualViewModel SelectedObject
|
{
|
get
|
{
|
var vm = this.propertyGridControl1.SelectedObject as HydroVisualViewModel;
|
return vm;
|
}
|
set
|
{
|
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();
|
}
|
}
|
|
/// <summary>
|
/// 重新从数据源中读取数据,外观恢复刚开始加载的样子
|
/// </summary>
|
public void UpdateData()
|
{
|
this.propertyGridControl1.UpdateData();
|
}
|
|
/// <summary>
|
/// 更新数据,样式不变
|
/// </summary>
|
public void UpdateRows()
|
{
|
this.propertyGridControl1.UpdateRows();
|
}
|
|
//获取行的视图对象
|
private HydroVisualViewModel GetPropertyViewModel(DevExpress.XtraVerticalGrid.Rows.BaseRow row)
|
{
|
if (row == null)
|
{
|
return default;
|
}
|
if (row.Level <= 1)
|
{
|
return this.SelectedObject;
|
}
|
if (row.ParentRow == null)
|
{
|
return this.SelectedObject;
|
}
|
if (row.ParentRow.Properties.Value is HydroVisualViewModel)
|
{
|
return row.ParentRow.Properties.Value as HydroVisualViewModel;
|
}
|
return GetPropertyViewModel(row.ParentRow);
|
}
|
|
//设置描述控件的可见性
|
private void SetDescriptionVisible(bool isVisible)
|
{
|
var visible = isVisible ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.layoutDescription.Visibility = this.splitterItem1.Visibility = visible;
|
}
|
|
//自定义属性Header缩进
|
private void propertyGridControl1_CustomDrawRowHeaderIndent(object sender, CustomDrawRowHeaderIndentEventArgs e)
|
{
|
|
}
|
|
//自定义属性Header显示
|
private void propertyGridControl1_CustomDrawRowHeaderCell(object sender, CustomDrawRowHeaderCellEventArgs e)
|
{
|
//字段名称
|
var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last();
|
if (string.IsNullOrEmpty(fieldName))
|
{
|
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))
|
{
|
e.Caption = displayNameAttri.DisplayName;
|
}
|
//图标
|
var calcuProAttri = (HydroCalcuProAttribute)descriptor.Attributes[typeof(HydroCalcuProAttribute)];
|
if (calcuProAttri != null)
|
{
|
|
}
|
}
|
|
//颜色
|
var vm = GetPropertyViewModel(e.Row);
|
if (vm != null)
|
{
|
var propStatusInfo = _propStatusHelper?.GetPropStatusInfo(vm.Code, realFieldName);
|
if (propStatusInfo != null)
|
{
|
e.Appearance.ForeColor = HydroPropStatusColorHelper.GetColor(propStatusInfo.PropStatus);
|
}
|
}
|
}
|
|
//自定义属性值显示
|
private void propertyGridControl1_CustomDrawRowValueCell(object sender, CustomDrawRowValueCellEventArgs e)
|
{
|
//行字段名称
|
var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last();
|
if (string.IsNullOrEmpty(fieldName))
|
{
|
return;
|
}
|
//行类型全名称
|
var fullTypeName = e.Row.Properties.RowType.FullName;
|
|
if (fullTypeName == typeof(DateTime).FullName)
|
{
|
e.CellText = ((DateTime)e.Properties.Value).ToString("yyyy-MM-dd HH:mm:ss");
|
}
|
else if (fullTypeName == typeof(string[]).FullName)
|
{
|
var stringValue = (string[])e.Properties.Value;
|
e.CellText = stringValue?.Length.ToString();
|
}
|
else if (fullTypeName == typeof(DictionaryPropertyAdapter).FullName)
|
{
|
e.CellText = string.Empty;
|
}
|
else
|
{
|
var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row);
|
if (descriptor != null)
|
{
|
var calcuPropAttri = (HydroCalcuProAttribute)descriptor.Attributes[typeof(HydroCalcuProAttribute)];
|
if (calcuPropAttri != null)
|
{
|
if (e.Properties.Value == null)
|
{
|
e.CellText = "尚未计算";
|
e.Appearance.ForeColor = Color.OrangeRed;
|
}
|
}
|
var displayUnitAttri = (DisplayUnitAttribute)descriptor.Attributes[typeof(DisplayUnitAttribute)];
|
if (displayUnitAttri != null)
|
{
|
if (e.Properties.Value != null)
|
{
|
e.CellText = e.Properties.Value.ToString() + " " + displayUnitAttri.Unit;
|
}
|
}
|
}
|
}
|
}
|
|
//属性编辑框的显示与取消
|
private void propertyGridControl1_ShowingEditor(object sender, CancelEventArgs e)
|
{
|
var rowTypeFullName = this.propertyGridControl1.FocusedRow.Properties.RowType.FullName;
|
var fieldName = this.propertyGridControl1.FocusedRow.Properties.FieldName.Split(new char[] { '.' }).Last();
|
|
if (rowTypeFullName == typeof(Image).FullName)
|
{
|
e.Cancel = true;
|
return;
|
}
|
|
var descriptor = this.propertyGridControl1.GetPropertyDescriptor(this.propertyGridControl1.FocusedRow);
|
|
if (this.AllowEdit)
|
{
|
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;
|
}
|
}
|
}
|
|
//编辑框
|
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
|
|
if (rowTypeFullName == typeof(bool).FullName)
|
{
|
var ckEdit = new RepositoryItemCheckEdit();
|
ckEdit.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Standard;
|
if (e.Row.Properties.ReadOnly == true)
|
{
|
ckEdit.ReadOnly = true;
|
}
|
e.RepositoryItem = ckEdit;
|
}
|
|
#endregion
|
|
#region 富文本
|
|
if (descriptor != null)
|
{
|
var attri_multi = (MultiTextAttribute)descriptor.Attributes[typeof(MultiTextAttribute)];
|
if (attri_multi != null)
|
{
|
var memoEdit = new RepositoryItemMemoEdit();
|
if (e.Row.Properties.ReadOnly == true)
|
{
|
memoEdit.ReadOnly = true;
|
}
|
e.RepositoryItem = memoEdit;
|
}
|
}
|
|
#endregion
|
|
#region 图片
|
|
if (rowTypeFullName == typeof(Image).FullName)
|
{
|
var picEdit = new RepositoryItemPictureEdit();
|
picEdit.ReadOnly = true;
|
picEdit.NullText = "空";
|
e.RepositoryItem = picEdit;
|
e.Row.Expanded = true;
|
}
|
|
#endregion
|
|
#region 曲线
|
|
if (descriptor != null)
|
{
|
var curvePropAttri = (HydroCurveProAttribute)descriptor.Attributes[typeof(HydroCurveProAttribute)];
|
if (curvePropAttri != null)
|
{
|
var buttonEdit = new RepositoryItemButtonEdit();
|
buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor;
|
buttonEdit.ButtonClick += delegate
|
{
|
var vm = GetPropertyViewModel(e.Row);
|
if (vm == null)
|
{
|
return;
|
}
|
if (string.IsNullOrEmpty(curvePropAttri.CurveType))
|
{
|
this.SetCurveEvent?.Invoke(vm, curvePropAttri.Curve, curvePropAttri.CurveType);
|
}
|
else
|
{
|
if (e.Row.Properties.Value == null || string.IsNullOrEmpty(e.Row.Properties.Value.ToString()))
|
{
|
return;
|
}
|
this.radialMenu1.ShowPopup(MousePosition);
|
}
|
};
|
e.RepositoryItem = buttonEdit;
|
}
|
}
|
|
#endregion
|
|
#region 模式
|
|
if (descriptor != null)
|
{
|
var patternProAttri = (HydroPatternProAttribute)descriptor.Attributes[typeof(HydroPatternProAttribute)];
|
if (patternProAttri != null)
|
{
|
var buttonEdit = new RepositoryItemButtonEdit();
|
buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor;
|
buttonEdit.ButtonClick += delegate
|
{
|
|
};
|
e.RepositoryItem = buttonEdit;
|
}
|
}
|
|
|
#endregion
|
|
#region 标签
|
|
if (descriptor != null)
|
{
|
var flagsProAttri = (HydroFlagsProAttribute)descriptor.Attributes[typeof(HydroFlagsProAttribute)];
|
if (flagsProAttri != 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, vm.Vmo.Flags);
|
dlg.ReloadDataEvent += (flags) =>
|
{
|
vm.Vmo.Flags = flags;
|
vm.Flags = Yw.Untity.FlagsHelper.ToString(flags);
|
this.propertyGridControl1.UpdateRows();
|
this.propertyGridControl1.RefreshEditor();
|
this.PropertyValueChangedEvent?.Invoke(vm);
|
};
|
dlg.ShowDialog();
|
};
|
e.RepositoryItem = buttonEdit;
|
}
|
}
|
|
#endregion
|
|
#region 参数
|
|
if (descriptor != null)
|
{
|
var parasProAttri = (HydroParasProAttribute)descriptor.Attributes[typeof(HydroParasProAttribute)];
|
if (parasProAttri != null)
|
{
|
var buttonEdit = new RepositoryItemButtonEdit();
|
buttonEdit.TextEditStyle = TextEditStyles.HideTextEditor;
|
buttonEdit.ButtonClick += delegate
|
{
|
var vm = GetPropertyViewModel(e.Row);
|
var dlg = new SetParasDlg();
|
dlg.SetBindingData(vm.Vmo.Paras);
|
dlg.ReloadDataEvent += (paras) =>
|
{
|
vm.Vmo.Paras = paras;
|
vm.Paras = new DictionaryPropertyAdapter(paras);
|
this.propertyGridControl1.UpdateRows();
|
this.propertyGridControl1.RefreshEditor();
|
this.PropertyValueChangedEvent?.Invoke(vm);
|
};
|
dlg.ShowDialog();
|
};
|
e.RepositoryItem = buttonEdit;
|
}
|
}
|
|
|
#endregion
|
|
#region 连接
|
|
if (e.Row.Properties.Value != null)
|
{
|
if (descriptor != null)
|
{
|
var linkCodeAttri = (HydroLinkProAttribute)descriptor.Attributes[typeof(HydroLinkProAttribute)];
|
if (linkCodeAttri != null)
|
{
|
var buttonEdit = new RepositoryItemButtonEdit();
|
buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor;
|
buttonEdit.ButtonClick += delegate
|
{
|
var vm = GetPropertyViewModel(e.Row);
|
var vmLink = vm as HydroLinkViewModel;
|
this.BlinkLinkNodeEvent?.Invoke(vmLink, e.Row.Properties.Value.ToString());
|
};
|
e.RepositoryItem = buttonEdit;
|
}
|
}
|
}
|
|
#endregion
|
|
#region 阀门
|
|
if (vm is HydroValveViewModel valve)
|
{
|
switch (valve.Vmo.ValveType)
|
{
|
case Yw.Hydro.ValveType.PSV:
|
{
|
if (fieldName == nameof(HydroValveViewModel.ValvePress))
|
{
|
e.Row.Visible = true;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveFlow))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveLength))
|
{
|
e.Row.Visible = false;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.PRV:
|
{
|
if (fieldName == nameof(HydroValveViewModel.ValvePress))
|
{
|
e.Row.Visible = true;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveFlow))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveLength))
|
{
|
e.Row.Visible = false;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.PBV:
|
{
|
if (fieldName == nameof(HydroValveViewModel.ValvePress))
|
{
|
e.Row.Visible = true;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveFlow))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveLength))
|
{
|
e.Row.Visible = false;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.FCV:
|
{
|
if (fieldName == nameof(HydroValveViewModel.ValvePress))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveFlow))
|
{
|
e.Row.Visible = true;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveLength))
|
{
|
e.Row.Visible = false;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.TCV:
|
{
|
if (fieldName == nameof(HydroValveViewModel.ValvePress))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveFlow))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveLength))
|
{
|
e.Row.Visible = false;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.GPV:
|
{
|
if (fieldName == nameof(HydroValveViewModel.ValvePress))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveFlow))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveLength))
|
{
|
e.Row.Visible = false;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.CV:
|
{
|
if (fieldName == nameof(HydroValveViewModel.ValvePress))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveFlow))
|
{
|
e.Row.Visible = false;
|
}
|
if (fieldName == nameof(HydroValveViewModel.ValveLength))
|
{
|
e.Row.Visible = true;
|
}
|
}
|
break;
|
default: break;
|
}
|
}
|
|
|
#endregion
|
|
|
}
|
|
//属性值改变
|
private void propertyGridControl1_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
|
{
|
var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last();
|
if (string.IsNullOrEmpty(fieldName))
|
{
|
return;
|
}
|
var vm = GetPropertyViewModel(e.Row);
|
if (vm == null)
|
{
|
return;
|
}
|
vm.UpdateVmoProperty();
|
this.PropertyValueChangedEvent?.Invoke(vm);
|
|
var realFieldName = fieldName;
|
var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row);
|
if (descriptor != null)
|
{
|
//真实属性名称
|
HydroRealProAttribute realPropAttri = (HydroRealProAttribute)descriptor.Attributes[typeof(HydroRealProAttribute)];
|
if (realPropAttri != null)
|
{
|
realFieldName = realPropAttri.RealPropName;
|
}
|
|
var hydroMarkPropAttri = descriptor.Attributes[typeof(HydroMarkProAttribute)];
|
if (hydroMarkPropAttri != null)
|
{
|
this.MarkPropertyValueChangedEvent?.Invoke(vm);
|
}
|
|
var hydroGradingPropAttri = descriptor.Attributes[typeof(HydroGradingProAttribute)];
|
if (hydroGradingPropAttri != null)
|
{
|
this.GradingPropertyValueChangedEvent?.Invoke(vm);
|
}
|
|
var hydroFlowDirectionAttri = descriptor.Attributes[typeof(HydroFlowDirectionProAttribute)];
|
if (hydroFlowDirectionAttri != null)
|
{
|
this.FlowDirectionPropertyValueChangedEvent?.Invoke(vm);
|
}
|
|
this.propertyGridControl1.UpdateRows();
|
}
|
_changeHelper?.Append(vm.Vmo, eChangeType.Update);
|
_propStatusHelper?.UpdatePropStatus(vm.Code, realFieldName, Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过属性控件修改");
|
}
|
|
//Db匹配
|
private void barBtnMatchingDb_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
var vm = this.SelectedObject;
|
if (vm == null)
|
{
|
return;
|
}
|
this.MatchingDbEvent?.Invoke(vm);
|
}
|
|
//改变连接节点
|
private void barBtnChangeLink_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
var result = XtraMessageBox.Show("是否确认调整上下游?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes;
|
if (!result)
|
{
|
return;
|
}
|
var link = this.SelectedObject as HydroLinkViewModel;
|
if (link != null)
|
{
|
var tempCode = link.StartCode;
|
link.StartCode = link.EndCode;
|
link.EndCode = tempCode;
|
link.UpdateVmoProperty();
|
|
_propStatusHelper?.UpdatePropStatus(link.Code, nameof(link.Vmo.StartCode), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}调整上下游");
|
_propStatusHelper?.UpdatePropStatus(link.Code, nameof(link.Vmo.EndCode), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}调整上下游");
|
|
var translation = this.SelectedObject as HydroTranslationViewModel;
|
if (translation != null)
|
{
|
var tempDiameter = translation.StartDiameter;
|
translation.StartDiameter = translation.EndDiameter;
|
translation.EndDiameter = tempDiameter;
|
translation.UpdateVmoProperty();
|
_propStatusHelper?.UpdatePropStatus(translation.Code, nameof(translation.Vmo.StartDiameter), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}调整上下游");
|
_propStatusHelper?.UpdatePropStatus(translation.Code, nameof(translation.Vmo.EndDiameter), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}调整上下游");
|
}
|
|
var pump = this.SelectedObject as HydroPumpViewModel;
|
if (pump != null)
|
{
|
var tempDiameter = pump.InletDiameter;
|
pump.InletDiameter = pump.OutletDiameter;
|
pump.OutletDiameter = tempDiameter;
|
pump.UpdateVmoProperty();
|
_propStatusHelper?.UpdatePropStatus(pump.Code, nameof(pump.Vmo.InletDiameter), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}调整上下游");
|
_propStatusHelper?.UpdatePropStatus(pump.Code, nameof(pump.Vmo.OutletDiameter), Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}调整上下游");
|
}
|
|
_changeHelper?.Append(link.Vmo, eChangeType.Update);
|
|
this.propertyGridControl1.UpdateRows();
|
}
|
}
|
|
//全部展开
|
private void barBtnExpandAll_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
this.propertyGridControl1.ExpandAllRows();
|
}
|
|
//全部折叠
|
private void barBtnCollpseAll_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
this.propertyGridControl1.CollapseAllRows();
|
}
|
|
//查看
|
private void barBtnView_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
var vm = this.SelectedObject;
|
if (vm == null)
|
{
|
return;
|
}
|
this.HydroViewEvent?.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)
|
{
|
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;
|
string realFieldName = fieldName;
|
|
|
//属性描述器
|
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 realPropAttri = (HydroRealProAttribute)descriptor.Attributes[typeof(HydroRealProAttribute)];
|
if (realPropAttri != null)
|
{
|
realFieldName = realPropAttri.RealPropName;
|
}
|
}
|
|
var propStatusInfo = _propStatusHelper?.GetPropStatusInfo(vm.Code, realFieldName);
|
this.hydroVisualPropertyDescriptionCtrl1.SetBindingData(caption, descrition, propStatusInfo);
|
|
}
|
|
//查看曲线
|
private void barBtnViewCurve_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
var vm = this.SelectedObject;
|
if (vm == null)
|
{
|
return;
|
}
|
var row = this.propertyGridControl1.FocusedRow;
|
var code = row.Properties.Value?.ToString();
|
var curve = vm.HydroInfo.Curves?.Find(x => x.Code == code);
|
if (curve == null)
|
{
|
return;
|
}
|
var dlg = new HydroCurveViewDlg();
|
dlg.SetBindingData(curve);
|
dlg.ShowDialog();
|
}
|
|
//编辑曲线
|
private void barBtnEditCurve_ItemClick(object sender, ItemClickEventArgs e)
|
{
|
var vm = this.SelectedObject;
|
if (vm == null)
|
{
|
return;
|
}
|
var row = this.propertyGridControl1.FocusedRow;
|
var code = row.Properties.Value?.ToString();
|
var curve = vm.HydroInfo.Curves?.Find(x => x.Code == code);
|
if (curve == null)
|
{
|
return;
|
}
|
var dlg = new HydroCurveEditDlg();
|
dlg.ReloadDataEvent += (rhs) =>
|
{
|
_changeHelper?.Append(rhs, eChangeType.Update);
|
};
|
dlg.SetBindingData(curve);
|
dlg.ShowDialog();
|
}
|
|
|
|
|
}
|
}
|