프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Events / Implementation / TopMenuEvent.cs @ 02a9f323

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

1
using KCOM.Common;
2
using KCOM.Common.Converter;
3
using KCOM.Controls;
4
using KCOM.Events;
5
using KCOMDataModel.DataModel;
6
using MarkupToPDF.Common;
7
using System;
8
using System.Collections.Generic;
9
using System.Linq;
10
using System.Text;
11
using System.Windows;
12
using System.Windows.Controls;
13
using System.Windows.Input;
14
using System.Windows.Media;
15
using System.Windows.Media.Imaging;
16
using Telerik.Windows.Controls;
17
using IKCOM;
18
using Microsoft.Win32;
19
using System.IO;
20
using System.Reflection;
21
using System.Windows.Controls.Primitives;
22
using MarkupToPDF.Controls.Parsing;
23
using Telerik.Windows.Data;
24
using System.ComponentModel;
25
using System.Web;
26
using Markus.Fonts;
27
using System.Threading.Tasks;
28
using System.Windows.Threading;
29
using System.Text.RegularExpressions;
30
using MarkupToPDF.Controls.Shape;
31
using MarkupToPDF.Controls.Polygon;
32
using MarkupToPDF.Controls.Line;
33
using MarkupToPDF.Controls.Cad;
34

    
35
namespace KCOM.Views
36
{
37
    public partial class TopMenu : UserControl
38
    {
39
        public int rotateOffSet = 0;
40
        private double[] rotateValue = { 0, 90, 180, 270 };
41
        public System.Windows.Threading.DispatcherTimer SaveTimer { get; set; }
42
        public bool isClosed = true;
43
        public RadWindow CheckPop;
44
        public RadWindow OptionPop;
45

    
46
        /// <summary>
47
        /// TaskBar에 메시지를 입력합니다
48
        /// </summary>
49
        /// <param name="message"></param>
50
        /// <param name="type"></param>
51
        public void TaskMessage(string message, TaskMessageType type)
52
        {
53
            /*
54
            if (taskBar != null)
55
            {
56
                string color = "";
57
                taskBar.Content = message;
58
                DicTaskMessage.TryGetValue(type, out color);
59
                taskBar.Foreground = new SolidColorBrush(StringToColorBrushConverter.Parse(color));
60
            }
61
            */
62
        }
63

    
64
        /// <summary>
65
        /// Task Type명을 Key값으로 지정합니다
66
        /// </summary>
67
        public enum TaskMessageType
68
        {
69
            Normal,
70
            Caption,
71
            Error,
72
        }
73

    
74
        private void CheckShapeState()
75
        {
76

    
77

    
78
            if (cbHatchShape.IsChecked == true)
79
            {
80
                cbFillShape.IsChecked = false;
81
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.Hatch;
82
            }
83
            else if(cbFillShape.IsChecked == true)
84
            {
85
                cbHatchShape.IsChecked = false;
86
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.Fill;
87
            }
88
            else
89
            {
90
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.None;
91
            }
92
        }
93

    
94
        /// <summary>
95
        ///  comment의 속성 변경시 저장여부 확인 하도록 undocommand에 추가
96
        /// </summary>
97
        /// <param name="adnoerFinal"></param>
98
        public void ChangeComment(Controls.AdornerFinal adnoerFinal)
99
        {
100
            var adornerMembers = adnoerFinal.Members.Cast<Controls.AdornerMember>();
101

    
102
            if (adornerMembers.Count() > 0)
103
            {
104
                //UndoCommand.Instance.Push(adornerMembers.Select(x => x.DrawingData).Cast<CommentUserInfo>().ToList(), adnoerFinal.AngleValue);
105
                UndoCommand.Instance.Push(EventType.Operation, adornerMembers.Select(x => x.DrawingData).Cast<CommentUserInfo>().ToList());
106
            }
107
        }
108

    
109
        //강인구 추가(Undo End)
110
        private void SetPaintEvent()
111
        {
112
            List<AdornerMember> AdonerList = GetAdornerItem();
113

    
114
            if (AdonerList.Count > 0)
115
            {
116
                UndoDataGroup UndoDataGrp = new UndoDataGroup()
117
                {
118
                    IsUndo = false,
119
                    Event = EventType.Operation,
120
                    paint = ViewerDataModel.Instance.paintSet
121
                };
122
                UndoData multi_UndoData = new UndoData();
123

    
124
                foreach (AdornerMember InnerItem in AdonerList)
125
                {
126
                    multi_UndoData.PointSet = new List<Point>();
127

    
128
                    if ((InnerItem.DrawingData as MarkupToPDF.Controls.Common.IShapeControl) != null)
129
                    {
130
                        (InnerItem.DrawingData as MarkupToPDF.Controls.Common.IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
131
                    }
132

    
133
                    multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
134
                    UndoDataGrp.MarkupDataColl.Add(multi_UndoData);
135
                    multi_UndoData = new UndoData();
136
                }
137

    
138
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
139
                {
140
                    ViewerDataModel.Instance.UndoDataList.Remove(i);                    
141
                });
142
                ViewerDataModel.Instance.UndoDataList.Add(UndoDataGrp);
143
            }
144
        }
145

    
146
        private void SetHighlightEvent()
147
        {
148
            List<AdornerMember> AdonerList = GetAdornerItem();
149

    
150
            if (AdonerList.Count > 0)
151
            {
152
                foreach (AdornerMember InnerItem in AdonerList)
153
                {
154
                    switch (InnerItem.DrawingData.GetType().Name)
155
                    {
156
                        case ("TextControl"):
157
                            {
158
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
159
                            }
160
                            break;
161
                        case ("ArrowTextControl"):
162
                            {
163
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
164
                            }
165
                            break;
166
                    }
167
                }
168

    
169
                ViewerDataModel.Instance.IsMarkupUpdate = true;
170
            }
171

    
172
        }
173

    
174
        private void FillShapeEvent(object sender, RoutedEventArgs e)
175
        {
176
            #region 주석
177
            //if ((sender as CheckBox).IsChecked.Value)
178
            //{
179
            //    cbHatchShape.IsChecked = false;
180
            //    imgShape_RectCloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/RectCloud_Fill.png", UriKind.Relative));
181
            //    imgShape_Cloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/Cloud_Fill.png", UriKind.Relative));
182
            //    imgShape_Rect.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/Rectangle_Fill.png", UriKind.Relative));
183
            //    imgShape_Tri.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/triangle-icon.png", UriKind.Relative));
184
            //    imgShape_Cicle.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/circle-icon.png", UriKind.Relative));
185
            //    imgShape_Poly.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/polygon_Fill.png", UriKind.Relative));
186
            //    TaskMessage("채우기 옵션이 적용되었습니다", TaskMessageType.Normal);
187
            //}
188
            //else
189
            //{
190

    
191
            //    imgShape_RectCloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/RectCloud.png", UriKind.Relative));
192
            //    imgShape_Cloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/Cloud.png", UriKind.Relative));
193
            //    imgShape_Rect.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/Rectangle.png", UriKind.Relative));
194
            //    imgShape_Tri.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/triangle-icon_None.png", UriKind.Relative));
195
            //    imgShape_Cicle.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/circle-icon_None.png", UriKind.Relative));
196
            //    imgShape_Poly.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/polygon.png", UriKind.Relative));
197
            //    TaskMessage("채우기 옵션이 해제되었습니다", TaskMessageType.Caption);
198
            //}
199
            #endregion
200
            ViewerDataModel.Instance.checkFillShape = (sender as CheckBox).IsChecked.Value;
201

    
202
            if (ViewerDataModel.Instance.checkFillShape)
203
            {
204
                cbHatchShape.IsChecked = false;
205
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.Fill;
206
            }
207
            else
208
            {
209
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.None;
210
            }
211
            SetPaintEvent();
212
        }
213

    
214
        /// <summary>
215
        /// 도형 빗금 처리
216
        /// </summary>
217
        /// <param name="sender"></param>
218
        /// <param name="e"></param>
219
        private void HatchShapeEvent(object sender, RoutedEventArgs e)
220
        {
221
			#region 주석
222
            //if ((sender as CheckBox).IsChecked.Value)
223
            //{
224
            //    cbFillShape.IsChecked = false;
225
            //    imgShape_RectCloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/RectCloud_Hatch.png", UriKind.Relative));
226
            //    imgShape_Cloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/Cloud_Hatch.png", UriKind.Relative));
227
            //    imgShape_Rect.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/rectangle-icon_Hatch.png", UriKind.Relative));
228
            //    imgShape_Tri.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/triangle-icon_Hatch.png", UriKind.Relative));
229
            //    imgShape_Cicle.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/circle-icon_Hatch.png", UriKind.Relative));
230
            //    imgShape_Poly.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/polygon_hatch.png", UriKind.Relative));
231
            //    TaskMessage("무늬 옵션이 적용되었습니다", TaskMessageType.Normal);
232
            //}
233
            //else
234
            //{
235
            //    imgShape_RectCloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/RectCloud.png", UriKind.Relative));
236
            //    imgShape_Cloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/Cloud.png", UriKind.Relative));
237
            //    imgShape_Rect.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/Rectangle.png", UriKind.Relative));
238
            //    imgShape_Tri.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/triangle-icon_None.png", UriKind.Relative));
239
            //    imgShape_Cicle.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/circle-icon_None.png", UriKind.Relative));
240
            //    imgShape_Poly.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/polygon.png", UriKind.Relative));
241
            //    TaskMessage("무늬 옵션이 해제되었습니다", TaskMessageType.Caption);
242
            //} 
243
            #endregion
244

    
245
            //강인구 추가
246
            ViewerDataModel.Instance.checkHatchShape = (sender as CheckBox).IsChecked.Value;
247
            if (ViewerDataModel.Instance.checkHatchShape)
248
            {
249
                cbFillShape.IsChecked = false;
250
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.Hatch;
251
            }
252
            else
253
            {
254
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.None;  
255
            }
256
            SetPaintEvent();
257
        }
258

    
259
        void SaveTimer_Tick(object sender, EventArgs e)
260
        {
261
            //if (this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode != IKCOM.MouseHandlingMode.Drawing)
262
            if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl == null && this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count == 0)
263
            {
264
                SaveEventCallback(null, null);
265
            }
266
        }
267

    
268
        private void SaveTime(bool IsRun)
269
        {
270
            if(SaveTimer == null)
271
            {
272
                SaveTimer = new System.Windows.Threading.DispatcherTimer();
273
                SaveTimer.Interval = new TimeSpan(0, 0, 5);
274
                SaveTimer.Tick += new EventHandler(SaveTimer_Tick);
275
            }
276

    
277
            if (IsRun)
278
            {
279
                SaveTimer.Start();
280
            }
281
            else
282
            {
283
                SaveTimer.Stop();
284
            }
285
        }
286
        private void SaveTime(bool IsRun,int timeinterval)
287
        {
288
            if (SaveTimer == null)
289
            {
290
                SaveTimer = new System.Windows.Threading.DispatcherTimer();
291
                SaveTimer.Interval = new TimeSpan(0, timeinterval, 0);
292
                SaveTimer.Tick += new EventHandler(SaveTimer_Tick);
293
            }
294
            else
295
            {
296
                SaveTimer.Stop();
297
                SaveTimer.Interval = new TimeSpan(0, timeinterval, 0);
298
            }
299

    
300
            if (IsRun)
301
            {
302
                SaveTimer.Start();
303
            }
304
            else
305
            {
306
                SaveTimer.Stop();
307
            }
308
        }
309
        /// <summary>
310
        /// enable busy indicator and then call _SaveEvent method.
311
        /// </summary>
312
        /// <param name="sender"></param>
313
        /// <param name="e"></param>
314
        public  void SaveEventCallback(object sender, RoutedEventArgs e)
315
        {
316
            var mianMenu = this.ParentOfType<MainWindow>().dzMainMenu;
317

    
318
            if (mianMenu.busyIndicator.IsBusy == true)
319
            {
320
                return;
321
            }
322

    
323
            //var result = await Dispatcher.InvokeAsync<bool>(()=>
324
            //{
325
                this.ParentOfType<MainWindow>().dzMainMenu.busyIndicator.IsBusy = true;
326

    
327
                _SaveEvent(sender, e);
328

    
329
                mianMenu.busyIndicator.IsBusy = false;
330
               
331
            //});
332

    
333
            //System.Threading.Tasks.Task SaveTask = System.Threading.Tasks.Task.Factory.StartNew(() =>
334
            //{
335
            //    Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action<object, RoutedEventArgs>(_SaveEvent), sender, e);
336
            //}).ContinueWith(task =>
337
            //{
338
            //    Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate () { this.ParentOfType<MainWindow>().dzMainMenu.busyIndicator.IsBusy = false; }));
339
            //});
340
        }
341

    
342
        /// <summary>
343
        /// save markup
344
        ///  - convert ink control to polygon control if ink control exists
345
        ///  - unselect and update my markup list
346
        /// <param name="sender"></param>
347
        /// <param name="e"></param>
348
        public async Task<bool> _SaveEvent(object sender, RoutedEventArgs e)
349
        {
350
            bool result = false;
351

    
352
            var mainMenu = this.ParentOfType<MainWindow>().dzMainMenu;
353
            try
354
            {
355
                mainMenu.ConvertInkControlToPolygon();
356

    
357
                mainMenu.UpdateMyMarkupList();
358

    
359
                if (mainMenu.gridViewMarkup.SelectedItems.Count == 0 && mainMenu.gridViewMarkup.Items.Count > 0)
360
                {
361
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("Please Select Your Comment List Item", "Alert");
362
                }
363
                else
364
                {                    
365
                    foreach (var item in mainMenu.gridViewMarkup.SelectedItems)
366
                    {
367
                        if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
368
                        {
369
                            #region 저장 서비스 호출(저장 완료시까지 대기)
370
                            await this.ExecuteSaveCommandAsync(mainMenu);
371
                            #endregion
372

    
373
                            var info = ViewerDataModel.Instance._markupInfoList.FirstOrDefault(data => data.MarkupInfoID == (item as IKCOM.MarkupInfoItem).MarkupInfoID);
374
                            if(info != null) info.UpdateTime = DateTime.Now;
375
                            if (!ViewerDataModel.Instance.IsConsolidate && (sender != null))
376
                            {
377
                                this.ParentOfType<MainWindow>().DialogMessage_Alert("Save is complete.", "Info");
378
                            }
379

    
380
                            result = true;
381
                        }
382
                    }
383
                }
384

    
385
                mainMenu.SetCommentPages(null);
386

    
387
                ViewerDataModel.Instance.UndoDataList.Clear();
388
            }
389
            catch (Exception ex)
390
            {
391
                System.Diagnostics.Debug.WriteLine("_SaveEvent Error : " + ex.ToString());
392
            }
393
            finally
394
            {
395
                /*
396
                /// delete markup information when 코멘트가 없을 경우
397
                if (ViewerDataModel.Instance.MyMarkupList.Count == 0)
398
                {
399
                    foreach (var item in menu.gridViewMarkup.SelectedItems)
400
                    {
401
                        if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
402
                        {
403
                            //this.ParentOfType<MainWindow>().dzMainMenu.DeleteItem((item as IKCOM.MarkupInfoItem));
404
                        }
405
                    }
406
                }
407
                */
408
            }
409

    
410
            return result;
411
        }
412

    
413
        public async Task<bool>  SaveEventAsync()
414
        {
415
            bool result = false;
416

    
417
            var mainMenu = this.ParentOfType<MainWindow>().dzMainMenu;
418
            try
419
            {
420
                mainMenu.ConvertInkControlToPolygon();
421

    
422
                // update mylist and gridview
423
                mainMenu.UpdateMyMarkupList();
424

    
425
                if (mainMenu.gridViewMarkup.SelectedItems.Count == 0 && mainMenu.gridViewMarkup.Items.Count > 0)
426
                {
427
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("Please Select Your Comment List Item", "Alert");
428
                }
429
                else
430
                {
431
                    foreach (var item in mainMenu.gridViewMarkup.SelectedItems)
432
                    {
433
                        if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
434
                        {
435
                            /// 저장 서비스 호출
436
                            result = await this.ExecuteSaveCommandAsync(mainMenu);
437
                            ViewerDataModel.Instance._markupInfoList.Where(data => data.MarkupInfoID == (item as IKCOM.MarkupInfoItem).MarkupInfoID).FirstOrDefault().UpdateTime = DateTime.Now;
438
                        }
439
                    }
440
                }
441

    
442
                mainMenu.SetCommentPages(null);
443

    
444
                ViewerDataModel.Instance.UndoDataList.Clear();
445
                result = true;
446
            }
447
            catch (Exception ex)
448
            {
449
                System.Diagnostics.Debug.WriteLine("_SaveEvent Error : " + ex.ToString());
450
            }
451
            finally
452
            {
453
                /*
454
                /// delete markup information when 코멘트가 없을 경우
455
                if (ViewerDataModel.Instance.MyMarkupList.Count == 0)
456
                {
457
                    foreach (var item in menu.gridViewMarkup.SelectedItems)
458
                    {
459
                        if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
460
                        {
461
                            //this.ParentOfType<MainWindow>().dzMainMenu.DeleteItem((item as IKCOM.MarkupInfoItem));
462
                        }
463
                    }
464
                }
465
                */
466
            }
467

    
468
            return result;
469
        }
470

    
471
        /// <summary>
472
        /// 마크업 데이터를 저장한다.
473
        /// </summary>
474
        /// <param name="menu"></param>
475
        /// <returns></returns>
476
        public async Task<bool> ExecuteSaveCommandAsync(MainMenu menu)
477
        {
478
            bool result = false;
479

    
480
            if (menu.pageNavigator.CurrentPage != null)
481
            {
482
                SaveCommand.Instance.Project_No = App.ViewInfo.ProjectNO;
483
                SaveCommand.Instance.document_id = App.ViewInfo.DocumentItemID;
484
                SaveCommand.Instance.user_id = App.ViewInfo.UserID;
485
                SaveCommand.Instance.page_no = menu.pageNavigator.CurrentPage.PageNumber;
486

    
487
                try
488
                {
489
                    if (ViewerDataModel.Instance.UndoDataList.Count > 0 || ViewerDataModel.Instance.IsMarkupUpdate)
490
                    {
491
                        List<IKCOM.MarkupInfoItem> SelectedMarkupInfos = new List<IKCOM.MarkupInfoItem>();
492
                        foreach (var item in menu.gridViewMarkup.SelectedItems)
493
                        {
494
                            if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
495
                            {
496
                                SelectedMarkupInfos.Add(item as IKCOM.MarkupInfoItem);
497
                            }
498
                        }
499

    
500
                        result = await SaveCommand.Instance.Execute(SelectedMarkupInfos);
501
                        ViewerDataModel.Instance.IsMarkupUpdate = false;
502
                    }
503
                    else
504
                    {
505
                        result = true;
506
                    }
507

    
508
                    if (ViewerDataModel.Instance.RotationDocs.Count > 0)
509
                    {
510
                        SaveCommand.Instance.PageAngleSave(App.ViewInfo.ProjectNO, ViewerDataModel.Instance.RotationDocs);
511
                    }
512
                }
513
                catch (Exception ex)
514
                {
515
                    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(string.Format("세이브 실패:{0}", ex.Message), "Alert");
516
                    throw new InvalidOperationException(ex.Message);
517
                }
518
            }
519
            else
520
            {
521
                System.Diagnostics.Debug.WriteLine("ExecuteSaveCommand Error - pageNavigator.CurrentPage null");
522
            }
523

    
524
            return result;
525
        }
526

    
527
        //강인구 추가
528
        public void Print_Start(string Type)
529
        {
530
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
531
            {
532
                var menu = this.ParentOfType<MainWindow>().dzMainMenu;
533
                SelectionSet.Instance.UnSelect(menu);
534
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
535
                {
536
                    this.SaveEventCallback(null, null);
537
                }
538
                else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
539
                {
540

    
541
                }
542
                else
543
                {
544
                    this.SaveEventCallback(null, null);
545
                }
546
            }
547

    
548
            bool isprint = false;
549
            if (Type == "Print")
550
            {
551
                isprint = true;
552
            }
553

    
554
            RadWindow PrintWindow = new RadWindow();
555
            PrintWindow.Width = 850;
556
            PrintWindow.Height = 600;
557
            PrintWindow.Header = Type;
558

    
559
            List<IKCOM.MarkupInfoItem> markupinfo = new List<IKCOM.MarkupInfoItem>();
560

    
561
            markupinfo = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetPrintDocItemList(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID, ViewerDataModel.Instance._markupInfoList.ToList());
562

    
563
            if (markupinfo?.Count() > 0)
564
            {
565
                //Logger.sendResLog("GetPrintDocItemList", "TRUE", 1);
566
            }
567
            else
568
            {
569
                //Logger.sendResLog("GetPrintDocItemList", "FALSE", 1);
570
            }
571

    
572
            /// Tile Source URL을 구한다
573

    
574
            string sImageURL = ViewerDataModel.Instance.SystemMain.dzMainMenu.GetImageURL(App.ViewInfo.DocumentItemID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber);
575
            var url = new Uri(sImageURL);
576
            string sFolder = App.ViewInfo.DocumentItemID.All(char.IsDigit) ? (Convert.ToInt64(App.ViewInfo.DocumentItemID) / 100).ToString() : App.ViewInfo.DocumentItemID.Substring(0, 5);
577
            var Tile_Url = string.Format(@"{0}://{1}:{2}/TileSource/{3}_Tile/{4}/{5}/",
578
                url.Scheme, url.Host, url.Port,
579
                App.ViewInfo.ProjectNO,
580
                sFolder,
581
                App.ViewInfo.DocumentItemID
582
                );
583
            /// up to here
584

    
585
            var docitem = this.ParentOfType<MainWindow>().dzMainMenu._DocItem;
586

    
587
            PrintWindow.Content = new KCOM.Control.PrintControl(
588
                      Tile_Url,
589
                      App.ViewInfo.ProjectNO,
590
                      this.ParentOfType<MainWindow>().dzMainMenu._DocInfo,
591
                      markupinfo,
592
                      this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber,
593
                      docitem.GROUP_NO,
594
                      docitem.DOCUMENT_NO,
595
                      docitem.ORIGINAL_FILE,
596
                      isprint);
597

    
598
            //프린트 팝업 옵션
599
            //PrintWindow.BorderThickness = new Thickness(3);
600
            //PrintWindow.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 37, 160, 218));
601
            PrintWindow.ResizeMode = System.Windows.ResizeMode.NoResize;
602
            PrintWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
603
            PrintWindow.Background = new SolidColorBrush(Colors.Black);
604
            PrintWindow.Background.Opacity = 0.6;
605
            PrintWindow.Owner = Application.Current.MainWindow;
606
            Telerik.Windows.Controls.StyleManager.SetTheme(PrintWindow, new Telerik.Windows.Controls.VisualStudio2013Theme());
607
            PrintWindow.ShowDialog();
608
        }
609

    
610
        //강인구 추가
611
        private void PrintEvent(object sender, RoutedEventArgs e)
612
        {
613
            RadRibbonButton button = sender as RadRibbonButton;
614
            Print_Start(button.Content.ToString());
615
        }
616

    
617
        private List<AdornerMember> GetAdornerItem()
618
        {
619
            List<AdornerMember> AdonerList = new List<AdornerMember>();
620

    
621
            if (this.ParentOfType<MainWindow>() != null)
622
            {
623
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
624
                {
625
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
626
                    {
627
                        if (item.GetType().Name == "AdornerFinal")
628
                        {
629
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
630
                            {
631
                                AdonerList.Add(InnerItem);
632
                            }
633
                        }
634
                    }
635
                }
636
            }
637

    
638
            return AdonerList;
639
        }
640
        /// <summary>
641
        /// 투명도
642
        /// </summary>
643
        /// <param name="sender"></param>
644
        /// <param name="e"></param>
645
        //강인구 추가(Undo End)
646
        private void sdOpacity_ValueChanged(object sender, RoutedEventArgs e)
647
        {
648
            List<AdornerMember> AdonerList = GetAdornerItem();
649
            if(AdonerList.Count > 0)
650
            {
651
                UndoDataGroup UndoDataGrp = new UndoDataGroup()
652
                {
653
                    IsUndo = false,
654
                    Event = EventType.Operation,
655
                    Opacity = ViewerDataModel.Instance.ControlOpacity
656
                };
657

    
658
                foreach (AdornerMember InnerItem in AdonerList)
659
                {
660
                    InnerItem.DrawingData.Opacity = ViewerDataModel.Instance.ControlOpacity;
661

    
662
                    UndoData UndoData = new UndoData();
663
                    UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
664
                    UndoDataGrp.MarkupDataColl.Add(UndoData);
665
                }
666

    
667
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
668
                {
669
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
670
                });
671
                ViewerDataModel.Instance.UndoDataList.Add(UndoDataGrp);
672
            }
673
        }
