프로젝트

일반

사용자정보

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

markus / KCOM / Events / Implementation / TopMenuEvent.cs @ 8118ba81

이력 | 보기 | 이력해설 | 다운로드 (154 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 UndoData = new UndoDataGroup()
117
                {
118
                    IsUndo = false,
119
                    Event = EventType.Operation,
120
                    EventTime = DateTime.Now,
121
                    paint = ViewerDataModel.Instance.paintSet,
122
                    MarkupDataColl = new List<UndoData>()
123
                };
124
                UndoData multi_UndoData = new UndoData();
125

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

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

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

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

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

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

    
171
                ViewerDataModel.Instance.IsMarkupUpdate = true;
172
            }
173

    
174
        }
175

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

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

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

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

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

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

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

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

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

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

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

    
329
                _SaveEvent(sender, e);
330

    
331
                mianMenu.busyIndicator.IsBusy = false;
332
               
333
            //});
334

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

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

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

    
359
                mainMenu.UpdateMyMarkupList();
360

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

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

    
382
                            result = true;
383
                        }
384
                    }
385
                }
386

    
387
                mainMenu.SetCommentPages(null);
388

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

    
412
            return result;
413
        }
414

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

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

    
424
                // update mylist and gridview
425
                mainMenu.UpdateMyMarkupList();
426

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

    
444
                mainMenu.SetCommentPages(null);
445

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

    
470
            return result;
471
        }
472

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

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

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

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

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

    
526
            return result;
527
        }
528

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

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

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

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

    
561
            List<IKCOM.MarkupInfoItem> markupinfo = new List<IKCOM.MarkupInfoItem>();
562

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

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

    
574
            /// Tile Source URL을 구한다
575

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

    
587
            var docitem = this.ParentOfType<MainWindow>().dzMainMenu._DocItem;
588

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

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

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

    
619
        private List<AdornerMember> GetAdornerItem()
620
        {
621
            List<AdornerMember> AdonerList = new List<AdornerMember>();
622

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

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

    
663
                foreach (AdornerMember InnerItem in AdonerList)
664
                {
665
                    InnerItem.DrawingData.Opacity = ViewerDataModel.Instance.ControlOpacity;
666
                  
667
                    multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
668
                    UndoData.MarkupDataColl.Add(multi_UndoData);
669
                    multi_UndoData = new UndoData();
670
                }
671

    
672
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
673
                {
674
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
675
                });
676
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
677
            }
678
        }
679

    
680
        //강인구 추가(Undo End)
681
        private void cbLineSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
682
        {
683
            if (string.IsNullOrEmpty(cbLineSize.Value.ToString()))
684
            {
685
                cbLineSize.Value = cbLineSize.Minimum;
686
            }
687
            List<AdornerMember> AdonerList = GetAdornerItem();
688
            if (AdonerList.Count > 0)
689
            {
690
                UndoDataGroup UndoData = new UndoDataGroup()
691
                {
692
                    IsUndo = false,
693
                    Event = EventType.Operation,
694
                    EventTime = DateTime.Now,
695
                    LineSize = ViewerDataModel.Instance.LineSize,
696
                    MarkupDataColl = new List<UndoData>()
697
                };
698
                UndoData multi_UndoData = new UndoData();
699

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

    
788
                    multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
789
                    UndoData.MarkupDataColl.Add(multi_UndoData);
790
                    multi_UndoData = new UndoData();
791
                }
792

    
793
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
794
                {
795
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
796
                });
797
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
798

    
799
                
800
            }
801
            KCOM.Properties.Settings.Default.LineSize = (double)cbLineSize.Value;
802
            Properties.Settings.Default.Save();
803
        }
804

    
805

    
806
        private void cbIntervalSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
807
        {
808
            if (string.IsNullOrEmpty(cbIntervalSize.Value.ToString()))
809
            {
810
                cbIntervalSize.Value = cbIntervalSize.Minimum;
811
            }
812
            List<AdornerMember> AdonerList = GetAdornerItem();
813
            if (AdonerList.Count > 0)
814
            {
815

    
816
                UndoDataGroup UndoData = new UndoDataGroup()
817
                {
818
                    IsUndo = false,
819
                    Event = EventType.Operation,
820
                    EventTime = DateTime.Now,
821
                    Interval = ViewerDataModel.Instance.Interval,
822
                    MarkupDataColl = new List<UndoData>()
823
                };
824
                UndoData multi_UndoData = new UndoData();
825

    
826
                foreach (AdornerMember InnerItem in AdonerList)
827
                {
828
                    switch (InnerItem.DrawingData.GetType().Name)
829
                    {
830
                        case ("LineControl"):
831
                            {
832
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).Interval = ViewerDataModel.Instance.Interval;
833

    
834
                                multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
835
                                UndoData.MarkupDataColl.Add(multi_UndoData);
836
                                multi_UndoData = new UndoData();
837
                            }
838
                            break;
839
                    }
840
                }
841

    
842
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
843
                {
844
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
845
                });
846
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
847
            }
848
            KCOM.Properties.Settings.Default.Interval = (double)cbIntervalSize.Value;
849
            Properties.Settings.Default.Save();
850
        }
851
        
852
        /// <summary>
853
        /// ArcLength가 수정되었을때
854
        /// </summary>
855
        /// <param name="sender"></param>
856
        /// <param name="e"></param>
857
        private void cbArcLength_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
858
        {
859
            if (string.IsNullOrEmpty(cbArcLength.Value.ToString()))
860
            {
861
                cbArcLength.Value = cbArcLength.Minimum;
862
            }
863

    
864
            List<AdornerMember> AdonerList = GetAdornerItem();
865
            if (AdonerList.Count > 0)
866
            {
867
                var comments = (from drawing in AdonerList
868
                                select drawing.DrawingData as CommentUserInfo)
869
                                .Where(x => x is RectCloudControl || x is CloudControl ||
870
                                x is MarkupToPDF.Controls.Text.TextControl || x is MarkupToPDF.Controls.Text.ArrowTextControl)
871
                                .ToList();
872
                UndoCommand.Instance.Push(EventType.Operation, comments);
873

    
874
                foreach (AdornerMember InnerItem in AdonerList)
875
                {
876
                    switch (InnerItem.DrawingData.GetType().Name)
877
                    {
878
                        case ("RectCloudControl"):
879
                            {
880
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl;
881
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
882
                            }
883
                        break;
884
                        case ("CloudControl"):
885
                        {
886
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl;
887
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
888
                        }
889
                        break;
890
                        case ("TextControl"):
891
                        {
892
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl;
893
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
894
                        }
895
                        break;
896
                        case ("ArrowTextControl"):
897
                        {
898
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl;
899
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
900
                        }
901
                        break;
902
                    }
903
                }
904
            }
905

    
906
            KCOM.Properties.Settings.Default.ArcLength = (double)cbArcLength.Value;
907
            Properties.Settings.Default.Save();
908
        }
909

    
910
        //강인구 추가(Undo End)
911
        private void cbDashStyle_SelectionChanged(object sender, SelectionChangedEventArgs e)
912
        {
913
            //강인구 추가
914
            if (this.ParentOfType<MainWindow>() != null)
915
            {
916
                ViewerDataModel.Instance.DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
917
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
918
                {
919
                    //UndoDataGroup UndoData = new UndoDataGroup()
920
                    //{
921
                    //    IsUndo = false,
922
                    //    Event = EventType.Operation,
923
                    //    EventTime = DateTime.Now,
924
                    //    DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData,
925
                    //    MarkupDataColl = new List<UndoData>()
926
                    //};
927
                    //UndoData multi_UndoData = new UndoData();
928

    
929
                    if (ViewerDataModel.Instance.UndoDataList == null)
930
                    {
931
                        return;
932
                    }
933

    
934
                    List<AdornerMember> AdonerList = GetAdornerItem();
935

    
936
                    var comments = (from drawing in AdonerList
937
                                    select drawing.DrawingData as CommentUserInfo)
938
                        .Where(x => x is LineControl || x is ArcControl || x is ArrowArcControl || x is ArrowControl_Multi
939
                        || x is CloudControl || x is PolygonControl || x is PolygonControl || x is RectangleControl ||
940
                        x is RectCloudControl || x is TriControl || x is CircleControl || x is InsideWhiteControl ||
941
                        x is OverlapWhiteControl || x is ClipWhiteControl || x is CoordinateControl ||
942
                        x is MarkupToPDF.Controls.Text.TextControl || x is MarkupToPDF.Controls.Text.ArrowTextControl)
943
                        .ToList();
944

    
945
                    UndoCommand.Instance.Push(EventType.Operation, comments);
946

    
947

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

    
1028
                                //multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
1029
                                //UndoData.MarkupDataColl.Add(multi_UndoData);
1030
                                //multi_UndoData = new UndoData();
1031
                            }
1032

    
1033
                            //ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
1034
                            //{
1035
                            //    ViewerDataModel.Instance.UndoDataList.Remove(i);
1036
                            //});
1037
                            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
1038

    
1039
                        }
1040
                    }
