프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter_AutoModeling / ConverterForm.cs @ df4559fc

이력 | 보기 | 이력해설 | 다운로드 (9.08 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Linq;
7
using System.Text;
8
using System.Threading.Tasks;
9
using System.Windows.Forms;
10
using Microsoft.VisualBasic;
11
using Converter.BaseModel;
12
using DevExpress.XtraEditors.Repository;
13
using DevExpress.XtraEditors.Controls;
14
using DevExpress.XtraEditors;
15
using System.Globalization;
16
using System.Threading;
17
using System.IO;
18
using Converter.SPPID.AutoModeling.Properties;
19
using Converter.SPPID.AutoModeling.DB;
20
using Converter.SPPID.AutoModeling.Util;
21
using Converter.SPPID.AutoModeling.Form;
22

    
23
namespace Converter.SPPID.AutoModeling
24
{
25
    public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm
26
    {
27
        private DataTable converterDT = new DataTable();
28
        private RepositoryItemComboBox templateComboBox;
29

    
30
        ProjectInfo _ProjectInfo = ProjectInfo.GetInstance();
31
        SPPIDInfo _SPPIDInfo = SPPIDInfo.GetInstance();
32

    
33
        public ConverterForm()
34
        {
35
            InitializeComponent();
36

    
37
            CultureInfo culture = CultureInfo.GetCultureInfo("en");
38
            Msg.Culture = culture;
39

    
40
            //Color color = Color.FromArgb(67, 117, 219);
41
            //layoutControlGroupAutoConverter.AppearanceGroup.BorderColor = color;
42
            //layoutControlGroupAutoConverter.AllowBorderColorBlending = true;
43
            //layoutControlGroupSPPIDDB.AppearanceGroup.BorderColor = color;
44
            //layoutControlGroupSPPIDDB.AllowBorderColorBlending = true;
45
            //layoutControlGroupID2Project.AppearanceGroup.BorderColor = color;
46
            //layoutControlGroupID2Project.AllowBorderColorBlending = true;
47
            //layoutControlGroupItemMapping.AppearanceGroup.BorderColor = color;
48
            //layoutControlGroupItemMapping.AllowBorderColorBlending = true;
49

    
50
            SPPIDUtil.ReadSPPIDInfo();
51
            SPPIDUtil.ReadID2ProjectInfo();
52

    
53
            InitGridControl();
54
            SetID2ProjectUI();
55
            SetSPPIDDBUI();
56
        }
57

    
58
        private void InitGridControl()
59
        {
60
            #region Converter Page
61
            gridViewConverter.OptionsSelection.MultiSelect = true;
62
            gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
63

    
64
            DataColumn col = converterDT.Columns.Add("colDrawingFileName");
65
            col.Caption = "Drawing File Name";
66
            col = converterDT.Columns.Add("colUnit");
67
            col.Caption = "Unit";
68
            col = converterDT.Columns.Add("colTemplate");
69
            col.Caption = "Template";
70
            col = converterDT.Columns.Add("colDrawingNumber");
71
            col.Caption = "Drawing Number";
72
            col = converterDT.Columns.Add("colDrawingName");
73
            col.Caption = "Drawing Name";
74
            col = converterDT.Columns.Add("colStatus");
75
            col.Caption = "Status";
76
            col = converterDT.Columns.Add("colUID");
77
            gridControlConverter.DataSource = converterDT;
78

    
79
            templateComboBox = new RepositoryItemComboBox();
80
            templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor;
81
            gridControlConverter.RepositoryItems.Add(templateComboBox);
82
            gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox;
83

    
84
            RepositoryItemButtonEdit unitButton = new RepositoryItemButtonEdit();
85
            unitButton.ButtonClick += UnitButton_ButtonClick;
86
            unitButton.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
87
            gridControlConverter.RepositoryItems.Add(unitButton);
88
            gridViewConverter.Columns["colUnit"].ColumnEdit = unitButton;
89

    
90
            gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false;
91
            gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true;
92
            gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false;
93
            gridViewConverter.Columns["colUID"].Visible = false;
94

    
95
            gridViewConverter.BestFitColumns();
96
            #endregion
97
        }
98

    
99
        private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e)
100
        {
101
            if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK)
102
            {
103
                bool result = false;
104
                string dirPath = xtraFolderBrowserDialog.SelectedPath;
105
                if (IsID2Project(dirPath))
106
                {
107
                    _ProjectInfo.Path = dirPath;
108
                    _ProjectInfo.Enable = true;
109
                    if (SPPIDUtil.SaveID2ProjectInfo())
110
                    {
111
                        result = true;
112
                        SetID2ProjectUI();
113
                        MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
114
                    }
115
                }
116

    
117
                if (!result)
118
                {
119
                    _ProjectInfo.Enable = false;
120
                    SetID2ProjectUI();
121
                    MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
122
                }
123
            }
124
        }
125

    
126
        private void SetID2ProjectUI()
127
        {
128
            if (_ProjectInfo.Enable)
129
            {
130
                btnID2Project.Text = _ProjectInfo.Path;
131
                labelID2ProjectName.Text = _ProjectInfo.Name;
132
                labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue;
133
                labelID2ProjectStatus.Text = Msg.ConnectionSuccessful;
134
                labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue;
135
            }
136
            else
137
            {
138
                btnID2Project.Text = "";
139
                labelID2ProjectName.Text = " ";
140
                labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red;
141
                labelID2ProjectStatus.Text = Msg.ConnectionFail;
142
                labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red;
143
            }
144
        }
145

    
146
        private void SetSPPIDDBUI()
147
        {
148
            if (_SPPIDInfo.Enable)
149
            {
150
                labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant;
151
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue;
152
                labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful;
153
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue;
154
            }
155
            else
156
            {
157
                labelSPPIDPlantName.Text = " ";
158
                labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red;
159
                labelSPPIDDBStatus.Text = Msg.ConnectionFail;
160
                labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red;
161
            }
162
        }
163

    
164
        private bool IsID2Project(string path)
165
        {
166
            bool result = false;
167
            string[] directories = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly);
168
            for (int i = 0; i < directories.Length; i++)
169
                directories[i] = Path.GetFileName(directories[i]);
170
            List<string> dirList = directories.ToList();
171

    
172
            if (dirList.Contains("db") &&
173
                dirList.Contains("Temp") &&
174
                dirList.Contains("image"))
175
            {
176
                result = true;
177
            }
178

    
179
            return result;
180
        }