674

    
675
        //강인구 추가(Undo End)
676
        private void cbLineSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
677
        {
678
            if (string.IsNullOrEmpty(cbLineSize.Value.ToString()))
679
            {
680
                cbLineSize.Value = cbLineSize.Minimum;
681
            }
682
            List<AdornerMember> AdonerList = GetAdornerItem();
683
            if (AdonerList.Count > 0)
684
            {
685
                UndoDataGroup UndoDataGrp = new UndoDataGroup()
686
                {
687
                    IsUndo = false,
688
                    Event = EventType.Operation,
689
                    LineSize = ViewerDataModel.Instance.LineSize
690
                };
691
                UndoData multi_UndoData = new UndoData();
692

    
693
                foreach (AdornerMember InnerItem in AdonerList)
694
                {
695
                    switch (InnerItem.DrawingData.GetType().Name)
696
                    {
697
                        case ("LineControl"):
698
                            {
699
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).LineSize = ViewerDataModel.Instance.LineSize;
700
                            }
701
                            break;
702
                        case ("ArcControl"):
703
                            {
704
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArcControl).LineSize = ViewerDataModel.Instance.LineSize;
705
                            }
706
                            break;
707
                        case ("ArrowArcControl"):
708
                            {
709
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowArcControl).LineSize = ViewerDataModel.Instance.LineSize;
710
                            }
711
                            break;
712
                        case ("ArrowControl_Multi"):
713
                            {
714
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowControl_Multi).LineSize = ViewerDataModel.Instance.LineSize;
715
                            }