1041
                }
1042
            }
1043
        }
1044

    
1045
        //강인구 추가
1046
        private void comboFontSize_SelectionChanged(object sender, SelectionChangedEventArgs e)
1047
        {
1048
            //if (this.ParentOfType<MainWindow>() != null)
1049
            //{
1050
            //    if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1051
            //    {
1052
            //        foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1053
            //        {
1054
            //            if (item.GetType().Name == "AdornerFinal")
1055
            //            {
1056
            //                foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
1057
            //                {
1058
            //                    switch (InnerItem.DrawingData.GetType().Name)
1059
            //                    {
1060
            //                        case ("TextControl"):
1061
            //                            {
1062
            //                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextSize = int.Parse(comboFontSize.Text);
1063
            //                            }
1064
            //                            break;
1065
            //                        case ("ArrowTextControl"):
1066
            //                            {
1067
            //                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextSize = int.Parse(comboFontSize.Text);
1068
            //                            }
1069
            //                            break;
1070
            //                    }
1071
            //                }
1072
            //            }
1073
            //        }
1074
            //    }
1075
            //}
1076
        }
1077

    
1078
        //강인구 추가
1079
        private void btnBold_Checked(object sender, RoutedEventArgs e)
1080
        {
1081
            if (this.ParentOfType<MainWindow>() != null)
1082
            {
1083
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1084
                {
1085
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1086
                    {
1087
                        if (item.GetType().Name == "AdornerFinal")
1088
                        {
1089
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1090
                            {
1091
                                switch (InnerItem.DrawingData.GetType().Name)
1092
                                {
1093
                                    case ("TextControl"):
1094
                                        {
1095
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight == FontWeights.Bold)
1096
                                            {
1097
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight = FontWeights.Normal;
1098
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1099
                                            }
1100
                                            else
1101
                                            {
1102
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight = FontWeights.Bold;
1103
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1104
                                            }
1105

    
1106
                                        }
1107
                                        break;
1108
                                    case ("ArrowTextControl"):
1109
                                        {
1110
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight == FontWeights.Bold)
1111
                                            {
1112
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight = FontWeights.Normal;
1113
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1114
                                            }
1115
                                            else
1116
                                            {
1117
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight = FontWeights.Bold;
1118
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1119
                                            }
1120
                                        }
1121
                                        break;
1122
                                }
1123
                            }
1124
                        }
1125
                    }
1126
                }
1127
            }
1128
        }
1129

    
1130
        //강인구 추가
1131
        private void btnItalic_Checked(object sender, RoutedEventArgs e)
1132
        {
1133
            if (this.ParentOfType<MainWindow>() != null)
1134
            {
1135
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1136
                {
1137
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1138
                    {
1139
                        if (item.GetType().Name == "AdornerFinal")
1140
                        {
1141
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1142
                            {
1143
                                switch (InnerItem.DrawingData.GetType().Name)
1144
                                {
1145
                                    case ("TextControl"):
1146
                                        {
1147
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle == FontStyles.Italic)
1148
                                            {
1149
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle = System.Windows.FontStyles.Normal;
1150
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1151
                                            }
1152
                                            else
1153
                                            {
1154
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle = FontStyles.Italic;
1155
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1156
                                            }
1157

    
1158
                                        }
1159
                                        break;
1160
                                    case ("ArrowTextControl"):
1161
                                        {
1162
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle == FontStyles.Italic)
1163
                                            {
1164
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle = FontStyles.Normal;
1165
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1166
                                            }
1167
                                            else
1168
                                            {
1169
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle = FontStyles.Italic;
1170
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1171
                                            }
1172
                                        }
1173
                                        break;
1174
                                }
1175
                            }
1176
                        }
1177
                    }
1178
                }
1179
            }
1180
        }
1181

    
1182
        //강인구 추가
1183
        private void btnUnderLine_Checked(object sender, RoutedEventArgs e)
1184
        {
1185
            if (this.ParentOfType<MainWindow>() != null)
1186
            {
1187
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1188
                {
1189
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1190
                    {
1191
                        if (item.GetType().Name == "AdornerFinal")
1192
                        {
1193
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1194
                            {
1195
                                switch (InnerItem.DrawingData.GetType().Name)
1196
                                {
1197
                                    case ("TextControl"):
1198
                                        {
1199
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine == TextDecorations.Underline)
1200
                                            {
1201
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine = null;
1202
                                            }
1203
                                            else
1204
                                            {
1205
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine = TextDecorations.Underline;
1206
                                            }
1207
                                        }
1208
                                        break;
1209
                                    case ("ArrowTextControl"):
1210
                                        {
1211
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine == TextDecorations.Underline)
1212
                                            {
1213
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine = null;
1214
                                            }
1215
                                            else
1216
                                            {
1217
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine = TextDecorations.Underline;
1218
                                            }
1219
                                        }
1220
                                        break;
1221
                                }
1222

    
1223
                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1224
                            }
1225
                        }
1226
                    }
1227
                }
1228
            }
1229
        }
1230

    
1231

    
1232
        private void cbLineSize_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1233
        {
1234
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1235
            {
1236
                e.Handled = true;
1237
            }
1238

    
1239
        }
1240

    
1241
        private void cbLineSize_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1242
        {
1243
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1244
            if (regex.IsMatch(e.Text))
1245
            {
1246
                e.Handled = true;
1247
            }
1248

    
1249
        }
1250

    
1251
        private void cbArcLength_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1252
        {
1253
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1254
            {
1255
                e.Handled = true;
1256
            }
1257
        }
1258

    
1259
        private void cbArcLength_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1260
        {
1261
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1262
            if (regex.IsMatch(e.Text))
1263
            {
1264
                e.Handled = true;
1265
            }
1266
        }
1267

    
1268
        private void comboFontSize_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1269
        {
1270
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1271
            {
1272
                e.Handled = true;
1273
            }
1274
        }
1275

    
1276
        private void cbIntervalSize_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1277
        {
1278
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1279
            {
1280
                e.Handled = true;
1281
            }
1282
        }
1283

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

    
1293
        private void comboFontSize_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1294
        {
1295
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1296
            if (regex.IsMatch(e.Text))
1297
            {
1298
                e.Handled = true;
1299
            }
1300
        }
1301

    
1302
        private void comboFontSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
1303
        {
1304
            if (string.IsNullOrEmpty(comboFontSize.Value.ToString()))
1305
            {
1306
                comboFontSize.Value = comboFontSize.Minimum;
1307
            }
1308
            if (this.ParentOfType<MainWindow>() != null)
1309
            {
1310
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1311
                {
1312
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1313
                    {
1314
                        if (item.GetType().Name == "AdornerFinal")
1315
                        {
1316
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1317
                            {
1318
                                switch (InnerItem.DrawingData.GetType().Name)
1319
                                {
1320
                                    case ("TextControl"):
1321
                                        {
1322
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextSize = int.Parse(comboFontSize.Value.ToString());
1323
                                        }
1324
                                        break;
1325
                                    case ("ArrowTextControl"):
1326
                                        {
1327
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextSize = int.Parse(comboFontSize.Value.ToString());
1328
                                        }
1329
                                        break;
1330
                                }
1331
                            }
1332

    
1333
                            ChangeComment(item as Controls.AdornerFinal);
1334
                        }
1335
                    }
1336
                }
1337
            }
1338

    
1339
            KCOM.Properties.Settings.Default.TextSize = (double)comboFontSize.Value;
1340
            Properties.Settings.Default.Save();
1341
        }
