프로젝트

일반

사용자정보

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

markus / KCOM / Events / Implementation / TopMenuEvent.cs @ 646a4bb9

이력 | 보기 | 이력해설 | 다운로드 (160 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

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

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

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

    
73
        private void CheckShapeState()
74
        {
75

    
76

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

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

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

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

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

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

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

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

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

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

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

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

    
173
        }
174

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

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

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

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

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

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

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

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

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

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

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

    
328
                _SaveEvent(sender, e);
329

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

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

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

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

    
358
                //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl_MouseDown(this, new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Right));
359

    
360
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
361
                // update mylist and gridview
362
                mainMenu.UpdateMyMarkupList();
363

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

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

    
385
                            result = true;
386
                        }
387
                    }
388
                }
389

    
390
                mainMenu.SetCommentPages(null);
391

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

    
415
            return result;
416
        }
417

    
418
        public async Task<bool>  SaveEventAsync()
419
        {
420
            bool result = false;
421

    
422
            var mainMenu = this.ParentOfType<MainWindow>().dzMainMenu;
423
            try
424
            {
425
                mainMenu.ConvertInkControlToPolygon();
426

    
427
                SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
428
                // update mylist and gridview
429
                mainMenu.UpdateMyMarkupList();
430

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

    
444
                            ViewerDataModel.Instance._markupInfoList.Where(data => data.MarkupInfoID == (item as IKCOM.MarkupInfoItem).MarkupInfoID).FirstOrDefault().UpdateTime = DateTime.Now;
445
                        }
446
                    }
447
                }
448

    
449
                mainMenu.SetCommentPages(null);
450

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

    
475
            return result;
476
        }
477

    
478
        public bool SaveEvent()
479
        {
480
            bool result = false;
481

    
482
            var mainMenu = this.ParentOfType<MainWindow>().dzMainMenu;
483
            try
484
            {
485
                mainMenu.ConvertInkControlToPolygon();
486

    
487
                SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
488
                // update mylist and gridview
489
                mainMenu.UpdateMyMarkupList();
490

    
491
                if (mainMenu.gridViewMarkup.SelectedItems.Count == 0 && mainMenu.gridViewMarkup.Items.Count > 0)
492
                {
493
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("Please Select Your Comment List Item", "Alert");
494
                }
495
                else
496
                {
497
                    foreach (var item in mainMenu.gridViewMarkup.SelectedItems)
498
                    {
499
                        if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
500
                        {
501
                            /// 저장 서비스 호출
502
                            result = this.ExecuteSaveCommandAsync(mainMenu).GetAwaiter().GetResult();
503

    
504
                            ViewerDataModel.Instance._markupInfoList.Where(data => data.MarkupInfoID == (item as IKCOM.MarkupInfoItem).MarkupInfoID).FirstOrDefault().UpdateTime = DateTime.Now;
505
                        }
506
                    }
507
                }
508

    
509
                mainMenu.SetCommentPages(null);
510

    
511
                ViewerDataModel.Instance.UndoDataList.Clear();
512
                result = true;
513
            }
514
            catch (Exception ex)
515
            {
516
                System.Diagnostics.Debug.WriteLine("_SaveEvent Error : " + ex.ToString());
517
            }
518
            finally
519
            {
520
                /*
521
                /// delete markup information when 코멘트가 없을 경우
522
                if (ViewerDataModel.Instance.MyMarkupList.Count == 0)
523
                {
524
                    foreach (var item in menu.gridViewMarkup.SelectedItems)
525
                    {
526
                        if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
527
                        {
528
                            //this.ParentOfType<MainWindow>().dzMainMenu.DeleteItem((item as IKCOM.MarkupInfoItem));
529
                        }
530
                    }
531
                }
532
                */
533
            }
534

    
535
            return result;
536
        }
537

    
538
        /// <summary>
539
        /// call save command
540
        /// </summary>
541
        /// <param name="menu"></param>
542
		public void ExecuteSaveCommand2(MainMenu menu)
543
        {
544
            if (menu.pageNavigator.CurrentPage != null)
545
            {
546
                SaveCommand.Instance.Project_No = App.ViewInfo.ProjectNO;
547
                SaveCommand.Instance.document_id = App.ViewInfo.DocumentItemID;
548
                SaveCommand.Instance.user_id = App.ViewInfo.UserID;
549
                SaveCommand.Instance.page_no = menu.pageNavigator.CurrentPage.PageNumber;
550

    
551
                try
552
                {
553
                    if (ViewerDataModel.Instance.UndoDataList.Count > 0)
554
                    {
555
                        List<IKCOM.MarkupInfoItem> SelectedMarkupInfos = new List<IKCOM.MarkupInfoItem>();
556
                        foreach (var item in menu.gridViewMarkup.SelectedItems)
557
                        {
558
                            if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
559
                            {
560
                                SelectedMarkupInfos.Add(item as IKCOM.MarkupInfoItem);
561
                            }
562
                        }
563

    
564
                        SaveCommand.Instance.Execute(SelectedMarkupInfos);
565
                    }
566

    
567
                    if (ViewerDataModel.Instance.RotationDocs.Count > 0)
568
                    {
569
                        SaveCommand.Instance.PageAngleSave(App.ViewInfo.ProjectNO, ViewerDataModel.Instance.RotationDocs);
570
                    }
571
                }
572
                catch (Exception ex)
573
                {
574
                    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(string.Format("세이브 실패:{0}", ex.Message), "Alert");
575
                    throw ex;
576
                }
577
            }
578
            else
579
            {
580
                System.Diagnostics.Debug.WriteLine("ExecuteSaveCommand Error - pageNavigator.CurrentPage null");
581
            }
582
        }
583
        public async Task<bool> ExecuteSaveCommandAsync(MainMenu menu)
584
        {
585
            bool result = false;
586

    
587
            if (menu.pageNavigator.CurrentPage != null)
588
            {
589
                SaveCommand.Instance.Project_No = App.ViewInfo.ProjectNO;
590
                SaveCommand.Instance.document_id = App.ViewInfo.DocumentItemID;
591
                SaveCommand.Instance.user_id = App.ViewInfo.UserID;
592
                SaveCommand.Instance.page_no = menu.pageNavigator.CurrentPage.PageNumber;
593

    
594
                try
595
                {
596
                    if (ViewerDataModel.Instance.UndoDataList.Count > 0 || ViewerDataModel.Instance.IsMarkupUpdate)
597
                    {
598
                        List<IKCOM.MarkupInfoItem> SelectedMarkupInfos = new List<IKCOM.MarkupInfoItem>();
599
                        foreach (var item in menu.gridViewMarkup.SelectedItems)
600
                        {
601
                            if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
602
                            {
603
                                SelectedMarkupInfos.Add(item as IKCOM.MarkupInfoItem);
604
                            }
605
                        }
606

    
607
                        result = await SaveCommand.Instance.Execute(SelectedMarkupInfos);
608
                        ViewerDataModel.Instance.IsMarkupUpdate = false;
609
                    }
610
                    else
611
                    {
612
                        result = true;
613
                    }
614

    
615
                    if (ViewerDataModel.Instance.RotationDocs.Count > 0)
616
                    {
617
                        SaveCommand.Instance.PageAngleSave(App.ViewInfo.ProjectNO, ViewerDataModel.Instance.RotationDocs);
618
                    }
619
                }
620
                catch (Exception ex)
621
                {
622
                    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(string.Format("세이브 실패:{0}", ex.Message), "Alert");
623
                    throw ex;
624
                }
625
            }
626
            else
627
            {
628
                System.Diagnostics.Debug.WriteLine("ExecuteSaveCommand Error - pageNavigator.CurrentPage null");
629
            }
630

    
631
            return result;
632
        }
633

    
634
        public bool ExecuteSaveCommand(MainMenu menu)
635
        {
636
            bool result = false;
637

    
638
            if (menu.pageNavigator.CurrentPage != null)
639
            {
640
                SaveCommand.Instance.Project_No = App.ViewInfo.ProjectNO;
641
                SaveCommand.Instance.document_id = App.ViewInfo.DocumentItemID;
642
                SaveCommand.Instance.user_id = App.ViewInfo.UserID;
643
                SaveCommand.Instance.page_no = menu.pageNavigator.CurrentPage.PageNumber;
644

    
645
                try
646
                {
647
                    if (ViewerDataModel.Instance.UndoDataList.Count > 0 || ViewerDataModel.Instance.IsMarkupUpdate)
648
                    {
649
                        List<IKCOM.MarkupInfoItem> SelectedMarkupInfos = new List<IKCOM.MarkupInfoItem>();
650
                        foreach (var item in menu.gridViewMarkup.SelectedItems)
651
                        {
652
                            if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
653
                            {
654
                                SelectedMarkupInfos.Add(item as IKCOM.MarkupInfoItem);
655
                            }
656
                        }
657

    
658
                        result = SaveCommand.Instance.Execute(SelectedMarkupInfos).GetAwaiter().GetResult();
659
                        ViewerDataModel.Instance.IsMarkupUpdate = false;
660
                    }
661
                    else
662
                    {
663
                        result = true;
664
                    }
665

    
666
                    if (ViewerDataModel.Instance.RotationDocs.Count > 0)
667
                    {
668
                        SaveCommand.Instance.PageAngleSave(App.ViewInfo.ProjectNO, ViewerDataModel.Instance.RotationDocs);
669
                    }
670
                }
671
                catch (Exception ex)
672
                {
673
                    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(string.Format("세이브 실패:{0}", ex.Message), "Alert");
674
                    throw ex;
675
                }
676
            }
677
            else
678
            {
679
                System.Diagnostics.Debug.WriteLine("ExecuteSaveCommand Error - pageNavigator.CurrentPage null");
680
            }
681

    
682
            return result;
683
        }
684

    
685
        //강인구 추가
686
        public void Print_Start(string Type)
687
        {
688
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
689
            {
690
                var menu = this.ParentOfType<MainWindow>().dzMainMenu;
691
                SelectionSet.Instance.UnSelect(menu);
692
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
693
                {
694
                    this.SaveEventCallback(null, null);
695
                }
696
                else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
697
                {
698

    
699
                }
700
                else
701
                {
702
                    this.SaveEventCallback(null, null);
703
                }
704
            }
705

    
706
            bool isprint = false;
707
            if (Type == "Print")
708
            {
709
                isprint = true;
710
            }
711

    
712
            RadWindow PrintWindow = new RadWindow();
713
            PrintWindow.Width = 850;
714
            PrintWindow.Height = 600;
715
            PrintWindow.Header = Type;
716

    
717
            List<IKCOM.MarkupInfoItem> markupinfo = new List<IKCOM.MarkupInfoItem>();
718

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

    
721
            if (markupinfo?.Count() > 0)
722
            {
723
                //Logger.sendResLog("GetPrintDocItemList", "TRUE", 1);
724
            }
725
            else
726
            {
727
                //Logger.sendResLog("GetPrintDocItemList", "FALSE", 1);
728
            }
729

    
730
            /// Tile Source URL을 구한다
731

    
732
            string sImageURL = ViewerDataModel.Instance.SystemMain.dzMainMenu.GetImageURL(App.ViewInfo.DocumentItemID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber);
733
            var url = new Uri(sImageURL);
734
            string sFolder = App.ViewInfo.DocumentItemID.All(char.IsDigit) ? (Convert.ToInt64(App.ViewInfo.DocumentItemID) / 100).ToString() : App.ViewInfo.DocumentItemID.Substring(0, 5);
735
            var Tile_Url = string.Format(@"{0}://{1}:{2}/TileSource/{3}_Tile/{4}/{5}/",
736
                url.Scheme, url.Host, url.Port,
737
                App.ViewInfo.ProjectNO,
738
                sFolder,
739
                App.ViewInfo.DocumentItemID
740
                );
741
            /// up to here
742

    
743
            var docitem = this.ParentOfType<MainWindow>().dzMainMenu._DocItem;
744

    
745
            PrintWindow.Content = new KCOM.Control.PrintControl(
746
                      Tile_Url,
747
                      App.ViewInfo.ProjectNO,
748
                      this.ParentOfType<MainWindow>().dzMainMenu._DocInfo,
749
                      markupinfo,
750
                      this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber,
751
                      docitem.GROUP_NO,
752
                      docitem.DOCUMENT_NO,
753
                      docitem.ORIGINAL_FILE,
754
                      isprint);
755

    
756
            //프린트 팝업 옵션
757
            //PrintWindow.BorderThickness = new Thickness(3);
758
            //PrintWindow.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 37, 160, 218));
759
            PrintWindow.ResizeMode = System.Windows.ResizeMode.NoResize;
760
            PrintWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
761
            PrintWindow.Background = new SolidColorBrush(Colors.Black);
762
            PrintWindow.Background.Opacity = 0.6;
763
            PrintWindow.Owner = Application.Current.MainWindow;
764
            Telerik.Windows.Controls.StyleManager.SetTheme(PrintWindow, new Telerik.Windows.Controls.VisualStudio2013Theme());
765
            PrintWindow.ShowDialog();
766
        }