716
                            break;
717
                        case ("CloudControl"):
718
                            {
719
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl).LineSize = ViewerDataModel.Instance.LineSize;
720
                            }
721
                            break;
722
                        case ("PolygonControl"):
723
                            {
724
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.PolygonControl).LineSize = ViewerDataModel.Instance.LineSize;
725
                            }
726
                            break;
727
                        case ("RectangleControl"):
728
                            {
729
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectangleControl).LineSize = ViewerDataModel.Instance.LineSize;
730
                            }
731
                            break;
732
                        case ("RectCloudControl"):
733
                            {
734
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl).LineSize = ViewerDataModel.Instance.LineSize;
735
                            }
736
                            break;
737
                        case ("TriControl"):
738
                            {
739
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.TriControl).LineSize = ViewerDataModel.Instance.LineSize;
740
                            }
741
                            break;
742
                        case ("CircleControl"):
743
                            {
744
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.CircleControl).LineSize = ViewerDataModel.Instance.LineSize;
745
                            }
746
                            break;
747
                        case ("ArrowTextControl"):
748
                            {
749
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).LineSize = ViewerDataModel.Instance.LineSize;
750
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).BorderSize = new Thickness(ViewerDataModel.Instance.LineSize);
751
                            }
752
                            break;
753
                        case ("TextControl"):
754
                            {
755
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).LineSize = new Thickness(ViewerDataModel.Instance.LineSize);
756
                            }
757
                            break;
758
                        case ("InsideWhiteControl"):
759
                            {
760
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.InsideWhiteControl).LineSize = ViewerDataModel.Instance.LineSize;
761
                            }
762
                            break;
763
                        case ("OverlapWhiteControl"):
764
                            {
765
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.OverlapWhiteControl).LineSize = ViewerDataModel.Instance.LineSize;
766
                            }
767
                            break;
768
                        case ("ClipWhiteControl"):
769
                            {
770
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.ClipWhiteControl).LineSize = ViewerDataModel.Instance.LineSize;
771
                            }
772
                            break;
773
                        case ("CoordinateControl"):
774
                            {
775
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.CoordinateControl).LineSize = 10; //ViewerDataModel.Instance.LineSize
776
                            }
777
                            break;
778
                    }
779

    
780
                    multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
781
                    UndoDataGrp.MarkupDataColl.Add(multi_UndoData);
782
                    multi_UndoData = new UndoData();
783
                }
784

    
785
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
786
                {
787
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
788
                });
789
                ViewerDataModel.Instance.UndoDataList.Add(UndoDataGrp);
790
            }
791
            KCOM.Properties.Settings.Default.LineSize = (double)cbLineSize.Value;
792
            Properties.Settings.Default.Save();
793
        }
794

    
795

    
796
        private void cbIntervalSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
797
        {
798
            if (string.IsNullOrEmpty(cbIntervalSize.Value.ToString()))
799
            {
800
                cbIntervalSize.Value = cbIntervalSize.Minimum;
801
            }
802
            List<AdornerMember> AdonerList = GetAdornerItem();
803
            if (AdonerList.Count > 0)
804
            {
805

    
806
                UndoDataGroup UndoDataGrp = new UndoDataGroup()
807
                {
808
                    IsUndo = false,
809
                    Event = EventType.Operation,
810
                    Interval = ViewerDataModel.Instance.Interval
811
                };
812
                UndoData multi_UndoData = new UndoData();
813

    
814
                foreach (AdornerMember InnerItem in AdonerList)
815
                {
816
                    switch (InnerItem.DrawingData.GetType().Name)
817
                    {
818
                        case ("LineControl"):
819
                            {
820
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).Interval = ViewerDataModel.Instance.Interval;
821

    
822
                                multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
823
                                UndoDataGrp.MarkupDataColl.Add(multi_UndoData);
824
                                multi_UndoData = new UndoData();
825
                            }
826
                            break;
827
                    }
828
                }
829

    
830
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
831
                {
832
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
833
                });
834
                ViewerDataModel.Instance.UndoDataList.Add(UndoDataGrp);
835
            }
836
            KCOM.Properties.Settings.Default.Interval = (double)cbIntervalSize.Value;
837
            Properties.Settings.Default.Save();
838
        }
839
        
840
        /// <summary>
841
        /// ArcLength가 수정되었을때
842
        /// </summary>
843
        /// <param name="sender"></param>
844
        /// <param name="e"></param>
845
        private void cbArcLength_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
846
        {
847
            if (string.IsNullOrEmpty(cbArcLength.Value.ToString()))
848
            {
849
                cbArcLength.Value = cbArcLength.Minimum;
850
            }
851

    
852
            List<AdornerMember> AdonerList = GetAdornerItem();
853
            if (AdonerList.Count > 0)
854
            {
855
                var comments = (from drawing in AdonerList
856
                                select drawing.DrawingData as CommentUserInfo)
857
                                .Where(x => x is RectCloudControl || x is CloudControl ||
858
                                x is MarkupToPDF.Controls.Text.TextControl || x is MarkupToPDF.Controls.Text.ArrowTextControl)
859
                                .ToList();
860
                UndoCommand.Instance.Push(EventType.Operation, comments);
861

    
862
                foreach (AdornerMember InnerItem in AdonerList)
863
                {
864
                    switch (InnerItem.DrawingData.GetType().Name)
865
                    {
866
                        case ("RectCloudControl"):
867
                            {
868
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl;
869
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
870
                            }
871
                        break;
872
                        case ("CloudControl"):
873
                        {
874
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl;
875
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
876
                        }
877
                        break;
878
                        case ("TextControl"):
879
                        {
880
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl;
881
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
882
                        }
883
                        break;
884
                        case ("ArrowTextControl"):
885
                        {
886
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl;
887
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
888
                        }
889
                        break;
890
                    }
891
                }
892
            }
893

    
894
            KCOM.Properties.Settings.Default.ArcLength = (double)cbArcLength.Value;
895
            Properties.Settings.Default.Save();
896
        }
897

    
898
        //강인구 추가(Undo End)
899
        private void cbDashStyle_SelectionChanged(object sender, SelectionChangedEventArgs e)
900
        {
901
            //강인구 추가
902
            if (this.ParentOfType<MainWindow>() != null)
903
            {
904
                ViewerDataModel.Instance.DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
905
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
906
                {
907
                    //UndoDataGroup UndoData = new UndoDataGroup()
908
                    //{
909
                    //    IsUndo = false,
910
                    //    Event = EventType.Operation,
911
                    //    EventTime = DateTime.Now,
912
                    //    DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData,
913
                    //    MarkupDataColl = new List<UndoData>()
914
                    //};
915
                    //UndoData multi_UndoData = new UndoData();
916

    
917
                    if (ViewerDataModel.Instance.UndoDataList == null)
918
                    {
919
                        return;
920
                    }
921

    
922
                    List<AdornerMember> AdonerList = GetAdornerItem();
923

    
924
                    var comments = (from drawing in AdonerList
925
                                    select drawing.DrawingData as CommentUserInfo)
926
                        .Where(x => x is LineControl || x is ArcControl || x is ArrowArcControl || x is ArrowControl_Multi
927
                        || x is CloudControl || x is PolygonControl || x is PolygonControl || x is RectangleControl ||
928
                        x is RectCloudControl || x is TriControl || x is CircleControl || x is InsideWhiteControl ||
929
                        x is OverlapWhiteControl || x is ClipWhiteControl || x is CoordinateControl ||
930
                        x is MarkupToPDF.Controls.Text.TextControl || x is MarkupToPDF.Controls.Text.ArrowTextControl)
931
                        .ToList();
932

    
933
                    UndoCommand.Instance.Push(EventType.Operation, comments);
934

    
935

    
936
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
937
                    {
938
                        if (item.GetType().Name == "AdornerFinal")
939
                        {
940
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
941
                            {
942
                                switch (InnerItem.DrawingData.GetType().Name)
943
                                {
944
                                    case ("LineControl"):
945
                                        {
946
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
947
                                        }
948
                                        break;
949
                                    case ("ArcControl"):
950
                                        {
951
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArcControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
952
                                        }
953
                                        break;
954
                                    case ("ArrowArcControl"):
955
                                        {
956
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowArcControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
957
                                        }
958
                                        break;
959
                                    case ("ArrowControl_Multi"):
960
                                        {
961
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowControl_Multi).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
962
                                        }
963
                                        break;
964
                                    case ("CloudControl"):
965
                                        {
966
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
967
                                        }
968
                                        break;
969
                                    case ("PolygonControl"):
970
                                        {
971
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.PolygonControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
972
                                        }
973
                                        break;
974
                                    case ("RectangleControl"):
975
                                        {
976
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectangleControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
977
                                        }
978
                                        break;
979
                                    case ("RectCloudControl"):
980
                                        {
981
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
982
                                        }
983
                                        break;
984
                                    case ("TriControl"):
985
                                        {
986
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.TriControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
987
                                        }
988
                                        break;
989
                                    case ("CircleControl"):
990
                                        {
991
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.CircleControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
992
                                        }
993
                                        break;
994
                                    case ("InsideWhiteControl"):
995
                                        {
996
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.InsideWhiteControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
997
                                        }
998
                                        break;
999
                                    case ("OverlapWhiteControl"):
1000
                                        {
1001
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.OverlapWhiteControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1002
                                        }
1003
                                        break;
1004
                                    case ("ClipWhiteControl"):
1005
                                        {
1006
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.ClipWhiteControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1007
                                        }
1008
                                        break;
1009
                                    case ("CoordinateControl"):
1010
                                        {
1011
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.CoordinateControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1012
                                        }
1013
                                        break;
1014
                                }
1015

    
1016
                                //multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
1017
                                //UndoData.MarkupDataColl.Add(multi_UndoData);
1018
                                //multi_UndoData = new UndoData();
1019
                            }
1020

    
1021
                            //ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
1022
                            //{
1023
                            //    ViewerDataModel.Instance.UndoDataList.Remove(i);
1024
                            //});
1025
                            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
1026

    
1027
                        }
1028
                    }
1029
                }
1030
            }
1031
        }
1032

    
1033
        //강인구 추가
1034
        private void comboFontSize_SelectionChanged(object sender, SelectionChangedEventArgs e)
1035
        {
1036
            //if (this.ParentOfType<MainWindow>() != null)
1037
            //{
1038
            //    if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1039
            //    {
1040
            //        foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1041
            //        {
1042
            //            if (item.GetType().Name == "AdornerFinal")
1043
            //            {
1044
            //                foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
1045
            //                {
1046
            //                    switch (InnerItem.DrawingData.GetType().Name)
1047
            //                    {
1048
            //                        case ("TextControl"):
1049
            //                            {
1050
            //                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextSize = int.Parse(comboFontSize.Text);
1051
            //                            }
1052
            //                            break;
1053
            //                        case ("ArrowTextControl"):
1054
            //                            {
1055
            //                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextSize = int.Parse(comboFontSize.Text);
1056
            //                            }
1057
            //                            break;
1058
            //                    }
1059
            //                }
1060
            //            }
1061
            //        }
1062
            //    }
1063
            //}
1064
        }
1065

    
1066
        //강인구 추가
1067
        private void btnBold_Checked(object sender, RoutedEventArgs e)
1068
        {
1069
            if (this.ParentOfType<MainWindow>() != null)
1070
            {
1071
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1072
                {
1073
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1074
                    {
1075
                        if (item.GetType().Name == "AdornerFinal")
1076
                        {
1077
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1078
                            {
1079
                                switch (InnerItem.DrawingData.GetType().Name)
1080
                                {
1081
                                    case ("TextControl"):
1082
                                        {
1083
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight == FontWeights.Bold)
1084
                                            {
1085
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight = FontWeights.Normal;
1086
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1087
                                            }
1088
                                            else
1089
                                            {
1090
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight = FontWeights.Bold;
1091
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1092
                                            }
1093

    
1094
                                        }
1095
                                        break;
1096
                                    case ("ArrowTextControl"):
1097
                                        {
1098
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight == FontWeights.Bold)
1099
                                            {
1100
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight = FontWeights.Normal;
1101
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1102
                                            }
1103
                                            else
1104
                                            {
1105
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight = FontWeights.Bold;
1106
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1107
                                            }
1108
                                        }
1109
                                        break;
1110
                                }
1111
                            }
1112
                        }
1113
                    }
1114
                }
1115
            }
1116
        }
1117

    
1118
        //강인구 추가
1119
        private void btnItalic_Checked(object sender, RoutedEventArgs e)