1342

    
1343
        //강인구 추가
1344
        private void comboFontFamily_SelectionChanged(object sender, SelectionChangedEventArgs e)
1345
        {
1346
            
1347
            if (comboFontFamily.SelectedItem != null && !IsSuspendChange)
1348
            {
1349
                var main = this.ParentOfType<MainWindow>()?.dzMainMenu;
1350
                var font = comboFontFamily.SelectedItem as Markus.Fonts.MarkusFont;
1351
                var lstTextCtrl = SelectTextControl();
1352

    
1353
                foreach (var item in lstTextCtrl)
1354
                {
1355
                    if (item is MarkupToPDF.Controls.Text.ArrowTextControl ctrl1)
1356
                    {
1357
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1358
                        ctrl1.SetFontFamily(font.FontFamily);
1359
                    }
1360
                    else if (item is MarkupToPDF.Controls.Text.TextControl ctrl2)
1361
                    {
1362
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1363
                        ctrl2.SetFontFamily(font.FontFamily);
1364
                    }
1365
                }
1366

    
1367
                KCOM.Properties.Settings.Default.FontFamily = font.FontFamily.FontName();
1368
                Properties.Settings.Default.Save();
1369
            }
1370
        }
1371

    
1372
        private List<UIElement> SelectTextControl()
1373
        {
1374
            List<UIElement> lstTextCtrl = new List<UIElement>();
1375

    
1376
            var main = this.ParentOfType<MainWindow>()?.dzMainMenu;
1377
            var font = comboFontFamily.SelectedItem as Markus.Fonts.MarkusFont;
1378

    
1379

    
1380
            if (main.SelectLayer.FindChildByType<AdornerFinal>() != null)
1381
            {
1382
                lstTextCtrl.AddRange(main.SelectLayer.FindChildByType<AdornerFinal>().Members.Where(x => x.DrawingData is MarkupToPDF.Controls.Common.ITextControl).Select(x => x.DrawingData));
1383
            }
1384

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

    
1387
            return lstTextCtrl;
1388
        }
1389

    
1390

    
1391
        /// <summary>
1392
        /// 텍스트 컨트롤 하일라이트 처리
1393
        /// </summary>
1394
        /// <param name="sender"></param>
1395
        /// <param name="e"></param>
1396
        private void HighlightEvent(object sender, RoutedEventArgs e)
1397
        {
1398

    
1399
            ViewerDataModel.Instance.checkHighShape = (sender as CheckBox).IsChecked.Value;
1400
            SetHighlightEvent();
1401
            //if ((sender as CheckBox).IsChecked.Value)
1402
            //{
1403
            //    TaskMessage("HighLight가 설정되었습니다", TaskMessageType.Normal);
1404
            //}
1405
            //else
1406
            //{
1407
            //    TaskMessage("HighLight가 해제되었습니다", TaskMessageType.Caption);
1408
            //}
1409
            //if (ViewerDataModel.Instance.SelectedEditor as MarkupToPDF.Controls.Text.TextControl != null)
1410
            //{
1411
            //    MarkupToPDF.Controls.Text.TextControl instance = (ViewerDataModel.Instance.SelectedEditor as MarkupToPDF.Controls.Text.TextControl);
1412
            //    instance.IsHighLight = ViewerDataModel.Instance.checkHighShape;
1413
            //    instance.SetText();
1414
            //}
1415
        }
1416

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

    
1490
                    ((TextBox)sender).Text = previousText;
1491
                }
1492
            }
1493
        }
1494

    
1495
        /// <summary>
1496
        /// 입력한 페이지로 이동한다
1497
        /// </summary>
1498
        /// <param name="sender"></param>
1499
        /// <param name="e"></param>
1500
        private void tlcurrentPage_readonly_KeyDown(object sender, KeyEventArgs e)
1501
        {
1502
            if (e.Key == Key.Enter)
1503
            {
1504
                try
1505
                {
1506
                    var instanceMain = this.ParentOfType<MainWindow>();
1507
                    instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage_readonly.Text));
1508
                }
1509
                catch (Exception)
1510
                {
1511
                    RadWindow.Alert(new DialogParameters
1512
                    {
1513
                        Owner = Application.Current.MainWindow,
1514
                        Theme = new VisualStudio2013Theme(),
1515
                        Header = "Info",
1516
                        Content = "Enter the correct page number.",
1517
                    });
1518
                }
1519
            }
1520
        }
1521
        
1522
        private void PanoramaEvent(object sender, RoutedEventArgs e)
1523
        {
1524
            PanoramaShow();
1525
        }
1526

    
1527
        public void PanoramaShow()
1528
        {
1529
            Panorama check = new Panorama();
1530
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
1531
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
1532
            //double windowWidth = this.Width;
1533
            //double windowHeight = this.Height;
1534

    
1535
            var PanoramaPop = new RadWindow
1536
            {
1537
                //MinWidth = 600,
1538
                //MinHeight = 400,
1539
                //Header = "My Check List",
1540
                Header = "Document No : " + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO + " / Revision :" + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.REVISION,
1541
                Content = check,
1542
                Owner = this,
1543
                ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1544
                //ResizeMode = System.Windows.ResizeMode.NoResize,
1545
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1546
                IsTopmost = false,
1547
                //Left = (screenWidth / 2) - (windowWidth / 2),
1548
                //Top = (screenHeight / 2) - (windowHeight / 2),
1549
                //Left = (screenWidth / 2),
1550
                //Top = (screenHeight / 2),
1551
                Width = screenWidth * 0.4,
1552
                Height = screenHeight * 0.4,
1553
            };
1554
            StyleManager.SetTheme(PanoramaPop, new VisualStudio2013Theme());
1555
            //CheckPop.ShowDialog();
1556
            PanoramaPop.Owner = Application.Current.MainWindow;
1557
            PanoramaPop.Show();
1558
        }
1559

    
1560
        private void CheckEvent(object sender, RoutedEventArgs e)
1561
        {
1562
            //창이 떠있을 경우 재 실행 방지
1563
            if (isClosed)
1564
            {
1565
                //토글 및 마우스 상태 초기화
1566
                var toggleList = this.Parent.ChildrenOfType<RadToggleButton>();
1567
                foreach(var togle in toggleList)
1568
                {
1569
                    togle.IsChecked = false;
1570
                }
1571
                this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1572

    
1573
                isClosed = false;
1574

    
1575
                
1576
                CheckList check = new CheckList(this.ParentOfType<MainWindow>());
1577

    
1578
                CheckPop = new RadWindow
1579
                {
1580
                    MinWidth = 1200,
1581
                    MinHeight = 500,
1582
                    //Header = "My Check List",
1583
                    Header = "Document No : " + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO + " / Revision :" + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.REVISION,
1584
                    Content = check,
1585
                    //Owner = this,
1586
                    //ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1587
                    ResizeMode = System.Windows.ResizeMode.NoResize,
1588
                    WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1589
                    IsTopmost = true,
1590
                };
1591
                StyleManager.SetTheme(CheckPop, new Office2013Theme());
1592
                CheckPop.Closed += CheckPop_Closed;
1593
                
1594
                //CheckPop.ShowDialog();
1595
                CheckPop.Show();
1596
            }
1597
        }
1598

    
1599
        private void SignManagerEvent(object sender, RoutedEventArgs e)
1600
        {
1601
            OpenSignManager();
1602
        }
1603

    
1604
        private void OpenSignManager()