767

    
768
        //강인구 추가
769
        private void PrintEvent(object sender, RoutedEventArgs e)
770
        {
771
            RadRibbonButton button = sender as RadRibbonButton;
772
            Print_Start(button.Content.ToString());
773
        }
774

    
775
        private List<AdornerMember> GetAdornerItem()
776
        {
777
            List<AdornerMember> AdonerList = new List<AdornerMember>();
778

    
779
            if (this.ParentOfType<MainWindow>() != null)
780
            {
781
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
782
                {
783
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
784
                    {
785
                        if (item.GetType().Name == "AdornerFinal")
786
                        {
787
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
788
                            {
789
                                AdonerList.Add(InnerItem);
790
                            }
791
                        }
792
                    }
793
                }
794
            }
795

    
796
            return AdonerList;
797
        }
798
        /// <summary>
799
        /// 투명도
800
        /// </summary>
801
        /// <param name="sender"></param>
802
        /// <param name="e"></param>
803
        //강인구 추가(Undo End)
804
        private void sdOpacity_ValueChanged(object sender, RoutedEventArgs e)
805
        {
806
            List<AdornerMember> AdonerList = GetAdornerItem();
807
            if(AdonerList.Count > 0)
808
            {
809
                UndoDataGroup UndoData = new UndoDataGroup()
810
                {
811
                    IsUndo = false,
812
                    Event = EventType.Operation,
813
                    EventTime = DateTime.Now,
814
                    Opacity = ViewerDataModel.Instance.ControlOpacity,
815
                    MarkupDataColl = new List<UndoData>()
816
                };
817
                UndoData multi_UndoData = new UndoData();
818

    
819
                foreach (AdornerMember InnerItem in AdonerList)
820
                {
821
                    InnerItem.DrawingData.Opacity = ViewerDataModel.Instance.ControlOpacity;
822
                  
823
                    multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
824
                    UndoData.MarkupDataColl.Add(multi_UndoData);
825
                    multi_UndoData = new UndoData();
826
                }
827

    
828
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
829
                {
830
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
831
                });
832
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
833
            }
834
        }
835

    
836
        //강인구 추가(Undo End)
837
        private void cbLineSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
838
        {
839
            if (string.IsNullOrEmpty(cbLineSize.Value.ToString()))
840
            {
841
                cbLineSize.Value = cbLineSize.Minimum;
842
            }
843
            List<AdornerMember> AdonerList = GetAdornerItem();
844
            if (AdonerList.Count > 0)
845
            {
846
                UndoDataGroup UndoData = new UndoDataGroup()
847
                {
848
                    IsUndo = false,
849
                    Event = EventType.Operation,
850
                    EventTime = DateTime.Now,
851
                    LineSize = ViewerDataModel.Instance.LineSize,
852
                    MarkupDataColl = new List<UndoData>()
853
                };
854
                UndoData multi_UndoData = new UndoData();
855

    
856
                foreach (AdornerMember InnerItem in AdonerList)
857
                {
858
                    switch (InnerItem.DrawingData.GetType().Name)
859
                    {
860
                        case ("LineControl"):
861
                            {
862
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).LineSize = ViewerDataModel.Instance.LineSize;
863
                            }
864
                            break;
865
                        case ("ArcControl"):
866
                            {
867
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArcControl).LineSize = ViewerDataModel.Instance.LineSize;
868
                            }
869
                            break;
870
                        case ("ArrowArcControl"):
871
                            {
872
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowArcControl).LineSize = ViewerDataModel.Instance.LineSize;
873
                            }
874
                            break;
875
                        case ("ArrowControl_Multi"):
876
                            {
877
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowControl_Multi).LineSize = ViewerDataModel.Instance.LineSize;
878
                            }
879
                            break;
880
                        case ("CloudControl"):
881
                            {
882
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl).LineSize = ViewerDataModel.Instance.LineSize;
883
                            }
884
                            break;
885
                        case ("PolygonControl"):
886
                            {
887
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.PolygonControl).LineSize = ViewerDataModel.Instance.LineSize;
888
                            }
889
                            break;
890
                        case ("RectangleControl"):
891
                            {
892
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectangleControl).LineSize = ViewerDataModel.Instance.LineSize;
893
                            }
894
                            break;
895
                        case ("RectCloudControl"):
896
                            {
897
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl).LineSize = ViewerDataModel.Instance.LineSize;
898
                            }
899
                            break;
900
                        case ("TriControl"):
901
                            {
902
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.TriControl).LineSize = ViewerDataModel.Instance.LineSize;
903
                            }
904
                            break;
905
                        case ("CircleControl"):
906
                            {
907
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.CircleControl).LineSize = ViewerDataModel.Instance.LineSize;
908
                            }
909
                            break;
910
                        case ("ArrowTextControl"):
911
                            {
912
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).LineSize = ViewerDataModel.Instance.LineSize;
913
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).BorderSize = new Thickness(ViewerDataModel.Instance.LineSize);
914
                            }
915
                            break;
916
                        case ("TextControl"):
917
                            {
918
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).LineSize = new Thickness(ViewerDataModel.Instance.LineSize);
919
                            }
920
                            break;
921
                        case ("InsideWhiteControl"):
922
                            {
923
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.InsideWhiteControl).LineSize = ViewerDataModel.Instance.LineSize;
924
                            }
925
                            break;
926
                        case ("OverlapWhiteControl"):
927
                            {
928
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.OverlapWhiteControl).LineSize = ViewerDataModel.Instance.LineSize;
929
                            }
930
                            break;
931
                        case ("ClipWhiteControl"):
932
                            {
933
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.ClipWhiteControl).LineSize = ViewerDataModel.Instance.LineSize;
934
                            }
935
                            break;
936
                        case ("CoordinateControl"):
937
                            {
938
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.CoordinateControl).LineSize = 10; //ViewerDataModel.Instance.LineSize
939
                            }
940
                            break;
941
                    }
942
                    
943

    
944
                    multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
945
                    UndoData.MarkupDataColl.Add(multi_UndoData);
946
                    multi_UndoData = new UndoData();
947
                }
948

    
949
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
950
                {
951
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
952
                });
953
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
954

    
955
                
956
            }
957
            KCOM.Properties.Settings.Default.LineSize = (double)cbLineSize.Value;
958
            Properties.Settings.Default.Save();
959
        }
960

    
961

    
962
        private void cbIntervalSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
963
        {
964
            if (string.IsNullOrEmpty(cbIntervalSize.Value.ToString()))
965
            {
966
                cbIntervalSize.Value = cbIntervalSize.Minimum;
967
            }
968
            List<AdornerMember> AdonerList = GetAdornerItem();
969
            if (AdonerList.Count > 0)
970
            {
971

    
972
                UndoDataGroup UndoData = new UndoDataGroup()
973
                {
974
                    IsUndo = false,
975
                    Event = EventType.Operation,
976
                    EventTime = DateTime.Now,
977
                    Interval = ViewerDataModel.Instance.Interval,
978
                    MarkupDataColl = new List<UndoData>()
979
                };
980
                UndoData multi_UndoData = new UndoData();
981

    
982
                foreach (AdornerMember InnerItem in AdonerList)
983
                {
984
                    switch (InnerItem.DrawingData.GetType().Name)
985
                    {
986
                        case ("LineControl"):
987
                            {
988
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).Interval = ViewerDataModel.Instance.Interval;
989

    
990
                                multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
991
                                UndoData.MarkupDataColl.Add(multi_UndoData);
992
                                multi_UndoData = new UndoData();
993
                            }
994
                            break;
995
                    }
996
                }
997

    
998
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
999
                {
1000
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
1001
                });
1002
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
1003
            }
1004
            KCOM.Properties.Settings.Default.Interval = (double)cbIntervalSize.Value;
1005
            Properties.Settings.Default.Save();
1006
        }
1007
        
1008
        /// <summary>
1009
        /// ArcLength가 수정되었을때
1010
        /// </summary>
1011
        /// <param name="sender"></param>
1012
        /// <param name="e"></param>
1013
        private void cbArcLength_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
1014
        {
1015
            if (string.IsNullOrEmpty(cbArcLength.Value.ToString()))
1016
            {
1017
                cbArcLength.Value = cbArcLength.Minimum;
1018
            }
1019

    
1020
            List<AdornerMember> AdonerList = GetAdornerItem();
1021
            if (AdonerList.Count > 0)
1022
            {
1023
                var comments = (from drawing in AdonerList
1024
                                select drawing.DrawingData as CommentUserInfo)
1025
                                .Where(x => x is RectCloudControl || x is CloudControl ||
1026
                                x is MarkupToPDF.Controls.Text.TextControl || x is MarkupToPDF.Controls.Text.ArrowTextControl)
1027
                                .ToList();
1028
                UndoCommand.Instance.Push(EventType.Operation, comments);
1029

    
1030
                foreach (AdornerMember InnerItem in AdonerList)
1031
                {
1032
                    switch (InnerItem.DrawingData.GetType().Name)
1033
                    {
1034
                        case ("RectCloudControl"):
1035
                            {
1036
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl;
1037
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
1038
                            }
1039
                        break;
1040
                        case ("CloudControl"):
1041
                        {
1042
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl;
1043
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
1044
                        }
1045
                        break;
1046
                        case ("TextControl"):
1047
                        {
1048
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl;
1049
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
1050
                        }
1051
                        break;
1052
                        case ("ArrowTextControl"):
1053
                        {
1054
                                var item = InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl;
1055
                                item.ArcLength = ViewerDataModel.Instance.ArcLength;
1056
                        }
1057
                        break;
1058
                    }
1059
                }
1060
            }
1061

    
1062
            KCOM.Properties.Settings.Default.ArcLength = (double)cbArcLength.Value;
1063
            Properties.Settings.Default.Save();
1064
        }
1065

    
1066
        //강인구 추가(Undo End)
1067
        private void cbDashStyle_SelectionChanged(object sender, SelectionChangedEventArgs e)
1068
        {
1069
            //강인구 추가
1070
            if (this.ParentOfType<MainWindow>() != null)
1071
            {
1072
                ViewerDataModel.Instance.DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1073
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1074
                {
1075
                    UndoDataGroup UndoData = new UndoDataGroup()
1076
                    {
1077
                        IsUndo = false,
1078
                        Event = EventType.Operation,
1079
                        EventTime = DateTime.Now,
1080
                        DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData,
1081
                        MarkupDataColl = new List<UndoData>()
1082
                    };
1083
                    UndoData multi_UndoData = new UndoData();
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 ("LineControl"):
1094
                                        {
1095
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1096
                                        }
1097
                                        break;
1098
                                    case ("ArcControl"):
1099
                                        {
1100
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArcControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1101
                                        }
1102
                                        break;
1103
                                    case ("ArrowArcControl"):
1104
                                        {
1105
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowArcControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1106
                                        }
1107
                                        break;
1108
                                    case ("ArrowControl_Multi"):
1109
                                        {
1110
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowControl_Multi).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1111
                                        }
1112
                                        break;
1113
                                    case ("CloudControl"):
1114
                                        {
1115
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1116
                                        }
1117
                                        break;
1118
                                    case ("PolygonControl"):
1119
                                        {
1120
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.PolygonControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1121
                                        }
1122
                                        break;
1123
                                    case ("RectangleControl"):
1124
                                        {
1125
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectangleControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1126
                                        }
1127
                                        break;
1128
                                    case ("RectCloudControl"):
1129
                                        {
1130
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1131
                                        }
1132
                                        break;
1133
                                    case ("TriControl"):
1134
                                        {
1135
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.TriControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1136
                                        }
1137
                                        break;
1138
                                    case ("CircleControl"):
1139
                                        {
1140
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.CircleControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1141
                                        }
1142
                                        break;
1143
                                    case ("InsideWhiteControl"):
1144
                                        {
1145
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.InsideWhiteControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1146
                                        }
1147
                                        break;
1148
                                    case ("OverlapWhiteControl"):
1149
                                        {
1150
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.OverlapWhiteControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1151
                                        }
1152
                                        break;
1153
                                    case ("ClipWhiteControl"):
1154
                                        {
1155
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.ClipWhiteControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1156
                                        }
1157
                                        break;
1158
                                    case ("CoordinateControl"):
1159
                                        {
1160
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.CoordinateControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
1161
                                        }
1162
                                        break;
1163
                                }
1164

    
1165
                                multi_UndoData.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
1166
                                UndoData.MarkupDataColl.Add(multi_UndoData);
1167
                                multi_UndoData = new UndoData();
1168
                            }
