using DevExpress.XtraEditors;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class XhsSchemeElbowChangeListCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public XhsSchemeElbowChangeListCtrl()
|
{
|
InitializeComponent();
|
this.layoutView1.SetDefuaulView();
|
this.layoutView1.SetFindPanel();
|
}
|
|
/// <summary>
|
/// 水力查看事件
|
/// </summary>
|
public event Action<string> HydroViewEvent;
|
|
/// <summary>
|
/// 水力改变事件
|
/// </summary>
|
public event Action<HydroElbowViewModel> HydroChangeEvent;
|
|
|
private BindingList<XhsSchemeElbowChangeViewModel> _allBindingList = null;//所有绑定列表
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
|
{
|
_allBindingList = new BindingList<XhsSchemeElbowChangeViewModel>();
|
if (hydroInfo != null)
|
{
|
if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0)
|
{
|
foreach (var blunthead in hydroInfo.Elbows)
|
{
|
var vm = new HydroElbowViewModel(blunthead, hydroInfo);
|
var viewModel = new XhsSchemeElbowChangeViewModel(vm);
|
viewModel.ViewImage = this.svgImg32[0];
|
_allBindingList.Add(viewModel);
|
}
|
}
|
}
|
this.xhsSchemeElbowChangeViewModelBindingSource.DataSource = _allBindingList;
|
this.xhsSchemeElbowChangeViewModelBindingSource.ResetBindings(false);
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList)
|
{
|
_allBindingList = new BindingList<XhsSchemeElbowChangeViewModel>();
|
if (allVisualViewModelList != null && allVisualViewModelList.Count > 0)
|
{
|
foreach (var visualViewModel in allVisualViewModelList)
|
{
|
if (visualViewModel.Vmo.Catalog == Yw.Hydro.ParterCatalog.Elbow)
|
{
|
var vm = visualViewModel as HydroElbowViewModel;
|
if (vm != null)
|
{
|
var viewModel = new XhsSchemeElbowChangeViewModel(vm);
|
viewModel.ViewImage = this.svgImg32[0];
|
_allBindingList.Add(viewModel);
|
}
|
}
|
}
|
}
|
this.xhsSchemeElbowChangeViewModelBindingSource.DataSource = _allBindingList;
|
this.xhsSchemeElbowChangeViewModelBindingSource.ResetBindings(false);
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(List<HydroElbowViewModel> allElbowViewModelList)
|
{
|
_allBindingList = new BindingList<XhsSchemeElbowChangeViewModel>();
|
if (allElbowViewModelList != null && allElbowViewModelList.Count > 0)
|
{
|
foreach (var fourlinkViewModel in allElbowViewModelList)
|
{
|
var viewModel = new XhsSchemeElbowChangeViewModel(fourlinkViewModel);
|
viewModel.ViewImage = this.svgImg32[0];
|
_allBindingList.Add(viewModel);
|
}
|
}
|
this.xhsSchemeElbowChangeViewModelBindingSource.DataSource = _allBindingList;
|
this.xhsSchemeElbowChangeViewModelBindingSource.ResetBindings(false);
|
}
|
|
/// <summary>
|
/// 设置聚焦行
|
/// </summary>
|
public void SetFocusedRow(int rowHandle)
|
{
|
this.layoutView1.FocusedRowHandle = rowHandle;
|
}
|
|
//字段点击
|
private void layoutView1_FieldValueClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.FieldValueClickEventArgs e)
|
{
|
var row = this.layoutView1.GetRow(e.RowHandle) as XhsSchemeElbowChangeViewModel;
|
if (row == null)
|
{
|
return;
|
}
|
if (e.Column == this.colSvgImage)
|
{
|
var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.ViewModel.Vmo, row.ViewModel.HydroInfo);
|
var dlg = new AssetsElbowSingleMatchingDlg();
|
dlg.ReloadDataEvent += (output) =>
|
{
|
if (Yw.WinFrmUI.HydroMatchingHelper.Apply(row.ViewModel, output))
|
{
|
this.layoutView1.RefreshRow(e.RowHandle);
|
this.HydroChangeEvent?.Invoke(row.ViewModel);
|
}
|
};
|
dlg.SetBindingData(input);
|
dlg.ShowDialog();
|
}
|
else if (e.Column == this.colViewImage)
|
{
|
this.HydroViewEvent?.Invoke(row.ViewModel.Vmo.Code);
|
}
|
}
|
|
//卡片点击
|
private void layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e)
|
{
|
var row = this.layoutView1.GetRow(e.RowHandle) as XhsSchemeElbowChangeViewModel;
|
if (row == null)
|
{
|
return;
|
}
|
}
|
|
//选中列变换
|
private void layoutView1_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e)
|
{
|
|
}
|
|
//单元格值变换
|
private void layoutView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
{
|
var row = this.layoutView1.GetRow(e.RowHandle) as XhsSchemeElbowChangeViewModel;
|
if (row == null)
|
{
|
return;
|
}
|
row.ViewModel.UpdateVmoProperty();
|
this.HydroChangeEvent?.Invoke(row.ViewModel);
|
}
|
|
private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
|
{
|
// 获取当前鼠标所在的单元格信息
|
//var hitInfo = this.layoutView1.CalcHitInfo(e.ControlMousePosition);
|
//if (hitInfo != null && hitInfo.RowHandle >= 0 && hitInfo.Column != null)
|
//{
|
// if (hitInfo.Column == this.colSvgImage)
|
// {
|
// e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "从产品中选择");
|
// }
|
// else if (hitInfo.Column == this.colName)
|
// {
|
// e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "名称");
|
// }
|
// else if (hitInfo.Column == this.colViewImage)
|
// {
|
// e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "模型定位");
|
// }
|
// else if (hitInfo.Column == this.colMaterial)
|
// {
|
// e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "材质");
|
// }
|
// else if (hitInfo.Column == this.colCaliber)
|
// {
|
// e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "口径(mm)");
|
// }
|
// else if (hitInfo.Column == this.colRunningThroughLoss)
|
// {
|
// e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "主管通过损失系数");
|
// }
|
// else if (hitInfo.Column == this.colBranchThroughLoss)
|
// {
|
// e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "支管通过损失系数");
|
// }
|
// else
|
// {
|
// //e.Info = null;
|
// }
|
// return;
|
//}
|
//else
|
//{
|
// //e.Info = null;
|
//}
|
|
}
|
|
|
}
|
}
|