1120
        {
1121
            if (this.ParentOfType<MainWindow>() != null)
1122
            {
1123
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1124
                {
1125
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1126
                    {
1127
                        if (item.GetType().Name == "AdornerFinal")
1128
                        {
1129
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1130
                            {
1131
                                switch (InnerItem.DrawingData.GetType().Name)
1132
                                {
1133
                                    case ("TextControl"):
1134
                                        {
1135
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle == FontStyles.Italic)
1136
                                            {
1137
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle = System.Windows.FontStyles.Normal;
1138
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1139
                                            }
1140
                                            else
1141
                                            {
1142
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle = FontStyles.Italic;
1143
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1144
                                            }
1145

    
1146
                                        }
1147
                                        break;
1148
                                    case ("ArrowTextControl"):
1149
                                        {
1150
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle == FontStyles.Italic)
1151
                                            {
1152
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle = FontStyles.Normal;
1153
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1154
                                            }
1155
                                            else
1156
                                            {
1157
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle = FontStyles.Italic;
1158
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1159
                                            }
1160
                                        }
1161
                                        break;
1162
                                }
1163
                            }
1164
                        }
1165
                    }
1166
                }
1167
            }
1168
        }
1169

    
1170
        //강인구 추가
1171
        private void btnUnderLine_Checked(object sender, RoutedEventArgs e)
1172
        {
1173
            if (this.ParentOfType<MainWindow>() != null)
1174
            {
1175
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1176
                {
1177
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1178
                    {
1179
                        if (item.GetType().Name == "AdornerFinal")
1180
                        {
1181
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1182
                            {
1183
                                switch (InnerItem.DrawingData.GetType().Name)
1184
                                {
1185
                                    case ("TextControl"):
1186
                                        {
1187
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine == TextDecorations.Underline)
1188
                                            {
1189
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine = null;
1190
                                            }
1191
                                            else
1192
                                            {
1193
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine = TextDecorations.Underline;
1194
                                            }
1195
                                        }
1196
                                        break;
1197
                                    case ("ArrowTextControl"):
1198
                                        {
1199
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine == TextDecorations.Underline)
1200
                                            {
1201
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine = null;
1202
                                            }
1203
                                            else
1204
                                            {
1205
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine = TextDecorations.Underline;
1206
                                            }
1207
                                        }
1208
                                        break;
1209
                                }
1210

    
1211
                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1212
                            }
1213
                        }
1214
                    }
1215
                }
1216
            }
1217
        }
1218

    
1219

    
1220
        private void cbLineSize_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1221
        {
1222
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1223
            {
1224
                e.Handled = true;
1225
            }
1226

    
1227
        }
1228

    
1229
        private void cbLineSize_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1230
        {
1231
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1232
            if (regex.IsMatch(e.Text))
1233
            {
1234
                e.Handled = true;
1235
            }
1236

    
1237
        }
1238

    
1239
        private void cbArcLength_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1240
        {
1241
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1242
            {
1243
                e.Handled = true;
1244
            }
1245
        }
1246

    
1247
        private void cbArcLength_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1248
        {
1249
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1250
            if (regex.IsMatch(e.Text))
1251
            {
1252
                e.Handled = true;
1253
            }
1254
        }
1255

    
1256
        private void comboFontSize_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1257
        {
1258
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1259
            {
1260
                e.Handled = true;
1261
            }
1262
        }
1263

    
1264
        private void cbIntervalSize_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1265
        {
1266
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1267
            {
1268
                e.Handled = true;
1269
            }
1270
        }
1271

    
1272
        private void cbIntervalSize_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1273
        {
1274
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1275
            if (regex.IsMatch(e.Text))
1276
            {
1277
                e.Handled = true;
1278
            }
1279
        }
1280

    
1281
        private void comboFontSize_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1282
        {
1283
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1284
            if (regex.IsMatch(e.Text))
1285
            {
1286
                e.Handled = true;
1287
            }
1288
        }
1289

    
1290
        private void comboFontSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
1291
        {
1292
            if (string.IsNullOrEmpty(comboFontSize.Value.ToString()))
1293
            {
1294
                comboFontSize.Value = comboFontSize.Minimum;
1295
            }
1296
            if (this.ParentOfType<MainWindow>() != null)
1297
            {
1298
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1299
                {
1300
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1301
                    {
1302
                        if (item.GetType().Name == "AdornerFinal")
1303
                        {
1304
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1305
                            {
1306
                                switch (InnerItem.DrawingData.GetType().Name)
1307
                                {
1308
                                    case ("TextControl"):
1309
                                        {
1310
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextSize = int.Parse(comboFontSize.Value.ToString());
1311
                                        }
1312
                                        break;
1313
                                    case ("ArrowTextControl"):
1314
                                        {
1315
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextSize = int.Parse(comboFontSize.Value.ToString());
1316
                                        }
1317
                                        break;
1318
                                }
1319
                            }
1320

    
1321
                            ChangeComment(item as Controls.AdornerFinal);
1322
                        }
1323
                    }
1324
                }
1325
            }
1326

    
1327
            KCOM.Properties.Settings.Default.TextSize = (double)comboFontSize.Value;
1328
            Properties.Settings.Default.Save();
1329
        }
1330

    
1331
        //강인구 추가
1332
        private void comboFontFamily_SelectionChanged(object sender, SelectionChangedEventArgs e)
1333
        {
1334
            
1335
            if (comboFontFamily.SelectedItem != null && !IsSuspendChange)
1336
            {
1337
                var main = this.ParentOfType<MainWindow>()?.dzMainMenu;
1338
                var font = comboFontFamily.SelectedItem as Markus.Fonts.MarkusFont;
1339
                var lstTextCtrl = SelectTextControl();
1340

    
1341
                foreach (var item in lstTextCtrl)
1342
                {
1343
                    if (item is MarkupToPDF.Controls.Text.ArrowTextControl ctrl1)
1344
                    {
1345
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1346
                        ctrl1.SetFontFamily(font.FontFamily);
1347
                    }
1348
                    else if (item is MarkupToPDF.Controls.Text.TextControl ctrl2)
1349
                    {
1350
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1351
                        ctrl2.SetFontFamily(font.FontFamily);
1352
                    }
1353
                }
1354

    
1355
                KCOM.Properties.Settings.Default.FontFamily = font.FontFamily.FontName();
1356
                Properties.Settings.Default.Save();
1357
            }
1358
        }
1359

    
1360
        private List<UIElement> SelectTextControl()
1361
        {
1362
            List<UIElement> lstTextCtrl = new List<UIElement>();
1363

    
1364
            var main = this.ParentOfType<MainWindow>()?.dzMainMenu;
1365
            var font = comboFontFamily.SelectedItem as Markus.Fonts.MarkusFont;
1366

    
1367

    
1368
            if (main.SelectLayer.FindChildByType<AdornerFinal>() != null)
1369
            {
1370
                lstTextCtrl.AddRange(main.SelectLayer.FindChildByType<AdornerFinal>().Members.Where(x => x.DrawingData is MarkupToPDF.Controls.Common.ITextControl).Select(x => x.DrawingData));
1371
            }
1372

    
1373
            lstTextCtrl.AddRange(main.zoomAndPanCanvas.FindAllChildren(x => x is MarkupToPDF.Controls.Common.ITextControl c && (c.IsSelected || c.IsEditingMode == true)).Select(x => (UIElement)x));
1374

    
1375
            return lstTextCtrl;
1376
        }
1377

    
1378

    
1379
        /// <summary>
1380
        /// 텍스트 컨트롤 하일라이트 처리
1381
        /// </summary>
1382
        /// <param name="sender"></param>
1383
        /// <param name="e"></param>
1384
        private void HighlightEvent(object sender, RoutedEventArgs e)
1385
        {
1386

    
1387
            ViewerDataModel.Instance.checkHighShape = (sender as CheckBox).IsChecked.Value;
1388
            SetHighlightEvent();
1389
            //if ((sender as CheckBox).IsChecked.Value)
1390
            //{
1391
            //    TaskMessage("HighLight가 설정되었습니다", TaskMessageType.Normal);
1392
            //}
1393
            //else
1394
            //{
1395
            //    TaskMessage("HighLight가 해제되었습니다", TaskMessageType.Caption);
1396
            //}
1397
            //if (ViewerDataModel.Instance.SelectedEditor as MarkupToPDF.Controls.Text.TextControl != null)
1398
            //{
1399
            //    MarkupToPDF.Controls.Text.TextControl instance = (ViewerDataModel.Instance.SelectedEditor as MarkupToPDF.Controls.Text.TextControl);
1400
            //    instance.IsHighLight = ViewerDataModel.Instance.checkHighShape;
1401
            //    instance.SetText();
1402
            //}
1403
        }
1404

    
1405
        //추가페이지 이동 엔터
1406
        private void tlcurrentPage_KeyDown(object sender, KeyEventArgs e)
1407
        {
1408
            //강인구 추가 tlcurrentPage을 이상하게 입력할수 있기때문에 Try Catch
1409
            if (e.Key == Key.Enter)
1410
            {
1411
                try
1412
                {
1413
                    var instanceMain = this.ParentOfType<MainWindow>();
1414
                    var max = instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Max(f => f.PageNumber);
1415
                    if (string.IsNullOrEmpty(tlcurrentPage.Text))
1416
                    {
1417
                        RadWindow.Alert(new DialogParameters
1418
                        {
1419
                            Owner = Application.Current.MainWindow,
1420
                            Theme = new VisualStudio2013Theme(),
1421
                            Header = "Info",
1422
                            Content = "Enter the correct page number.",
1423
                        });
1424
                    }
1425
                    else
1426
                    {
1427
                        if (Convert.ToInt32(tlcurrentPage.Text) > max || Convert.ToInt32(tlcurrentPage.Text) == 0)
1428
                        {
1429
                            RadWindow.Alert(new DialogParameters
1430
                            {
1431
                                Owner = Application.Current.MainWindow,
1432
                                Theme = new VisualStudio2013Theme(),
1433
                                Header = "Info",
1434
                                Content = "Enter the correct page number.",
1435
                            });
1436
                        }
1437
                        else
1438
                        {
1439
                            instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text));
1440
                        }
1441
                    }
1442
                    
1443
                }
1444
                catch (Exception)
1445
                {
1446
                    RadWindow.Alert(new DialogParameters
1447
                    {
1448
                        Owner = Application.Current.MainWindow,
1449
                        Theme = new VisualStudio2013Theme(),
1450
                        Header = "Info",
1451
                        Content = "Enter the correct page number.",
1452
                    });
1453
                }
1454
                
1455
            }
1456
        }
1457
        private string previousText;
1458
        private void TlcurrentPage_PreviewTextInput(object sender, TextCompositionEventArgs e)
1459
        {
1460
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("[^0-9]+");
1461
            e.Handled = regex.IsMatch(e.Text);
1462
        }
1463
        private void TlcurrentPage_TextChanged(object sender, TextChangedEventArgs e)
1464
        {
1465
            double num = 0;
1466
            bool success = double.TryParse(((TextBox)sender).Text, out num);
1467
            if (success & num >= 0)
1468
                previousText = ((TextBox)sender).Text;
1469
            else
1470
            {
1471
                if (string.IsNullOrEmpty(((TextBox)sender).Text))
1472
                {
1473
                    ((TextBox)sender).Text = "";
1474
                }
1475
                else
1476
                {
1477

    
1478
                    ((TextBox)sender).Text = previousText;
1479
                }
1480
            }
1481
        }
1482

    
1483
        /// <summary>
1484
        /// 입력한 페이지로 이동한다
1485
        /// </summary>
1486
        /// <param name="sender"></param>
1487
        /// <param name="e"></param>
1488
        private void tlcurrentPage_readonly_KeyDown(object sender, KeyEventArgs e)
1489
        {
1490
            if (e.Key == Key.Enter)
1491
            {
1492
                try
1493
                {
1494
                    var instanceMain = this.ParentOfType<MainWindow>();
1495
                    instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage_readonly.Text));
1496
                }
1497
                catch (Exception)
1498
                {
1499
                    RadWindow.Alert(new DialogParameters
1500
                    {
1501
                        Owner = Application.Current.MainWindow,
1502
                        Theme = new VisualStudio2013Theme(),
1503
                        Header = "Info",
1504
                        Content = "Enter the correct page number.",
1505
                    });
1506
                }
1507
            }
1508
        }
1509
        
1510
        private void PanoramaEvent(object sender, RoutedEventArgs e)
1511
        {
1512
            PanoramaShow();
1513
        }
1514

    
1515
        public void PanoramaShow()
1516
        {
1517
            Panorama check = new Panorama();
1518
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
1519
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
1520
            //double windowWidth = this.Width;
1521
            //double windowHeight = this.Height;
1522

    
1523
            var PanoramaPop = new RadWindow
1524
            {
1525
                //MinWidth = 600,
1526
                //MinHeight = 400,
1527
                //Header = "My Check List",
1528
                Header = "Document No : " + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO + " / Revision :" + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.REVISION,
1529
                Content = check,
1530
                Owner = this,
1531
                ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1532
                //ResizeMode = System.Windows.ResizeMode.NoResize,
1533
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1534
                IsTopmost = false,
1535
                //Left = (screenWidth / 2) - (windowWidth / 2),
1536
                //Top = (screenHeight / 2) - (windowHeight / 2),
1537
                //Left = (screenWidth / 2),
1538
                //Top = (screenHeight / 2),
1539
                Width = screenWidth * 0.4,
1540
                Height = screenHeight * 0.4,
1541
            };
1542
            StyleManager.SetTheme(PanoramaPop, new VisualStudio2013Theme());
1543
            //CheckPop.ShowDialog();
1544
            PanoramaPop.Owner = Application.Current.MainWindow;
1545
            PanoramaPop.Show();
1546
        }