1169

    
1170
                            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
1171
                            {
1172
                                ViewerDataModel.Instance.UndoDataList.Remove(i);
1173
                            });
1174
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
1175
                        }
1176
                    }
1177
                }
1178
            }
1179
        }
1180

    
1181
        //강인구 추가
1182
        private void comboFontSize_SelectionChanged(object sender, SelectionChangedEventArgs e)
1183
        {
1184
            //if (this.ParentOfType<MainWindow>() != null)
1185
            //{
1186
            //    if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1187
            //    {
1188
            //        foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1189
            //        {
1190
            //            if (item.GetType().Name == "AdornerFinal")
1191
            //            {
1192
            //                foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
1193
            //                {
1194
            //                    switch (InnerItem.DrawingData.GetType().Name)
1195
            //                    {
1196
            //                        case ("TextControl"):
1197
            //                            {
1198
            //                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextSize = int.Parse(comboFontSize.Text);
1199
            //                            }
1200
            //                            break;
1201
            //                        case ("ArrowTextControl"):
1202
            //                            {
1203
            //                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextSize = int.Parse(comboFontSize.Text);
1204
            //                            }
1205
            //                            break;
1206
            //                    }
1207
            //                }
1208
            //            }
1209
            //        }
1210
            //    }
1211
            //}
1212
        }
1213

    
1214
        //강인구 추가
1215
        private void btnBold_Checked(object sender, RoutedEventArgs e)
1216
        {
1217
            if (this.ParentOfType<MainWindow>() != null)
1218
            {
1219
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1220
                {
1221
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1222
                    {
1223
                        if (item.GetType().Name == "AdornerFinal")
1224
                        {
1225
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1226
                            {
1227
                                switch (InnerItem.DrawingData.GetType().Name)
1228
                                {
1229
                                    case ("TextControl"):
1230
                                        {
1231
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight == FontWeights.Bold)
1232
                                            {
1233
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight = FontWeights.Normal;
1234
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1235
                                            }
1236
                                            else
1237
                                            {
1238
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight = FontWeights.Bold;
1239
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1240
                                            }
1241

    
1242
                                        }
1243
                                        break;
1244
                                    case ("ArrowTextControl"):
1245
                                        {
1246
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight == FontWeights.Bold)
1247
                                            {
1248
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight = FontWeights.Normal;
1249
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1250
                                            }
1251
                                            else
1252
                                            {
1253
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight = FontWeights.Bold;
1254
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1255
                                            }
1256
                                        }
1257
                                        break;
1258
                                }
1259
                            }
1260
                        }
1261
                    }
1262
                }
1263
            }
1264
        }
1265

    
1266
        //강인구 추가
1267
        private void btnItalic_Checked(object sender, RoutedEventArgs e)
1268
        {
1269
            if (this.ParentOfType<MainWindow>() != null)
1270
            {
1271
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1272
                {
1273
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1274
                    {
1275
                        if (item.GetType().Name == "AdornerFinal")
1276
                        {
1277
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1278
                            {
1279
                                switch (InnerItem.DrawingData.GetType().Name)
1280
                                {
1281
                                    case ("TextControl"):
1282
                                        {
1283
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle == FontStyles.Italic)
1284
                                            {
1285
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle = System.Windows.FontStyles.Normal;
1286
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1287
                                            }
1288
                                            else
1289
                                            {
1290
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle = FontStyles.Italic;
1291
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1292
                                            }
1293

    
1294
                                        }
1295
                                        break;
1296
                                    case ("ArrowTextControl"):
1297
                                        {
1298
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle == FontStyles.Italic)
1299
                                            {
1300
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle = FontStyles.Normal;
1301
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1302
                                            }
1303
                                            else
1304
                                            {
1305
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle = FontStyles.Italic;
1306
                                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1307
                                            }
1308
                                        }
1309
                                        break;
1310
                                }
1311
                            }
1312
                        }
1313
                    }
1314
                }
1315
            }
1316
        }
1317

    
1318
        //강인구 추가
1319
        private void btnUnderLine_Checked(object sender, RoutedEventArgs e)
1320
        {
1321
            if (this.ParentOfType<MainWindow>() != null)
1322
            {
1323
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1324
                {
1325
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1326
                    {
1327
                        if (item.GetType().Name == "AdornerFinal")
1328
                        {
1329
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1330
                            {
1331
                                switch (InnerItem.DrawingData.GetType().Name)
1332
                                {
1333
                                    case ("TextControl"):
1334
                                        {
1335
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine == TextDecorations.Underline)
1336
                                            {
1337
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine = null;
1338
                                            }
1339
                                            else
1340
                                            {
1341
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine = TextDecorations.Underline;
1342
                                            }
1343
                                        }
1344
                                        break;
1345
                                    case ("ArrowTextControl"):
1346
                                        {
1347
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine == TextDecorations.Underline)
1348
                                            {
1349
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine = null;
1350
                                            }
1351
                                            else
1352
                                            {
1353
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine = TextDecorations.Underline;
1354
                                            }
1355
                                        }
1356
                                        break;
1357
                                }
1358

    
1359
                                ViewerDataModel.Instance.IsMarkupUpdate = true;
1360
                            }
1361
                        }
1362
                    }
1363
                }
1364
            }
1365
        }
1366

    
1367

    
1368
        private void cbLineSize_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1369
        {
1370
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1371
            {
1372
                e.Handled = true;
1373
            }
1374

    
1375
        }
1376

    
1377
        private void cbLineSize_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1378
        {
1379
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1380
            if (regex.IsMatch(e.Text))
1381
            {
1382
                e.Handled = true;
1383
            }
1384

    
1385
        }
1386

    
1387
        private void cbArcLength_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1388
        {
1389
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1390
            {
1391
                e.Handled = true;
1392
            }
1393
        }
1394

    
1395
        private void cbArcLength_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1396
        {
1397
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1398
            if (regex.IsMatch(e.Text))
1399
            {
1400
                e.Handled = true;
1401
            }
1402
        }
1403

    
1404
        private void comboFontSize_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1405
        {
1406
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1407
            {
1408
                e.Handled = true;
1409
            }
1410
        }
1411

    
1412
        private void cbIntervalSize_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
1413
        {
1414
            if (e.Key == Key.Space || e.Key == Key.ImeProcessed)
1415
            {
1416
                e.Handled = true;
1417
            }
1418
        }
1419

    
1420
        private void cbIntervalSize_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1421
        {
1422
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1423
            if (regex.IsMatch(e.Text))
1424
            {
1425
                e.Handled = true;
1426
            }
1427
        }
1428

    
1429
        private void comboFontSize_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
1430
        {
1431
            var regex = new Regex(@"[^a-zA-Z0-9\s]");
1432
            if (regex.IsMatch(e.Text))
1433
            {
1434
                e.Handled = true;
1435
            }
1436
        }
1437

    
1438
        private void comboFontSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
1439
        {
1440
            if (string.IsNullOrEmpty(comboFontSize.Value.ToString()))
1441
            {
1442
                comboFontSize.Value = comboFontSize.Minimum;
1443
            }
1444
            if (this.ParentOfType<MainWindow>() != null)
1445
            {
1446
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1447
                {
1448
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1449
                    {
1450
                        if (item.GetType().Name == "AdornerFinal")
1451
                        {
1452
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1453
                            {
1454
                                switch (InnerItem.DrawingData.GetType().Name)
1455
                                {
1456
                                    case ("TextControl"):
1457
                                        {
1458
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextSize = int.Parse(comboFontSize.Value.ToString());
1459
                                        }
1460
                                        break;
1461
                                    case ("ArrowTextControl"):
1462
                                        {
1463
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextSize = int.Parse(comboFontSize.Value.ToString());
1464
                                        }
1465
                                        break;
1466
                                }
1467
                            }
1468

    
1469
                            ChangeComment(item as Controls.AdornerFinal);
1470
                        }
1471
                    }
1472
                }
1473
            }
1474

    
1475
            KCOM.Properties.Settings.Default.TextSize = (double)comboFontSize.Value;
1476
            Properties.Settings.Default.Save();
1477
        }
1478

    
1479
        //강인구 추가
1480
        private void comboFontFamily_SelectionChanged(object sender, SelectionChangedEventArgs e)
1481
        {
1482
            
1483
            if (comboFontFamily.SelectedItem != null && !IsSuspendChange)
1484
            {
1485
                var main = this.ParentOfType<MainWindow>()?.dzMainMenu;
1486
                var font = comboFontFamily.SelectedItem as Markus.Fonts.MarkusFont;
1487
                var lstTextCtrl = SelectTextControl();
1488

    
1489
                foreach (var item in lstTextCtrl)
1490
                {
1491
                    if (item is MarkupToPDF.Controls.Text.ArrowTextControl ctrl1)
1492
                    {
1493
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1494
                        ctrl1.SetFontFamily(font.FontFamily);
1495
                    }
1496
                    else if (item is MarkupToPDF.Controls.Text.TextControl ctrl2)
1497
                    {
1498
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1499
                        ctrl2.SetFontFamily(font.FontFamily);
1500
                    }
1501
                }
1502

    
1503
                KCOM.Properties.Settings.Default.FontFamily = font.FontFamily.FontName();
1504
                Properties.Settings.Default.Save();
1505
            }
1506
        }
1507

    
1508
        private List<UIElement> SelectTextControl()
1509
        {
1510
            List<UIElement> lstTextCtrl = new List<UIElement>();
1511

    
1512
            var main = this.ParentOfType<MainWindow>()?.dzMainMenu;
1513
            var font = comboFontFamily.SelectedItem as Markus.Fonts.MarkusFont;
1514

    
1515

    
1516
            if (main.SelectLayer.FindChildByType<AdornerFinal>() != null)
1517
            {
1518
                lstTextCtrl.AddRange(main.SelectLayer.FindChildByType<AdornerFinal>().Members.Where(x => x.DrawingData is MarkupToPDF.Controls.Common.ITextControl).Select(x => x.DrawingData));
1519
            }
1520

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

    
1523
            return lstTextCtrl;
1524
        }
1525

    
1526

    
1527
        /// <summary>
1528
        /// 텍스트 컨트롤 하일라이트 처리
1529
        /// </summary>
1530
        /// <param name="sender"></param>
1531
        /// <param name="e"></param>
1532
        private void HighlightEvent(object sender, RoutedEventArgs e)
1533
        {
1534

    
1535
            ViewerDataModel.Instance.checkHighShape = (sender as CheckBox).IsChecked.Value;
1536
            SetHighlightEvent();
1537
            //if ((sender as CheckBox).IsChecked.Value)
1538
            //{
1539
            //    TaskMessage("HighLight가 설정되었습니다", TaskMessageType.Normal);
1540
            //}
1541
            //else
1542
            //{
1543
            //    TaskMessage("HighLight가 해제되었습니다", TaskMessageType.Caption);
1544
            //}
1545
            //if (ViewerDataModel.Instance.SelectedEditor as MarkupToPDF.Controls.Text.TextControl != null)
1546
            //{
1547
            //    MarkupToPDF.Controls.Text.TextControl instance = (ViewerDataModel.Instance.SelectedEditor as MarkupToPDF.Controls.Text.TextControl);
1548
            //    instance.IsHighLight = ViewerDataModel.Instance.checkHighShape;
1549
            //    instance.SetText();
1550
            //}
1551
        }
1552

    
1553
        //추가페이지 이동 엔터
1554
        private void tlcurrentPage_KeyDown(object sender, KeyEventArgs e)