1605
        { 
1606
            SignManager signManager = new SignManager();
1607

    
1608
            RadWindow signManagerPop = new RadWindow
1609
            {
1610
                MinWidth = 1200,
1611
                MinHeight = 500,
1612
                //Header = "My Check List",
1613
                Header = "",
1614
                Content = signManager,
1615
                Owner = this,
1616
                //ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1617
                ResizeMode = System.Windows.ResizeMode.CanResize,
1618
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1619
            };
1620
            StyleManager.SetTheme(signManagerPop, new Office2013Theme());
1621

    
1622
            //CheckPop.ShowDialog();
1623
            signManagerPop.ShowDialog();
1624
        }
1625

    
1626
        private void OptionPop_Closed(object sender, WindowClosedEventArgs e)
1627
        {
1628
            isClosed = true;
1629
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
1630
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1631
            ViewerDataModel.Instance.Capture_Opacity = 0;
1632
        }
1633

    
1634
        private void CheckPop_Closed(object sender, WindowClosedEventArgs e)
1635
        {
1636
            isClosed = true;
1637
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
1638
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1639
            ViewerDataModel.Instance.Capture_Opacity = 0;
1640
        }
1641

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

    
1681
        private void viewEvent(object sender, RoutedEventArgs e)
1682
        {
1683
            RadRibbonToggleButton viewButton = sender as RadRibbonToggleButton;
1684
            var instanceMain = this.ParentOfType<MainWindow>();
1685

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

    
1688
            //if ((sender as RadRibbonToggleButton) != null)
1689
            //{
1690
            //    Common.ViewerDataModel.Instance.ControlTag = (sender as RadRibbonToggleButton).Tag.ToString();
1691
            //    instanceToggle = (sender as RadRibbonToggleButton);
1692
            //}
1693

    
1694
            //instanceToggle.IsChecked = false;
1695

    
1696
            switch (viewButton.CommandParameter.ToString())
1697
            {
1698
                case "zoomout":
1699
                    {
1700
                        //장원
1701
                        //instanceMain.dzMainMenu.zoomAndPanControl.ZoomTo(new Rect(0, 0, instanceMain.dzMainMenu.zoomAndPanCanvas.ActualWidth, instanceMain.dzMainMenu.zoomAndPanCanvas.ActualHeight));
1702
                        instanceMain.dzMainMenu.zoomAndPanControl.ZoomPointToViewportCenter(ViewerDataModel.Instance.ContentScale -= 0.1, point);
1703
                        viewButton.IsChecked = false;
1704
                        //Common.ViewerDataModel.Instance.zom
1705
                    }
1706
                    break;
1707
                case "zoomin":
1708
                    {
1709
                        instanceMain.dzMainMenu.zoomAndPanControl.ZoomPointToViewportCenter(ViewerDataModel.Instance.ContentScale += 0.1, point);
1710
                        viewButton.IsChecked = false;
1711
                    }
1712
                    break;             
1713
                case "fitWidth":
1714
                    {
1715
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1716
                        viewButton.IsChecked = false;
1717
                    }
1718
                    break;
1719
                case "fitHeight":
1720
                    {
1721
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1722
                        viewButton.IsChecked = false;
1723
                    }
1724
                    break;
1725
                case "boundzoom":
1726
                    {
1727

    
1728
                    }
1729
                    break;
1730
                case "Rotate_M":
1731
                    {
1732
                        drawingPannelRotate(false);
1733
                        viewButton.IsChecked = false;
1734
                    }
1735
                    break;
1736
                case "Rotate_P":
1737
                    {
1738
                        drawingPannelRotate(true);
1739
                        viewButton.IsChecked = false;
1740
                    }
1741
                    break;
1742
                case "Rotate_half":
1743
                    {
1744
                        drawingPannelRotate(true);
1745
                        drawingPannelRotate(true);
1746
                        viewButton.IsChecked = false;
1747
                    }
1748
                    break;
1749
                    //case "fullscreen":
1750
                    //    {
1751
                    //        instanceMain.WindowStyle = WindowStyle.None;
1752
                    //        instanceMain.WindowState = WindowState.Maximized;
1753
                    //        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1754
                    //        viewButton.IsChecked = false;
1755
                    //    }
1756
                    //    break;
1757
            }
1758
        }
1759

    
1760
        private void Control_Event(object sender, RoutedEventArgs e)
1761
        {
1762

    
1763
        }
1764

    
1765
        #region 대기
1766

    
1767
        public void drawingPannelRotate(bool Flag)
1768
        {
1769
            var instanceMain = this.ParentOfType<MainWindow>();
1770

    
1771
            //if (rotateOffSet > 3)
1772
            //    rotateOffSet = 0;
1773

    
1774
            //if (rotateOffSet < 0)
1775
            //    rotateOffSet = 3;
1776

    
1777
            if(Flag)
1778
            {
1779
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
1780
                {
1781
                    instanceMain.dzMainMenu.rotate.Angle = 0;
1782
                }
1783
                else
1784
                {
1785
                    instanceMain.dzMainMenu.rotate.Angle += 90;
1786
                }
1787
            }
1788
            else
1789
            {
1790
                if(instanceMain.dzMainMenu.rotate.Angle == 0)
1791
                {
1792
                    instanceMain.dzMainMenu.rotate.Angle = 270;
1793
                }
1794
                else
1795
                {
1796
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
1797
                }
1798
            }
1799
            //double angle = (double)rotateValue.GetValue(rotateOffSet);
1800
            //instanceMain.dzMainMenu.rotate.Angle = angle;
1801
            var rotationNum = Math.Abs((instanceMain.dzMainMenu.rotate.Angle / 90));
1802

    
1803
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
1804
            {
1805
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1806
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1807
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
1808
            }
1809
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
1810
            {
1811
                instanceMain.dzMainMenu.translate.X = 0;
1812
                instanceMain.dzMainMenu.translate.Y = 0;
1813
            }
1814
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
1815
            {
1816
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1817
                instanceMain.dzMainMenu.translate.Y = 0;
1818
            }
1819
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
1820
            {
1821
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1822
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1823
            }
1824
            else
1825
            {
1826
                instanceMain.dzMainMenu.translate.X = 0;
1827
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1828
            }
1829

    
1830
            //instanceMain.dzMainMenu.zoomAndPanControl.RenderTransformOrigin = new Point(0.5, 0.5);
1831
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
1832
            //대기(강인구)
1833
            //instanceMain.dzMainMenu.imageViewer.RotateAngle = instanceMain.dzMainMenu.rotate.Angle;
1834

    
1835

    
1836
            //instanceMain.dzMainMenu.imageViewer.RenderTransformOrigin = new Point(0.5, 0.5);
1837
            //RotateTransform rotateTransform = new RotateTransform(instanceMain.dzMainMenu.rotate.Angle);
1838
            //instanceMain.dzMainMenu.imageViewer.RenderTransform = rotateTransform;
1839

    
1840

    
1841
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1842
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1843
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
1844
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
1845
            ViewerDataModel.Instance.PageAngle = instanceMain.dzMainMenu.rotate.Angle;
1846
            //ViewerDataModel.Instance.Document_Info.Clear();
1847
            //ViewerDataModel.Instance.Document_Info.Where(i => i.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(value =>
1848
            //{
1849
            //    value.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1850
            //});
1851

    
1852

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

    
1856
            foreach (var data in thumbnaillist)
1857
            {
1858
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1859

    
1860
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
1861
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
1862
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1863

    
1864
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
1865

    
1866
                //rotation page add or update
1867
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
1868
                if (rotationdoc != null)
1869
                {
1870
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
1871
                }
1872
                else
1873
                {
1874
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
1875
                }
1876
            }
1877
        }
1878
        #endregion
1879

    
1880
        private void ImageConverter(RadToggleButton instanceToggle)
