namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
/// 上传文件
|
/// </summary>
|
public partial class UploadBimfaceFileDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public UploadBimfaceFileDlg()
|
{
|
InitializeComponent();
|
this.layoutControl1.SetupLayoutControl();
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public event Action<BimfaceFileUploadViewModel> ReloadDataEvent;
|
|
/// <summary>
|
///
|
/// </summary>
|
public void SetBindingData()
|
{
|
this.imgCmbFormatType.Properties.Items.AddEnum(typeof(eFormatType), false);
|
this.imgCmbFormatType.EditValue = eFormatType.d3;
|
}
|
|
//验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.imgCmbFormatType.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.imgCmbFormatType, "必选项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(this.btnFullFilePath.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.btnFullFilePath, "必选项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtName, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//确定
|
private void btnOk_Click(object sender, EventArgs e)
|
{
|
if (!Valid())
|
{
|
return;
|
}
|
var vm = new BimfaceFileUploadViewModel();
|
vm.FormatType = (eFormatType)this.imgCmbFormatType.EditValue;
|
vm.FilePath = this.btnFullFilePath.Text.Trim();
|
vm.FileName = this.txtName.Text.Trim();
|
vm.Description = this.txtDescription.Text.Trim();
|
this.ReloadDataEvent?.Invoke(vm);
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
//获取BIM文件路径
|
private void btnFullFilePath_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
{
|
var filter = string.Empty;
|
var formatType = (eFormatType)this.imgCmbFormatType.EditValue;
|
switch (formatType)
|
{
|
case eFormatType.d3: filter = "模型文件|*.rvt;*.rfa"; break;
|
case eFormatType.d2: filter = "模型文件|*.dwg"; break;
|
default: break;
|
}
|
if (string.IsNullOrEmpty(filter))
|
{
|
return;
|
}
|
var dlg = new OpenFileDialog();
|
dlg.Filter = filter;
|
dlg.Title = "选择模型文件";
|
if (dlg.ShowDialog() == DialogResult.OK)
|
{
|
this.btnFullFilePath.EditValue = dlg.FileName;
|
if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
{
|
this.txtName.Text = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName);
|
}
|
}
|
}
|
|
|
|
|
|
}
|
}
|