1555
        {
1556
            //강인구 추가 tlcurrentPage을 이상하게 입력할수 있기때문에 Try Catch
1557
            if (e.Key == Key.Enter)
1558
            {
1559
                try
1560
                {
1561
                    var instanceMain = this.ParentOfType<MainWindow>();
1562
                    var max = instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Max(f => f.PageNumber);
1563
                    if (string.IsNullOrEmpty(tlcurrentPage.Text))
1564
                    {
1565
                        RadWindow.Alert(new DialogParameters
1566
                        {
1567
                            Owner = Application.Current.MainWindow,
1568
                            Theme = new VisualStudio2013Theme(),
1569
                            Header = "Info",
1570
                            Content = "Enter the correct page number.",
1571
                        });
1572
                    }
1573
                    else
1574
                    {
1575
                        if (Convert.ToInt32(tlcurrentPage.Text) > max || Convert.ToInt32(tlcurrentPage.Text) == 0)
1576
                        {
1577
                            RadWindow.Alert(new DialogParameters
1578
                            {
1579
                                Owner = Application.Current.MainWindow,
1580
                                Theme = new VisualStudio2013Theme(),
1581
                                Header = "Info",
1582
                                Content = "Enter the correct page number.",
1583
                            });
1584
                        }
1585
                        else
1586
                        {
1587
                            instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text));
1588
                        }
1589
                    }
1590
                    
1591
                }
1592
                catch (Exception)
1593
                {
1594
                    RadWindow.Alert(new DialogParameters
1595
                    {
1596
                        Owner = Application.Current.MainWindow,
1597
                        Theme = new VisualStudio2013Theme(),
1598
                        Header = "Info",
1599
                        Content = "Enter the correct page number.",
1600
                    });
1601
                }
1602
                
1603
            }
1604
        }
1605
        private string previousText;
1606
        private void TlcurrentPage_PreviewTextInput(object sender, TextCompositionEventArgs e)
1607
        {
1608
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("[^0-9]+");
1609
            e.Handled = regex.IsMatch(e.Text);
1610
        }
1611
        private void TlcurrentPage_TextChanged(object sender, TextChangedEventArgs e)
1612
        {
1613
            double num = 0;
1614
            bool success = double.TryParse(((TextBox)sender).Text, out num);
1615
            if (success & num >= 0)
1616
                previousText = ((TextBox)sender).Text;
1617
            else
1618
            {
1619
                if (string.IsNullOrEmpty(((TextBox)sender).Text))
1620
                {
1621
                    ((TextBox)sender).Text = "";
1622
                }
1623
                else
1624
                {
1625

    
1626
                    ((TextBox)sender).Text = previousText;
1627
                }
1628
            }
1629
        }
1630

    
1631
        /// <summary>
1632
        /// 입력한 페이지로 이동한다
1633
        /// </summary>
1634
        /// <param name="sender"></param>
1635
        /// <param name="e"></param>
1636
        private void tlcurrentPage_readonly_KeyDown(object sender, KeyEventArgs e)
1637
        {
1638
            if (e.Key == Key.Enter)
1639
            {
1640
                try
1641
                {
1642
                    var instanceMain = this.ParentOfType<MainWindow>();
1643
                    instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage_readonly.Text));
1644
                }
1645
                catch (Exception)
1646
                {
1647
                    RadWindow.Alert(new DialogParameters
1648
                    {
1649
                        Owner = Application.Current.MainWindow,
1650
                        Theme = new VisualStudio2013Theme(),
1651
                        Header = "Info",
1652
                        Content = "Enter the correct page number.",
1653
                    });
1654
                }
1655
            }
1656
        }
1657
        
1658
        private void PanoramaEvent(object sender, RoutedEventArgs e)
1659
        {
1660
            PanoramaShow();
1661
        }
1662

    
1663
        public void PanoramaShow()
1664
        {
1665
            Panorama check = new Panorama();
1666
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
1667
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
1668
            //double windowWidth = this.Width;
1669
            //double windowHeight = this.Height;
1670

    
1671
            var PanoramaPop = new RadWindow
1672
            {
1673
                //MinWidth = 600,
1674
                //MinHeight = 400,
1675
                //Header = "My Check List",
1676
                Header = "Document No : " + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO + " / Revision :" + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.REVISION,
1677
                Content = check,
1678
                Owner = this,
1679
                ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1680
                //ResizeMode = System.Windows.ResizeMode.NoResize,
1681
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1682
                IsTopmost = false,
1683
                //Left = (screenWidth / 2) - (windowWidth / 2),
1684
                //Top = (screenHeight / 2) - (windowHeight / 2),
1685
                //Left = (screenWidth / 2),
1686
                //Top = (screenHeight / 2),
1687
                Width = screenWidth * 0.4,
1688
                Height = screenHeight * 0.4,
1689
            };
1690
            StyleManager.SetTheme(PanoramaPop, new VisualStudio2013Theme());
1691
            //CheckPop.ShowDialog();
1692
            PanoramaPop.Owner = Application.Current.MainWindow;
1693
            PanoramaPop.Show();
1694
        }
1695

    
1696
        private void CheckEvent(object sender, RoutedEventArgs e)
1697
        {
1698
            //창이 떠있을 경우 재 실행 방지
1699
            if (isClosed)
1700
            {
1701
                //토글 및 마우스 상태 초기화
1702
                var toggleList = this.Parent.ChildrenOfType<RadToggleButton>();
1703
                foreach(var togle in toggleList)
1704
                {
1705
                    togle.IsChecked = false;
1706
                }
1707
                this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1708

    
1709
                isClosed = false;
1710

    
1711
                
1712
                CheckList check = new CheckList(this.ParentOfType<MainWindow>());
1713

    
1714
                CheckPop = new RadWindow
1715
                {
1716
                    MinWidth = 1200,
1717
                    MinHeight = 500,
1718
                    //Header = "My Check List",
1719
                    Header = "Document No : " + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO + " / Revision :" + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.REVISION,
1720
                    Content = check,
1721
                    //Owner = this,
1722
                    //ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1723
                    ResizeMode = System.Windows.ResizeMode.NoResize,
1724
                    WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1725
                    IsTopmost = true,
1726
                };
1727
                StyleManager.SetTheme(CheckPop, new Office2013Theme());
1728
                CheckPop.Closed += CheckPop_Closed;
1729
                
1730
                //CheckPop.ShowDialog();
1731
                CheckPop.Show();
1732
            }
1733
        }
1734

    
1735
        private void SignManagerEvent(object sender,RoutedEventArgs e)
1736
        {
1737
            SignManager signManager = new SignManager();
1738

    
1739
            RadWindow signManagerPop = new RadWindow
1740
            {
1741
                MinWidth = 1200,
1742
                MinHeight = 500,
1743
                //Header = "My Check List",
1744
                Header = "",
1745
                Content = signManager,
1746
                Owner = this,
1747
                //ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1748
                ResizeMode = System.Windows.ResizeMode.CanResize,
1749
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1750
            };
1751
            StyleManager.SetTheme(signManagerPop, new Office2013Theme());
1752

    
1753
            //CheckPop.ShowDialog();
1754
            signManagerPop.ShowDialog();
1755
        }
1756

    
1757
        private void OptionPop_Closed(object sender, WindowClosedEventArgs e)
1758
        {
1759
            isClosed = true;
1760
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
1761
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1762
            ViewerDataModel.Instance.Capture_Opacity = 0;
1763
        }
1764

    
1765
        private void CheckPop_Closed(object sender, WindowClosedEventArgs e)
1766
        {
1767
            isClosed = true;
1768
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
1769
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1770
            ViewerDataModel.Instance.Capture_Opacity = 0;
1771
        }
1772

    
1773
        /// <summary>
1774
        /// 사용자가 선택한 페이지로 이동(썸네일 동기화 시킴)
1775
        /// </summary>
1776
        /// <param name="sender"></param>
1777
        /// <param name="e"></param>
1778
        private void PageGoEvent(object sender, RoutedEventArgs e)
1779
        {
1780
            RadButton button = sender as RadButton;
1781
            var instanceMain = this.ParentOfType<MainWindow>();
1782
            
1783
            //강인구 추가 tlcurrentPage을 이상하게 입력할수 있기때문에 Try Catch
1784
            try
1785
            {
1786
                switch (button.CommandParameter.ToString())
1787
                {
1788
                    case "Down":
1789
                        {
1790
                            instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text) + 1);
1791
                        }
1792
                        break;
1793
                    case "Up":
1794
                        {
1795
                            instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text) - 1);
1796
                        }
1797
                        break;
1798
                }
1799
            }
1800
            catch (Exception)
1801
            {
1802
                RadWindow.Alert(new DialogParameters
1803
                {
1804
                    Owner = Application.Current.MainWindow,
1805
                    Theme = new VisualStudio2013Theme(),
1806
                    Header = "Info",
1807
                    Content = "Enter the correct page number.",
1808
                });
1809
            }
1810
        }
1811

    
1812
        private void viewEvent(object sender, RoutedEventArgs e)
1813
        {
1814
            RadRibbonToggleButton viewButton = sender as RadRibbonToggleButton;
1815
            var instanceMain = this.ParentOfType<MainWindow>();
1816

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

    
1819
            //if ((sender as RadRibbonToggleButton) != null)
1820
            //{
1821
            //    Common.ViewerDataModel.Instance.ControlTag = (sender as RadRibbonToggleButton).Tag.ToString();
1822
            //    instanceToggle = (sender as RadRibbonToggleButton);
1823
            //}
1824

    
1825
            //instanceToggle.IsChecked = false;
1826

    
1827
            switch (viewButton.CommandParameter.ToString())
1828
            {
1829
                case "zoomout":
1830
                    {
1831
                        //장원
1832
                        //instanceMain.dzMainMenu.zoomAndPanControl.ZoomTo(new Rect(0, 0, instanceMain.dzMainMenu.zoomAndPanCanvas.ActualWidth, instanceMain.dzMainMenu.zoomAndPanCanvas.ActualHeight));
1833
                        instanceMain.dzMainMenu.zoomAndPanControl.ZoomPointToViewportCenter(ViewerDataModel.Instance.ContentScale -= 0.1, point);
1834
                        viewButton.IsChecked = false;
1835
                        //Common.ViewerDataModel.Instance.zom
1836
                    }
1837
                    break;
1838
                case "zoomin":
1839
                    {
1840
                        instanceMain.dzMainMenu.zoomAndPanControl.ZoomPointToViewportCenter(ViewerDataModel.Instance.ContentScale += 0.1, point);
1841
                        viewButton.IsChecked = false;
1842
                    }
1843
                    break;
1844
                case "fullscreen":
1845
                    {
1846
                        instanceMain.WindowStyle = WindowStyle.None;
1847
                        instanceMain.WindowState = WindowState.Maximized;
1848
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1849
                        viewButton.IsChecked = false;
1850
                    }
1851
                    break;
1852
                case "fitWidth":
1853
                    {
1854
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1855
                        viewButton.IsChecked = false;
1856
                    }
1857
                    break;
1858
                case "fitHeight":
1859
                    {
1860
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1861
                        viewButton.IsChecked = false;
1862
                    }
1863
                    break;
1864
                case "boundzoom":
1865
                    {
1866

    
1867
                    }
1868
                    break;
1869
                case "Rotate_M":
1870
                    {
1871
                        drawingPannelRotate(false);
1872
                        viewButton.IsChecked = false;
1873
                    }
1874
                    break;
1875
                case "Rotate_P":
1876
                    {
1877
                        drawingPannelRotate(true);
1878
                        viewButton.IsChecked = false;
1879
                    }
1880
                    break;
1881
                case "Rotate_half":
1882
                    {
1883
                        drawingPannelRotate(true);
1884
                        drawingPannelRotate(true);
1885
                        viewButton.IsChecked = false;
1886
                    }
1887
                    break;
1888
            }
1889
        }
1890

    
1891
        private void Control_Event(object sender, RoutedEventArgs e)
1892
        {
1893

    
1894
        }
1895

    
1896
        #region 대기
1897

    
1898
        public void drawingPannelRotate(bool Flag)
