프로젝트

일반

사용자정보

개정판 42d7b127

ID42d7b127b49b9b19f28d38cdce7e9f4009b37512
상위 31cb9e0c
하위 3ce997d8, 7fcd60a0

백흠경이(가) 10달 전에 추가함

Feature: 원본 CAD의 텍스트들을 그리드에 표시하고 사용자가 키보드 방향 키를 눌러 텍스트를 확인하는 기능 추가

Change-Id: I123bef8660a13bae87ae292d5c85b595c4e20237

차이점 보기:

ID2.Manager/ID2.Manager.Compare/Main.cs
17 17

  
18 18
using Telerik.WinControls;
19 19
using Telerik.WinControls.UI;
20
using Telerik.Windows.Diagrams.Core;
21
using Xtractor.Viewer;
22
using devDept.Eyeshot;
20 23

  
21 24
namespace ID2.Manager
22 25
{
......
32 35
            }
33 36
        }
34 37

  
35
//#if DEBUG
36
//        Telerik.WinControls.RadControlSpy.RadControlSpyForm radControlSpyForm = new Telerik.WinControls.RadControlSpy.RadControlSpyForm();
37
//#endif
38 38
        private readonly Color _SummaryColor = Color.FromArgb(255, 108, 55);
39
        private BindingList<TextInfo> textInfos { get; } = new BindingList<TextInfo>();
39 40

  
40 41
        public Main()
41 42
        {
42 43
            InitializeComponent();
43 44
            var verification = new Controls.Verification(this.radProgressBarElement) { Dock = DockStyle.Fill };
45
            verification.OnCompareComplete += this.CompareCompleteHandler; 
44 46
            this.LayoutValidation.Controls.Add(verification);
45 47
            this.DockMainTabStrip.Select();
46 48

  
......
64 66
        }
65 67

  
66 68
        /// <summary>
69
        /// 비교가 끝나고 나서 Text를 그리드에 표시한다.
70
        /// </summary>
71
        /// <param name="list"></param>
72
        public void CompareCompleteHandler(List<TextInfo> list)
73
        {
74
            textInfos.Clear();
75
            textInfos.AddRange(list);
76
            #region 파일에서 일치하지 않는 텍스트들을 읽는다.
77
            var doc = this.radGridViewDocument.SelectedRows[0].DataBoundItem as Document;
78
            if (doc != null)
79
            {
80
                string ID2DrawingFolder = Program.AutoCADFolder;
81
                string FilePath = System.IO.Path.Combine(ID2DrawingFolder, $"{doc.DocumentNo}.dwg.txt");
82
                if (File.Exists(FilePath))
83
                {
84
                    using (var sr = new StreamReader(FilePath))
85
                    {
86
                        string line;
87
                        while ((line = sr.ReadLine()) != null)
88
                        {
89
                            var tokens = line.Split(',');
90
                            if (tokens.Length == 3)
91
                            {
92
                                double x, y;
93
                                double.TryParse(tokens[0], out x);
94
                                double.TryParse(tokens[1], out y);
95
                                var textinfo = new TextInfo(x, y, tokens[2]);
96
                                var found = this.textInfos.Find(param => param.Equals(textinfo));
97
                                if (found != null) found.Unmatched = true;
98
                            }
99
                        }
100
                    }
101
                }
102
            }
103
            #endregion
104

  
105
            this.radGridViewData.DataSource = list;
106
        }
107

  
108
        /// <summary>
67 109
        /// 사용자가 선택한 테마를 적용한다.
68 110
        /// </summary>
69 111
        /// <param name="sender"></param>
......
122 164

  
123 165
                this.radGridViewDocument.CellClick += RadGridViewDocument_CellClick;
124 166
                this.radGridViewDocument.SelectionChanged += RadGridViewDocument_SelectionChanged;
167
                this.radGridViewData.SelectionChanged += RadGridViewData_SelectionChanged;
168
                this.radGridViewData.DataBindingComplete += RadGridViewData_DataBindingComplete;
169
                this.radGridViewData.ViewRowFormatting += RadGridViewData_ViewRowFormatting;
170
                this.radButtonSave.Click += RadButtonSave_Click;
125 171
            }
126 172
            catch (Exception ex)
127 173
            {
......
132 178
            base.OnLoad(e);
133 179
        }
134 180

  
181
        private void RadGridViewData_ViewRowFormatting(object sender, RowFormattingEventArgs e)
182
        {
183
            if (e.RowElement != null && e.RowElement.RowInfo.DataBoundItem is TextInfo textinfo)
184
            {
185
                e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
186
                if (textinfo.Unmatched)
187
                    e.RowElement.ForeColor = Color.Blue;
188
                else if (!textinfo.Found)
189
                    e.RowElement.ForeColor = Color.Magenta;
190
            }
191
        }
192

  
193
        /// <summary>
194
        /// 일치하지 않는 텍스트들을 파일로 저장한다.
195
        /// </summary>
196
        /// <param name="sender"></param>
197
        /// <param name="e"></param>
198
        /// <exception cref="NotImplementedException"></exception>
199
        private void RadButtonSave_Click(object sender, EventArgs e)
200
        {
201
            var doc = this.radGridViewDocument.SelectedRows[0].DataBoundItem as Document;
202
            if (doc != null)
203
            {
204
                string ID2DrawingFolder = Program.AutoCADFolder;
205
                string FilePath = System.IO.Path.Combine(ID2DrawingFolder, $"{doc.DocumentNo}.dwg.txt");
206
                var unmathced = textInfos.Where(x => x.Unmatched).ToList();
207
                using (var sw = new StreamWriter(FilePath))
208
                {
209
                    unmathced.ForEach(x => sw.WriteLine(x.ToString()));
210
                }
211

  
212
                RadMessageBox.Show("불일치 텍스트들을 저장했습니다.");
213
            }
214
        }
215

  
216
        /// <summary>
217
        /// 칼럼 길이를 데이터에 맞춘다.
218
        /// </summary>
219
        /// <param name="sender"></param>
220
        /// <param name="e"></param>
221
        private void RadGridViewData_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
222
        {
223
            this.radGridViewData.BestFitColumns(BestFitColumnMode.AllCells);
224
        }
225

  
226
        /// <summary>
227
        /// 선택한 Text를 그래픽 화면에서 Zoom한다.
228
        /// </summary>
229
        /// <param name="sender"></param>
230
        /// <param name="e"></param>
231
        private void RadGridViewData_SelectionChanged(object sender, EventArgs e)
232
        {
233
            if ((sender as RadGridView).CurrentRow != null)
234
            {
235
                var TextInfo = (sender as RadGridView).CurrentRow.DataBoundItem as TextInfo;
236
                if (TextInfo != null)
237
                {
238
                    var verification = this.LayoutValidation.Controls[0] as Controls.Verification;
239
                    TextInfo.Found = verification.Zoom(TextInfo);
240
                }
241
            }
242
        }
243

  
135 244
        private void RadGridViewDocument_CellClick(object sender, GridViewCellEventArgs e)
136 245
        {
137 246
            if (this.radGridViewDocument.SelectedRows.Any() && this.radGridViewDocument.SelectedRows[0].Equals(e.Row))

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)