lixiaojun
2024-10-23 549b9ad0a143b6fbd86ce02ddfa470b5556126e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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);
                }
            }
        }
 
 
 
 
 
    }
}