using DevExpress.Utils.Svg;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class CreateXhsSchemePipeChangePage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage<CreateXhsSchemeViewModel>
|
{
|
public CreateXhsSchemePipeChangePage()
|
{
|
InitializeComponent();
|
this.layoutView1.SetDefuaulView();
|
this.layoutView1.SetFindPanel();
|
}
|
|
/// <summary>
|
/// 页面状态改变事件
|
/// </summary>
|
public event Action PageStateChangedEvent;
|
|
private CreateXhsSchemeViewModel _vm = null;//操作对象
|
private bool _isInitialize = false;//是否初始化
|
|
private HStation.Vmo.XhsProjectVmo _project = null;//项目
|
private HStation.Vmo.XhsProjectSiteVmo _project_site = null;//项目站
|
private List<CreateXhsSchemePipeChangeViewMdoel> _vm_list = null;
|
|
|
|
/// <summary>
|
/// 初始化
|
/// </summary>
|
public void InitialPage(CreateXhsSchemeViewModel t)
|
{
|
if (_isInitialize)
|
{
|
return;
|
}
|
_vm = t;
|
_isInitialize = true;
|
_project = t.Project;
|
_project_site = t.ProjectSite;
|
if (t.HydroInfo.Pipes != null && t.HydroInfo.Pipes.Any())
|
{
|
var svg = SvgImage.FromStream(new MemoryStream(HStation.WinFrmUI.Xhs.Core.Properties.Resources.pipe));
|
_vm_list = new List<CreateXhsSchemePipeChangeViewMdoel>();
|
foreach (var pipe in t.HydroInfo.Pipes)
|
{
|
var vm = new Yw.WinFrmUI.HydroPipeViewModel(pipe, t.HydroInfo);
|
_vm_list.Add(new CreateXhsSchemePipeChangeViewMdoel(vm, svg));
|
}
|
}
|
|
this.createXhsSchemePipeChangeViewMdoelBindingSource.DataSource = _vm_list;
|
this.createXhsSchemePipeChangeViewMdoelBindingSource.ResetBindings(false);
|
|
ShowBimfaceCtrl();
|
}
|
|
#region Bimface
|
|
//bimface控件
|
private SimulationBimfaceCtrl _bimfaceCtrl = null;
|
|
//获取 bimface 控件
|
private async Task<SimulationBimfaceCtrl> GetBimfaceCtrl()
|
{
|
if (_vm == null)
|
return null;
|
if (_bimfaceCtrl == null)
|
{
|
_bimfaceCtrl = new SimulationBimfaceCtrl();
|
_bimfaceCtrl.Dock = DockStyle.Fill;
|
await _bimfaceCtrl.InitialData(_project, _project_site);
|
_bimfaceCtrl.HydroMouseLeftClickEvent += (code) =>
|
{
|
if (_vm_list == null || !_vm_list.Any())
|
return;
|
var index = _vm_list.FindIndex(x => x.ViewModel.Code == code);
|
this.layoutView1.FocusedRowHandle = index;
|
};
|
}
|
return _bimfaceCtrl;
|
}
|
|
|
//显示 bimface 控件
|
private async void ShowBimfaceCtrl()
|
{
|
var bimfaceCtrl = await GetBimfaceCtrl();
|
this.sidePanel3dModel.Controls.Clear();
|
this.sidePanel3dModel.Controls.Add(bimfaceCtrl);
|
}
|
|
|
#endregion
|
|
//保存
|
private bool Save()
|
{
|
if (!_isInitialize)
|
{
|
return false;
|
}
|
if (_vm_list == null || !_vm_list.Any())
|
{
|
return false;
|
}
|
_vm_list.ForEach(x => x.ViewModel.UpdateVmoProperty());
|
_vm.HydroInfo.Pipes = _vm_list.Select(x => x.ViewModel.Vmo).ToList();
|
return true;
|
}
|
|
//点击
|
private async void layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e)
|
{
|
if (this.layoutView1.GetRow(e.RowHandle) is not CreateXhsSchemePipeChangeViewMdoel row)
|
return;
|
await _bimfaceCtrl?.ZoomAndSelectComponent(row.ViewModel.Code);
|
}
|
|
//选中列变换
|
private void layoutView1_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e)
|
{
|
if (e.FocusedColumn == this.colModelType)
|
{
|
this.layoutView1.FocusedColumn = null;
|
if (this.layoutView1.GetFocusedRow() is not CreateXhsSchemePipeChangeViewMdoel row)
|
return;
|
|
var link_status = row.LinkStatus;
|
|
var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.ViewModel.Vmo, _vm.HydroInfo);
|
var dlg = new SimulationPipeSingleMatchingDlg();
|
dlg.SetBindingData(input);
|
dlg.ReloadDataEvent += (output) =>
|
{
|
Yw.WinFrmUI.HydroMatchingHelper.Apply(row.ViewModel, output);
|
row.LinkStatus = link_status;
|
if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code))
|
{
|
_vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pipe, row.ViewModel.Code, row.Name, row.SvgImage));
|
}
|
};
|
dlg.ShowDialog();
|
}
|
}
|
|
//单元格值变换
|
private void layoutView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
{
|
if (this.layoutView1.GetRow(e.RowHandle) is not CreateXhsSchemePipeChangeViewMdoel row)
|
return;
|
if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code))
|
{
|
_vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pipe, row.ViewModel.Code, row.Name, row.SvgImage));
|
}
|
}
|
|
/// <summary>
|
/// 允许上一步
|
/// </summary>
|
public bool AllowPrev
|
{
|
get
|
{
|
return true;
|
}
|
}
|
|
/// <summary>
|
/// 允许下一步
|
/// </summary>
|
public bool AllowNext
|
{
|
get
|
{
|
return _isInitialize;
|
}
|
}
|
|
/// <summary>
|
/// 允许取消
|
/// </summary>
|
public bool AllowCancel
|
{
|
get { return false; }
|
}
|
|
/// <summary>
|
/// 允许完成
|
/// </summary>
|
public bool AllowComplete
|
{
|
get { return false; }
|
}
|
|
/// <summary>
|
/// 能否上一步
|
/// </summary>
|
public bool CanPrev()
|
{
|
return true;
|
}
|
|
/// <summary>
|
/// 能否下一步
|
/// </summary>
|
public bool CanNext()
|
{
|
if (!_isInitialize)
|
{
|
return false;
|
}
|
return Save();
|
}
|
|
/// <summary>
|
/// 能否关闭
|
/// </summary>
|
public bool CanCancel()
|
{
|
return true;
|
}
|
|
/// <summary>
|
/// 能否完成
|
/// </summary>
|
public bool CanComplete()
|
{
|
return false;
|
}
|
|
|
}
|
}
|