using DevExpress.Utils.Svg;
|
using Mapster;
|
using Yw;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class CreateXhsSchemeValveChangePage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage<CreateXhsSchemeViewModel>
|
{
|
public CreateXhsSchemeValveChangePage()
|
{
|
InitializeComponent();
|
InitialLinkStatus();
|
this.layoutView1.SetDefuaulView();
|
}
|
|
/// <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<CreateXhsSchemeValveChangeViewMdoel> _vm_list = null;
|
|
|
//初始化状态
|
private void InitialLinkStatus()
|
{
|
this.repImgCmbStatus.BeginUpdate();
|
this.repImgCmbStatus.Items.Clear();
|
this.repImgCmbStatus.Items.Add("开启", "开启", -1);
|
this.repImgCmbStatus.Items.Add("关闭", "关闭", -1);
|
this.repImgCmbStatus.EndUpdate();
|
}
|
|
/// <summary>
|
/// 初始化
|
/// </summary>
|
public void InitialPage(CreateXhsSchemeViewModel t)
|
{
|
if (_isInitialize)
|
{
|
return;
|
}
|
_vm = t;
|
_isInitialize = true;
|
_project = t.Project;
|
_project_site = t.ProjectSite;
|
if (t.HydroInfo.Valves != null && t.HydroInfo.Valves.Any())
|
{
|
var svg_img = SvgImage.FromStream(new MemoryStream(HStation.WinFrmUI.Xhs.Core.Properties.Resources.valve));
|
|
_vm_list = new List<CreateXhsSchemeValveChangeViewMdoel>();
|
foreach (var Valve in t.HydroInfo.Valves)
|
{
|
var vm = new Yw.WinFrmUI.HydroValveViewModel(Valve, t.HydroInfo).Adapt<CreateXhsSchemeValveChangeViewMdoel>();
|
vm.SvgImage = svg_img;
|
_vm_list.Add(vm);
|
}
|
}
|
|
//this.CreateXhsSchemeValveChangeViewMdoelBindingSource.DataSource = _vm_list;
|
//this.CreateXhsSchemeValveChangeViewMdoelBindingSource.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);
|
}
|
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.HydroInfo.Valves = _vm_list.Adapt<List<Yw.Model.HydroValveInfo>>();
|
return true;
|
}
|
|
//
|
private async void layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e)
|
{
|
var row = this.layoutView1.GetRow(e.RowHandle) as CreateXhsSchemeValveChangeViewMdoel;
|
if (row == null)
|
return;
|
await _bimfaceCtrl?.ZoomAndSelectComponent(row.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 CreateXhsSchemeValveChangeViewMdoel row)
|
return;
|
|
var link_status = row.LinkStatus;
|
|
var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.Vmo, _vm.HydroInfo);
|
var dlg = new SimulationValveSingleMatchingDlg();
|
dlg.SetBindingData(input);
|
dlg.ReloadDataEvent += (output) =>
|
{
|
Yw.WinFrmUI.HydroMatchingHelper.Apply(row, output);
|
row.LinkStatus = link_status;
|
};
|
dlg.ShowDialog();
|
}
|
}
|
|
/// <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;
|
}
|
|
|
}
|
}
|