1547

    
1548
        private void CheckEvent(object sender, RoutedEventArgs e)
1549
        {
1550
            //창이 떠있을 경우 재 실행 방지
1551
            if (isClosed)
1552
            {
1553
                //토글 및 마우스 상태 초기화
1554
                var toggleList = this.Parent.ChildrenOfType<RadToggleButton>();
1555
                foreach(var togle in toggleList)
1556
                {
1557
                    togle.IsChecked = false;
1558
                }
1559
                this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1560

    
1561
                isClosed = false;
1562

    
1563
                
1564
                CheckList check = new CheckList(this.ParentOfType<MainWindow>());
1565

    
1566
                CheckPop = new RadWindow
1567
                {
1568
                    MinWidth = 1200,
1569
                    MinHeight = 500,
1570
                    //Header = "My Check List",
1571
                    Header = "Document No : " + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO + " / Revision :" + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.REVISION,
1572
                    Content = check,
1573
                    //Owner = this,
1574
                    //ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1575
                    ResizeMode = System.Windows.ResizeMode.NoResize,
1576
                    WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1577
                    IsTopmost = true,
1578
                };
1579
                StyleManager.SetTheme(CheckPop, new Office2013Theme());
1580
                CheckPop.Closed += CheckPop_Closed;
1581
                
1582
                //CheckPop.ShowDialog();
1583
                CheckPop.Show();
1584
            }
1585
        }
1586

    
1587
        private void SignManagerEvent(object sender, RoutedEventArgs e)
1588
        {
1589
            OpenSignManager();
1590
        }
1591

    
1592
        private void OpenSignManager()
1593
        { 
1594
            SignManager signManager = new SignManager();
1595

    
1596
            RadWindow signManagerPop = new RadWindow
1597
            {
1598
                MinWidth = 1200,
1599
                MinHeight = 500,
1600
                //Header = "My Check List",
1601
                Header = "",
1602
                Content = signManager,
1603
                Owner = this,
1604
                //ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1605
                ResizeMode = System.Windows.ResizeMode.CanResize,
1606
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1607
            };
1608
            StyleManager.SetTheme(signManagerPop, new Office2013Theme());
1609

    
1610
            //CheckPop.ShowDialog();
1611
            signManagerPop.ShowDialog();
1612
        }
1613

    
1614
        private void OptionPop_Closed(object sender, WindowClosedEventArgs e)
1615
        {
1616
            isClosed = true;
1617
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
1618
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1619
            ViewerDataModel.Instance.Capture_Opacity = 0;
1620
        }
1621

    
1622
        private void CheckPop_Closed(object sender, WindowClosedEventArgs e)
1623
        {
1624
            isClosed = true;
1625
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
1626
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1627
            ViewerDataModel.Instance.Capture_Opacity = 0;
1628
        }
1629

    
1630
        /// <summary>
1631
        /// 사용자가 선택한 페이지로 이동(썸네일 동기화 시킴)
1632
        /// </summary>
1633
        /// <param name="sender"></param>
1634
        /// <param name="e"></param>
1635
        private void PageGoEvent(object sender, RoutedEventArgs e)
1636
        {
1637
            RadButton button = sender as RadButton;
1638
            var instanceMain = this.ParentOfType<MainWindow>();
1639
            
1640
            //강인구 추가 tlcurrentPage을 이상하게 입력할수 있기때문에 Try Catch
1641
            try
1642
            {
1643
                switch (button.CommandParameter.ToString())
1644
                {
1645
                    case "Down":
1646
                        {
1647
                            instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text) + 1);
1648
                        }
1649
                        break;
1650
                    case "Up":
1651
                        {
1652
                            instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text) - 1);
1653
                        }
1654
                        break;
1655
                }
1656
            }
1657
            catch (Exception)
1658
            {
1659
                RadWindow.Alert(new DialogParameters
1660
                {
1661
                    Owner = Application.Current.MainWindow,
1662
                    Theme = new VisualStudio2013Theme(),
1663
                    Header = "Info",
1664
                    Content = "Enter the correct page number.",
1665
                });
1666
            }
1667
        }
1668

    
1669
        private void viewEvent(object sender, RoutedEventArgs e)
1670
        {
1671
            RadRibbonToggleButton viewButton = sender as RadRibbonToggleButton;
1672
            var instanceMain = this.ParentOfType<MainWindow>();
1673

    
1674
            Point point = new Point(instanceMain.dzMainMenu.zoomAndPanCanvas.Width / 2, instanceMain.dzMainMenu.zoomAndPanCanvas.Height / 2);
1675

    
1676
            //if ((sender as RadRibbonToggleButton) != null)
1677
            //{
1678
            //    Common.ViewerDataModel.Instance.ControlTag = (sender as RadRibbonToggleButton).Tag.ToString();
1679
            //    instanceToggle = (sender as RadRibbonToggleButton);
1680
            //}
1681

    
1682
            //instanceToggle.IsChecked = false;
1683

    
1684
            switch (viewButton.CommandParameter.ToString())
1685
            {
1686
                case "zoomout":
1687
                    {
1688
                        //장원
1689
                        //instanceMain.dzMainMenu.zoomAndPanControl.ZoomTo(new Rect(0, 0, instanceMain.dzMainMenu.zoomAndPanCanvas.ActualWidth, instanceMain.dzMainMenu.zoomAndPanCanvas.ActualHeight));
1690
                        instanceMain.dzMainMenu.zoomAndPanControl.ZoomPointToViewportCenter(ViewerDataModel.Instance.ContentScale -= 0.1, point);
1691
                        viewButton.IsChecked = false;
1692
                        //Common.ViewerDataModel.Instance.zom
1693
                    }
1694
                    break;
1695
                case "zoomin":
1696
                    {
1697
                        instanceMain.dzMainMenu.zoomAndPanControl.ZoomPointToViewportCenter(ViewerDataModel.Instance.ContentScale += 0.1, point);
1698
                        viewButton.IsChecked = false;
1699
                    }
1700
                    break;             
1701
                case "fitWidth":
1702
                    {
1703
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1704
                        viewButton.IsChecked = false;
1705
                    }
1706
                    break;
1707
                case "fitHeight":
1708
                    {
1709
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1710
                        viewButton.IsChecked = false;
1711
                    }
1712
                    break;
1713
                case "boundzoom":
1714
                    {
1715

    
1716
                    }
1717
                    break;
1718
                case "Rotate_M":
1719
                    {
1720
                        drawingPannelRotate(false);
1721
                        viewButton.IsChecked = false;
1722
                    }
1723
                    break;
1724
                case "Rotate_P":
1725
                    {
1726
                        drawingPannelRotate(true);
1727
                        viewButton.IsChecked = false;
1728
                    }
1729
                    break;
1730
                case "Rotate_half":
1731
                    {
1732
                        drawingPannelRotate(true);
1733
                        drawingPannelRotate(true);
1734
                        viewButton.IsChecked = false;
1735
                    }
1736
                    break;
1737
                    //case "fullscreen":
1738
                    //    {
1739
                    //        instanceMain.WindowStyle = WindowStyle.None;
1740
                    //        instanceMain.WindowState = WindowState.Maximized;
1741
                    //        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1742
                    //        viewButton.IsChecked = false;
1743
                    //    }
1744
                    //    break;
1745
            }
1746
        }
1747

    
1748
        private void Control_Event(object sender, RoutedEventArgs e)
1749
        {
1750

    
1751
        }
1752

    
1753
        #region 대기
1754

    
1755
        public void drawingPannelRotate(bool Flag)
1756
        {
1757
            var instanceMain = this.ParentOfType<MainWindow>();
1758

    
1759
            //if (rotateOffSet > 3)
1760
            //    rotateOffSet = 0;
1761

    
1762
            //if (rotateOffSet < 0)
1763
            //    rotateOffSet = 3;
1764

    
1765
            if(Flag)
1766
            {
1767
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
1768
                {
1769
                    instanceMain.dzMainMenu.rotate.Angle = 0;
1770
                }
1771
                else
1772
                {
1773
                    instanceMain.dzMainMenu.rotate.Angle += 90;
1774
                }
1775
            }
1776
            else
1777
            {
1778
                if(instanceMain.dzMainMenu.rotate.Angle == 0)
1779
                {
1780
                    instanceMain.dzMainMenu.rotate.Angle = 270;
1781
                }
1782
                else
1783
                {
1784
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
1785
                }
1786
            }
1787
            //double angle = (double)rotateValue.GetValue(rotateOffSet);
1788
            //instanceMain.dzMainMenu.rotate.Angle = angle;
1789
            var rotationNum = Math.Abs((instanceMain.dzMainMenu.rotate.Angle / 90));
1790

    
1791
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
1792
            {
1793
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1794
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1795
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
1796
            }
1797
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
1798
            {
1799
                instanceMain.dzMainMenu.translate.X = 0;
1800
                instanceMain.dzMainMenu.translate.Y = 0;
1801
            }
1802
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
1803
            {
1804
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1805
                instanceMain.dzMainMenu.translate.Y = 0;
1806
            }
1807
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
1808
            {
1809
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1810
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1811
            }
1812
            else
1813
            {
1814
                instanceMain.dzMainMenu.translate.X = 0;
1815
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1816
            }
1817

    
1818
            //instanceMain.dzMainMenu.zoomAndPanControl.RenderTransformOrigin = new Point(0.5, 0.5);
1819
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
1820
            //대기(강인구)
1821
            //instanceMain.dzMainMenu.imageViewer.RotateAngle = instanceMain.dzMainMenu.rotate.Angle;
1822

    
1823

    
1824
            //instanceMain.dzMainMenu.imageViewer.RenderTransformOrigin = new Point(0.5, 0.5);
1825
            //RotateTransform rotateTransform = new RotateTransform(instanceMain.dzMainMenu.rotate.Angle);
1826
            //instanceMain.dzMainMenu.imageViewer.RenderTransform = rotateTransform;
1827

    
1828

    
1829
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1830
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1831
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
1832
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
1833
            ViewerDataModel.Instance.PageAngle = instanceMain.dzMainMenu.rotate.Angle;
1834
            //ViewerDataModel.Instance.Document_Info.Clear();
1835
            //ViewerDataModel.Instance.Document_Info.Where(i => i.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(value =>
1836
            //{
1837
            //    value.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1838
            //});
1839

    
1840

    
1841
            //이미지 각도 변경 시 실시간 Thumbnail 각도 변경(강인구 추가)
1842
            var thumbnaillist = instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1843

    
1844
            foreach (var data in thumbnaillist)
1845
            {
1846
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1847

    
1848
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
1849
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
1850
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1851

    
1852
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
1853

    
1854
                //rotation page add or update
1855
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
1856
                if (rotationdoc != null)
1857
                {
1858
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
1859
                }
1860
                else
1861
                {
1862
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
1863
                }
1864
            }
1865
        }
1866
        #endregion
1867

    
1868
        private void ImageConverter(RadToggleButton instanceToggle)
