using DevExpress.XtraEditors.Controls;
|
using IBox.WinFrmUI;
|
using System.Net.NetworkInformation;
|
|
namespace PBS.WinFrmUI.Box
|
{
|
public partial class ChoiceFacilityDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public ChoiceFacilityDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Action<bool> VisibleChanged;
|
|
public async void SetDataSource()
|
{
|
var allFac = await new PBS.BLL.Facility().GetAll();
|
foreach (var item in allFac)
|
{
|
var imageItem = new ImageComboBoxItem(item.Name, item.ID);
|
this.imageComboBoxEdit1.Properties.Items.Add(imageItem);
|
}
|
this.imageComboxConnectType.Properties.AddEnum(typeof(eConnectionType));
|
}
|
|
private bool Verify()
|
{
|
bool isContinue = true;
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.TxtConnectionAddress.Text))
|
{
|
this.dxErrorProvider1.SetError(this.TxtConnectionAddress, "请输入连接地址");
|
isContinue = false;
|
}
|
return isContinue;
|
}
|
|
private void BtnOk_Click(object sender, EventArgs e)
|
{
|
if (!Verify())
|
{
|
return;
|
}
|
IBoxHelper.ConnectionAddress = this.TxtConnectionAddress.Text;
|
IBoxHelper.ConnectionType = (eConnectionType)this.imageComboxConnectType.EditValue;
|
if (IBoxHelper.Ping())
|
{
|
VisibleChanged.Invoke(true);
|
}
|
this.Close();
|
}
|
|
private async void imageComboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
var select = this.imageComboBoxEdit1.EditValue;
|
if (select != null)
|
{
|
var model = await new PBS.BLL.Facility().GetByID((long)select);
|
this.imageComboxConnectType.EditValue = model.ConnectionType;
|
this.TxtConnectionAddress.Text = model.ConnectionAddress;
|
}
|
}
|
}
|
}
|