1881
        {
1882
            try
1883
            {           
1884
                var instanceMain = this.ParentOfType<MainWindow>();
1885

    
1886
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
1887
                dlg.Filter = "All files (*.*)|*.*|PNG Images (*.png)|*.png";
1888
                Nullable<bool> result = dlg.ShowDialog();
1889
                if (result == true)
1890
                {
1891
                    instanceMain.dzMainMenu.filename = dlg.FileName;
1892
                    instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
1893

    
1894
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(instanceMain.dzMainMenu.filename);
1895
                    String strFile = System.IO.Path.GetFileName(instanceMain.dzMainMenu.filename);
1896
                    long numByte = fileInfo.Length;
1897
                    double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
1898
                    kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
1899
             
1900
                    if (dLen < 4)
1901
                    {
1902
                        System.IO.FileStream fStream = new System.IO.FileStream(instanceMain.dzMainMenu.filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
1903
                        System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
1904
                        byte[] data = br.ReadBytes((int)numByte);
1905
                        br.Close();
1906

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

    
1909
                        Check_Uri.UriCheck(filepath);
1910

    
1911
                        instanceMain.dzMainMenu.filename = filepath;
1912

    
1913
                        fStream.Close();
1914
                        fStream.Dispose();
1915
                    }
1916
                    else
1917
                    {
1918
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
1919
                    }
1920
                }
1921
                else
1922
                {
1923
                    instanceToggle.IsChecked = false;
1924
                    Common.ViewerDataModel.Instance.SelectedControl = "";
1925
                    Common.ViewerDataModel.Instance.ControlTag = null;
1926
                    this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
1927
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1928
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("No Image selected.", "Alert");
1929
                }
1930
            }
1931
            catch(Exception ex)
1932
            {
1933
                instanceToggle.IsChecked = false;
1934
                Common.ViewerDataModel.Instance.SelectedControl = "";
1935
                Common.ViewerDataModel.Instance.ControlTag = null;
1936
                this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
1937
                this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1938
                App.FileLogger.Error("Image Converter ",ex);
1939

    
1940
                this.ParentOfType<MainWindow>().DialogMessage_Alert(ex.Message, "Alert");
1941
            }
1942
        }
1943

    
1944
        private void Control_Init(RadToggleButton instanceToggle, object sender)
1945
        {
1946

    
1947
        }
1948

    
1949
        private void ControlEvent(object sender, RoutedEventArgs e)
1950
        {
1951
            RadToggleButton instanceToggle = sender as RadToggleButton;
1952
            var instanceMain = this.ParentOfType<MainWindow>();
1953

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

    
1974
            //if (!instanceMain.IsFreeSelectionMode)
1975
            //{
1976
            //    instanceMain.IsSwingMode = true;
1977
            //}
1978

    
1979
            //#region 다른 컨트롤 버튼 선택 해제
1980
            //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.SelectedControl).Subscribe(ControlState =>
1981
            //{
1982
            //    if (ControlState == null)
1983
            //    {
1984
            //        instanceToggle.IsChecked = false;
1985
            //        HiddenControlHide();
1986
            //    }
1987
            //});
1988
            //#endregion
1989

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

    
1992
            if (instanceToggle != null)
1993
            {
1994
                Common.ViewerDataModel.Instance.ControlTag = instanceToggle.Tag.ToString();
1995
            }
1996
            else if ((sender as RadRibbonToggleButton) != null)
1997
            {
1998
                Common.ViewerDataModel.Instance.ControlTag = (sender as RadRibbonToggleButton).Tag.ToString();
1999
                instanceToggle = (sender as RadRibbonToggleButton);
2000
            }
2001
            else if ((sender as RadRibbonButton) != null)
2002
            {
2003
                RadRibbonButton instanceButton = sender as RadRibbonButton;
2004
                Common.ViewerDataModel.Instance.ControlTag = instanceButton.Tag.ToString();
2005
            }
2006
            else
2007
            {
2008
                RadButton instanceButton = sender as RadButton;
2009
                Common.ViewerDataModel.Instance.ControlTag = instanceButton.Tag.ToString();
2010
            }
2011

    
2012

    
2013
            //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.AngleVisibility).Subscribe(isSee =>
2014
            //{
2015
            //    if (instanceToggle.CommandParameter.ToString() == "ChainLine")
2016
            //    {
2017

    
2018
            //    }
2019
            //    else
2020
            //    {
2021
            //        System.Diagnostics.Debug.WriteLine(" instanceMain.dzMainMenu.MainAngle.Visibility   " + isSee);
2022

    
2023
            //        if (instanceMain.dzMainMenu.MainAngle.Visibility != isSee)
2024
            //        {
2025
            //            instanceMain.dzMainMenu.MainAngle.Visibility = isSee;
2026
            //        }
2027
            //    }
2028
            //    //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.AngleValue).Subscribe(p =>
2029
            //    //{
2030
            //    //    instanceMain.dzMainMenu.MainAngle.AngleValue = p;
2031
            //    //});
2032
            //});
2033

    
2034
            instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2035

    
2036
            instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2037

    
2038
            if (instanceToggle.IsChecked != false)
2039
            {
2040
                string param = instanceToggle.CommandParameter.ToString();
2041
                string MacroIndex = "";
2042

    
2043
                if (param.StartsWith("MACRO"))
2044
                {
2045
                    param = "MACRO";
2046
                    MacroIndex = param.Replace("MACRO;","");
2047

    
2048
                    //Common.ViewerDataModel.Instance.MacroItems = MacroHelper.LoadMacroItems(MacroIndex);
2049
                    //var items = MacroHelper.TopMenuItems();
2050

    
2051
                    Common.ViewerDataModel.Instance.MacroItems = new List<MacroItem>
2052
                    {
2053
                        new MacroItem
2054
                        {
2055
                            Desc = "Cloud Rectangle",
2056
                            ControlType = MarkupToPDF.Controls.Common.ControlType.RectCloud
2057
                        },
2058
                        new MacroItem
2059
                        {
2060
                             Desc = "Arrow TextBox",
2061
                            ControlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl
2062
                        }
2063
                    };
2064
                }
2065

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

    
2289
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = true;
2290

    
2291
                        Common.ViewerDataModel.Instance.SelectedControl = "Ink";
2292
                        Common.ViewerDataModel.Instance.LineSize = (double)cbLineSize.Value;
2293
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PenControl;
2294
                        break;
2295
                    #endregion
2296
                    #region Select
2297
                    case "Select":
2298
                        if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2299
                        {
2300
                            if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl is MarkupToPDF.Controls.Text.TextControl
2301
                                && !string.IsNullOrEmpty(((MarkupToPDF.Controls.Text.TextControl)this.ParentOfType<MainWindow>().dzMainMenu.currentControl).Text))
2302
                            {
2303
                                DependencyObject focusScope1 = FocusManager.GetFocusScope((MarkupToPDF.Controls.Text.TextControl)this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2304
                                FocusManager.SetFocusedElement(focusScope1, (MarkupToPDF.Controls.Text.TextControl)this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2305

    
2306
                                this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2307
                                Keyboard.ClearFocus();
2308

    
2309
                            }
2310
                            else
2311
                            {
2312
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2313
                                this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2314
                            }
2315
                        }
2316

    
2317
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
2318
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2319
                        instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2320
                        break;
2321
                    #endregion
2322
                    #region Image
2323
                    case "Image":
2324
                        Common.ViewerDataModel.Instance.SelectedControl = "ImgControl";
2325
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
2326
                        ImageConverter(instanceToggle);
2327
                        break;
2328
                    #endregion
2329
                    #region Sign
2330
                    case "Sign":
2331
                        Common.ViewerDataModel.Instance.SelectedControl = "Sign";
2332
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2333
                        //강인구 추가
2334
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Sign;
2335
                        //instanceMain.BaseClient.GetUserSignCompleted += (sen, ea) =>
2336
                        //{
2337
                        //    if (ea.Result == null)
2338
                        //    {
2339

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

    
2376
                    #region MACRO -MACRO1
2377
                    case "MACRO":
2378
                        Common.ViewerDataModel.Instance.SelectedControl = "MACRO";
2379
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2380

    
2381
                        MacroHelper.MacroAction();
2382

    
2383
                        break;
2384
                    #endregion
2385

    
2386
                    #region Copy
2387
                    case "Copy":
2388
                        CopyCommand.Instance.Execute();
2389
                        //Copy_Start();
2390
                        instanceToggle.IsChecked = false;
2391
                        ViewerDataModel.Instance.SelectedControl = "";
2392
                        ViewerDataModel.Instance.ControlTag = null;
2393
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2394
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2395
                        break;
2396
                    #endregion
2397
                    #region Cut
2398
                    case "Cut":
2399
                        //Cut_Start();
2400
                        CutCommand.Instance.Execute();
2401
                        instanceToggle.IsChecked = false;
2402
                        ViewerDataModel.Instance.SelectedControl = "";
2403
                        ViewerDataModel.Instance.ControlTag = null;
2404
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2405
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2406
                        break;
2407
                    #endregion
2408
                    #region Paste
2409
                    case "Paste":
2410
                        PasteCommand.Instance.Execute();
2411
                        //Paste_Start();
2412
                        instanceToggle.IsChecked = false;
2413
                        ViewerDataModel.Instance.SelectedControl = "";
2414
                        ViewerDataModel.Instance.ControlTag = null;
2415
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2416
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;                        
2417
                        break;
2418
                    #endregion
2419
                    #region Delete
2420
                    case "Delete":
2421
                        UndoCommand.Instance.Push(EventType.Delete, SelectionSet.Instance.SelectedItems);
2422
                        this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Clear();
2423

    
2424
                        instanceToggle.IsChecked = false;
2425
                        ViewerDataModel.Instance.SelectedControl = "";
2426
                        ViewerDataModel.Instance.ControlTag = null;
2427
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2428
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2429
                        break;
2430
                    #endregion
2431
                    #region Undo
2432
                    case "Undo":
2433
                        UndoCommand.Instance.Execute();
2434
                        instanceToggle.IsChecked = false;
2435
                        ViewerDataModel.Instance.SelectedControl = "";
2436
                        ViewerDataModel.Instance.ControlTag = null;
2437
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2438
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2439
                        break;
2440
                    #endregion
2441
                    #region Redo
2442
                    case "Redo":
2443
                        RedoCommand.Instance.Execute();
2444
                        instanceToggle.IsChecked = false;
2445
                        ViewerDataModel.Instance.SelectedControl = "";
2446
                        ViewerDataModel.Instance.ControlTag = null;
2447
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2448
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2449
                        break;
2450
                    #endregion
2451
                    #region DragZoom
2452
                    case "DragZoom":
2453
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.DragZoom;
2454
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2455
                        instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2456
                        break;
2457
                    #endregion
2458
                    #region Grouping
2459
                    case "Group":
2460
                        //var GrouptoggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2461
                        //foreach (var togle in GrouptoggleList)
2462
                        //{
2463
                        //    togle.IsChecked = false;
2464
                        //}
2465

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

    
2526
                        //if (ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
2527
                        //{
2528
                        //    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Please Select Controls", "Alert");
2529
                        //}
2530
                        //else//if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2531
                        //{
2532
                        //    // string MarkupData = "";
2533
                        //    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2534
                        //    {
2535
                        //        if (item.GetType().Name == "AdornerFinal" && (item as AdornerFinal).MemberSet.Count >= 1) // 1개 이상 
2536
                        //        {
2537
                        //            //MARKUP_DATA UPDATE
2538
                        //            foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
2539
                        //            {
2540
                        //                if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2541
                        //                {
2542
                        //                    long group_id = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault().Group_ID;
2543
                        //                    //MARKUP_DATA UPDATE
2544
                        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupData((InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID, 0, App.ViewInfo.ProjectNO);
2545
                        //                    ////Logger.sendReqLog("UpdateMarkupData: ", "", 1);
2546
                        //                    ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().Group_ID = 0;
2547
                        //                    ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().IsUpdate = true;
2548

    
2549

    
2550
                        //                    //MARKUP_DATA_GROUP UPDATE
2551
                        //                    //bool value = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupDataGroup(group_id, App.ViewInfo.ProjectNO);
2552
                        //                    ////Logger.sendReqLog("AddMarkupDataGroup: ", value.ToString(), 1);
2553
                        //                }
2554
                        //            }
2555
                        //        }
2556
                        //    }
2557
                        //}
2558
                        break;
2559
                    #endregion
2560
                    #region Capture
2561
                    case "Capture":
2562
                        SyncInit();
2563
                        //   instanceToggle.IsChecked = false;
2564
                        var CaptureList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2565
                        foreach (var togle in CaptureList)
2566
                        {
2567
                            togle.IsChecked = false;
2568
                        }
2569

    
2570
                        if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2571
                        {
2572
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2573
                            this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2574
                        }
2575

    
2576
                        ViewerDataModel.Instance.SelectedControl = "ImgControl";
2577
                   //     ViewerDataModel.Instance.ControlTag = null;
2578
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
2579

    
2580
                        /*
2581
                        //캡쳐 하기 전에 코멘트 저장
2582
                        if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
2583
                        {
2584
                            var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
2585
                            menu.ReleaseAdorner();
2586
                            if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
2587
                            {
2588
                                (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
2589
                            }
2590
                            else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
2591
                            {
2592

    
2593
                            }
2594
                            else
2595
                            {
2596
                                (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
2597
                            }
2598
                        }*/
2599

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

    
2638
                        //    isClosed = false;
2639
                        //    //Control 파일 먼저 생성
2640
                        //    CollapsedButton_Click();
2641
                        //    CadViewer check = new CadViewer();
2642
                        //    check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2643
                        //    check.Title = "Export Viewer";
2644
                        //    //check.Topmost = true;
2645
                        //    check.Show();
2646
                        //    check.Closed += Check_Closed;
2647
                        //    instanceToggle.IsChecked = false;
2648
                        //}
2649
                        //break;
2650
                    case "CadViewer":
2651
                        //if (isClosed)
2652
                        //{
2653
                        //    //토글 및 마우스 상태 초기화
2654
                        //    var toggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2655
                        //    foreach (var togle in toggleList)
2656
                        //    {
2657
                        //        togle.IsChecked = false;
2658
                        //    }
2659
                        //    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2660

    
2661
                        //    isClosed = false;
2662
                        //    CadResultViewer check = new CadResultViewer();
2663
                        //    check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2664
                        //    check.Title = "Viewer";
2665
                        //    check.Show();
2666

    
2667
                        //    check.Closed += Check_Closed;
2668

    
2669
                        //}
2670
                        break;
2671
                    #endregion
2672
                    default:
2673
                        break;
2674
                }
2675
                #endregion
2676
            }
2677
            else
2678
            {
2679
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
2680
                {
2681
                    MacroHelper.Clear();
2682
                }
2683

    
2684
                if (!instanceMain.dzMainMenu.IsFreeSelectionMode)
2685
                {
2686
                    instanceMain.dzMainMenu.IsSwingMode = false;
2687
                    Common.ViewerDataModel.Instance.SelectedControl = "";
2688
                    Common.ViewerDataModel.Instance.ControlTag = null;
2689
                    this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2690
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2691
                }
2692
            }
2693

    
2694
        }
2695

    
2696
        private void SyncInit()
2697
        {
2698
            try
2699
            {
2700
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden)
2701
                {
2702
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true;
2703
                    ViewerDataModel.Instance.PageBalanceMode = false;
2704
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
2705
                    ViewerDataModel.Instance.SyncPageNumber = 0;
2706
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
2707
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed;
2708
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false;
2709
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false;
2710
                }
2711
            }
2712
            catch (Exception ex)
2713
            {
2714
                //Logger.sendResLog("SyncInit", ex.Message, 0);
2715
            }
2716

    
2717
        }
2718

    
2719
        UndoData multi_UndoData = new UndoData();
2720
        CommentUserInfo currentControl { get; set; }
2721
        private void Check_Closed(object sender, EventArgs e)
2722
        {
2723
            isClosed = true;
2724
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
2725
            //토글 및 마우스 상태 초기화
2726
            var toggleList = this.Parent.ChildrenOfType<RadToggleButton>();
2727
            foreach (var togle in toggleList)
2728
            {
2729
                togle.IsChecked = false;
2730
            }
2731
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2732
            ViewerDataModel.Instance.Capture_Opacity = 0;
2733

    
2734
        }
2735

    
2736
        /* public class test 
2737
         {
2738
             public double width { get; set; }
2739
             public double height { get; set; }
2740
         }
2741
         */
2742
        private async void CollapsedButton_Click()
2743
        {
2744
            this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null); // 저장하지 못한 데이터가 있다면 저장
2745

    
2746
            string[] data = new string[0];
2747

    
2748
            int cnt = 0;
2749
            var menu = this.ParentOfType<MainWindow>().dzMainMenu;
2750

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

    
2753
            foreach (var item in gridSelectionItem)
2754
            {
2755
                if ((item.UserID == App.ViewInfo.UserID) && (ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage != null))
2756
                {
2757
                    var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber &&
2758
                    d.MarkupInfoID == item.MarkupInfoID).ToList();
2759
                    data = new string[instance.Count];
2760
                    foreach (var markup in instance)
2761
                    {
2762
                        data[cnt++] = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(markup.Data,ViewerDataModel.Instance.NewMarkupCancelToken());
2763
                    }
2764
                }
2765
            }