1899
        {
1900
            var instanceMain = this.ParentOfType<MainWindow>();
1901

    
1902
            //if (rotateOffSet > 3)
1903
            //    rotateOffSet = 0;
1904

    
1905
            //if (rotateOffSet < 0)
1906
            //    rotateOffSet = 3;
1907

    
1908
            if(Flag)
1909
            {
1910
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
1911
                {
1912
                    instanceMain.dzMainMenu.rotate.Angle = 0;
1913
                }
1914
                else
1915
                {
1916
                    instanceMain.dzMainMenu.rotate.Angle += 90;
1917
                }
1918
            }
1919
            else
1920
            {
1921
                if(instanceMain.dzMainMenu.rotate.Angle == 0)
1922
                {
1923
                    instanceMain.dzMainMenu.rotate.Angle = 270;
1924
                }
1925
                else
1926
                {
1927
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
1928
                }
1929
            }
1930
            //double angle = (double)rotateValue.GetValue(rotateOffSet);
1931
            //instanceMain.dzMainMenu.rotate.Angle = angle;
1932
            var rotationNum = Math.Abs((instanceMain.dzMainMenu.rotate.Angle / 90));
1933

    
1934
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
1935
            {
1936
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1937
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1938
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
1939
            }
1940
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
1941
            {
1942
                instanceMain.dzMainMenu.translate.X = 0;
1943
                instanceMain.dzMainMenu.translate.Y = 0;
1944
            }
1945
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
1946
            {
1947
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1948
                instanceMain.dzMainMenu.translate.Y = 0;
1949
            }
1950
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
1951
            {
1952
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1953
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1954
            }
1955
            else
1956
            {
1957
                instanceMain.dzMainMenu.translate.X = 0;
1958
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1959
            }
1960

    
1961
            //instanceMain.dzMainMenu.zoomAndPanControl.RenderTransformOrigin = new Point(0.5, 0.5);
1962
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
1963
            //대기(강인구)
1964
            //instanceMain.dzMainMenu.imageViewer.RotateAngle = instanceMain.dzMainMenu.rotate.Angle;
1965

    
1966

    
1967
            //instanceMain.dzMainMenu.imageViewer.RenderTransformOrigin = new Point(0.5, 0.5);
1968
            //RotateTransform rotateTransform = new RotateTransform(instanceMain.dzMainMenu.rotate.Angle);
1969
            //instanceMain.dzMainMenu.imageViewer.RenderTransform = rotateTransform;
1970

    
1971

    
1972
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1973
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1974
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
1975
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
1976
            ViewerDataModel.Instance.PageAngle = instanceMain.dzMainMenu.rotate.Angle;
1977
            //ViewerDataModel.Instance.Document_Info.Clear();
1978
            //ViewerDataModel.Instance.Document_Info.Where(i => i.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(value =>
1979
            //{
1980
            //    value.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1981
            //});
1982

    
1983

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

    
1987
            foreach (var data in thumbnaillist)
1988
            {
1989
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1990

    
1991
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
1992
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
1993
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1994

    
1995
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
1996

    
1997
                //rotation page add or update
1998
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
1999
                if (rotationdoc != null)
2000
                {
2001
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
2002
                }
2003
                else
2004
                {
2005
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
2006
                }
2007
            }
2008
        }
2009
        #endregion
2010

    
2011
        private void ImageConverter(RadToggleButton instanceToggle)