1869
        {
1870
            try
1871
            {           
1872
                var instanceMain = this.ParentOfType<MainWindow>();
1873

    
1874
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
1875
                dlg.Filter = "All files (*.*)|*.*|PNG Images (*.png)|*.png";
1876
                Nullable<bool> result = dlg.ShowDialog();
1877
                if (result == true)
1878
                {
1879
                    instanceMain.dzMainMenu.filename = dlg.FileName;
1880
                    instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
1881

    
1882
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(instanceMain.dzMainMenu.filename);
1883
                    String strFile = System.IO.Path.GetFileName(instanceMain.dzMainMenu.filename);
1884
                    long numByte = fileInfo.Length;
1885
                    double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
1886
                    kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
1887
             
1888
                    if (dLen < 4)
1889
                    {
1890
                        System.IO.FileStream fStream = new System.IO.FileStream(instanceMain.dzMainMenu.filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
1891
                        System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
1892
                        byte[] data = br.ReadBytes((int)numByte);
1893
                        br.Close();
1894

    
1895
                        string filepath = fileUploader.Run(App.ViewInfo.ProjectNO, instanceMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile, data);
1896

    
1897
                        Check_Uri.UriCheck(filepath);
1898

    
1899
                        instanceMain.dzMainMenu.filename = filepath;
1900

    
1901
                        fStream.Close();
1902
                        fStream.Dispose();
1903
                    }
1904
                    else
1905
                    {
1906
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
1907
                    }
1908
                }
1909
                else
1910
                {
1911
                    instanceToggle.IsChecked = false;
1912
                    Common.ViewerDataModel.Instance.SelectedControl = "";
1913
                    Common.ViewerDataModel.Instance.ControlTag = null;
1914
                    this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
1915
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1916
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("No Image selected.", "Alert");
1917
                }
1918
            }
1919
            catch(Exception ex)
1920
            {
1921
                instanceToggle.IsChecked = false;
1922
                Common.ViewerDataModel.Instance.SelectedControl = "";
1923
                Common.ViewerDataModel.Instance.ControlTag = null;
1924
                this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
1925
                this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1926
                App.FileLogger.Error("Image Converter ",ex);
1927

    
1928
                this.ParentOfType<MainWindow>().DialogMessage_Alert(ex.Message, "Alert");
1929
            }
1930
        }
1931

    
1932
        private void Control_Init(RadToggleButton instanceToggle, object sender)
1933
        {
1934

    
1935
        }
1936

    
1937
        private void ControlEvent(object sender, RoutedEventArgs e)
1938
        {
1939
            RadToggleButton instanceToggle = sender as RadToggleButton;
1940
            var instanceMain = this.ParentOfType<MainWindow>();
1941

    
1942
            #region Ctrl + A 눌렀을 때 대처 방법 
1943
            //원인 : Ctrl + A를 누르면 UIElementSet에 등록을 시키지 않는다(이유는 한꺼번에 많은 양의 컨트롤의 동작이 유입되기 때문에
1944
            //       시스템의 성능저하를 불러올 수 있기 때문이다. 그래서 선택 후 다른 컨트롤을 누르면 등록되지 않은 컨트롤이기 때문에 삭제된다
1945
            //       이를 대처하는 방법으로 아래 코드를 사용한다.
1946
            if (Common.ViewerDataModel.Instance.MarkupControls.Count == 0 && Common.ViewerDataModel.Instance.MarkupControls.Count >= 1)
1947
            {
1948
                //var lstItem = instanceMain.DeepLayer._SelectLayer.ChildrenOfType<AdornerFinal>().ToList();
1949
                //foreach (var item in lstItem)
1950
                //{
1951
                //    foreach (var member in item.MemberSet)
1952
                //    {
1953
                //        if (!instanceMain.DeepLayer.UIElementSet.Contains(member.DrawingData))
1954
                //        {
1955
                //            instanceMain.DeepLayer.UIElementSet.Add(member.DrawingData);
1956
                //        }
1957
                //    }
1958
                //}
1959
            }
1960
            #endregion
1961

    
1962
            //if (!instanceMain.IsFreeSelectionMode)
1963
            //{
1964
            //    instanceMain.IsSwingMode = true;
1965
            //}
1966

    
1967
            //#region 다른 컨트롤 버튼 선택 해제
1968
            //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.SelectedControl).Subscribe(ControlState =>
1969
            //{
1970
            //    if (ControlState == null)
1971
            //    {
1972
            //        instanceToggle.IsChecked = false;
1973
            //        HiddenControlHide();
1974
            //    }
1975
            //});
1976
            //#endregion
1977

    
1978
            Release_ToggleButton(sender); //-> 해당 컨트롤을 제외한 모든 컨트롤에 대해 해제 처리
1979

    
1980
            if (instanceToggle != null)
1981
            {
1982
                Common.ViewerDataModel.Instance.ControlTag = instanceToggle.Tag.ToString();
1983
            }
1984
            else if ((sender as RadRibbonToggleButton) != null)
1985
            {
1986
                Common.ViewerDataModel.Instance.ControlTag = (sender as RadRibbonToggleButton).Tag.ToString();
1987
                instanceToggle = (sender as RadRibbonToggleButton);
1988
            }
1989
            else if ((sender as RadRibbonButton) != null)
1990
            {
1991
                RadRibbonButton instanceButton = sender as RadRibbonButton;
1992
                Common.ViewerDataModel.Instance.ControlTag = instanceButton.Tag.ToString();
1993
            }
1994
            else
1995
            {
1996
                RadButton instanceButton = sender as RadButton;
1997
                Common.ViewerDataModel.Instance.ControlTag = instanceButton.Tag.ToString();
1998
            }
1999

    
2000

    
2001
            //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.AngleVisibility).Subscribe(isSee =>
2002
            //{
2003
            //    if (instanceToggle.CommandParameter.ToString() == "ChainLine")
2004
            //    {
2005

    
2006
            //    }
2007
            //    else
2008
            //    {
2009
            //        System.Diagnostics.Debug.WriteLine(" instanceMain.dzMainMenu.MainAngle.Visibility   " + isSee);
2010

    
2011
            //        if (instanceMain.dzMainMenu.MainAngle.Visibility != isSee)
2012
            //        {
2013
            //            instanceMain.dzMainMenu.MainAngle.Visibility = isSee;
2014
            //        }
2015
            //    }
2016
            //    //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.AngleValue).Subscribe(p =>
2017
            //    //{
2018
            //    //    instanceMain.dzMainMenu.MainAngle.AngleValue = p;
2019
            //    //});
2020
            //});
2021

    
2022
            instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2023

    
2024
            instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2025

    
2026
            if (instanceToggle.IsChecked != false)
2027
            {
2028
                string param = instanceToggle.CommandParameter.ToString();
2029
                string MacroIndex = "";
2030

    
2031
                if (param.StartsWith("MACRO"))
2032
                {
2033
                    param = "MACRO";
2034
                    MacroIndex = param.Replace("MACRO;","");
2035

    
2036
                    //Common.ViewerDataModel.Instance.MacroItems = MacroHelper.LoadMacroItems(MacroIndex);
2037
                    //var items = MacroHelper.TopMenuItems();
2038

    
2039
                    Common.ViewerDataModel.Instance.MacroItems = new List<MacroItem>
2040
                    {
2041
                        new MacroItem
2042
                        {
2043
                            Desc = "Cloud Rectangle",
2044
                            ControlType = MarkupToPDF.Controls.Common.ControlType.RectCloud
2045
                        },
2046
                        new MacroItem
2047
                        {
2048
                             Desc = "Arrow TextBox",
2049
                            ControlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl
2050
                        }
2051
                    };
2052
                }
2053

    
2054
                #region 컨트롤이 체크되었다면
2055
                switch (param)
2056
                {
2057
                    #region Line
2058
                    case "Line":
2059
                        Common.ViewerDataModel.Instance.SelectedControl = "Line";
2060
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2061
                        if (instanceToggle.Tag.ToString() == "LineDelete")
2062
                        {
2063
                            //HiddenInterval.Visibility = Visibility.Visible;
2064
                        }
2065
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.SingleLine;
2066
                        break;
2067
                    #endregion
2068
                    #region ChainLine
2069
                    case "ChainLine":
2070
                        Common.ViewerDataModel.Instance.SelectedControl = "ChainLine";
2071
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2072
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ChainLine;
2073
                        break;
2074
                    #endregion
2075
                    #region DimLine
2076
                    case "DimLine":
2077
                        Common.ViewerDataModel.Instance.SelectedControl = "DimLine";
2078
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2079
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.DimLine;
2080
                        break;
2081
                    #endregion
2082
                    #region TwinLine
2083
                    case "TwinLine":
2084
                        Common.ViewerDataModel.Instance.SelectedControl = "TwinLine";
2085
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2086
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TwinLine;
2087
                        break;
2088
                    #endregion
2089
                    #region CancelLine
2090
                    case "CancelLine":
2091
                        Common.ViewerDataModel.Instance.SelectedControl = "CancelLine";
2092
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2093
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.CancelLine;
2094
                        break;
2095
                    #endregion
2096
                    #region PolygonCloud
2097
                    case "PolygonCloud":
2098
                        Common.ViewerDataModel.Instance.SelectedControl = "PolygonCloud";
2099
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2100
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PolygonCloud;
2101
                        break;
2102
                    #endregion
2103
                    #region RectCloud
2104
                    case "RectCloud":
2105
                        Common.ViewerDataModel.Instance.SelectedControl = "RectCloud";
2106
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2107
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.RectCloud;
2108
                        break;
2109
                    #endregion
2110
                    #region Rectangle
2111
                    case "Rectangle":
2112
                        Common.ViewerDataModel.Instance.SelectedControl = "Rectangle";
2113
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2114
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Rectangle;
2115
                        break;
2116
                    #endregion
2117
                    #region Triangle
2118
                    case "Triangle":
2119
                        Common.ViewerDataModel.Instance.SelectedControl = "Triangle";
2120
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2121
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Triangle;
2122
                        break;
2123
                    #endregion
2124
                    #region RectCloud
2125
                    case "Circle":
2126
                        Common.ViewerDataModel.Instance.SelectedControl = "Circle";
2127
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2128
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Circle;
2129
                        break;
2130
                    #endregion
2131
                    #region Symbol
2132
                    case "Symbol":
2133
                        Common.ViewerDataModel.Instance.SelectedControl = "Symbol";
2134
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2135
                        break;
2136
                    #endregion
2137
                    #region SymbolN
2138
                    case "SymbolN":
2139
                        Common.ViewerDataModel.Instance.SelectedControl = "SymbolN";
2140
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Stamp;
2141
                        break;
2142
                    #endregion
2143
                    #region Text
2144
                    case "Text":
2145
                        Common.ViewerDataModel.Instance.SelectedControl = "Text";
2146
                        TaskMessage("Text 도구는 텍스트 영역을 더블 클릭하여 텍스트를 재 편집 할 수 있습니다", TaskMessageType.Normal);
2147
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TextControl;
2148
                        break;
2149
                    #endregion
2150
                    #region TextBorder
2151
                    case "TextBorder":
2152
                        Common.ViewerDataModel.Instance.SelectedControl = "TextBorder";
2153
                        TaskMessage("Text 도구는 텍스트 영역을 더블 클릭하여 텍스트를 재 편집 할 수 있습니다", TaskMessageType.Normal);
2154
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TextBorder;
2155
                        break;
2156
                    #endregion
2157
                    #region TextCloud
2158
                    case "TextCloud":
2159
                        Common.ViewerDataModel.Instance.SelectedControl = "TextCloud";
2160
                        TaskMessage("Text 도구는 텍스트 영역을 더블 클릭하여 텍스트를 재 편집 할 수 있습니다", TaskMessageType.Normal);
2161
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TextCloud;
2162
                        break;
2163
                    #endregion
2164
                    #region Date
2165
                    case "Date":
2166
                        Common.ViewerDataModel.Instance.SelectedControl = "Date";
2167
                        TaskMessage("날짜 컨트롤을 더블 클릭하면 날짜를 변경할 수 있습니다", TaskMessageType.Normal);
2168
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Date;
2169
                        break;
2170
                    #endregion
2171
                    #region ArrowText
2172
                    case "ArrowText":
2173
                        TaskMessage("ArrowText 컨트롤은 그린 후 컨트롤을 선택하였을 시 중간점을 조정할 수 있습니다", TaskMessageType.Normal);
2174
                        if (instanceToggle.Tag.ToString() == "ArrowText_Cloud")
2175
                        {
2176
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowText_Cloud";
2177
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl;
2178
                        }
2179
                        else if (instanceToggle.Tag.ToString() == "ArrowText_Border")
2180
                        {
2181
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTextBorderControl";
2182
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl;
2183
                        }
2184
                        else if (instanceToggle.Tag.ToString() == "ArrowTextFix_Normal")
2185
                        {
2186
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTransTextControl";
2187
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl;
2188
                        }
2189
                        else if (instanceToggle.Tag.ToString() == "ArrowTextFix_Border")
2190
                        {
2191
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTransTextBorderControl";
2192
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl;
2193
                        }
2194
                        else if (instanceToggle.Tag.ToString() == "ArrowTextFix_Cloud")
2195
                        {
2196
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTransTextCloudControl";
2197
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl;
2198
                        }
2199
                        else
2200
                        {
2201
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowText";
2202
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextControl;
2203
                            //HiddenAxisLock.Visibility = Visibility.Visible;
2204
                        }
2205
                        break;
2206
                    #endregion
2207
                    #region Arrow
2208
                    case "Arrow":
2209
                        Common.ViewerDataModel.Instance.SelectedControl = "Arrow";
2210
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2211
                        //HiddenDimSize.Visibility = Visibility.Visible;
2212
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowLine;
2213
                        break;
2214
                    #endregion
2215
                    #region Shape
2216
                    case "Shape":
2217
                        Common.ViewerDataModel.Instance.SelectedControl = "Shape";
2218
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Mark;
2219
                        break;
2220
                    #endregion
2221
                    #region Polygon
2222
                    case "Polygon":
2223
                        Common.ViewerDataModel.Instance.SelectedControl = "Polygon";
2224
                        TaskMessage("자유형 코멘트 도구는 오른쪽 마우스 클릭을 통해 그리기를 마칠 수 있습니다", TaskMessageType.Normal);
2225
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2226
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PolygonControl;
2227
                        break;
2228
                    #endregion
2229
                    #region Arc
2230
                    case "Arc":
2231
                        Common.ViewerDataModel.Instance.SelectedControl = "Arc";
2232
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArcLine;
2233
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2234
                        TaskMessage("Arc 코멘트 도구는 오른쪽 마우스를 사용해 좌우 반전을 사용하실 수 있습니다", TaskMessageType.Normal);
2235
                        break;
2236
                    #endregion
2237
                    #region ArrowArc
2238
                    case "ArrowArc":
2239
                        Common.ViewerDataModel.Instance.SelectedControl = "ArrowArc";
2240
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArcArrow;
2241
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2242
                        TaskMessage("ArcArrow 코멘트 도구는 오른쪽 마우스를 사용해 좌우 반전을 사용하실 수 있습니다", TaskMessageType.Normal);
2243
                        break;
2244
                    #endregion
2245
                    #region ArrowMulti
2246
                    case "ArrowMulti":
2247
                        Common.ViewerDataModel.Instance.SelectedControl = "ArrowMulti";
2248
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowMultiLine;
2249
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2250
                        break;
2251
                    #endregion
2252
                    #region Etc
2253
                    case "Etc":
2254
                        Common.ViewerDataModel.Instance.SelectedControl = "Etc";
2255
                        break;
2256
                    #endregion
2257
                    #region Ink
2258
                    case "Ink":
2259
                        if (instanceToggle.Tag.ToString() == "EraserClear")
2260
                        {
2261
                            TaskMessage("해당 컨트롤은 점 단위로 그려진 펜을 지웁니다", TaskMessageType.Normal);
2262
                            //instanceMain.dzMainMenu.inkDrawingCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
2263
                            instanceMain.dzMainMenu.inkBoard.Tag = "EraseByPoint";
2264
                        }
2265
                        else if (instanceToggle.Tag.ToString() == "Eraser")
2266
                        {
2267
                            TaskMessage("해당 컨트롤은 선 단위로 그려진 펜을 지웁니다", TaskMessageType.Normal);
2268
                            instanceMain.dzMainMenu.inkBoard.Tag = "EraseByStroke";
2269
                            //instanceMain.dzMainMenu.inkDrawingCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
2270
                        }
2271
                        else
2272
                        {
2273
                            instanceMain.dzMainMenu.inkBoard.Tag = "Ink";
2274
                            //instanceMain.dzMainMenu.inkDrawingCanvas.EditingMode = InkCanvasEditingMode.Ink;
2275
                        }
2276

    
2277
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = true;
2278

    
2279
                        Common.ViewerDataModel.Instance.SelectedControl = "Ink";
2280
                        Common.ViewerDataModel.Instance.LineSize = (double)cbLineSize.Value;
2281
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PenControl;
2282
                        break;
2283
                    #endregion
2284
                    #region Select
2285
                    case "Select":
2286
                        if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2287
                        {
2288
                            if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl is MarkupToPDF.Controls.Text.TextControl
2289
                                && !string.IsNullOrEmpty(((MarkupToPDF.Controls.Text.TextControl)this.ParentOfType<MainWindow>().dzMainMenu.currentControl).Text))
2290
                            {
2291
                                DependencyObject focusScope1 = FocusManager.GetFocusScope((MarkupToPDF.Controls.Text.TextControl)this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2292
                                FocusManager.SetFocusedElement(focusScope1, (MarkupToPDF.Controls.Text.TextControl)this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2293

    
2294
                                this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2295
                                Keyboard.ClearFocus();
2296

    
2297
                            }
2298
                            else
2299
                            {
2300
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2301
                                this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2302
                            }
2303
                        }
2304

    
2305
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
2306
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2307
                        instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2308
                        break;
2309
                    #endregion
2310
                    #region Image
2311
                    case "Image":
2312
                        Common.ViewerDataModel.Instance.SelectedControl = "ImgControl";
2313
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
2314
                        ImageConverter(instanceToggle);
2315
                        break;
2316
                    #endregion
2317
                    #region Sign
2318
                    case "Sign":
2319
                        Common.ViewerDataModel.Instance.SelectedControl = "Sign";
2320
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2321
                        //강인구 추가
2322
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Sign;
2323
                        //instanceMain.BaseClient.GetUserSignCompleted += (sen, ea) =>
2324
                        //{
2325
                        //    if (ea.Result == null)
2326
                        //    {
2327

    
2328
                        //        this.ParentOfType<MainPage>().DialogMessage_Alert("You Don't Have Sign Data", "Alert");
2329
                        //    }
2330
                        //    else
2331
                        //    {
2332
                        //        byte[] imageBytes = System.Convert.FromBase64String(ea.Result);
2333
                        //        using (MemoryStream ms = new MemoryStream(imageBytes))
2334
                        //        {
2335
                        //            BitmapImage im = new BitmapImage();
2336
                        //            im.SetSource(ms);
2337
                        //            instanceMain.DeepLayer.SignImage = im;
2338
                        //            ms.Close();
2339
                        //        }
2340
                        //    }
2341
                        //};
2342
                        //instanceMain.BaseClient.GetUserSignAsync(instanceMain._ViewInfo.UserID);
2343
                        break;
2344
                    #endregion
2345
                    #region Check
2346
                    case "Check":
2347
                        Common.ViewerDataModel.Instance.SelectedControl = "Check";
2348
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2349
                        //강인구 추가
2350
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Symbol;
2351
                        break;
2352
                    #endregion
2353
                    #region Batch
2354
                    case "Batch":
2355
                        Common.ViewerDataModel.Instance.SelectedControl = "Batch";
2356
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2357
                        //강인구 추가
2358
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Mark;
2359
                        instanceMain.dzMainMenu.txtBatch.Visibility = Visibility.Visible;
2360
                        instanceMain.dzMainMenu.txtBatch.Text = "Place Mark";
2361
                        break;
2362
                    #endregion
2363

    
2364
                    #region MACRO -MACRO1
2365
                    case "MACRO":
2366
                        Common.ViewerDataModel.Instance.SelectedControl = "MACRO";
2367
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2368

    
2369
                        MacroHelper.MacroAction();
2370

    
2371
                        break;
2372
                    #endregion
2373

    
2374
                    #region Copy
2375
                    case "Copy":
2376
                        CopyCommand.Instance.Execute();
2377
                        //Copy_Start();
2378
                        instanceToggle.IsChecked = false;
2379
                        ViewerDataModel.Instance.SelectedControl = "";
2380
                        ViewerDataModel.Instance.ControlTag = null;
2381
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2382
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2383
                        break;
2384
                    #endregion
2385
                    #region Cut
2386
                    case "Cut":
2387
                        CutCommand.Instance.Execute();
2388
                        instanceToggle.IsChecked = false;
2389
                        ViewerDataModel.Instance.SelectedControl = "";
2390
                        ViewerDataModel.Instance.ControlTag = null;
2391
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2392
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2393
                        break;
2394
                    #endregion
2395
                    #region Paste
2396
                    case "Paste":
2397
                        PasteCommand.Instance.Execute();
2398
                        //Paste_Start();
2399
                        instanceToggle.IsChecked = false;
2400
                        ViewerDataModel.Instance.SelectedControl = "";
2401
                        ViewerDataModel.Instance.ControlTag = null;
2402
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2403
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;                        
2404
                        break;
2405
                    #endregion
2406
                    #region Delete
2407
                    case "Delete":
2408
                        UndoCommand.Instance.Push(EventType.Delete, SelectionSet.Instance.SelectedItems);
2409
                        this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Clear();
2410

    
2411
                        instanceToggle.IsChecked = false;
2412
                        ViewerDataModel.Instance.SelectedControl = "";
2413
                        ViewerDataModel.Instance.ControlTag = null;
2414
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2415
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2416
                        break;
2417
                    #endregion
2418
                    #region Undo
2419
                    case "Undo":
2420
                        UndoCommand.Instance.Execute();
2421
                        instanceToggle.IsChecked = false;
2422
                        ViewerDataModel.Instance.SelectedControl = "";
2423
                        ViewerDataModel.Instance.ControlTag = null;
2424
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2425
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2426
                        break;
2427
                    #endregion
2428
                    #region Redo
2429
                    case "Redo":
2430
                        RedoCommand.Instance.Execute();
2431
                        instanceToggle.IsChecked = false;
2432
                        ViewerDataModel.Instance.SelectedControl = "";
2433
                        ViewerDataModel.Instance.ControlTag = null;
2434
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2435
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2436
                        break;
2437
                    #endregion
2438
                    #region DragZoom
2439
                    case "DragZoom":
2440
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.DragZoom;
2441
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2442
                        instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2443
                        break;
2444
                    #endregion
2445
                    #region Grouping
2446
                    case "Group":
2447
                        //var GrouptoggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2448
                        //foreach (var togle in GrouptoggleList)
2449
                        //{
2450
                        //    togle.IsChecked = false;
2451
                        //}
2452

    
2453
                        //if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2454
                        //{
2455
                        //    ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2456
                        //    this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2457
                        //}
2458
                        //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2459
                        //instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2460
                        //instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2461
                        //if (ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
2462
                        //{
2463
                        //    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Please Select Controls", "Alert");
2464
                        //}
2465
                        //else//if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2466
                        //{
2467
                        //    // string MarkupData = "";
2468
                        //    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2469
                        //    {
2470
                        //        if (item.GetType().Name == "AdornerFinal" && (item as AdornerFinal).MemberSet.Count >= 2) // 얘가 2개 이상이여야 그룹가능 버튼도 막을거긴하지만 일단..
2471
                        //        {
2472
                        //            //MARKUP_DATA_GROUP INSERT
2473
                        //            MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2474
                        //            {
2475
                        //                SYMBOL_ID = null,//InnerItem.Symbol_ID
2476
                        //                STATE = 0,
2477
                        //            };
2478
                        //            long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
2479
                        //            //Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
2480
                        //            if (group_id > 0)
2481
                        //            {
2482
                        //                foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
2483
                        //                {
2484
                        //                    if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2485
                        //                    {
2486
                        //                        //MARKUP_DATA UPDATE
2487
                        //                        //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupData((InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID, group_id, App.ViewInfo.ProjectNO);
2488
                        //                        ////Logger.sendReqLog("UpdateMarkupData: ", "", 1);
2489
                        //                        ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().Group_ID = group_id;
2490
                        //                        ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().IsUpdate = true;
2491
                        //                    }
2492
                        //                }
2493
                        //            }
2494
                        //        }
2495
                        //    }
2496
                        //}
2497
                        break;
2498
                    case "UnGroup":
2499
                        //var UnGrouptoggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2500
                        //foreach (var togle in UnGrouptoggleList)
2501
                        //{
2502
                        //    togle.IsChecked = false;
2503
                        //}
2504
                        //if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2505
                        //{
2506
                        //    ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2507
                        //    this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2508
                        //}
2509
                        //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2510
                        //instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2511
                        //instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2512

    
2513
                        //if (ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
2514
                        //{
2515
                        //    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Please Select Controls", "Alert");
2516
                        //}
2517
                        //else//if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2518
                        //{
2519
                        //    // string MarkupData = "";
2520
                        //    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2521
                        //    {
2522
                        //        if (item.GetType().Name == "AdornerFinal" && (item as AdornerFinal).MemberSet.Count >= 1) // 1개 이상 
2523
                        //        {
2524
                        //            //MARKUP_DATA UPDATE
2525
                        //            foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
2526
                        //            {
2527
                        //                if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2528
                        //                {
2529
                        //                    long group_id = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault().Group_ID;
2530
                        //                    //MARKUP_DATA UPDATE
2531
                        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupData((InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID, 0, App.ViewInfo.ProjectNO);
2532
                        //                    ////Logger.sendReqLog("UpdateMarkupData: ", "", 1);
2533
                        //                    ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().Group_ID = 0;
2534
                        //                    ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().IsUpdate = true;
2535

    
2536

    
2537
                        //                    //MARKUP_DATA_GROUP UPDATE
2538
                        //                    //bool value = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupDataGroup(group_id, App.ViewInfo.ProjectNO);
2539
                        //                    ////Logger.sendReqLog("AddMarkupDataGroup: ", value.ToString(), 1);
2540
                        //                }
2541
                        //            }
2542
                        //        }
2543
                        //    }
2544
                        //}
2545
                        break;
2546
                    #endregion
2547
                    #region Capture
2548
                    case "Capture":
2549
                        SyncInit();
2550
                        //   instanceToggle.IsChecked = false;
2551
                        var CaptureList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2552
                        foreach (var togle in CaptureList)
2553
                        {
2554
                            togle.IsChecked = false;
2555
                        }
2556

    
2557
                        if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2558
                        {
2559
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2560
                            this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2561
                        }
2562

    
2563
                        ViewerDataModel.Instance.SelectedControl = "ImgControl";
2564
                   //     ViewerDataModel.Instance.ControlTag = null;
2565
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
2566

    
2567
                        /*
2568
                        //캡쳐 하기 전에 코멘트 저장
2569
                        if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
2570
                        {
2571
                            var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
2572
                            menu.ReleaseAdorner();
2573
                            if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
2574
                            {
2575
                                (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
2576
                            }
2577
                            else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
2578
                            {
2579

    
2580
                            }
2581
                            else
2582
                            {
2583
                                (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
2584
                            }
2585
                        }*/
2586

    
2587
                        //Common.ViewerDataModel.Instance.CheckList_ID = ((e.Source as Telerik.Windows.Controls.RadButton).DataContext as Customer).ID;
2588
                        //Common.ViewerDataModel.Instance.CheckList_ID = ((e.Source as Image).DataContext as Customer).ID;
2589
                        //Common.ViewerDataModel.Instance.PageNumber = ((e.Source as Image).DataContext as Customer).PAGENUMBER;
2590
                        Application.Current.MainWindow.Focus();
2591
                        Common.ViewerDataModel.Instance.Capture_Opacity = 0.49;
2592
                        (Application.Current.MainWindow as MainWindow).dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture;
2593
                        break;
2594
                    #endregion
2595
                    #region Cad
2596
                    case "Inside":
2597
                        //instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2598
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2599
                        Common.ViewerDataModel.Instance.SelectedControl = "InsideWhite";
2600
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.InsideWhite;
2601
                        break;
2602
                    case "Overlap":
2603
                        //instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2604
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2605
                        Common.ViewerDataModel.Instance.SelectedControl = "OverlapWhite";
2606
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.OverlapWhite;
2607
                        break;
2608
                    case "Clip":
2609
                        //instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2610
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2611
                        Common.ViewerDataModel.Instance.SelectedControl = "ClipWhite";
2612
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ClipWhite;
2613
                        break;
2614
                    case "CadExport":
2615
                        //if (isClosed)
2616
                        //{
2617
                        //    //토글 및 마우스 상태 초기화
2618
                        //    var toggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2619
                        //    foreach (var togle in toggleList)
2620
                        //    {
2621
                        //        togle.IsChecked = false;
2622
                        //    }
2623
                        //    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2624

    
2625
                        //    isClosed = false;
2626
                        //    //Control 파일 먼저 생성
2627
                        //    CollapsedButton_Click();
2628
                        //    CadViewer check = new CadViewer();
2629
                        //    check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2630
                        //    check.Title = "Export Viewer";
2631
                        //    //check.Topmost = true;
2632
                        //    check.Show();
2633
                        //    check.Closed += Check_Closed;
2634
                        //    instanceToggle.IsChecked = false;
2635
                        //}
2636
                        //break;
2637
                    case "CadViewer":
2638
                        //if (isClosed)
2639
                        //{
2640
                        //    //토글 및 마우스 상태 초기화
2641
                        //    var toggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2642
                        //    foreach (var togle in toggleList)
2643
                        //    {
2644
                        //        togle.IsChecked = false;
2645
                        //    }
2646
                        //    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2647

    
2648
                        //    isClosed = false;
2649
                        //    CadResultViewer check = new CadResultViewer();
2650
                        //    check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2651
                        //    check.Title = "Viewer";
2652
                        //    check.Show();
2653

    
2654
                        //    check.Closed += Check_Closed;
2655

    
2656
                        //}
2657
                        break;
2658
                    #endregion
2659
                    default:
2660
                        break;
2661
                }
2662
                #endregion
2663
            }
2664
            else
2665
            {
2666
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
2667
                {
2668
                    MacroHelper.Clear();
2669
                }
2670

    
2671
                if (!instanceMain.dzMainMenu.IsFreeSelectionMode)
2672
                {
2673
                    instanceMain.dzMainMenu.IsSwingMode = false;
2674
                    Common.ViewerDataModel.Instance.SelectedControl = "";
2675
                    Common.ViewerDataModel.Instance.ControlTag = null;
2676
                    this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2677
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2678
                }
2679
            }
2680

    
2681
        }
2682

    
2683
        private void SyncInit()
2684
        {
2685
            try
2686
            {
2687
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden)
2688
                {
2689
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true;
2690
                    ViewerDataModel.Instance.PageBalanceMode = false;
2691
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
2692
                    ViewerDataModel.Instance.SyncPageNumber = 0;
2693
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
2694
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed;
2695
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false;
2696
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false;
2697
                }
2698
            }
2699
            catch (Exception ex)
2700
            {
2701
                //Logger.sendResLog("SyncInit", ex.Message, 0);
2702
            }
2703

    
2704
        }
2705

    
2706
        UndoData multi_UndoData = new UndoData();
2707
        CommentUserInfo currentControl { get; set; }
2708
        private void Check_Closed(object sender, EventArgs e)
2709
        {
2710
            isClosed = true;
2711
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
2712
            //토글 및 마우스 상태 초기화
2713
            var toggleList = this.Parent.ChildrenOfType<RadToggleButton>();
2714
            foreach (var togle in toggleList)
2715
            {
2716
                togle.IsChecked = false;
2717
            }
2718
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2719
            ViewerDataModel.Instance.Capture_Opacity = 0;
2720

    
2721
        }
2722

    
2723
        /* public class test 
2724
         {
2725
             public double width { get; set; }
2726
             public double height { get; set; }
2727
         }
2728
         */
2729
        private async void CollapsedButton_Click()
2730
        {
2731
            this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null); // 저장하지 못한 데이터가 있다면 저장
2732

    
2733
            string[] data = new string[0];
2734

    
2735
            int cnt = 0;
2736
            var menu = this.ParentOfType<MainWindow>().dzMainMenu;
2737

    
2738
            List<MarkupInfoItem> gridSelectionItem = menu.gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
2739

    
2740
            foreach (var item in gridSelectionItem)
2741
            {
2742
                if ((item.UserID == App.ViewInfo.UserID) && (ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage != null))
2743
                {
2744
                    var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber &&
2745
                    d.MarkupInfoID == item.MarkupInfoID).ToList();
2746
                    data = new string[instance.Count];
2747
                    foreach (var markup in instance)
2748
                    {
2749
                        data[cnt++] = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(markup.Data,ViewerDataModel.Instance.NewMarkupCancelToken());
2750
                    }
2751
                }
2752
            }
2753

    
2754
            if (data != null && KCOM.Properties.Settings.Default.cad == 1)
2755
            {
2756
                string FilePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Cad");
2757
                string FileName = FilePath + "\\commentstring.json"; // Default file name
2758
                if (!File.Exists(FilePath))
2759
                {
2760
                    Directory.CreateDirectory(FilePath);
2761
                }
2762

    
2763
                if (!string.IsNullOrEmpty(FileName))
2764
                {
2765
                    //  File.WriteAllText(SaveDig.FileName, data);
2766
                    File.WriteAllLines(FileName, data);
2767
                }
2768
            }
2769
        }