2766

    
2767
            if (data != null && KCOM.Properties.Settings.Default.cad == 1)
2768
            {
2769
                string FilePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Cad");
2770
                string FileName = FilePath + "\\commentstring.json"; // Default file name
2771
                if (!File.Exists(FilePath))
2772
                {
2773
                    Directory.CreateDirectory(FilePath);
2774
                }
2775

    
2776
                if (!string.IsNullOrEmpty(FileName))
2777
                {
2778
                    //  File.WriteAllText(SaveDig.FileName, data);
2779
                    File.WriteAllLines(FileName, data);
2780
                }
2781
            }
2782
        }
2783

    
2784
        private double minHeight;
2785
        private double minWidth;
2786

    
2787
        private double maxHeight;
2788
        private double maxWidth;
2789

    
2790
        public bool CanVResize { get; private set; }
2791
        public bool CanHResize { get; private set; }
2792

    
2793
        public void DesignerComponent(FrameworkElement content)
2794
        {
2795
            this.InitializeComponent();
2796

    
2797
            if (!double.IsNaN(content.Width))
2798
            {
2799
                CanHResize = false;
2800
                this.Width = content.Width;
2801
            }
2802
            else
2803
            {
2804
                CanHResize = true;
2805
                this.Width = 23.0;
2806
            }
2807
            if (!double.IsNaN(content.Height))
2808
            {
2809
                CanVResize = false;
2810
                this.Height = content.Height; ;
2811
            }
2812
            else
2813
            {
2814
                CanVResize = true;
2815
                this.Height = 23.0;
2816
            }
2817

    
2818
            minWidth = content.MinWidth < 10.0 ? 10.0 : content.MinWidth;
2819
            minHeight = content.MinHeight < 10.0 ? 10.0 : content.MinHeight;
2820
            maxWidth = content.MaxWidth;
2821
            maxHeight = content.MaxHeight;
2822

    
2823
            double top = (double)content.GetValue(Canvas.TopProperty);
2824
            if (double.IsNaN(top))
2825
                top = 0.0;
2826
            double left = (double)content.GetValue(Canvas.LeftProperty);
2827
            if (double.IsNaN(left))
2828
                left = 0.0;
2829
            SetValue(Canvas.TopProperty, top);
2830
            SetValue(Canvas.LeftProperty, left);
2831

    
2832
            //Set the actual content. Note that "Content" property is a new property. See below
2833
            this.Content = content;
2834
        }