2012
        {
2013
            try
2014
            {           
2015
                var instanceMain = this.ParentOfType<MainWindow>();
2016

    
2017
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
2018
                dlg.Filter = "All files (*.*)|*.*|PNG Images (*.png)|*.png";
2019
                Nullable<bool> result = dlg.ShowDialog();
2020
                if (result == true)
2021
                {
2022
                    instanceMain.dzMainMenu.filename = dlg.FileName;
2023
                    instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
2024

    
2025
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(instanceMain.dzMainMenu.filename);
2026
                    String strFile = System.IO.Path.GetFileName(instanceMain.dzMainMenu.filename);
2027
                    long numByte = fileInfo.Length;
2028
                    double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
2029
                    kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
2030
             
2031
                    if (dLen < 4)
2032
                    {
2033
                        System.IO.FileStream fStream = new System.IO.FileStream(instanceMain.dzMainMenu.filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
2034
                        System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
2035
                        byte[] data = br.ReadBytes((int)numByte);
2036
                        br.Close();
2037

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

    
2040
                        Check_Uri.UriCheck(filepath);
2041

    
2042
                        instanceMain.dzMainMenu.filename = filepath;
2043

    
2044
                        fStream.Close();
2045
                        fStream.Dispose();
2046
                    }
2047
                    else
2048
                    {
2049
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
2050
                    }
2051
                }
2052
                else
2053
                {
2054
                    instanceToggle.IsChecked = false;
2055
                    Common.ViewerDataModel.Instance.SelectedControl = "";
2056
                    Common.ViewerDataModel.Instance.ControlTag = null;
2057
                    this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2058
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2059
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("No Image selected.", "Alert");
2060
                }
2061
            }
2062
            catch(Exception ex)
2063
            {
2064
                instanceToggle.IsChecked = false;
2065
                Common.ViewerDataModel.Instance.SelectedControl = "";
2066
                Common.ViewerDataModel.Instance.ControlTag = null;
2067
                this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2068
                this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2069
                App.FileLogger.Error("Image Converter ",ex);
2070

    
2071
                this.ParentOfType<MainWindow>().DialogMessage_Alert(ex.Message, "Alert");
2072
            }
2073
        }
2074

    
2075
        private void Control_Init(RadToggleButton instanceToggle, object sender)
2076
        {
2077

    
2078
        }
2079

    
2080
        private void ControlEvent(object sender, RoutedEventArgs e)
2081
        {
2082
            RadToggleButton instanceToggle = sender as RadToggleButton;
2083
            var instanceMain = this.ParentOfType<MainWindow>();
2084

    
2085
            #region Ctrl + A 눌렀을 때 대처 방법 
2086
            //원인 : Ctrl + A를 누르면 UIElementSet에 등록을 시키지 않는다(이유는 한꺼번에 많은 양의 컨트롤의 동작이 유입되기 때문에
2087
            //       시스템의 성능저하를 불러올 수 있기 때문이다. 그래서 선택 후 다른 컨트롤을 누르면 등록되지 않은 컨트롤이기 때문에 삭제된다
2088
            //       이를 대처하는 방법으로 아래 코드를 사용한다.
2089
            if (Common.ViewerDataModel.Instance.MarkupControls.Count == 0 && Common.ViewerDataModel.Instance.MarkupControls.Count >= 1)
2090
            {
2091
                //var lstItem = instanceMain.DeepLayer._SelectLayer.ChildrenOfType<AdornerFinal>().ToList();
2092
                //foreach (var item in lstItem)
2093
                //{
2094
                //    foreach (var member in item.MemberSet)
2095
                //    {
2096
                //        if (!instanceMain.DeepLayer.UIElementSet.Contains(member.DrawingData))
2097
                //        {
2098
                //            instanceMain.DeepLayer.UIElementSet.Add(member.DrawingData);
2099
                //        }
2100
                //    }
2101
                //}
2102
            }
2103
            #endregion
2104

    
2105
            //if (!instanceMain.IsFreeSelectionMode)
2106
            //{
2107
            //    instanceMain.IsSwingMode = true;
2108
            //}
2109

    
2110
            //#region 다른 컨트롤 버튼 선택 해제
2111
            //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.SelectedControl).Subscribe(ControlState =>
2112
            //{
2113
            //    if (ControlState == null)
2114
            //    {
2115
            //        instanceToggle.IsChecked = false;
2116
            //        HiddenControlHide();
2117
            //    }
2118
            //});
2119
            //#endregion
2120

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

    
2123
            if (instanceToggle != null)
2124
            {
2125
                Common.ViewerDataModel.Instance.ControlTag = instanceToggle.Tag.ToString();
2126
            }
2127
            else if ((sender as RadRibbonToggleButton) != null)
2128
            {
2129
                Common.ViewerDataModel.Instance.ControlTag = (sender as RadRibbonToggleButton).Tag.ToString();
2130
                instanceToggle = (sender as RadRibbonToggleButton);
2131
            }
2132
            else if ((sender as RadRibbonButton) != null)
2133
            {
2134
                RadRibbonButton instanceButton = sender as RadRibbonButton;
2135
                Common.ViewerDataModel.Instance.ControlTag = instanceButton.Tag.ToString();
2136
            }
2137
            else
2138
            {
2139
                RadButton instanceButton = sender as RadButton;
2140
                Common.ViewerDataModel.Instance.ControlTag = instanceButton.Tag.ToString();
2141
            }
2142

    
2143

    
2144
            //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.AngleVisibility).Subscribe(isSee =>
2145
            //{
2146
            //    if (instanceToggle.CommandParameter.ToString() == "ChainLine")
2147
            //    {
2148

    
2149
            //    }
2150
            //    else
2151
            //    {
2152
            //        System.Diagnostics.Debug.WriteLine(" instanceMain.dzMainMenu.MainAngle.Visibility   " + isSee);
2153

    
2154
            //        if (instanceMain.dzMainMenu.MainAngle.Visibility != isSee)
2155
            //        {
2156
            //            instanceMain.dzMainMenu.MainAngle.Visibility = isSee;
2157
            //        }
2158
            //    }
2159
            //    //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.AngleValue).Subscribe(p =>
2160
            //    //{
2161
            //    //    instanceMain.dzMainMenu.MainAngle.AngleValue = p;
2162
            //    //});
2163
            //});
2164

    
2165
            instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2166

    
2167
            instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2168

    
2169
            if (instanceToggle.IsChecked != false)
2170
            {
2171
                string param = instanceToggle.CommandParameter.ToString();
2172
                string MacroIndex = "";
2173

    
2174
                if (param.StartsWith("MACRO"))
2175
                {
2176
                    param = "MACRO";
2177
                    MacroIndex = param.Replace("MACRO;","");
2178

    
2179
                    //Common.ViewerDataModel.Instance.MacroItems = MacroHelper.LoadMacroItems(MacroIndex);
2180
                    //var items = MacroHelper.TopMenuItems();
2181

    
2182
                    Common.ViewerDataModel.Instance.MacroItems = new List<MacroItem>
2183
                    {
2184
                        new MacroItem
2185
                        {
2186
                            Desc = "Cloud Rectangle",
2187
                            ControlType = MarkupToPDF.Controls.Common.ControlType.RectCloud
2188
                        },
2189
                        new MacroItem
2190
                        {
2191
                             Desc = "Arrow TextBox",
2192
                            ControlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl
2193
                        }
2194
                    };
2195
                }
2196

    
2197
                #region 컨트롤이 체크되었다면
2198
                switch (param)
2199
                {
2200
                    #region Line
2201
                    case "Line":
2202
                        Common.ViewerDataModel.Instance.SelectedControl = "Line";
2203
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2204
                        if (instanceToggle.Tag.ToString() == "LineDelete")
2205
                        {
2206
                            //HiddenInterval.Visibility = Visibility.Visible;
2207
                        }
2208
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.SingleLine;
2209
                        break;
2210
                    #endregion
2211
                    #region ChainLine
2212
                    case "ChainLine":
2213
                        Common.ViewerDataModel.Instance.SelectedControl = "ChainLine";
2214
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2215
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ChainLine;
2216
                        break;
2217
                    #endregion
2218
                    #region DimLine
2219
                    case "DimLine":
2220
                        Common.ViewerDataModel.Instance.SelectedControl = "DimLine";
2221
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2222
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.DimLine;
2223
                        break;
2224
                    #endregion
2225
                    #region TwinLine
2226
                    case "TwinLine":
2227
                        Common.ViewerDataModel.Instance.SelectedControl = "TwinLine";
2228
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2229
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TwinLine;
2230
                        break;
2231
                    #endregion
2232
                    #region CancelLine
2233
                    case "CancelLine":
2234
                        Common.ViewerDataModel.Instance.SelectedControl = "CancelLine";
2235
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2236
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.CancelLine;
2237
                        break;
2238
                    #endregion
2239
                    #region PolygonCloud
2240
                    case "PolygonCloud":
2241
                        Common.ViewerDataModel.Instance.SelectedControl = "PolygonCloud";
2242
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2243
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PolygonCloud;
2244
                        break;
2245
                    #endregion
2246
                    #region RectCloud
2247
                    case "RectCloud":
2248
                        Common.ViewerDataModel.Instance.SelectedControl = "RectCloud";
2249
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2250
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.RectCloud;
2251
                        break;
2252
                    #endregion
2253
                    #region Rectangle
2254
                    case "Rectangle":
2255
                        Common.ViewerDataModel.Instance.SelectedControl = "Rectangle";
2256
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2257
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Rectangle;
2258
                        break;
2259
                    #endregion
2260
                    #region Triangle
2261
                    case "Triangle":
2262
                        Common.ViewerDataModel.Instance.SelectedControl = "Triangle";
2263
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2264
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Triangle;
2265
                        break;
2266
                    #endregion
2267
                    #region RectCloud
2268
                    case "Circle":
2269
                        Common.ViewerDataModel.Instance.SelectedControl = "Circle";
2270
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2271
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Circle;
2272
                        break;
2273
                    #endregion
2274
                    #region Symbol
2275
                    case "Symbol":
2276
                        Common.ViewerDataModel.Instance.SelectedControl = "Symbol";
2277
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2278
                        break;
2279
                    #endregion
2280
                    #region SymbolN
2281
                    case "SymbolN":
2282
                        Common.ViewerDataModel.Instance.SelectedControl = "SymbolN";
2283
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Stamp;
2284
                        break;
2285
                    #endregion
2286
                    #region Text
2287
                    case "Text":
2288
                        Common.ViewerDataModel.Instance.SelectedControl = "Text";
2289
                        TaskMessage("Text 도구는 텍스트 영역을 더블 클릭하여 텍스트를 재 편집 할 수 있습니다", TaskMessageType.Normal);
2290
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TextControl;
2291
                        break;
2292
                    #endregion
2293
                    #region TextBorder
2294
                    case "TextBorder":
2295
                        Common.ViewerDataModel.Instance.SelectedControl = "TextBorder";
2296
                        TaskMessage("Text 도구는 텍스트 영역을 더블 클릭하여 텍스트를 재 편집 할 수 있습니다", TaskMessageType.Normal);
2297
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TextBorder;
2298
                        break;
2299
                    #endregion
2300
                    #region TextCloud
2301
                    case "TextCloud":
2302
                        Common.ViewerDataModel.Instance.SelectedControl = "TextCloud";
2303
                        TaskMessage("Text 도구는 텍스트 영역을 더블 클릭하여 텍스트를 재 편집 할 수 있습니다", TaskMessageType.Normal);
2304
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TextCloud;
2305
                        break;
2306
                    #endregion
2307
                    #region Date
2308
                    case "Date":
2309
                        Common.ViewerDataModel.Instance.SelectedControl = "Date";
2310
                        TaskMessage("날짜 컨트롤을 더블 클릭하면 날짜를 변경할 수 있습니다", TaskMessageType.Normal);
2311
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Date;
2312
                        break;
2313
                    #endregion
2314
                    #region ArrowText
2315
                    case "ArrowText":
2316
                        TaskMessage("ArrowText 컨트롤은 그린 후 컨트롤을 선택하였을 시 중간점을 조정할 수 있습니다", TaskMessageType.Normal);
2317
                        if (instanceToggle.Tag.ToString() == "ArrowText_Cloud")
2318
                        {
2319
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowText_Cloud";
2320
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl;
2321
                        }
2322
                        else if (instanceToggle.Tag.ToString() == "ArrowText_Border")
2323
                        {
2324
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTextBorderControl";
2325
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl;
2326
                        }
2327
                        else if (instanceToggle.Tag.ToString() == "ArrowTextFix_Normal")
2328
                        {
2329
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTransTextControl";
2330
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl;
2331
                        }
2332
                        else if (instanceToggle.Tag.ToString() == "ArrowTextFix_Border")
2333
                        {
2334
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTransTextBorderControl";
2335
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl;
2336
                        }
2337
                        else if (instanceToggle.Tag.ToString() == "ArrowTextFix_Cloud")
2338
                        {
2339
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTransTextCloudControl";
2340
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl;
2341
                        }
2342
                        else
2343
                        {
2344
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowText";
2345
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextControl;
2346
                            //HiddenAxisLock.Visibility = Visibility.Visible;
2347
                        }
2348
                        break;
2349
                    #endregion
2350
                    #region Arrow
2351
                    case "Arrow":
2352
                        Common.ViewerDataModel.Instance.SelectedControl = "Arrow";
2353
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2354
                        //HiddenDimSize.Visibility = Visibility.Visible;
2355
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowLine;
2356
                        break;
2357
                    #endregion
2358
                    #region Shape
2359
                    case "Shape":
2360
                        Common.ViewerDataModel.Instance.SelectedControl = "Shape";
2361
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Mark;
2362
                        break;
2363
                    #endregion
2364
                    #region Polygon
2365
                    case "Polygon":
2366
                        Common.ViewerDataModel.Instance.SelectedControl = "Polygon";
2367
                        TaskMessage("자유형 코멘트 도구는 오른쪽 마우스 클릭을 통해 그리기를 마칠 수 있습니다", TaskMessageType.Normal);
2368
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2369
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PolygonControl;
2370
                        break;
2371
                    #endregion
2372
                    #region Arc
2373
                    case "Arc":
2374
                        Common.ViewerDataModel.Instance.SelectedControl = "Arc";
2375
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArcLine;
2376
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2377
                        TaskMessage("Arc 코멘트 도구는 오른쪽 마우스를 사용해 좌우 반전을 사용하실 수 있습니다", TaskMessageType.Normal);
2378
                        break;
2379
                    #endregion
2380
                    #region ArrowArc
2381
                    case "ArrowArc":
2382
                        Common.ViewerDataModel.Instance.SelectedControl = "ArrowArc";
2383
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArcArrow;
2384
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2385
                        TaskMessage("ArcArrow 코멘트 도구는 오른쪽 마우스를 사용해 좌우 반전을 사용하실 수 있습니다", TaskMessageType.Normal);
2386
                        break;
2387
                    #endregion
2388
                    #region ArrowMulti
2389
                    case "ArrowMulti":
2390
                        Common.ViewerDataModel.Instance.SelectedControl = "ArrowMulti";
2391
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowMultiLine;
2392
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2393
                        break;
2394
                    #endregion
2395
                    #region Etc
2396
                    case "Etc":
2397
                        Common.ViewerDataModel.Instance.SelectedControl = "Etc";
2398
                        break;
2399
                    #endregion
2400
                    #region Ink
2401
                    case "Ink":
2402
                        if (instanceToggle.Tag.ToString() == "EraserClear")
2403
                        {
2404
                            TaskMessage("해당 컨트롤은 점 단위로 그려진 펜을 지웁니다", TaskMessageType.Normal);
2405
                            //instanceMain.dzMainMenu.inkDrawingCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
2406
                            instanceMain.dzMainMenu.inkBoard.Tag = "EraseByPoint";
2407
                        }
2408
                        else if (instanceToggle.Tag.ToString() == "Eraser")
2409
                        {
2410
                            TaskMessage("해당 컨트롤은 선 단위로 그려진 펜을 지웁니다", TaskMessageType.Normal);
2411
                            instanceMain.dzMainMenu.inkBoard.Tag = "EraseByStroke";
2412
                            //instanceMain.dzMainMenu.inkDrawingCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
2413
                        }
2414
                        else
2415
                        {
2416
                            instanceMain.dzMainMenu.inkBoard.Tag = "Ink";
2417
                            //instanceMain.dzMainMenu.inkDrawingCanvas.EditingMode = InkCanvasEditingMode.Ink;
2418
                        }
2419

    
2420
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = true;
2421

    
2422
                        Common.ViewerDataModel.Instance.SelectedControl = "Ink";
2423
                        Common.ViewerDataModel.Instance.LineSize = (double)cbLineSize.Value;
2424
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PenControl;
2425
                        break;
2426
                    #endregion
2427
                    #region Select
2428
                    case "Select":
2429
                        if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2430
                        {
2431
                            if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl is MarkupToPDF.Controls.Text.TextControl
2432
                                && !string.IsNullOrEmpty(((MarkupToPDF.Controls.Text.TextControl)this.ParentOfType<MainWindow>().dzMainMenu.currentControl).Text))
2433
                            {
2434
                                DependencyObject focusScope1 = FocusManager.GetFocusScope((MarkupToPDF.Controls.Text.TextControl)this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2435
                                FocusManager.SetFocusedElement(focusScope1, (MarkupToPDF.Controls.Text.TextControl)this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2436

    
2437
                                this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2438
                                Keyboard.ClearFocus();
2439

    
2440
                            }
2441
                            else
2442
                            {
2443
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2444
                                this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2445
                            }
2446
                        }
2447

    
2448
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
2449
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2450
                        instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2451
                        break;
2452
                    #endregion
2453
                    #region Image
2454
                    case "Image":
2455
                        Common.ViewerDataModel.Instance.SelectedControl = "ImgControl";
2456
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
2457
                        ImageConverter(instanceToggle);
2458
                        break;
2459
                    #endregion
2460
                    #region Sign
2461
                    case "Sign":
2462
                        Common.ViewerDataModel.Instance.SelectedControl = "Sign";
2463
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2464
                        //강인구 추가
2465
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Sign;
2466
                        //instanceMain.BaseClient.GetUserSignCompleted += (sen, ea) =>
2467
                        //{
2468
                        //    if (ea.Result == null)
2469
                        //    {
2470

    
2471
                        //        this.ParentOfType<MainPage>().DialogMessage_Alert("You Don't Have Sign Data", "Alert");
2472
                        //    }
2473
                        //    else
2474
                        //    {
2475
                        //        byte[] imageBytes = System.Convert.FromBase64String(ea.Result);
2476
                        //        using (MemoryStream ms = new MemoryStream(imageBytes))
2477
                        //        {
2478
                        //            BitmapImage im = new BitmapImage();
2479
                        //            im.SetSource(ms);
2480
                        //            instanceMain.DeepLayer.SignImage = im;
2481
                        //            ms.Close();
2482
                        //        }
2483
                        //    }
2484
                        //};
2485
                        //instanceMain.BaseClient.GetUserSignAsync(instanceMain._ViewInfo.UserID);
2486
                        break;
2487
                    #endregion
2488
                    #region Check
2489
                    case "Check":
2490
                        Common.ViewerDataModel.Instance.SelectedControl = "Check";
2491
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2492
                        //강인구 추가
2493
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Symbol;
2494
                        break;
2495
                    #endregion
2496
                    #region Batch
2497
                    case "Batch":
2498
                        Common.ViewerDataModel.Instance.SelectedControl = "Batch";
2499
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2500
                        //강인구 추가
2501
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Mark;
2502
                        instanceMain.dzMainMenu.txtBatch.Visibility = Visibility.Visible;
2503
                        instanceMain.dzMainMenu.txtBatch.Text = "Place Mark";
2504
                        break;
2505
                    #endregion
2506

    
2507
                    #region MACRO -MACRO1
2508
                    case "MACRO":
2509
                        Common.ViewerDataModel.Instance.SelectedControl = "MACRO";
2510
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2511

    
2512
                        MacroHelper.MacroAction();
2513

    
2514
                        break;
2515
                    #endregion
2516

    
2517
                    #region Copy
2518
                    case "Copy":
2519
                        CopyCommand.Instance.Execute();
2520
                        //Copy_Start();
2521
                        instanceToggle.IsChecked = false;
2522
                        ViewerDataModel.Instance.SelectedControl = "";
2523
                        ViewerDataModel.Instance.ControlTag = null;
2524
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2525
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2526
                        break;
2527
                    #endregion
2528
                    #region Cut
2529
                    case "Cut":
2530
                        //Cut_Start();
2531
                        CutCommand.Instance.Execute();
2532
                        instanceToggle.IsChecked = false;
2533
                        ViewerDataModel.Instance.SelectedControl = "";
2534
                        ViewerDataModel.Instance.ControlTag = null;
2535
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2536
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2537
                        break;
2538
                    #endregion
2539
                    #region Paste
2540
                    case "Paste":
2541
                        PasteCommand.Instance.Execute();
2542
                        //Paste_Start();
2543
                        instanceToggle.IsChecked = false;
2544
                        ViewerDataModel.Instance.SelectedControl = "";
2545
                        ViewerDataModel.Instance.ControlTag = null;
2546
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2547
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;                        
2548
                        break;
2549
                    #endregion
2550
                    #region Delete
2551
                    case "Delete":
2552
                        UndoCommand.Instance.Push(EventType.Delete, SelectionSet.Instance.SelectedItems);
2553
                        this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Clear();
2554

    
2555
                        instanceToggle.IsChecked = false;
2556
                        ViewerDataModel.Instance.SelectedControl = "";
2557
                        ViewerDataModel.Instance.ControlTag = null;
2558
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2559
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2560
                        break;
2561
                    #endregion
2562
                    #region Undo
2563
                    case "Undo":
2564
                        UndoCommand.Instance.Execute();
2565
                        instanceToggle.IsChecked = false;
2566
                        ViewerDataModel.Instance.SelectedControl = "";
2567
                        ViewerDataModel.Instance.ControlTag = null;
2568
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2569
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2570
                        break;
2571
                    #endregion
2572
                    #region Redo
2573
                    case "Redo":
2574
                        RedoCommand.Instance.Execute();
2575
                        instanceToggle.IsChecked = false;
2576
                        ViewerDataModel.Instance.SelectedControl = "";
2577
                        ViewerDataModel.Instance.ControlTag = null;
2578
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2579
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2580
                        break;
2581
                    #endregion
2582
                    #region DragZoom
2583
                    case "DragZoom":
2584
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.DragZoom;
2585
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2586
                        instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2587
                        break;
2588
                    #endregion
2589
                    #region Grouping
2590
                    case "Group":
2591
                        //var GrouptoggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2592
                        //foreach (var togle in GrouptoggleList)
2593
                        //{
2594
                        //    togle.IsChecked = false;
2595
                        //}
2596

    
2597
                        //if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2598
                        //{
2599
                        //    ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2600
                        //    this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2601
                        //}
2602
                        //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2603
                        //instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2604
                        //instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2605
                        //if (ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
2606
                        //{
2607
                        //    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Please Select Controls", "Alert");
2608
                        //}
2609
                        //else//if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2610
                        //{
2611
                        //    // string MarkupData = "";
2612
                        //    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2613
                        //    {
2614
                        //        if (item.GetType().Name == "AdornerFinal" && (item as AdornerFinal).MemberSet.Count >= 2) // 얘가 2개 이상이여야 그룹가능 버튼도 막을거긴하지만 일단..
2615
                        //        {
2616
                        //            //MARKUP_DATA_GROUP INSERT
2617
                        //            MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2618
                        //            {
2619
                        //                SYMBOL_ID = null,//InnerItem.Symbol_ID
2620
                        //                STATE = 0,
2621
                        //            };
2622
                        //            long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
2623
                        //            //Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
2624
                        //            if (group_id > 0)
2625
                        //            {
2626
                        //                foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
2627
                        //                {
2628
                        //                    if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2629
                        //                    {
2630
                        //                        //MARKUP_DATA UPDATE
2631
                        //                        //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupData((InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID, group_id, App.ViewInfo.ProjectNO);
2632
                        //                        ////Logger.sendReqLog("UpdateMarkupData: ", "", 1);
2633
                        //                        ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().Group_ID = group_id;
2634
                        //                        ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().IsUpdate = true;
2635
                        //                    }
2636
                        //                }
2637
                        //            }
2638
                        //        }
2639
                        //    }
2640
                        //}
2641
                        break;
2642
                    case "UnGroup":
2643
                        //var UnGrouptoggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2644
                        //foreach (var togle in UnGrouptoggleList)
2645
                        //{
2646
                        //    togle.IsChecked = false;
2647
                        //}
2648
                        //if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2649
                        //{
2650
                        //    ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2651
                        //    this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2652
                        //}
2653
                        //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2654
                        //instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2655
                        //instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2656

    
2657
                        //if (ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
2658
                        //{
2659
                        //    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Please Select Controls", "Alert");
2660
                        //}
2661
                        //else//if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2662
                        //{
2663
                        //    // string MarkupData = "";
2664
                        //    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2665
                        //    {
2666
                        //        if (item.GetType().Name == "AdornerFinal" && (item as AdornerFinal).MemberSet.Count >= 1) // 1개 이상 
2667
                        //        {
2668
                        //            //MARKUP_DATA UPDATE
2669
                        //            foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
2670
                        //            {
2671
                        //                if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2672
                        //                {
2673
                        //                    long group_id = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault().Group_ID;
2674
                        //                    //MARKUP_DATA UPDATE
2675
                        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupData((InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID, 0, App.ViewInfo.ProjectNO);
2676
                        //                    ////Logger.sendReqLog("UpdateMarkupData: ", "", 1);
2677
                        //                    ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().Group_ID = 0;
2678
                        //                    ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().IsUpdate = true;
2679

    
2680

    
2681
                        //                    //MARKUP_DATA_GROUP UPDATE
2682
                        //                    //bool value = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupDataGroup(group_id, App.ViewInfo.ProjectNO);
2683
                        //                    ////Logger.sendReqLog("AddMarkupDataGroup: ", value.ToString(), 1);
2684
                        //                }
2685
                        //            }
2686
                        //        }
2687
                        //    }
2688
                        //}
2689
                        break;
2690
                    #endregion
2691
                    #region Capture
2692
                    case "Capture":
2693
                        SyncInit();
2694
                        //   instanceToggle.IsChecked = false;
2695
                        var CaptureList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2696
                        foreach (var togle in CaptureList)
2697
                        {
2698
                            togle.IsChecked = false;
2699
                        }
2700

    
2701
                        if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2702
                        {
2703
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2704
                            this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2705
                        }
2706

    
2707
                        ViewerDataModel.Instance.SelectedControl = "ImgControl";
2708
                   //     ViewerDataModel.Instance.ControlTag = null;
2709
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
2710

    
2711
                        /*
2712
                        //캡쳐 하기 전에 코멘트 저장
2713
                        if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
2714
                        {
2715
                            var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
2716
                            menu.ReleaseAdorner();
2717
                            if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
2718
                            {
2719
                                (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
2720
                            }
2721
                            else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
2722
                            {
2723

    
2724
                            }
2725
                            else
2726
                            {
2727
                                (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
2728
                            }
2729
                        }*/
2730

    
2731
                        //Common.ViewerDataModel.Instance.CheckList_ID = ((e.Source as Telerik.Windows.Controls.RadButton).DataContext as Customer).ID;
2732
                        //Common.ViewerDataModel.Instance.CheckList_ID = ((e.Source as Image).DataContext as Customer).ID;
2733
                        //Common.ViewerDataModel.Instance.PageNumber = ((e.Source as Image).DataContext as Customer).PAGENUMBER;
2734
                        Application.Current.MainWindow.Focus();
2735
                        Common.ViewerDataModel.Instance.Capture_Opacity = 0.49;
2736
                        (Application.Current.MainWindow as MainWindow).dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture;
2737
                        break;
2738
                    #endregion
2739
                    #region Cad
2740
                    case "Inside":
2741
                        //instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2742
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2743
                        Common.ViewerDataModel.Instance.SelectedControl = "InsideWhite";
2744
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.InsideWhite;
2745
                        break;
2746
                    case "Overlap":
2747
                        //instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2748
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2749
                        Common.ViewerDataModel.Instance.SelectedControl = "OverlapWhite";
2750
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.OverlapWhite;
2751
                        break;
2752
                    case "Clip":
2753
                        //instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2754
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2755
                        Common.ViewerDataModel.Instance.SelectedControl = "ClipWhite";
2756
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ClipWhite;
2757
                        break;
2758
                    case "CadExport":
2759
                        //if (isClosed)
2760
                        //{
2761
                        //    //토글 및 마우스 상태 초기화
2762
                        //    var toggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2763
                        //    foreach (var togle in toggleList)
2764
                        //    {
2765
                        //        togle.IsChecked = false;
2766
                        //    }
2767
                        //    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2768

    
2769
                        //    isClosed = false;
2770
                        //    //Control 파일 먼저 생성
2771
                        //    CollapsedButton_Click();
2772
                        //    CadViewer check = new CadViewer();
2773
                        //    check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2774
                        //    check.Title = "Export Viewer";
2775
                        //    //check.Topmost = true;
2776
                        //    check.Show();
2777
                        //    check.Closed += Check_Closed;
2778
                        //    instanceToggle.IsChecked = false;
2779
                        //}
2780
                        //break;
2781
                    case "CadViewer":
2782
                        //if (isClosed)
2783
                        //{
2784
                        //    //토글 및 마우스 상태 초기화
2785
                        //    var toggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2786
                        //    foreach (var togle in toggleList)
2787
                        //    {
2788
                        //        togle.IsChecked = false;
2789
                        //    }
2790
                        //    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2791

    
2792
                        //    isClosed = false;
2793
                        //    CadResultViewer check = new CadResultViewer();
2794
                        //    check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2795
                        //    check.Title = "Viewer";
2796
                        //    check.Show();
2797

    
2798
                        //    check.Closed += Check_Closed;
2799

    
2800
                        //}
2801
                        break;
2802
                    #endregion
2803
                    default:
2804
                        break;
2805
                }
2806
                #endregion
2807
            }
2808
            else
2809
            {
2810
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
2811
                {
2812
                    MacroHelper.Clear();
2813
                }
2814

    
2815
                if (!instanceMain.dzMainMenu.IsFreeSelectionMode)
2816
                {
2817
                    instanceMain.dzMainMenu.IsSwingMode = false;
2818
                    Common.ViewerDataModel.Instance.SelectedControl = "";
2819
                    Common.ViewerDataModel.Instance.ControlTag = null;
2820
                    this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2821
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2822
                }
2823
            }
2824

    
2825
        }
2826

    
2827
        private void SyncInit()
2828
        {
2829
            try
2830
            {
2831
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden)
2832
                {
2833
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true;
2834
                    ViewerDataModel.Instance.PageBalanceMode = false;
2835
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
2836
                    ViewerDataModel.Instance.SyncPageNumber = 0;
2837
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
2838
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed;
2839
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false;
2840
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false;
2841
                }
2842
            }
2843
            catch (Exception ex)
2844
            {
2845
                //Logger.sendResLog("SyncInit", ex.Message, 0);
2846
            }
2847

    
2848
        }
2849

    
2850
        UndoData multi_UndoData = new UndoData();
2851
        CommentUserInfo currentControl { get; set; }
2852
        private void Check_Closed(object sender, EventArgs e)
2853
        {
2854
            isClosed = true;
2855
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
2856
            //토글 및 마우스 상태 초기화
2857
            var toggleList = this.Parent.ChildrenOfType<RadToggleButton>();
2858
            foreach (var togle in toggleList)
2859
            {
2860
                togle.IsChecked = false;
2861
            }
2862
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2863
            ViewerDataModel.Instance.Capture_Opacity = 0;
2864

    
2865
        }
2866

    
2867
        /* public class test 
2868
         {
2869
             public double width { get; set; }
2870
             public double height { get; set; }
2871
         }
2872
         */
2873
        private async void CollapsedButton_Click()
2874
        {
2875
            this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null); // 저장하지 못한 데이터가 있다면 저장
2876

    
2877
            string[] data = new string[0];
2878

    
2879
            int cnt = 0;
2880
            var menu = this.ParentOfType<MainWindow>().dzMainMenu;
2881

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

    
2884
            foreach (var item in gridSelectionItem)
2885
            {
2886
                if ((item.UserID == App.ViewInfo.UserID) && (ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage != null))
2887
                {
2888
                    var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber &&
2889
                    d.MarkupInfoID == item.MarkupInfoID).ToList();
2890
                    data = new string[instance.Count];
2891
                    foreach (var markup in instance)
2892
                    {
2893
                        data[cnt++] = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(markup.Data,ViewerDataModel.Instance.NewMarkupCancelToken());
2894
                    }
2895
                }
2896
            }
2897

    
2898
            if (data != null && KCOM.Properties.Settings.Default.cad == 1)
2899
            {
2900
                string FilePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Cad");
2901
                string FileName = FilePath + "\\commentstring.json"; // Default file name
2902
                if (!File.Exists(FilePath))
2903
                {
2904
                    Directory.CreateDirectory(FilePath);
2905
                }
2906

    
2907
                if (!string.IsNullOrEmpty(FileName))
2908
                {
2909
                    //  File.WriteAllText(SaveDig.FileName, data);
2910
                    File.WriteAllLines(FileName, data);
2911
                }
2912
            }
2913
        }