181

    
182
        private void UnitButton_ButtonClick(object sender, ButtonPressedEventArgs e)
183
        {
184
            //UnitForm unitForm = new UnitForm(dUnit);
185
            //if (unitForm.ShowDialog() == DialogResult.OK)
186
            //{
187
            //    ButtonEdit button = sender as ButtonEdit;
188
            //    button.EditValue = unitForm.SelectedUnit;
189
            //    gridViewConverter.CloseEditor();
190
            //    gridViewConverter.UpdateCurrentRow();
191
            //    gridViewConverter.BestFitColumns();
192
            //}
193
        }
194

    
195
        private void btnLoadFile_Click(object sender, EventArgs e)
196
        {
197
            if (!_ProjectInfo.Enable)
198
            {
199
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
200
                return;
201
            }
202

    
203
            xtraOpenFileDialog.InitialDirectory = _ProjectInfo.Path + @"\temp";
204
            if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK)
205
            {
206
                foreach (string fileName in xtraOpenFileDialog.FileNames)
207
                {
208
                    
209
                }
210
            }
211
        }
212

    
213
        private void btnRun_Click(object sender, EventArgs e)
214
        {
215
            DialogResult = DialogResult.OK;
216
        }
217

    
218
        private void btnSPPIDDB_Click(object sender, EventArgs e)
219
        {
220
            SPPID_DB_SettingForm form = new SPPID_DB_SettingForm();
221
            if (form.ShowDialog() == DialogResult.OK)
222
                SetSPPIDDBUI();
223
        }
224

    
225
        private void btnItemMapping_Click(object sender, EventArgs e)
226
        {
227
            if (!_ProjectInfo.Enable)
228
            {
229
                MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
230
                return;
231
            }
232

    
233
            MappingForm form = new MappingForm();
234
            form.ShowDialog();
235
        }
236
    }
237
}
클립보드 이미지 추가 (최대 크기: 500 MB)