2835
        private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
2836
        {
2837
            string name = ((Thumb)sender).Name;
2838
            if (name.Contains("Top"))
2839
            {
2840
                double newHeight = this.Height - e.VerticalChange;
2841
                if (newHeight >= minHeight && newHeight <= maxHeight)
2842
                {
2843
                    this.Height = newHeight;
2844
                    SetValue(Canvas.TopProperty,
2845
                (double)GetValue(Canvas.TopProperty) + e.VerticalChange);
2846
                }
2847
            }
2848
            if (name.Contains("Right"))
2849
            {
2850
                double newWidth = this.Width + e.HorizontalChange;
2851
                if (newWidth >= minWidth && newWidth <= maxWidth)
2852
                    this.Width = newWidth;
2853
            }
2854
            if (name.Contains("Bottom"))
2855
            {
2856
                double newHeight = this.Height + e.VerticalChange;
2857
                if (newHeight >= minHeight && newHeight <= maxHeight)
2858
                    this.Height = newHeight;
2859
            }
2860
            if (name.Contains("Left"))
2861
            {
2862
                double newWidth = this.Width - e.HorizontalChange;
2863
                if (newWidth >= minWidth && newWidth <= maxWidth)
2864
                {
2865
                    this.Width = newWidth;
2866
                    SetValue(Canvas.LeftProperty,
2867
                (double)GetValue(Canvas.LeftProperty) + e.HorizontalChange);
2868
                }
2869
            }
2870
        }
2871

    
2872
        private void drawControlBorder(object sender)
2873
        {
2874
            System.Windows.Controls.Control control = (System.Windows.Controls.Control)sender;
2875
        }
2876

    
2877
        private void ResizeThumb_DragDelta(object sender, MouseButtonEventArgs e)
2878
        {
2879
            System.Windows.Controls.Control designerItem = (System.Windows.Controls.Control)sender;
2880
            if (designerItem != null)
2881
            {
2882
                double deltaVertical, deltaHorizontal;
2883

    
2884
                switch (VerticalAlignment)
2885
                {
2886
                    case VerticalAlignment.Bottom:
2887
                        deltaVertical = designerItem.ActualHeight - designerItem.MinHeight;
2888
                        designerItem.Height -= deltaVertical;
2889
                        break;
2890
                    case VerticalAlignment.Top:
2891
                        deltaVertical = designerItem.ActualHeight - designerItem.MinHeight;
2892
                        Canvas.SetTop(designerItem, Canvas.GetTop(designerItem) + deltaVertical);
2893
                        designerItem.Height -= deltaVertical;
2894
                        break;
2895
                    default:
2896
                        break;
2897
                }
2898

    
2899
                switch (HorizontalAlignment)
2900
                {
2901
                    case HorizontalAlignment.Left:
2902
                        deltaHorizontal = designerItem.ActualWidth - designerItem.MinWidth;
2903
                        Canvas.SetLeft(designerItem, Canvas.GetLeft(designerItem) + deltaHorizontal);
2904
                        designerItem.Width -= deltaHorizontal;
2905
                        break;
2906
                    case HorizontalAlignment.Right:
2907
                        deltaHorizontal = designerItem.ActualWidth - designerItem.MinWidth;
2908
                        designerItem.Width -= deltaHorizontal;
2909
                        break;
2910
                    default:
2911
                        break;
2912
                }
2913
            }
2914
            e.Handled = true;
2915
        }
2916

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

    
2919
        void ExportMethod()
2920
        {
2921
            //FileDialogFilter filterImage = new FileDialogFilter("Image Files", "*.jpg", "*.png");
2922
            SaveDig.Filter = "PDF file format|*.pdf";
2923
            SaveDig.Title = "Save an DWG File";
2924
            SaveDig.ShowDialog();
2925
        }
2926

    
2927
        private void cbAutoSave_Checked(object sender, RoutedEventArgs e)
2928
        {            
2929
            if (cbAutoSave.IsChecked == true)
2930
            {
2931
                SaveTime(true, (int)cbSaveInterval.Value);
2932
            }
2933
            else
2934
            {
2935
                SaveTime(false, (int)cbSaveInterval.Value);
2936
            }
2937
        }
2938
        private void cbSaveInterval_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
2939
        {
2940
            if(string.IsNullOrEmpty(cbSaveInterval.Value.ToString()))
2941
            {
2942
                cbSaveInterval.Value = cbSaveInterval.Minimum;
2943
            }
2944
            if (cbAutoSave.IsChecked == true)
2945
            {
2946
                SaveTime(true, (int)cbSaveInterval.Value);
2947
            }
2948

    
2949
            KCOM.Properties.Settings.Default.SaveInterval = (double)cbSaveInterval.Value;
2950
            Properties.Settings.Default.Save();
2951
        }
2952
        //강인구 자동 저장 추가