2770

    
2771
        private double minHeight;
2772
        private double minWidth;
2773

    
2774
        private double maxHeight;
2775
        private double maxWidth;
2776

    
2777
        public bool CanVResize { get; private set; }
2778
        public bool CanHResize { get; private set; }
2779

    
2780
        public void DesignerComponent(FrameworkElement content)
2781
        {
2782
            this.InitializeComponent();
2783

    
2784
            if (!double.IsNaN(content.Width))
2785
            {
2786
                CanHResize = false;
2787
                this.Width = content.Width;
2788
            }
2789
            else
2790
            {
2791
                CanHResize = true;
2792
                this.Width = 23.0;
2793
            }
2794
            if (!double.IsNaN(content.Height))
2795
            {
2796
                CanVResize = false;
2797
                this.Height = content.Height; ;
2798
            }
2799
            else
2800
            {
2801
                CanVResize = true;
2802
                this.Height = 23.0;
2803
            }
2804

    
2805
            minWidth = content.MinWidth < 10.0 ? 10.0 : content.MinWidth;
2806
            minHeight = content.MinHeight < 10.0 ? 10.0 : content.MinHeight;
2807
            maxWidth = content.MaxWidth;
2808
            maxHeight = content.MaxHeight;
2809

    
2810
            double top = (double)content.GetValue(Canvas.TopProperty);
2811
            if (double.IsNaN(top))
2812
                top = 0.0;
2813
            double left = (double)content.GetValue(Canvas.LeftProperty);
2814
            if (double.IsNaN(left))
2815
                left = 0.0;
2816
            SetValue(Canvas.TopProperty, top);
2817
            SetValue(Canvas.LeftProperty, left);
2818

    
2819
            //Set the actual content. Note that "Content" property is a new property. See below
2820
            this.Content = content;
2821
        }