2914

    
2915
        private double minHeight;
2916
        private double minWidth;
2917

    
2918
        private double maxHeight;
2919
        private double maxWidth;
2920

    
2921
        public bool CanVResize { get; private set; }
2922
        public bool CanHResize { get; private set; }
2923

    
2924
        public void DesignerComponent(FrameworkElement content)
2925
        {
2926
            this.InitializeComponent();
2927

    
2928
            if (!double.IsNaN(content.Width))
2929
            {
2930
                CanHResize = false;
2931
                this.Width = content.Width;
2932
            }
2933
            else
2934
            {
2935
                CanHResize = true;
2936
                this.Width = 23.0;
2937
            }
2938
            if (!double.IsNaN(content.Height))
2939
            {
2940
                CanVResize = false;
2941
                this.Height = content.Height; ;
2942
            }
2943
            else
2944
            {
2945
                CanVResize = true;
2946
                this.Height = 23.0;
2947
            }
2948

    
2949
            minWidth = content.MinWidth < 10.0 ? 10.0 : content.MinWidth;
2950
            minHeight = content.MinHeight < 10.0 ? 10.0 : content.MinHeight;
2951
            maxWidth = content.MaxWidth;
2952
            maxHeight = content.MaxHeight;
2953

    
2954
            double top = (double)content.GetValue(Canvas.TopProperty);
2955
            if (double.IsNaN(top))
2956
                top = 0.0;
2957
            double left = (double)content.GetValue(Canvas.LeftProperty);
2958
            if (double.IsNaN(left))
2959
                left = 0.0;
2960
            SetValue(Canvas.TopProperty, top);
2961
            SetValue(Canvas.LeftProperty, left);
2962

    
2963
            //Set the actual content. Note that "Content" property is a new property. See below
2964
            this.Content = content;
2965
        }