2953
        private void AutoSave(object sender, RoutedEventArgs e)
2954
        {
2955
            RadToggleButton instanceToggle = sender as RadToggleButton;
2956

    
2957
            if(instanceToggle.IsChecked == true)
2958
            {
2959
                SaveTime(true);
2960
            }
2961
            else
2962
            {
2963
                SaveTime(false);
2964
            }
2965
        }
2966

    
2967
        public void Copy_Start()
2968
        {
2969
            if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2970
            {
2971
                string MarkupData = "";
2972

    
2973
                foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2974
                {
2975
                    string id = string.Empty;
2976
                    if (item.GetType().Name == "AdornerFinal")
2977
                    {
2978
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
2979

    
2980
                        {
2981
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2982
                            {
2983
                                MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn res = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
2984
                                id = (InnerItem.Symbol_ID != null) ? "|SymbolID|" + InnerItem.Symbol_ID : "";
2985
                                MarkupData += "|OR|" + res.ConvertData + id;
2986
                            }
2987
                        }
2988

    
2989
                        this.Dispatcher.Invoke(() =>
2990
                        {
2991
                            Clipboard.SetData(DataFormats.StringFormat, MarkupData);
2992
                        }, DispatcherPriority.Background);
2993
                    }
2994
                }
2995
            }
2996
        }
2997

    
2998
        public void Cut_Start()
2999
        {
3000
            if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
3001
            {
3002
                foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
3003
                {
3004
                    string MarkupData = "";
3005

    
3006
                    if (item.GetType().Name == "AdornerFinal")
3007
                    {
3008
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
3009
                        {
3010
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
3011
                            {
3012
                                MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn res = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
3013
                                MarkupData += "|OR|" + res.ConvertData;
3014
                            }
3015
                        }
3016
                        //클립보드에 넣음
3017
                        Clipboard.SetDataObject(MarkupData);
3018
                    }
3019
                }
3020
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Clear();
3021
            }
3022
        }
3023

    
3024
        public async void Paste_Start()
3025
        {
3026
            //마크업 붙여넣기
3027

    
3028
            var markupData = Clipboard.GetData(DataFormats.StringFormat);
3029

    
3030
            if (markupData.GetType() == typeof(string) && markupData.ToString().Contains("|OR||DZ|"))
3031
            {
3032
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
3033

    
3034
                string[] delimiterChars = { "|OR|" };
3035
                string[] data = markupData.ToString().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
3036

    
3037
                SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
3038

    
3039
                UndoData multi_UndoData = new UndoData();
3040

    
3041
                //강인구 Undo/Redo 보류
3042
                MarkupToPDF.Common.UndoDataGroup UndoData = new UndoDataGroup()
3043
                {
3044
                    IsUndo = false,
3045
                    Event = EventType.Create,
3046
                    EventTime = DateTime.Now,
3047
                    MarkupDataColl = new List<UndoData>()
3048
                };
3049

    
3050
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3051
                {
3052
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
3053
                });
3054

    
3055
                foreach (string parse in data)
3056
                {
3057
                    if (parse != "")
3058
                    {
3059
                        System.Windows.Controls.Control item = await MarkupParser.ParseExAsync(App.BaseAddress,ViewerDataModel.Instance.NewMarkupCancelToken(),App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, string.Empty, string.Empty,
3060
                            STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
3061
                        (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.ShortGuid();
3062

    
3063
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
3064
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
3065

    
3066
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
3067

    
3068
                        multi_UndoData = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
3069

    
3070
                        UndoData.MarkupDataColl.Add(multi_UndoData);
3071
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);                        
3072
                    }
3073
                }
3074
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
3075

    
3076
                if(this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X < 0)
3077
                {
3078
                    Canvas.SetLeft(final, 0);
3079
                    Canvas.SetTop(final, 0);
3080
                }
3081
                else
3082
                {
3083
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
3084
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
3085
                    final.TranslateItems(realPointX, realPointY);
3086

    
3087
                    if (final.Members.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
3088
                    {
3089
                        final.TranslateItems(0.001, 0.001); //dummy
3090
                    }
3091
                }
3092

    
3093
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
3094
            }
3095
            //외부 이미지 붙여넣기
3096
            else if (Clipboard.GetImage() != null)
3097
            {
3098
                try
3099
                {
3100
                    UndoData multi_UndoData = new UndoData();
3101

    
3102
                    //강인구 Undo/Redo 보류
3103
                    MarkupToPDF.Common.UndoDataGroup UndoData = new UndoDataGroup()
3104
                    {
3105
                        IsUndo = false,
3106
                        Event = EventType.Create,
3107
                        EventTime = DateTime.Now,
3108
                        MarkupDataColl = new List<UndoData>()
3109
                    };
3110

    
3111

    
3112
                    string temppath = System.IO.Path.GetTempPath();
3113
                    //string filename = KCOM.Events.Save.shortCommentKey();
3114
                    string filename = Commons.ShortFileKey();
3115

    
3116
                    System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage();
3117
                    clipboardImage.Save(temppath + "\\" + filename);
3118

    
3119
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(temppath + "\\" + filename);
3120
                    String strFile = System.IO.Path.GetFileName(fileInfo.FullName);
3121
                    long numByte = fileInfo.Length;
3122
                    double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
3123
                    kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
3124

    
3125
                    if (dLen < 4)
3126
                    {
3127
                        System.IO.FileStream fStream = new System.IO.FileStream(fileInfo.FullName,
3128
                        System.IO.FileMode.Open, System.IO.FileAccess.Read,FileShare.Read);
3129
                        System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
3130
                        byte[] data = br.ReadBytes((int)numByte);
3131

    
3132
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data);
3133
                        Check_Uri.UriCheck(filename);
3134
                        br.Close();
3135
                        fStream.Close();
3136
                        fStream.Dispose();
3137
                    }
3138
                    else
3139
                    {
3140
                        this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
3141
                        return;
3142
                    }
3143

    
3144
                    fileInfo.Delete();
3145

    
3146
                    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(clipboardImage);
3147
                    IntPtr hBitmap = bmp.GetHbitmap();
3148
                    System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
3149
                    Image img = new Image();
3150
                    if (filename.Contains(".svg"))
3151
                    {
3152
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(filename);
3153
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
3154
                    }
3155
                    else
3156
                    {
3157
                        img.Source = new BitmapImage(new Uri(filename));
3158
                    }
3159

    
3160
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3161
                    {
3162
                        PointSet = new List<Point>(),
3163
                        FilePath = filename,
3164
                        ImageData = img.Source,
3165
                        StartPoint = new Point(100, 100),
3166
                        EndPoint = new Point(200, 200),
3167
                        TopRightPoint = new Point(100, 200),
3168
                        LeftBottomPoint = new Point(200, 100)
3169
                    };
3170

    
3171
                    currentControl.TopRightPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y);
3172
                    currentControl.LeftBottomPoint = new Point(currentControl.StartPoint.X, currentControl.StartPoint.Y + clipboardImage.Height);
3173
                    currentControl.EndPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y + clipboardImage.Height);
3174

    
3175
                    currentControl.PointSet = new List<Point>
3176
                                        {
3177
                                            currentControl.StartPoint,
3178
                                            currentControl.LeftBottomPoint,
3179
                                            currentControl.EndPoint,
3180
                                            currentControl.TopRightPoint,
3181
                                        };
3182

    
3183
                    multi_UndoData = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3184
                    UndoData.MarkupDataColl.Add(multi_UndoData);
3185
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3186

    
3187
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3188
                    currentControl.CommentID = Commons.ShortGuid();
3189

    
3190
                    currentControl.ApplyTemplate();
3191
                    currentControl.SetImage();
3192

    
3193
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3194
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3195
                    this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
3196

    
3197
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
3198
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
3199
                    final.TranslateItems(realPointX, realPointY);
3200
                }
3201
                catch(Exception ex)
3202
                {
3203
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("" + ex, "Alert");
3204
                }
3205
            }
3206
        }
3207
    }
3208
}
클립보드 이미지 추가 (최대 크기: 500 MB)