using System;
|
using System.ComponentModel;
|
using System.Drawing;
|
|
namespace TProduct.WinFrmUI.Data4Factory
|
{
|
[DefaultEvent("SelectProductValveListChangedEvent")]
|
public partial class SelectProductValveListCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public SelectProductValveListCtrl()
|
{
|
InitializeComponent();
|
|
this.selProductValveContentListCtrl1.SelectProductSeriesEvent += ProductSeriesCtrl1_CheckedChanedEvent;
|
this.selProductValveContentListCtrl1.SelectProductValveEvent += ProductMainExValveCtrl1_CheckedChanedEvent;
|
}
|
public event Action<Model.ProductSeries> SelectedSeriesEvent = null;
|
public event Action<Model.ProductMainExValve> SelectedValveChanedEvent = null;
|
public Model.ProductSeries SelectSeriesed { get; private set; }
|
public Model.ProductMainExValve SelectValveed { get; private set; }
|
|
private long seriesID = 0;
|
private long ValveID = 0;
|
public string Selected { get; private set; }
|
public void SetBindingData()
|
{
|
this.selProductValveContentListCtrl1.SetBindingData();
|
this.selProductValveContentListCtrl1.SetFocused();
|
}
|
//自定义显示
|
private void popupContainerEdit1_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
|
{
|
this.popupContainerControl1.Size = new Size(400, 400);
|
if (ValveID < 1 && seriesID < 0)
|
{
|
var Model = e?.Value as Model.ProductSeries;
|
e.DisplayText = Model?.Name;
|
}
|
else
|
{
|
if (ValveID < 1 && seriesID > 0)
|
{
|
var Model = e?.Value as Model.ProductSeries;
|
e.DisplayText = Model?.Name;
|
}
|
if (seriesID < 1 && ValveID > 0)
|
{
|
var Model = e?.Value as Model.ProductMainExValve;
|
e.DisplayText = Model?.Name;
|
}
|
}
|
}
|
|
private void ProductMainExValveCtrl1_CheckedChanedEvent(Model.ProductMainExValve obj)
|
{
|
ValveID = obj.ID;
|
seriesID = 0;
|
this.popupContainerEdit1.ClosePopup();
|
if (SelectValveed != null)
|
{
|
if (SelectValveed.ID == obj.ID)
|
return;
|
}
|
SelectValveed = obj;
|
this.popupContainerEdit1.EditValue = SelectValveed;
|
this.SelectedValveChanedEvent?.Invoke(SelectValveed);
|
|
}
|
|
private void ProductSeriesCtrl1_CheckedChanedEvent(Model.ProductSeries obj)
|
{
|
seriesID = obj.ID;
|
ValveID = 0;
|
this.popupContainerEdit1.ClosePopup();
|
if (SelectSeriesed != null)
|
{
|
if (SelectSeriesed.ID == obj.ID)
|
return;
|
}
|
SelectSeriesed = obj;
|
this.popupContainerEdit1.EditValue = SelectSeriesed;
|
this.SelectedSeriesEvent?.Invoke(SelectSeriesed);
|
|
}
|
}
|
}
|