2966
        private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
2967
        {
2968
            string name = ((Thumb)sender).Name;
2969
            if (name.Contains("Top"))
2970
            {
2971
                double newHeight = this.Height - e.VerticalChange;
2972
                if (newHeight >= minHeight && newHeight <= maxHeight)
2973
                {
2974
                    this.Height = newHeight;
2975
                    SetValue(Canvas.TopProperty,
2976
                (double)GetValue(Canvas.TopProperty) + e.VerticalChange);
2977
                }
2978
            }
2979
            if (name.Contains("Right"))
2980
            {
2981
                double newWidth = this.Width + e.HorizontalChange;
2982
                if (newWidth >= minWidth && newWidth <= maxWidth)
2983
                    this.Width = newWidth;
2984
            }
2985
            if (name.Contains("Bottom"))
2986
            {
2987
                double newHeight = this.Height + e.VerticalChange;
2988
                if (newHeight >= minHeight && newHeight <= maxHeight)
2989
                    this.Height = newHeight;
2990
            }
2991
            if (name.Contains("Left"))
2992
            {
2993
                double newWidth = this.Width - e.HorizontalChange;
2994
                if (newWidth >= minWidth && newWidth <= maxWidth)
2995
                {
2996
                    this.Width = newWidth;
2997
                    SetValue(Canvas.LeftProperty,
2998
                (double)GetValue(Canvas.LeftProperty) + e.HorizontalChange);
2999
                }
3000
            }
3001
        }
3002

    
3003
        private void drawControlBorder(object sender)
3004
        {
3005
            System.Windows.Controls.Control control = (System.Windows.Controls.Control)sender;
3006
        }
3007

    
3008
        private void ResizeThumb_DragDelta(object sender, MouseButtonEventArgs e)
3009
        {
3010
            System.Windows.Controls.Control designerItem = (System.Windows.Controls.Control)sender;
3011
            if (designerItem != null)
3012
            {
3013
                double deltaVertical, deltaHorizontal;
3014

    
3015
                switch (VerticalAlignment)
3016
                {
3017
                    case VerticalAlignment.Bottom:
3018
                        deltaVertical = designerItem.ActualHeight - designerItem.MinHeight;
3019
                        designerItem.Height -= deltaVertical;
3020
                        break;
3021
                    case VerticalAlignment.Top:
3022
                        deltaVertical = designerItem.ActualHeight - designerItem.MinHeight;
3023
                        Canvas.SetTop(designerItem, Canvas.GetTop(designerItem) + deltaVertical);
3024
                        designerItem.Height -= deltaVertical;
3025
                        break;
3026
                    default:
3027
                        break;
3028
                }
3029

    
3030
                switch (HorizontalAlignment)
3031
                {
3032
                    case HorizontalAlignment.Left:
3033
                        deltaHorizontal = designerItem.ActualWidth - designerItem.MinWidth;
3034
                        Canvas.SetLeft(designerItem, Canvas.GetLeft(designerItem) + deltaHorizontal);
3035
                        designerItem.Width -= deltaHorizontal;
3036
                        break;
3037
                    case HorizontalAlignment.Right:
3038
                        deltaHorizontal = designerItem.ActualWidth - designerItem.MinWidth;
3039
                        designerItem.Width -= deltaHorizontal;
3040
                        break;
3041
                    default:
3042
                        break;
3043
                }
3044
            }
3045
            e.Handled = true;
3046
        }
3047

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

    
3050
        void ExportMethod()
3051
        {
3052
            //FileDialogFilter filterImage = new FileDialogFilter("Image Files", "*.jpg", "*.png");
3053
            SaveDig.Filter = "PDF file format|*.pdf";
3054
            SaveDig.Title = "Save an DWG File";
3055
            SaveDig.ShowDialog();
3056
        }
3057

    
3058
        private void cbAutoSave_Checked(object sender, RoutedEventArgs e)
3059
        {            
3060
            if (cbAutoSave.IsChecked == true)
3061
            {
3062
                SaveTime(true, (int)cbSaveInterval.Value);
3063
            }
3064
            else
3065
            {
3066
                SaveTime(false, (int)cbSaveInterval.Value);
3067
            }
3068
        }
3069
        private void cbSaveInterval_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
3070
        {
3071
            if(string.IsNullOrEmpty(cbSaveInterval.Value.ToString()))
3072
            {
3073
                cbSaveInterval.Value = cbSaveInterval.Minimum;
3074
            }
3075
            if (cbAutoSave.IsChecked == true)
3076
            {
3077
                SaveTime(true, (int)cbSaveInterval.Value);
3078
            }
3079

    
3080
            KCOM.Properties.Settings.Default.SaveInterval = (double)cbSaveInterval.Value;
3081
            Properties.Settings.Default.Save();
3082
        }
3083
        //강인구 자동 저장 추가
3084
        private void AutoSave(object sender, RoutedEventArgs e)
3085
        {
3086
            RadToggleButton instanceToggle = sender as RadToggleButton;
3087

    
3088
            if(instanceToggle.IsChecked == true)
3089
            {
3090
                SaveTime(true);
3091
            }
3092
            else
3093
            {
3094
                SaveTime(false);
3095
            }
3096
        }
3097

    
3098
        public void Copy_Start()
3099
        {
3100
            if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
3101
            {
3102
                string MarkupData = "";
3103

    
3104
                foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
3105
                {
3106
                    string id = string.Empty;
3107
                    if (item.GetType().Name == "AdornerFinal")
3108
                    {
3109
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
3110

    
3111
                        {
3112
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
3113
                            {
3114
                                MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn res = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
3115
                                id = (InnerItem.Symbol_ID != null) ? "|SymbolID|" + InnerItem.Symbol_ID : "";
3116
                                MarkupData += "|OR|" + res.ConvertData + id;
3117
                            }
3118
                        }
3119

    
3120
                        this.Dispatcher.Invoke(() =>
3121
                        {
3122
                            Clipboard.SetData(DataFormats.StringFormat, MarkupData);
3123
                        }, DispatcherPriority.Background);
3124
                    }
3125
                }
3126
            }
3127
        }
3128

    
3129
        public void Cut_Start()
3130
        {
3131
            if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
3132
            {
3133
                foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
3134
                {
3135
                    string MarkupData = "";
3136

    
3137
                    if (item.GetType().Name == "AdornerFinal")
3138
                    {
3139
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
3140
                        {
3141
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
3142
                            {
3143
                                MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn res = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
3144
                                MarkupData += "|OR|" + res.ConvertData;
3145
                            }
3146
                        }
3147
                        //클립보드에 넣음
3148
                        Clipboard.SetDataObject(MarkupData);
3149
                    }
3150
                }
3151
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Clear();
3152
            }
3153
        }
3154

    
3155
        public async void Paste_Start()
3156
        {
3157
            //마크업 붙여넣기
3158

    
3159
            var markupData = Clipboard.GetData(DataFormats.StringFormat);
3160

    
3161
            if (markupData.GetType() == typeof(string) && markupData.ToString().Contains("|OR||DZ|"))
3162
            {
3163
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
3164

    
3165
                string[] delimiterChars = { "|OR|" };
3166
                string[] data = markupData.ToString().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
3167

    
3168
                SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
3169

    
3170
                UndoData multi_UndoData = new UndoData();
3171

    
3172
                //강인구 Undo/Redo 보류
3173
                MarkupToPDF.Common.UndoDataGroup UndoData = new UndoDataGroup()
3174
                {
3175
                    IsUndo = false,
3176
                    Event = EventType.Create,
3177
                    EventTime = DateTime.Now,
3178
                    MarkupDataColl = new List<UndoData>()
3179
                };
3180

    
3181
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3182
                {
3183
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
3184
                });
3185

    
3186
                foreach (string parse in data)
3187
                {
3188
                    if (parse != "")
3189
                    {
3190
                        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);
3191
                        (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
3192

    
3193
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
3194
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
3195

    
3196
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
3197

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

    
3200
                        UndoData.MarkupDataColl.Add(multi_UndoData);
3201
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);                        
3202
                    }
3203
                }
3204
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
3205

    
3206
                if(this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X < 0)
3207
                {
3208
                    Canvas.SetLeft(final, 0);
3209
                    Canvas.SetTop(final, 0);
3210
                }
3211
                else
3212
                {
3213
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
3214
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
3215
                    final.TranslateItems(realPointX, realPointY);
3216

    
3217
                    if (final.Members.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
3218
                    {
3219
                        final.TranslateItems(0.001, 0.001); //dummy
3220
                    }
3221
                }
3222

    
3223
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
3224
            }
3225
            //외부 이미지 붙여넣기
3226
            else if (Clipboard.GetImage() != null)
3227
            {
3228
                try
3229
                {
3230
                    UndoData multi_UndoData = new UndoData();
3231

    
3232
                    //강인구 Undo/Redo 보류
3233
                    MarkupToPDF.Common.UndoDataGroup UndoData = new UndoDataGroup()
3234
                    {
3235
                        IsUndo = false,
3236
                        Event = EventType.Create,
3237
                        EventTime = DateTime.Now,
3238
                        MarkupDataColl = new List<UndoData>()
3239
                    };
3240

    
3241

    
3242
                    string temppath = System.IO.Path.GetTempPath();
3243
                    //string filename = KCOM.Events.Save.shortCommentKey();
3244
                    string filename = Commons.shortFileKey();
3245

    
3246
                    System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage();
3247
                    clipboardImage.Save(temppath + "\\" + filename);
3248

    
3249
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(temppath + "\\" + filename);
3250
                    String strFile = System.IO.Path.GetFileName(fileInfo.FullName);
3251
                    long numByte = fileInfo.Length;
3252
                    double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
3253
                    kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
3254

    
3255
                    if (dLen < 4)
3256
                    {
3257
                        System.IO.FileStream fStream = new System.IO.FileStream(fileInfo.FullName,
3258
                        System.IO.FileMode.Open, System.IO.FileAccess.Read,FileShare.Read);
3259
                        System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
3260
                        byte[] data = br.ReadBytes((int)numByte);
3261

    
3262
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data);
3263
                        Check_Uri.UriCheck(filename);
3264
                        br.Close();
3265
                        fStream.Close();
3266
                        fStream.Dispose();
3267
                    }
3268
                    else
3269
                    {
3270
                        this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
3271
                        return;
3272
                    }
3273

    
3274
                    fileInfo.Delete();
3275

    
3276
                    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(clipboardImage);
3277
                    IntPtr hBitmap = bmp.GetHbitmap();
3278
                    System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
3279
                    Image img = new Image();
3280
                    if (filename.Contains(".svg"))
3281
                    {
3282
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(filename);
3283
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
3284
                    }
3285
                    else
3286
                    {
3287
                        img.Source = new BitmapImage(new Uri(filename));
3288
                    }
3289

    
3290
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3291
                    {
3292
                        PointSet = new List<Point>(),
3293
                        FilePath = filename,
3294
                        ImageData = img.Source,
3295
                        StartPoint = new Point(100, 100),
3296
                        EndPoint = new Point(200, 200),
3297
                        TopRightPoint = new Point(100, 200),
3298
                        LeftBottomPoint = new Point(200, 100)
3299
                    };
3300

    
3301
                    currentControl.TopRightPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y);
3302
                    currentControl.LeftBottomPoint = new Point(currentControl.StartPoint.X, currentControl.StartPoint.Y + clipboardImage.Height);
3303
                    currentControl.EndPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y + clipboardImage.Height);
3304

    
3305
                    currentControl.PointSet = new List<Point>
3306
                                        {
3307
                                            currentControl.StartPoint,
3308
                                            currentControl.LeftBottomPoint,
3309
                                            currentControl.EndPoint,
3310
                                            currentControl.TopRightPoint,
3311
                                        };
3312

    
3313
                    multi_UndoData = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3314
                    UndoData.MarkupDataColl.Add(multi_UndoData);
3315
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3316

    
3317
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3318
                    currentControl.CommentID = Commons.shortGuid();
3319

    
3320
                    currentControl.ApplyTemplate();
3321
                    currentControl.SetImage();
3322

    
3323
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3324
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3325
                    this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
3326

    
3327
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
3328
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
3329
                    final.TranslateItems(realPointX, realPointY);
3330
                }
3331
                catch(Exception ex)
3332
                {
3333
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("" + ex, "Alert");
3334
                }
3335
            }
3336
        }
3337
    }
3338
}
클립보드 이미지 추가 (최대 크기: 500 MB)