2822
        private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
2823
        {
2824
            string name = ((Thumb)sender).Name;
2825
            if (name.Contains("Top"))
2826
            {
2827
                double newHeight = this.Height - e.VerticalChange;
2828
                if (newHeight >= minHeight && newHeight <= maxHeight)
2829
                {
2830
                    this.Height = newHeight;
2831
                    SetValue(Canvas.TopProperty,
2832
                (double)GetValue(Canvas.TopProperty) + e.VerticalChange);
2833
                }
2834
            }
2835
            if (name.Contains("Right"))
2836
            {
2837
                double newWidth = this.Width + e.HorizontalChange;
2838
                if (newWidth >= minWidth && newWidth <= maxWidth)
2839
                    this.Width = newWidth;
2840
            }
2841
            if (name.Contains("Bottom"))
2842
            {
2843
                double newHeight = this.Height + e.VerticalChange;
2844
                if (newHeight >= minHeight && newHeight <= maxHeight)
2845
                    this.Height = newHeight;
2846
            }
2847
            if (name.Contains("Left"))
2848
            {
2849
                double newWidth = this.Width - e.HorizontalChange;
2850
                if (newWidth >= minWidth && newWidth <= maxWidth)
2851
                {
2852
                    this.Width = newWidth;
2853
                    SetValue(Canvas.LeftProperty,
2854
                (double)GetValue(Canvas.LeftProperty) + e.HorizontalChange);
2855
                }
2856
            }
2857
        }
2858

    
2859
        private void drawControlBorder(object sender)
2860
        {
2861
            System.Windows.Controls.Control control = (System.Windows.Controls.Control)sender;
2862
        }
2863

    
2864
        private void ResizeThumb_DragDelta(object sender, MouseButtonEventArgs e)
2865
        {
2866
            System.Windows.Controls.Control designerItem = (System.Windows.Controls.Control)sender;
2867
            if (designerItem != null)
2868
            {
2869
                double deltaVertical, deltaHorizontal;
2870

    
2871
                switch (VerticalAlignment)
2872
                {
2873
                    case VerticalAlignment.Bottom:
2874
                        deltaVertical = designerItem.ActualHeight - designerItem.MinHeight;
2875
                        designerItem.Height -= deltaVertical;
2876
                        break;
2877
                    case VerticalAlignment.Top:
2878
                        deltaVertical = designerItem.ActualHeight - designerItem.MinHeight;
2879
                        Canvas.SetTop(designerItem, Canvas.GetTop(designerItem) + deltaVertical);
2880
                        designerItem.Height -= deltaVertical;
2881
                        break;
2882
                    default:
2883
                        break;
2884
                }
2885

    
2886
                switch (HorizontalAlignment)
2887
                {
2888
                    case HorizontalAlignment.Left:
2889
                        deltaHorizontal = designerItem.ActualWidth - designerItem.MinWidth;
2890
                        Canvas.SetLeft(designerItem, Canvas.GetLeft(designerItem) + deltaHorizontal);
2891
                        designerItem.Width -= deltaHorizontal;
2892
                        break;
2893
                    case HorizontalAlignment.Right:
2894
                        deltaHorizontal = designerItem.ActualWidth - designerItem.MinWidth;
2895
                        designerItem.Width -= deltaHorizontal;
2896
                        break;
2897
                    default:
2898
                        break;
2899
                }
2900
            }
2901
            e.Handled = true;
2902
        }
2903

    
2904
        SaveFileDialog SaveDig = new SaveFileDialog(); //파일 세이브 다이얼로그
2905

    
2906
        void ExportMethod()
2907
        {
2908
            //FileDialogFilter filterImage = new FileDialogFilter("Image Files", "*.jpg", "*.png");
2909
            SaveDig.Filter = "PDF file format|*.pdf";
2910
            SaveDig.Title = "Save an DWG File";
2911
            SaveDig.ShowDialog();
2912
        }
2913

    
2914
        private void cbAutoSave_Checked(object sender, RoutedEventArgs e)
2915
        {            
2916
            if (cbAutoSave.IsChecked == true)
2917
            {
2918
                SaveTime(true, (int)cbSaveInterval.Value);
2919
            }
2920
            else
2921
            {
2922
                SaveTime(false, (int)cbSaveInterval.Value);
2923
            }
2924
        }
2925
        private void cbSaveInterval_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
2926
        {
2927
            if(string.IsNullOrEmpty(cbSaveInterval.Value.ToString()))
2928
            {
2929
                cbSaveInterval.Value = cbSaveInterval.Minimum;
2930
            }
2931
            if (cbAutoSave.IsChecked == true)
2932
            {
2933
                SaveTime(true, (int)cbSaveInterval.Value);
2934
            }
2935

    
2936
            KCOM.Properties.Settings.Default.SaveInterval = (double)cbSaveInterval.Value;
2937
            Properties.Settings.Default.Save();
2938
        }
2939
        //강인구 자동 저장 추가
2940
        private void AutoSave(object sender, RoutedEventArgs e)
2941
        {
2942
            RadToggleButton instanceToggle = sender as RadToggleButton;
2943

    
2944
            if(instanceToggle.IsChecked == true)
2945
            {
2946
                SaveTime(true);
2947
            }
2948
            else
2949
            {
2950
                SaveTime(false);
2951
            }
2952
        }
2953

    
2954
        public void Copy_Start()
2955
        {
2956
            if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2957
            {
2958
                string MarkupData = "";
2959

    
2960
                foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2961
                {
2962
                    string id = string.Empty;
2963
                    if (item.GetType().Name == "AdornerFinal")
2964
                    {
2965
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
2966

    
2967
                        {
2968
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2969
                            {
2970
                                MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn res = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
2971
                                id = (InnerItem.Symbol_ID != null) ? "|SymbolID|" + InnerItem.Symbol_ID : "";
2972
                                MarkupData += "|OR|" + res.ConvertData + id;
2973
                            }
2974
                        }
2975

    
2976
                        this.Dispatcher.Invoke(() =>
2977
                        {
2978
                            Clipboard.SetData(DataFormats.StringFormat, MarkupData);
2979
                        }, DispatcherPriority.Background);
2980
                    }
2981
                }
2982
            }
2983
        }
2984
    }
2985
}