프로젝트

일반

사용자정보

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

markus / KCOM / Events / Implementation / TopMenuEvent.cs @ 00143658

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

1
using KCOM.Common;
2
using KCOM.Common.Converter;
3
using KCOM.Controls;
4
using KCOM.Events;
5
using KCOMDataModel.DataModel;
6
using MarkupToPDF.Common;
7
using Svg2Xaml;
8
using System;
9
using System.Collections.Generic;
10
using System.Linq;
11
using System.Text;
12
using System.Windows;
13
using System.Windows.Controls;
14
using System.Windows.Input;
15
using System.Windows.Media;
16
using System.Windows.Media.Imaging;
17
using Telerik.Windows.Controls;
18
using IKCOM;
19
using Microsoft.Win32;
20
using System.IO;
21
using System.Reflection;
22
using System.Windows.Controls.Primitives;
23
using MarkupToPDF.Controls.Parsing;
24
using Telerik.Windows.Data;
25
using System.ComponentModel;
26
using System.Web;
27

    
28
namespace KCOM.Views
29
{
30
    public partial class TopMenu : UserControl
31
    {
32
        public int rotateOffSet = 0;
33
        private double[] rotateValue = { 0, 90, 180, 270 };
34
        public System.Windows.Threading.DispatcherTimer SaveTimer { get; set; }
35
        public bool isClosed = true;
36
        public RadWindow CheckPop;
37
        public RadWindow OptionPop;
38

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

    
57
        /// <summary>
58
        /// Task Type명을 Key값으로 지정합니다
59
        /// </summary>
60
        public enum TaskMessageType
61
        {
62
            Normal,
63
            Caption,
64
            Error,
65
        }
66

    
67
        private void CheckShapeState()
68
        {
69

    
70

    
71
            if (cbHatchShape.IsChecked == true)
72
            {
73
                cbFillShape.IsChecked = false;
74
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.Hatch;
75
            }
76
            else if(cbFillShape.IsChecked == true)
77
            {
78
                cbHatchShape.IsChecked = false;
79
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.Fill;
80
            }
81
            else
82
            {
83
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.None;
84
            }
85
        }
86

    
87
        /// <summary>
88
        ///  comment의 속성 변경시 저장여부 확인 하도록 undocommand에 추가
89
        /// </summary>
90
        /// <param name="adnoerFinal"></param>
91
        public void ChangeComment(Controls.AdornerFinal adnoerFinal)
92
        {
93
            var adornerMembers = adnoerFinal.Members.Cast<Controls.AdornerMember>();
94

    
95
            if (adornerMembers.Count() > 0)
96
            {
97
                UndoCommand.Instance.Push(adornerMembers.Select(x => x.DrawingData).Cast<CommentUserInfo>().ToList(), adnoerFinal.AngleValue);
98
            }
99
        }
100

    
101
        //강인구 추가(Undo End)
102
        private void SetPaintEvent()
103
        {
104
            List<AdornerMember> AdonerList = GetAdornerItem();
105

    
106
            if (AdonerList.Count > 0)
107
            {
108
                Undo_data UndoData = new Undo_data()
109
                {
110
                    IsUndo = false,
111
                    Event = Event_Type.Option,
112
                    EventTime = DateTime.Now,
113
                    paint = ViewerDataModel.Instance.paintSet,
114
                    Markup_List = new List<Multi_Undo_data>()
115
                };
116
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
117

    
118
                foreach (AdornerMember InnerItem in AdonerList)
119
                {
120
                    multi_Undo_Data.PointSet = new List<Point>();
121

    
122
                    if ((InnerItem.DrawingData as MarkupToPDF.Controls.Common.IShapeControl) != null)
123
                    {
124
                        (InnerItem.DrawingData as MarkupToPDF.Controls.Common.IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
125
                    }
126

    
127
                    multi_Undo_Data.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
128
                    UndoData.Markup_List.Add(multi_Undo_Data);
129
                    multi_Undo_Data = new Multi_Undo_data();
130
                }
131

    
132
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
133
                {
134
                    ViewerDataModel.Instance.UndoDataList.Remove(i);                    
135
                });
136
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
137
            }
138
        }
139

    
140
        private void SetHighlightEvent()
141
        {
142
            List<AdornerMember> AdonerList = GetAdornerItem();
143

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

    
164
        }
165

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

    
183
            //    imgShape_RectCloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/RectCloud.png", UriKind.Relative));
184
            //    imgShape_Cloud.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/Cloud.png", UriKind.Relative));
185
            //    imgShape_Rect.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/Rectangle.png", UriKind.Relative));
186
            //    imgShape_Tri.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/triangle-icon_None.png", UriKind.Relative));
187
            //    imgShape_Cicle.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/circle-icon_None.png", UriKind.Relative));
188
            //    imgShape_Poly.Source = new BitmapImage(new Uri("/DeepView;component/Images/MenuImage/polygon.png", UriKind.Relative));
189
            //    TaskMessage("채우기 옵션이 해제되었습니다", TaskMessageType.Caption);
190
            //}
191
            #endregion
192
            ViewerDataModel.Instance.checkFillShape = (sender as CheckBox).IsChecked.Value;
193

    
194
            if (ViewerDataModel.Instance.checkFillShape)
195
            {
196
                cbHatchShape.IsChecked = false;
197
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.Fill;
198
            }
199
            else
200
            {
201
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.None;
202
            }
203
            SetPaintEvent();
204
        }
205

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

    
237
            //강인구 추가
238
            ViewerDataModel.Instance.checkHatchShape = (sender as CheckBox).IsChecked.Value;
239
            if (ViewerDataModel.Instance.checkHatchShape)
240
            {
241
                cbFillShape.IsChecked = false;
242
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.Hatch;
243
            }
244
            else
245
            {
246
                ViewerDataModel.Instance.paintSet = MarkupToPDF.Controls.Common.PaintSet.None;  
247
            }
248
            SetPaintEvent();
249
        }
250

    
251
        void SaveTimer_Tick(object sender, EventArgs e)
252
        {
253
            //if (this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode != IKCOM.MouseHandlingMode.Drawing)
254
            if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl == null && this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count == 0)
255
            {
256
                SaveEventCallback(null, null);
257
            }
258
        }
259

    
260
        private void SaveTime(bool IsRun)
261
        {
262
            if(SaveTimer == null)
263
            {
264
                SaveTimer = new System.Windows.Threading.DispatcherTimer();
265
                SaveTimer.Interval = new TimeSpan(0, 0, 5);
266
                SaveTimer.Tick += new EventHandler(SaveTimer_Tick);
267
            }
268

    
269
            if (IsRun)
270
            {
271
                SaveTimer.Start();
272
            }
273
            else
274
            {
275
                SaveTimer.Stop();
276
            }
277
        }
278
        private void SaveTime(bool IsRun,int timeinterval)
279
        {
280
            if (SaveTimer == null)
281
            {
282
                SaveTimer = new System.Windows.Threading.DispatcherTimer();
283
                SaveTimer.Interval = new TimeSpan(0, timeinterval, 0);
284
                SaveTimer.Tick += new EventHandler(SaveTimer_Tick);
285
            }
286
            else
287
            {
288
                SaveTimer.Stop();
289
                SaveTimer.Interval = new TimeSpan(0, timeinterval, 0);
290
            }
291

    
292
            if (IsRun)
293
            {
294
                SaveTimer.Start();
295
            }
296
            else
297
            {
298
                SaveTimer.Stop();
299
            }
300
        }
301
        /// <summary>
302
        /// enable busy indicator and then call _SaveEvent method.
303
        /// </summary>
304
        /// <param name="sender"></param>
305
        /// <param name="e"></param>
306
        public async void SaveEventCallback(object sender, RoutedEventArgs e)
307
        {
308
            var mianMenu = this.ParentOfType<MainWindow>().dzMainMenu;
309

    
310
            if (mianMenu.busyIndicator.IsBusy == true)
311
            {
312
                return;
313
            }
314

    
315
            var result = await Dispatcher.InvokeAsync<bool>(()=>
316
            {
317
                this.ParentOfType<MainWindow>().dzMainMenu.busyIndicator.IsBusy = true;
318

    
319
                _SaveEvent(sender, e);
320

    
321
                mianMenu.busyIndicator.IsBusy = false;
322
                return true;
323
            });
324

    
325
            //System.Threading.Tasks.Task SaveTask = System.Threading.Tasks.Task.Factory.StartNew(() =>
326
            //{
327
            //    Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action<object, RoutedEventArgs>(_SaveEvent), sender, e);
328
            //}).ContinueWith(task =>
329
            //{
330
            //    Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate () { this.ParentOfType<MainWindow>().dzMainMenu.busyIndicator.IsBusy = false; }));
331
            //});
332
        }
333

    
334
        /// <summary>
335
        /// save markup
336
        ///  - convert ink control to polygon control if ink control exists
337
        ///  - unselect and update my markup list
338
        /// <param name="sender"></param>
339
        /// <param name="e"></param>
340
        public void _SaveEvent(object sender, RoutedEventArgs e)
341
        {
342
            var mainMenu = this.ParentOfType<MainWindow>().dzMainMenu;
343
            try
344
            {
345
                mainMenu.ConvertInkControlToPolygon();
346

    
347
                SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
348
                // update mylist and gridview
349
                mainMenu.UpdateMyMarkupList();
350

    
351
                if (mainMenu.gridViewMarkup.SelectedItems.Count == 0 && mainMenu.gridViewMarkup.Items.Count > 0)
352
                {
353
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("Please Select Your Comment List Item", "Alert");
354
                }
355
                else
356
                {                    
357
                    foreach (var item in mainMenu.gridViewMarkup.SelectedItems)
358
                    {
359
                        if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
360
                        {
361
                            /// 저장 서비스 호출
362
                            this.ExecuteSaveCommand(mainMenu);
363

    
364
                            ViewerDataModel.Instance._markupInfoList.Where(data => data.MarkupInfoID == (item as IKCOM.MarkupInfoItem).MarkupInfoID).FirstOrDefault().UpdateTime = DateTime.Now;
365
                            if (!ViewerDataModel.Instance.IsConsolidate && (sender != null))
366
                            {
367
                                this.ParentOfType<MainWindow>().DialogMessage_Alert("Save is complete.", "Info");
368
                            }
369
                        }
370
                    }
371
                }
372

    
373
                mainMenu.SetCommentPages();
374

    
375
                ViewerDataModel.Instance.UndoDataList.Clear();
376
            }
377
            catch (Exception ex)
378
            {
379
                System.Diagnostics.Debug.WriteLine("_SaveEvent Error : " + ex.ToString());
380
            }
381
            finally
382
            {
383
                /*
384
                /// delete markup information when 코멘트가 없을 경우
385
                if (ViewerDataModel.Instance.MyMarkupList.Count == 0)
386
                {
387
                    foreach (var item in menu.gridViewMarkup.SelectedItems)
388
                    {
389
                        if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
390
                        {
391
                            //this.ParentOfType<MainWindow>().dzMainMenu.DeleteItem((item as IKCOM.MarkupInfoItem));
392
                        }
393
                    }
394
                }
395
                */
396
            }
397
        }
398

    
399
        /// <summary>
400
        /// call save command
401
        /// </summary>
402
        /// <param name="menu"></param>
403
		private void ExecuteSaveCommand(MainMenu menu)
404
        {
405
            if (menu.pageNavigator.CurrentPage != null)
406
            {
407
                SaveCommand.Instance.Project_No = App.ViewInfo.ProjectNO;
408
                SaveCommand.Instance.document_id = App.ViewInfo.DocumentItemID;
409
                SaveCommand.Instance.user_id = App.ViewInfo.UserID;
410
                SaveCommand.Instance.page_no = menu.pageNavigator.CurrentPage.PageNumber;
411

    
412
                try
413
                {
414
                    if (ViewerDataModel.Instance.UndoDataList.Count > 0)
415
                    {
416
                        List<IKCOM.MarkupInfoItem> SelectedMarkupInfos = new List<IKCOM.MarkupInfoItem>();
417
                        foreach (var item in menu.gridViewMarkup.SelectedItems)
418
                        {
419
                            if ((item as IKCOM.MarkupInfoItem).UserID == App.ViewInfo.UserID)
420
                            {
421
                                SelectedMarkupInfos.Add(item as IKCOM.MarkupInfoItem);
422
                            }
423
                        }
424

    
425
                        SaveCommand.Instance.Execute(SelectedMarkupInfos);
426
                    }
427

    
428
                    if (ViewerDataModel.Instance.RotationDocs.Count > 0)
429
                    {
430
                        SaveCommand.Instance.PageAngleSave(App.ViewInfo.ProjectNO, ViewerDataModel.Instance.RotationDocs);
431
                    }
432
                }
433
                catch (Exception ex)
434
                {
435
                    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(string.Format("세이브 실패:{0}", ex.Message), "Alert");
436
                    throw ex;
437
                }
438
            }
439
            else
440
            {
441
                System.Diagnostics.Debug.WriteLine("ExecuteSaveCommand Error - pageNavigator.CurrentPage null");
442
            }
443
        }
444

    
445
        //강인구 추가
446
        public void Print_Start(string Type)
447
        {
448
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
449
            {
450
                var menu = this.ParentOfType<MainWindow>().dzMainMenu;
451
                SelectionSet.Instance.UnSelect(menu);
452
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
453
                {
454
                    this.SaveEventCallback(null, null);
455
                }
456
                else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
457
                {
458

    
459
                }
460
                else
461
                {
462
                    this.SaveEventCallback(null, null);
463
                }
464
            }
465

    
466
            bool isprint = false;
467
            if (Type == "Print")
468
            {
469
                isprint = true;
470
            }
471

    
472
            RadWindow PrintWindow = new RadWindow();
473
            PrintWindow.Width = 850;
474
            PrintWindow.Height = 600;
475
            PrintWindow.Header = Type;
476

    
477
            List<IKCOM.MarkupInfoItem> markupinfo = new List<IKCOM.MarkupInfoItem>();
478

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

    
481
            if (markupinfo?.Count() > 0)
482
            {
483
                Logger.sendResLog("GetPrintDocItemList", "TRUE", 1);
484
            }
485
            else
486
            {
487
                Logger.sendResLog("GetPrintDocItemList", "FALSE", 1);
488
            }
489

    
490
            /// Tile Source URL을 구한다
491

    
492
            string sImageURL = ViewerDataModel.Instance.SystemMain.dzMainMenu.GetImageURL(App.ViewInfo.DocumentItemID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber);
493
            var url = new Uri(sImageURL);
494
            string sFolder = App.ViewInfo.DocumentItemID.All(char.IsDigit) ? (Convert.ToInt64(App.ViewInfo.DocumentItemID) / 100).ToString() : App.ViewInfo.DocumentItemID.Substring(0, 5);
495
            var Tile_Url = string.Format(@"{0}://{1}:{2}/TileSource/{3}_Tile/{4}/{5}/",
496
                url.Scheme, url.Host, url.Port,
497
                App.ViewInfo.ProjectNO,
498
                sFolder,
499
                App.ViewInfo.DocumentItemID
500
                );
501
            /// up to here
502

    
503
            var docitem = this.ParentOfType<MainWindow>().dzMainMenu._DocItem;
504

    
505
            PrintWindow.Content = new KCOM.Control.PrintControl(
506
                      Tile_Url,
507
                      App.ViewInfo.ProjectNO,
508
                      this.ParentOfType<MainWindow>().dzMainMenu._DocInfo,
509
                      markupinfo,
510
                      this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber,
511
                      docitem.GROUP_NO,
512
                      docitem.DOCUMENT_NO,
513
                      docitem.ORIGINAL_FILE,
514
                      isprint);
515

    
516
            //프린트 팝업 옵션
517
            //PrintWindow.BorderThickness = new Thickness(3);
518
            //PrintWindow.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 37, 160, 218));
519
            PrintWindow.ResizeMode = System.Windows.ResizeMode.NoResize;
520
            PrintWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
521
            PrintWindow.Background = new SolidColorBrush(Colors.Black);
522
            PrintWindow.Background.Opacity = 0.6;
523
            PrintWindow.Owner = Application.Current.MainWindow;
524
            Telerik.Windows.Controls.StyleManager.SetTheme(PrintWindow, new Telerik.Windows.Controls.VisualStudio2013Theme());
525
            PrintWindow.ShowDialog();
526
        }
527

    
528
        //강인구 추가
529
        private void PrintEvent(object sender, RoutedEventArgs e)
530
        {
531
            RadRibbonButton button = sender as RadRibbonButton;
532
            Print_Start(button.Content.ToString());
533
        }
534

    
535
        private List<AdornerMember> GetAdornerItem()
536
        {
537
            List<AdornerMember> AdonerList = new List<AdornerMember>();
538

    
539
            if (this.ParentOfType<MainWindow>() != null)
540
            {
541
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
542
                {
543
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
544
                    {
545
                        if (item.GetType().Name == "AdornerFinal")
546
                        {
547
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
548
                            {
549
                                AdonerList.Add(InnerItem);
550
                            }
551
                        }
552
                    }
553
                }
554
            }
555

    
556
            return AdonerList;
557
        }
558
        /// <summary>
559
        /// 투명도
560
        /// </summary>
561
        /// <param name="sender"></param>
562
        /// <param name="e"></param>
563
        //강인구 추가(Undo End)
564
        private void sdOpacity_ValueChanged(object sender, RoutedEventArgs e)
565
        {
566
            List<AdornerMember> AdonerList = GetAdornerItem();
567
            if(AdonerList.Count > 0)
568
            {
569
                Undo_data UndoData = new Undo_data()
570
                {
571
                    IsUndo = false,
572
                    Event = Event_Type.Option,
573
                    EventTime = DateTime.Now,
574
                    Opacity = ViewerDataModel.Instance.ControlOpacity,
575
                    Markup_List = new List<Multi_Undo_data>()
576
                };
577
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
578

    
579
                foreach (AdornerMember InnerItem in AdonerList)
580
                {
581
                    InnerItem.DrawingData.Opacity = ViewerDataModel.Instance.ControlOpacity;
582
                  
583
                    multi_Undo_Data.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
584
                    UndoData.Markup_List.Add(multi_Undo_Data);
585
                    multi_Undo_Data = new Multi_Undo_data();
586
                }
587

    
588
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
589
                {
590
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
591
                });
592
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
593
            }
594
        }
595

    
596
        //강인구 추가(Undo End)
597
        private void cbLineSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
598
        {
599
            if (string.IsNullOrEmpty(cbLineSize.Value.ToString()))
600
            {
601
                cbLineSize.Value = cbLineSize.Minimum;
602
            }
603
            List<AdornerMember> AdonerList = GetAdornerItem();
604
            if (AdonerList.Count > 0)
605
            {
606
                Undo_data UndoData = new Undo_data()
607
                {
608
                    IsUndo = false,
609
                    Event = Event_Type.Option,
610
                    EventTime = DateTime.Now,
611
                    LineSize = ViewerDataModel.Instance.LineSize,
612
                    Markup_List = new List<Multi_Undo_data>()
613
                };
614
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
615

    
616
                foreach (AdornerMember InnerItem in AdonerList)
617
                {
618
                    switch (InnerItem.DrawingData.GetType().Name)
619
                    {
620
                        case ("LineControl"):
621
                            {
622
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).LineSize = ViewerDataModel.Instance.LineSize;
623
                            }
624
                            break;
625
                        case ("ArcControl"):
626
                            {
627
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArcControl).LineSize = ViewerDataModel.Instance.LineSize;
628
                            }
629
                            break;
630
                        case ("ArrowArcControl"):
631
                            {
632
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowArcControl).LineSize = ViewerDataModel.Instance.LineSize;
633
                            }
634
                            break;
635
                        case ("ArrowControl_Multi"):
636
                            {
637
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowControl_Multi).LineSize = ViewerDataModel.Instance.LineSize;
638
                            }
639
                            break;
640
                        case ("CloudControl"):
641
                            {
642
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl).LineSize = ViewerDataModel.Instance.LineSize;
643
                            }
644
                            break;
645
                        case ("PolygonControl"):
646
                            {
647
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.PolygonControl).LineSize = ViewerDataModel.Instance.LineSize;
648
                            }
649
                            break;
650
                        case ("RectangleControl"):
651
                            {
652
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectangleControl).LineSize = ViewerDataModel.Instance.LineSize;
653
                            }
654
                            break;
655
                        case ("RectCloudControl"):
656
                            {
657
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl).LineSize = ViewerDataModel.Instance.LineSize;
658
                            }
659
                            break;
660
                        case ("TriControl"):
661
                            {
662
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.TriControl).LineSize = ViewerDataModel.Instance.LineSize;
663
                            }
664
                            break;
665
                        case ("CircleControl"):
666
                            {
667
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.CircleControl).LineSize = ViewerDataModel.Instance.LineSize;
668
                            }
669
                            break;
670
                        case ("ArrowTextControl"):
671
                            {
672
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).LineSize = ViewerDataModel.Instance.LineSize;
673
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).BorderSize = new Thickness(ViewerDataModel.Instance.LineSize);
674
                            }
675
                            break;
676
                        case ("TextControl"):
677
                            {
678
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).LineSize = new Thickness(ViewerDataModel.Instance.LineSize);
679
                            }
680
                            break;
681
                        case ("InsideWhiteControl"):
682
                            {
683
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.InsideWhiteControl).LineSize = ViewerDataModel.Instance.LineSize;
684
                            }
685
                            break;
686
                        case ("OverlapWhiteControl"):
687
                            {
688
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.OverlapWhiteControl).LineSize = ViewerDataModel.Instance.LineSize;
689
                            }
690
                            break;
691
                        case ("ClipWhiteControl"):
692
                            {
693
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.ClipWhiteControl).LineSize = ViewerDataModel.Instance.LineSize;
694
                            }
695
                            break;
696
                        case ("CoordinateControl"):
697
                            {
698
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.CoordinateControl).LineSize = 10; //ViewerDataModel.Instance.LineSize
699
                            }
700
                            break;
701
                    }
702
                    
703

    
704
                    multi_Undo_Data.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
705
                    UndoData.Markup_List.Add(multi_Undo_Data);
706
                    multi_Undo_Data = new Multi_Undo_data();
707
                }
708

    
709
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
710
                {
711
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
712
                });
713
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
714

    
715
                
716
            }
717
            KCOM.Properties.Settings.Default.LineSize = (double)cbLineSize.Value;
718
            Properties.Settings.Default.Save();
719
        }
720

    
721

    
722
        private void cbIntervalSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
723
        {
724
            if (string.IsNullOrEmpty(cbIntervalSize.Value.ToString()))
725
            {
726
                cbIntervalSize.Value = cbIntervalSize.Minimum;
727
            }
728
            List<AdornerMember> AdonerList = GetAdornerItem();
729
            if (AdonerList.Count > 0)
730
            {
731

    
732
                Undo_data UndoData = new Undo_data()
733
                {
734
                    IsUndo = false,
735
                    Event = Event_Type.Option,
736
                    EventTime = DateTime.Now,
737
                    Interval = ViewerDataModel.Instance.Interval,
738
                    Markup_List = new List<Multi_Undo_data>()
739
                };
740
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
741

    
742
                foreach (AdornerMember InnerItem in AdonerList)
743
                {
744
                    switch (InnerItem.DrawingData.GetType().Name)
745
                    {
746
                        case ("LineControl"):
747
                            {
748
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).Interval = ViewerDataModel.Instance.Interval;
749

    
750
                                multi_Undo_Data.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
751
                                UndoData.Markup_List.Add(multi_Undo_Data);
752
                                multi_Undo_Data = new Multi_Undo_data();
753
                            }
754
                            break;
755
                    }
756
                }
757

    
758
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
759
                {
760
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
761
                });
762
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
763
            }
764
            KCOM.Properties.Settings.Default.Interval = (double)cbIntervalSize.Value;
765
            Properties.Settings.Default.Save();
766
        }
767
        
768
        private void cbArcLength_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
769
        {
770
            if (string.IsNullOrEmpty(cbArcLength.Value.ToString()))
771
            {
772
                cbArcLength.Value = cbArcLength.Minimum;
773
            }
774
            List<AdornerMember> AdonerList = GetAdornerItem();
775
            if (AdonerList.Count > 0)
776
            {
777

    
778
                //Undo_data UndoData = new Undo_data()
779
                //{
780
                //    IsUndo = false,
781
                //    Event = Event_Type.Option,
782
                //    EventTime = DateTime.Now,
783
                //    Interval = ViewerDataModel.Instance.Interval,
784
                //    Markup_List = new List<Multi_Undo_data>()
785
                //};
786
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
787

    
788
                foreach (AdornerMember InnerItem in AdonerList)
789
                {
790
                    switch (InnerItem.DrawingData.GetType().Name)
791
                    {
792
                        case ("RectCloudControl"):
793
                            {
794
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
795

    
796
                                //multi_Undo_Data.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
797
                                //UndoData.Markup_List.Add(multi_Undo_Data);
798
                                //multi_Undo_Data = new Multi_Undo_data();
799
                            }
800
                            break;
801
                        case ("CloudControl"):
802
                            {
803
                                (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
804

    
805
                                //multi_Undo_Data.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
806
                                //UndoData.Markup_List.Add(multi_Undo_Data);
807
                                //multi_Undo_Data = new Multi_Undo_data();
808
                            }
809
                            break;
810
                    }
811
                }
812

    
813
                //ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
814
                //{
815
                //    ViewerDataModel.Instance.UndoDataList.Remove(i);
816
                //});
817
                //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
818
            }
819

    
820
            KCOM.Properties.Settings.Default.ArcLength = (double)cbArcLength.Value;
821
            Properties.Settings.Default.Save();
822
        }
823

    
824
        //강인구 추가(Undo End)
825
        private void cbDashStyle_SelectionChanged(object sender, SelectionChangedEventArgs e)
826
        {
827
            //강인구 추가
828
            if (this.ParentOfType<MainWindow>() != null)
829
            {
830
                ViewerDataModel.Instance.DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
831
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
832
                {
833
                    Undo_data UndoData = new Undo_data()
834
                    {
835
                        IsUndo = false,
836
                        Event = Event_Type.Option,
837
                        EventTime = DateTime.Now,
838
                        DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData,
839
                        Markup_List = new List<Multi_Undo_data>()
840
                    };
841
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
842

    
843
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
844
                    {
845
                        if (item.GetType().Name == "AdornerFinal")
846
                        {
847
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
848
                            {
849
                                switch (InnerItem.DrawingData.GetType().Name)
850
                                {
851
                                    case ("LineControl"):
852
                                        {
853
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.LineControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
854
                                        }
855
                                        break;
856
                                    case ("ArcControl"):
857
                                        {
858
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArcControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
859
                                        }
860
                                        break;
861
                                    case ("ArrowArcControl"):
862
                                        {
863
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowArcControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
864
                                        }
865
                                        break;
866
                                    case ("ArrowControl_Multi"):
867
                                        {
868
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Line.ArrowControl_Multi).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
869
                                        }
870
                                        break;
871
                                    case ("CloudControl"):
872
                                        {
873
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.CloudControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
874
                                        }
875
                                        break;
876
                                    case ("PolygonControl"):
877
                                        {
878
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Polygon.PolygonControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
879
                                        }
880
                                        break;
881
                                    case ("RectangleControl"):
882
                                        {
883
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectangleControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
884
                                        }
885
                                        break;
886
                                    case ("RectCloudControl"):
887
                                        {
888
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.RectCloudControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
889
                                        }
890
                                        break;
891
                                    case ("TriControl"):
892
                                        {
893
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.TriControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
894
                                        }
895
                                        break;
896
                                    case ("CircleControl"):
897
                                        {
898
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Shape.CircleControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
899
                                        }
900
                                        break;
901
                                    case ("InsideWhiteControl"):
902
                                        {
903
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.InsideWhiteControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
904
                                        }
905
                                        break;
906
                                    case ("OverlapWhiteControl"):
907
                                        {
908
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.OverlapWhiteControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
909
                                        }
910
                                        break;
911
                                    case ("ClipWhiteControl"):
912
                                        {
913
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.ClipWhiteControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
914
                                        }
915
                                        break;
916
                                    case ("CoordinateControl"):
917
                                        {
918
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Cad.CoordinateControl).DashSize = (cbDashStyle.SelectedValue as DashStyle).dashData;
919
                                        }
920
                                        break;
921
                                }
922

    
923
                                multi_Undo_Data.Markup = InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo;
924
                                UndoData.Markup_List.Add(multi_Undo_Data);
925
                                multi_Undo_Data = new Multi_Undo_data();
926
                            }
927

    
928
                            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
929
                            {
930
                                ViewerDataModel.Instance.UndoDataList.Remove(i);
931
                            });
932
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
933
                        }
934
                    }
935
                }
936
            }
937
        }
938

    
939
        //강인구 추가
940
        private void comboFontSize_SelectionChanged(object sender, SelectionChangedEventArgs e)
941
        {
942
            //if (this.ParentOfType<MainWindow>() != null)
943
            //{
944
            //    if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
945
            //    {
946
            //        foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
947
            //        {
948
            //            if (item.GetType().Name == "AdornerFinal")
949
            //            {
950
            //                foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
951
            //                {
952
            //                    switch (InnerItem.DrawingData.GetType().Name)
953
            //                    {
954
            //                        case ("TextControl"):
955
            //                            {
956
            //                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextSize = int.Parse(comboFontSize.Text);
957
            //                            }
958
            //                            break;
959
            //                        case ("ArrowTextControl"):
960
            //                            {
961
            //                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextSize = int.Parse(comboFontSize.Text);
962
            //                            }
963
            //                            break;
964
            //                    }
965
            //                }
966
            //            }
967
            //        }
968
            //    }
969
            //}
970
        }
971

    
972
        //강인구 추가
973
        private void btnBold_Checked(object sender, RoutedEventArgs e)
974
        {
975
            if (this.ParentOfType<MainWindow>() != null)
976
            {
977
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
978
                {
979
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
980
                    {
981
                        if (item.GetType().Name == "AdornerFinal")
982
                        {
983
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
984
                            {
985
                                switch (InnerItem.DrawingData.GetType().Name)
986
                                {
987
                                    case ("TextControl"):
988
                                        {
989
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight == FontWeights.Bold)
990
                                            {
991
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight = FontWeights.Normal;
992
                                            }
993
                                            else
994
                                            {
995
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextWeight = FontWeights.Bold;
996
                                            }
997

    
998
                                        }
999
                                        break;
1000
                                    case ("ArrowTextControl"):
1001
                                        {
1002
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight == FontWeights.Bold)
1003
                                            {
1004
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight = FontWeights.Normal;
1005
                                            }
1006
                                            else
1007
                                            {
1008
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextWeight = FontWeights.Bold;
1009
                                            }
1010
                                        }
1011
                                        break;
1012
                                }
1013
                            }
1014
                        }
1015
                    }
1016
                }
1017
            }
1018
        }
1019

    
1020
        //강인구 추가
1021
        private void btnItalic_Checked(object sender, RoutedEventArgs e)
1022
        {
1023
            if (this.ParentOfType<MainWindow>() != null)
1024
            {
1025
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1026
                {
1027
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1028
                    {
1029
                        if (item.GetType().Name == "AdornerFinal")
1030
                        {
1031
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1032
                            {
1033
                                switch (InnerItem.DrawingData.GetType().Name)
1034
                                {
1035
                                    case ("TextControl"):
1036
                                        {
1037
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle == FontStyles.Italic)
1038
                                            {
1039
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle = System.Windows.FontStyles.Normal;
1040
                                            }
1041
                                            else
1042
                                            {
1043
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextStyle = FontStyles.Italic;
1044
                                            }
1045

    
1046
                                        }
1047
                                        break;
1048
                                    case ("ArrowTextControl"):
1049
                                        {
1050
                                            if((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle == FontStyles.Italic)
1051
                                            {
1052
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle = FontStyles.Normal;
1053
                                            }
1054
                                            else
1055
                                            {
1056
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextStyle = FontStyles.Italic;
1057
                                            }
1058
                                        }
1059
                                        break;
1060
                                }
1061
                            }
1062
                        }
1063
                    }
1064
                }
1065
            }
1066
        }
1067

    
1068
        //강인구 추가
1069
        private void btnUnderLine_Checked(object sender, RoutedEventArgs e)
1070
        {
1071
            if (this.ParentOfType<MainWindow>() != null)
1072
            {
1073
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1074
                {
1075
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1076
                    {
1077
                        if (item.GetType().Name == "AdornerFinal")
1078
                        {
1079
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1080
                            {
1081
                                switch (InnerItem.DrawingData.GetType().Name)
1082
                                {
1083
                                    case ("TextControl"):
1084
                                        {
1085
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine == TextDecorations.Underline)
1086
                                            {
1087
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine = null;
1088
                                            }
1089
                                            else
1090
                                            {
1091
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).UnderLine = TextDecorations.Underline;
1092
                                            }
1093
                                        }
1094
                                        break;
1095
                                    case ("ArrowTextControl"):
1096
                                        {
1097
                                            if ((InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine == TextDecorations.Underline)
1098
                                            {
1099
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine = null;
1100
                                            }
1101
                                            else
1102
                                            {
1103
                                                (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).UnderLine = TextDecorations.Underline;
1104
                                            }
1105
                                        }
1106
                                        break;
1107
                                }
1108
                            }
1109
                        }
1110
                    }
1111
                }
1112
            }
1113
        }
1114

    
1115
        private void AxisLockEvent(object sender, RoutedEventArgs e)
1116
        {
1117
            ViewerDataModel.Instance.checkAxis = cbAxisLock.IsChecked.Value;
1118
        }
1119

    
1120
        private void comboFontSize_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
1121
        {
1122
            if (string.IsNullOrEmpty(comboFontSize.Value.ToString()))
1123
            {
1124
                comboFontSize.Value = comboFontSize.Minimum;
1125
            }
1126
            if (this.ParentOfType<MainWindow>() != null)
1127
            {
1128
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
1129
                {
1130
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1131
                    {
1132
                        if (item.GetType().Name == "AdornerFinal")
1133
                        {
1134
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
1135
                            {
1136
                                switch (InnerItem.DrawingData.GetType().Name)
1137
                                {
1138
                                    case ("TextControl"):
1139
                                        {
1140
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).TextSize = int.Parse(comboFontSize.Value.ToString());
1141
                                        }
1142
                                        break;
1143
                                    case ("ArrowTextControl"):
1144
                                        {
1145
                                            (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).TextSize = int.Parse(comboFontSize.Value.ToString());
1146
                                        }
1147
                                        break;
1148
                                }
1149
                            }
1150

    
1151
                            ChangeComment(item as Controls.AdornerFinal);
1152
                        }
1153
                    }
1154
                }
1155
            }
1156

    
1157
            KCOM.Properties.Settings.Default.TextSize = (double)comboFontSize.Value;
1158
            Properties.Settings.Default.Save();
1159
        }
1160

    
1161
        //강인구 추가
1162
        private void RadRibbonComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
1163
        {
1164
            if (this.ParentOfType<MainWindow>()?.dzMainMenu.SelectLayer.Children.Count > 0)
1165
            {
1166
                foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
1167
                {
1168
                    if (item.GetType().Name == "AdornerFinal")
1169
                    {
1170
                        var adnoerFinal = (item as Controls.AdornerFinal);
1171

    
1172
                        var adornerMembers = adnoerFinal.Members.Cast<Controls.AdornerMember>();
1173

    
1174
                        foreach (var InnerItem in adornerMembers)
1175
                        {
1176
                            switch (InnerItem.DrawingData.GetType().Name)
1177
                            {
1178
                                case ("TextControl"):
1179
                                        (InnerItem.DrawingData as MarkupToPDF.Controls.Text.TextControl).SetFontFamily(new FontFamily(comboFontFamily.Text));
1180
                                        break;
1181
                                case ("ArrowTextControl"):
1182
                                        (InnerItem.DrawingData as MarkupToPDF.Controls.Text.ArrowTextControl).SetFontFamily(new FontFamily(comboFontFamily.Text));
1183
                                    break;
1184
                            }
1185
                        }
1186

    
1187
                        ChangeComment(adnoerFinal);
1188
                    }
1189
                }
1190
            }
1191

    
1192
            KCOM.Properties.Settings.Default.FontFamily = comboFontFamily.Text;
1193
            Properties.Settings.Default.Save();
1194
        }
1195

    
1196

    
1197
        /// <summary>
1198
        /// 텍스트 컨트롤 하일라이트 처리
1199
        /// </summary>
1200
        /// <param name="sender"></param>
1201
        /// <param name="e"></param>
1202
        private void HighlightEvent(object sender, RoutedEventArgs e)
1203
        {
1204

    
1205
            ViewerDataModel.Instance.checkHighShape = (sender as CheckBox).IsChecked.Value;
1206
            SetHighlightEvent();
1207
            //if ((sender as CheckBox).IsChecked.Value)
1208
            //{
1209
            //    TaskMessage("HighLight가 설정되었습니다", TaskMessageType.Normal);
1210
            //}
1211
            //else
1212
            //{
1213
            //    TaskMessage("HighLight가 해제되었습니다", TaskMessageType.Caption);
1214
            //}
1215
            //if (ViewerDataModel.Instance.SelectedEditor as MarkupToPDF.Controls.Text.TextControl != null)
1216
            //{
1217
            //    MarkupToPDF.Controls.Text.TextControl instance = (ViewerDataModel.Instance.SelectedEditor as MarkupToPDF.Controls.Text.TextControl);
1218
            //    instance.IsHighLight = ViewerDataModel.Instance.checkHighShape;
1219
            //    instance.SetText();
1220
            //}
1221
        }
1222

    
1223
        //추가페이지 이동 엔터
1224
        private void tlcurrentPage_KeyDown(object sender, KeyEventArgs e)
1225
        {
1226
            //강인구 추가 tlcurrentPage을 이상하게 입력할수 있기때문에 Try Catch
1227
            if (e.Key == Key.Enter)
1228
            {
1229
                try
1230
                {
1231
                    var instanceMain = this.ParentOfType<MainWindow>();
1232
                    var max = instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Max(f => f.PageNumber);
1233
                    if (string.IsNullOrEmpty(tlcurrentPage.Text))
1234
                    {
1235
                        RadWindow.Alert(new DialogParameters
1236
                        {
1237
                            Owner = Application.Current.MainWindow,
1238
                            Theme = new VisualStudio2013Theme(),
1239
                            Header = "Info",
1240
                            Content = "Enter the correct page number.",
1241
                        });
1242
                    }
1243
                    else
1244
                    {
1245
                        if (Convert.ToInt32(tlcurrentPage.Text) > max || Convert.ToInt32(tlcurrentPage.Text) == 0)
1246
                        {
1247
                            RadWindow.Alert(new DialogParameters
1248
                            {
1249
                                Owner = Application.Current.MainWindow,
1250
                                Theme = new VisualStudio2013Theme(),
1251
                                Header = "Info",
1252
                                Content = "Enter the correct page number.",
1253
                            });
1254
                        }
1255
                        else
1256
                        {
1257
                            instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text));
1258
                        }
1259
                    }
1260
                    
1261
                }
1262
                catch (Exception)
1263
                {
1264
                    RadWindow.Alert(new DialogParameters
1265
                    {
1266
                        Owner = Application.Current.MainWindow,
1267
                        Theme = new VisualStudio2013Theme(),
1268
                        Header = "Info",
1269
                        Content = "Enter the correct page number.",
1270
                    });
1271
                }
1272
                
1273
            }
1274
        }
1275
        private string previousText;
1276
        private void TlcurrentPage_PreviewTextInput(object sender, TextCompositionEventArgs e)
1277
        {
1278
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("[^0-9]+");
1279
            e.Handled = regex.IsMatch(e.Text);
1280
        }
1281
        private void TlcurrentPage_TextChanged(object sender, TextChangedEventArgs e)
1282
        {
1283
            double num = 0;
1284
            bool success = double.TryParse(((TextBox)sender).Text, out num);
1285
            if (success & num >= 0)
1286
                previousText = ((TextBox)sender).Text;
1287
            else
1288
            {
1289
                if (string.IsNullOrEmpty(((TextBox)sender).Text))
1290
                {
1291
                    ((TextBox)sender).Text = "";
1292
                }
1293
                else
1294
                {
1295

    
1296
                    ((TextBox)sender).Text = previousText;
1297
                }
1298
            }
1299
        }
1300

    
1301
        /// <summary>
1302
        /// 입력한 페이지로 이동한다
1303
        /// </summary>
1304
        /// <param name="sender"></param>
1305
        /// <param name="e"></param>
1306
        private void tlcurrentPage_readonly_KeyDown(object sender, KeyEventArgs e)
1307
        {
1308
            if (e.Key == Key.Enter)
1309
            {
1310
                try
1311
                {
1312
                    var instanceMain = this.ParentOfType<MainWindow>();
1313
                    instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage_readonly.Text));
1314
                }
1315
                catch (Exception)
1316
                {
1317
                    RadWindow.Alert(new DialogParameters
1318
                    {
1319
                        Owner = Application.Current.MainWindow,
1320
                        Theme = new VisualStudio2013Theme(),
1321
                        Header = "Info",
1322
                        Content = "Enter the correct page number.",
1323
                    });
1324
                }
1325
            }
1326
        }
1327
        
1328
        private void PanoramaEvent(object sender, RoutedEventArgs e)
1329
        {
1330
            PanoramaShow();
1331
        }
1332

    
1333
        public void PanoramaShow()
1334
        {
1335
            Panorama check = new Panorama();
1336
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
1337
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
1338
            //double windowWidth = this.Width;
1339
            //double windowHeight = this.Height;
1340

    
1341
            var PanoramaPop = new RadWindow
1342
            {
1343
                //MinWidth = 600,
1344
                //MinHeight = 400,
1345
                //Header = "My Check List",
1346
                Header = "Document No : " + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO + " / Revision :" + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.REVISION,
1347
                Content = check,
1348
                Owner = this,
1349
                ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1350
                //ResizeMode = System.Windows.ResizeMode.NoResize,
1351
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1352
                IsTopmost = false,
1353
                //Left = (screenWidth / 2) - (windowWidth / 2),
1354
                //Top = (screenHeight / 2) - (windowHeight / 2),
1355
                //Left = (screenWidth / 2),
1356
                //Top = (screenHeight / 2),
1357
                Width = screenWidth * 0.4,
1358
                Height = screenHeight * 0.4,
1359
            };
1360
            StyleManager.SetTheme(PanoramaPop, new VisualStudio2013Theme());
1361
            //CheckPop.ShowDialog();
1362
            PanoramaPop.Owner = Application.Current.MainWindow;
1363
            PanoramaPop.Show();
1364
        }
1365

    
1366
        private void CheckEvent(object sender, RoutedEventArgs e)
1367
        {
1368
            //창이 떠있을 경우 재 실행 방지
1369
            if (isClosed)
1370
            {
1371
                //토글 및 마우스 상태 초기화
1372
                var toggleList = this.Parent.ChildrenOfType<RadToggleButton>();
1373
                foreach(var togle in toggleList)
1374
                {
1375
                    togle.IsChecked = false;
1376
                }
1377
                this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1378

    
1379
                isClosed = false;
1380

    
1381
                
1382
                CheckList check = new CheckList(this.ParentOfType<MainWindow>());
1383

    
1384
                CheckPop = new RadWindow
1385
                {
1386
                    MinWidth = 1200,
1387
                    MinHeight = 500,
1388
                    //Header = "My Check List",
1389
                    Header = "Document No : " + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO + " / Revision :" + this.ParentOfType<MainWindow>().dzMainMenu._DocItem.REVISION,
1390
                    Content = check,
1391
                    //Owner = this,
1392
                    //ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip,
1393
                    ResizeMode = System.Windows.ResizeMode.NoResize,
1394
                    WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
1395
                    IsTopmost = true,
1396
                };
1397
                StyleManager.SetTheme(CheckPop, new Office2013Theme());
1398
                CheckPop.Closed += CheckPop_Closed;
1399
                
1400
                //CheckPop.ShowDialog();
1401
                CheckPop.Show();
1402
            }
1403
        }
1404

    
1405
        private void OptionPop_Closed(object sender, WindowClosedEventArgs e)
1406
        {
1407
            isClosed = true;
1408
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
1409
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1410
            ViewerDataModel.Instance.Capture_Opacity = 0;
1411
        }
1412

    
1413
        private void CheckPop_Closed(object sender, WindowClosedEventArgs e)
1414
        {
1415
            isClosed = true;
1416
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
1417
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1418
            ViewerDataModel.Instance.Capture_Opacity = 0;
1419
        }
1420

    
1421
        /// <summary>
1422
        /// 사용자가 선택한 페이지로 이동(썸네일 동기화 시킴)
1423
        /// </summary>
1424
        /// <param name="sender"></param>
1425
        /// <param name="e"></param>
1426
        private void PageGoEvent(object sender, RoutedEventArgs e)
1427
        {
1428
            RadButton button = sender as RadButton;
1429
            var instanceMain = this.ParentOfType<MainWindow>();
1430
            
1431
            //강인구 추가 tlcurrentPage을 이상하게 입력할수 있기때문에 Try Catch
1432
            try
1433
            {
1434
                switch (button.CommandParameter.ToString())
1435
                {
1436
                    case "Down":
1437
                        {
1438
                            instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text) + 1);
1439
                        }
1440
                        break;
1441
                    case "Up":
1442
                        {
1443
                            instanceMain.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(tlcurrentPage.Text) - 1);
1444
                        }
1445
                        break;
1446
                }
1447
            }
1448
            catch (Exception)
1449
            {
1450
                RadWindow.Alert(new DialogParameters
1451
                {
1452
                    Owner = Application.Current.MainWindow,
1453
                    Theme = new VisualStudio2013Theme(),
1454
                    Header = "Info",
1455
                    Content = "Enter the correct page number.",
1456
                });
1457
            }
1458
        }
1459

    
1460
        private void viewEvent(object sender, RoutedEventArgs e)
1461
        {
1462
            RadRibbonToggleButton viewButton = sender as RadRibbonToggleButton;
1463
            var instanceMain = this.ParentOfType<MainWindow>();
1464

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

    
1467
            //if ((sender as RadRibbonToggleButton) != null)
1468
            //{
1469
            //    Common.ViewerDataModel.Instance.ControlTag = (sender as RadRibbonToggleButton).Tag.ToString();
1470
            //    instanceToggle = (sender as RadRibbonToggleButton);
1471
            //}
1472

    
1473
            //instanceToggle.IsChecked = false;
1474

    
1475
            switch (viewButton.CommandParameter.ToString())
1476
            {
1477
                case "zoomout":
1478
                    {
1479
                        //장원
1480
                        //instanceMain.dzMainMenu.zoomAndPanControl.ZoomTo(new Rect(0, 0, instanceMain.dzMainMenu.zoomAndPanCanvas.ActualWidth, instanceMain.dzMainMenu.zoomAndPanCanvas.ActualHeight));
1481
                        instanceMain.dzMainMenu.zoomAndPanControl.ZoomPointToViewportCenter(ViewerDataModel.Instance.ContentScale -= 0.1, point);
1482
                        viewButton.IsChecked = false;
1483
                        //Common.ViewerDataModel.Instance.zom
1484
                    }
1485
                    break;
1486
                case "zoomin":
1487
                    {
1488
                        instanceMain.dzMainMenu.zoomAndPanControl.ZoomPointToViewportCenter(ViewerDataModel.Instance.ContentScale += 0.1, point);
1489
                        viewButton.IsChecked = false;
1490
                    }
1491
                    break;
1492
                case "fullscreen":
1493
                    {
1494
                        instanceMain.WindowState = WindowState.Maximized;
1495
                        //Sizemode 대기(강인구)
1496
                        //instanceMain.dzMainMenu.imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
1497
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1498
                        viewButton.IsChecked = false;
1499
                    }
1500
                    break;
1501
                case "fitWidth":
1502
                    {
1503
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1504
                        viewButton.IsChecked = false;
1505
                    }
1506
                    break;
1507
                case "fitHeight":
1508
                    {
1509
                        instanceMain.dzMainMenu.zoomAndPanControl.ScaleToFit();
1510
                        viewButton.IsChecked = false;
1511
                    }
1512
                    break;
1513
                case "boundzoom":
1514
                    {
1515

    
1516
                    }
1517
                    break;
1518
                case "Rotate_M":
1519
                    {
1520
                        drawingPannelRotate(false);
1521
                        viewButton.IsChecked = false;
1522
                    }
1523
                    break;
1524
                case "Rotate_P":
1525
                    {
1526
                        drawingPannelRotate(true);
1527
                        viewButton.IsChecked = false;
1528
                    }
1529
                    break;
1530
                case "Rotate_half":
1531
                    {
1532
                        drawingPannelRotate(true);
1533
                        drawingPannelRotate(true);
1534
                        viewButton.IsChecked = false;
1535
                    }
1536
                    break;
1537
            }
1538
        }
1539

    
1540
        private void Control_Event(object sender, RoutedEventArgs e)
1541
        {
1542

    
1543
        }
1544

    
1545
        #region 대기
1546

    
1547
        public void drawingPannelRotate(bool Flag)
1548
        {
1549
            var instanceMain = this.ParentOfType<MainWindow>();
1550

    
1551
            //if (rotateOffSet > 3)
1552
            //    rotateOffSet = 0;
1553

    
1554
            //if (rotateOffSet < 0)
1555
            //    rotateOffSet = 3;
1556

    
1557
            if(Flag)
1558
            {
1559
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
1560
                {
1561
                    instanceMain.dzMainMenu.rotate.Angle = 0;
1562
                }
1563
                else
1564
                {
1565
                    instanceMain.dzMainMenu.rotate.Angle += 90;
1566
                }
1567
            }
1568
            else
1569
            {
1570
                if(instanceMain.dzMainMenu.rotate.Angle == 0)
1571
                {
1572
                    instanceMain.dzMainMenu.rotate.Angle = 270;
1573
                }
1574
                else
1575
                {
1576
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
1577
                }
1578
            }
1579
            //double angle = (double)rotateValue.GetValue(rotateOffSet);
1580
            //instanceMain.dzMainMenu.rotate.Angle = angle;
1581
            var rotationNum = Math.Abs((instanceMain.dzMainMenu.rotate.Angle / 90));
1582

    
1583
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
1584
            {
1585
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1586
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1587
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
1588
            }
1589
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
1590
            {
1591
                instanceMain.dzMainMenu.translate.X = 0;
1592
                instanceMain.dzMainMenu.translate.Y = 0;
1593
            }
1594
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
1595
            {
1596
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1597
                instanceMain.dzMainMenu.translate.Y = 0;
1598
            }
1599
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
1600
            {
1601
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1602
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1603
            }
1604
            else
1605
            {
1606
                instanceMain.dzMainMenu.translate.X = 0;
1607
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1608
            }
1609

    
1610
            //instanceMain.dzMainMenu.zoomAndPanControl.RenderTransformOrigin = new Point(0.5, 0.5);
1611
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
1612
            //대기(강인구)
1613
            //instanceMain.dzMainMenu.imageViewer.RotateAngle = instanceMain.dzMainMenu.rotate.Angle;
1614

    
1615

    
1616
            //instanceMain.dzMainMenu.imageViewer.RenderTransformOrigin = new Point(0.5, 0.5);
1617
            //RotateTransform rotateTransform = new RotateTransform(instanceMain.dzMainMenu.rotate.Angle);
1618
            //instanceMain.dzMainMenu.imageViewer.RenderTransform = rotateTransform;
1619

    
1620

    
1621
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
1622
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
1623
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
1624
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
1625
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
1626
            //ViewerDataModel.Instance.Document_Info.Clear();
1627
            //ViewerDataModel.Instance.Document_Info.Where(i => i.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(value =>
1628
            //{
1629
            //    value.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1630
            //});
1631

    
1632

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

    
1636
            foreach (var data in thumbnaillist)
1637
            {
1638
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1639

    
1640
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
1641
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
1642
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
1643

    
1644
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
1645

    
1646
                //rotation page add or update
1647
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
1648
                if (rotationdoc != null)
1649
                {
1650
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
1651
                }
1652
                else
1653
                {
1654
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
1655
                }
1656
            }
1657
        }
1658
        #endregion
1659

    
1660
        private void ImageConverter(RadToggleButton instanceToggle)
1661
        {
1662
            try
1663
            {           
1664
                var instanceMain = this.ParentOfType<MainWindow>();
1665
                //http://cloud.devdoftech.co.kr:5977/ImageUpload/FileUpload.asmx
1666

    
1667
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
1668
                dlg.Filter = "All files (*.*)|*.*|PNG Images (*.png)|*.png";
1669
                Nullable<bool> result = dlg.ShowDialog();
1670
                if (result == true)
1671
                {
1672
                    instanceMain.dzMainMenu.filename = dlg.FileName;
1673
                    instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
1674

    
1675
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(instanceMain.dzMainMenu.filename);
1676
                    String strFile = System.IO.Path.GetFileName(instanceMain.dzMainMenu.filename);
1677
                    long numByte = fileInfo.Length;
1678
                    double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
1679
                    kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
1680

    
1681
                    if (dLen < 4)
1682
                    {
1683
                        System.IO.FileStream fStream = new System.IO.FileStream(instanceMain.dzMainMenu.filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
1684
                        System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
1685
                        byte[] data = br.ReadBytes((int)numByte);
1686
                        br.Close();
1687

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

    
1690
                        Check_Uri.UriCheck(filepath);
1691

    
1692
                        instanceMain.dzMainMenu.filename = filepath;
1693

    
1694
                        fStream.Close();
1695
                        fStream.Dispose();
1696
                    }
1697
                    else
1698
                    {
1699
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
1700
                    }
1701
                }
1702
                else
1703
                {
1704
                    instanceToggle.IsChecked = false;
1705
                    Common.ViewerDataModel.Instance.SelectedControl = "";
1706
                    Common.ViewerDataModel.Instance.ControlTag = null;
1707
                    this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
1708
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1709
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("No Image selected.", "Alert");
1710
                }
1711
            }
1712
            catch(Exception ex)
1713
            {
1714
                instanceToggle.IsChecked = false;
1715
                Common.ViewerDataModel.Instance.SelectedControl = "";
1716
                Common.ViewerDataModel.Instance.ControlTag = null;
1717
                this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
1718
                this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1719
                this.ParentOfType<MainWindow>().DialogMessage_Alert(""+ ex , "Alert");
1720
            }
1721
        }
1722

    
1723
        private void Control_Init(RadToggleButton instanceToggle, object sender)
1724
        {
1725

    
1726
        }
1727

    
1728
        private void ControlEvent(object sender, RoutedEventArgs e)
1729
        {
1730
            RadToggleButton instanceToggle = sender as RadToggleButton;
1731
            var instanceMain = this.ParentOfType<MainWindow>();
1732

    
1733
            #region Ctrl + A 눌렀을 때 대처 방법 
1734
            //원인 : Ctrl + A를 누르면 UIElementSet에 등록을 시키지 않는다(이유는 한꺼번에 많은 양의 컨트롤의 동작이 유입되기 때문에
1735
            //       시스템의 성능저하를 불러올 수 있기 때문이다. 그래서 선택 후 다른 컨트롤을 누르면 등록되지 않은 컨트롤이기 때문에 삭제된다
1736
            //       이를 대처하는 방법으로 아래 코드를 사용한다.
1737
            if (Common.ViewerDataModel.Instance.MarkupControls.Count == 0 && Common.ViewerDataModel.Instance.MarkupControls.Count >= 1)
1738
            {
1739
                //var lstItem = instanceMain.DeepLayer._SelectLayer.ChildrenOfType<AdornerFinal>().ToList();
1740
                //foreach (var item in lstItem)
1741
                //{
1742
                //    foreach (var member in item.MemberSet)
1743
                //    {
1744
                //        if (!instanceMain.DeepLayer.UIElementSet.Contains(member.DrawingData))
1745
                //        {
1746
                //            instanceMain.DeepLayer.UIElementSet.Add(member.DrawingData);
1747
                //        }
1748
                //    }
1749
                //}
1750
            }
1751
            #endregion
1752

    
1753
            //if (!instanceMain.IsFreeSelectionMode)
1754
            //{
1755
            //    instanceMain.IsSwingMode = true;
1756
            //}
1757

    
1758
            #region 다른 컨트롤 버튼 선택 해제
1759
            System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.SelectedControl).Subscribe(ControlState =>
1760
            {
1761
                if (ControlState == null)
1762
                {
1763
                    instanceToggle.IsChecked = false;
1764
                    HiddenControlHide();
1765
                }
1766
            });
1767
            #endregion
1768

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

    
1771
            if (instanceToggle != null)
1772
            {
1773
                Common.ViewerDataModel.Instance.ControlTag = instanceToggle.Tag.ToString();
1774
            }
1775
            else if ((sender as RadRibbonToggleButton) != null)
1776
            {
1777
                Common.ViewerDataModel.Instance.ControlTag = (sender as RadRibbonToggleButton).Tag.ToString();
1778
                instanceToggle = (sender as RadRibbonToggleButton);
1779
            }
1780
            else if ((sender as RadRibbonButton) != null)
1781
            {
1782
                RadRibbonButton instanceButton = sender as RadRibbonButton;
1783
                Common.ViewerDataModel.Instance.ControlTag = instanceButton.Tag.ToString();
1784
            }
1785
            else
1786
            {
1787
                RadButton instanceButton = sender as RadButton;
1788
                Common.ViewerDataModel.Instance.ControlTag = instanceButton.Tag.ToString();
1789
            }
1790

    
1791

    
1792
            System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.AngleVisibility).Subscribe(isSee =>
1793
            {
1794
                if (instanceToggle.CommandParameter.ToString() == "ChainLine")
1795
                {
1796

    
1797
                }
1798
                else
1799
                {
1800
                    System.Diagnostics.Debug.WriteLine(" instanceMain.dzMainMenu.MainAngle.Visibility   " + isSee);
1801

    
1802
                    if (instanceMain.dzMainMenu.MainAngle.Visibility != isSee)
1803
                    {
1804
                        instanceMain.dzMainMenu.MainAngle.Visibility = isSee;
1805
                    }
1806
                }
1807
                //System.Reactive.Linq.Observable2.FromPropertyChangedPattern(Common.ViewerDataModel.Instance, temp => temp.AngleValue).Subscribe(p =>
1808
                //{
1809
                //    instanceMain.dzMainMenu.MainAngle.AngleValue = p;
1810
                //});
1811
            });
1812
            instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
1813

    
1814
            instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
1815

    
1816
            if (instanceToggle.IsChecked != false)
1817
            {
1818
                #region 컨트롤이 체크되었다면
1819
                switch (instanceToggle.CommandParameter.ToString())
1820
                {
1821
                    #region Line
1822
                    case "Line":
1823
                        Common.ViewerDataModel.Instance.SelectedControl = "Line";
1824
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1825
                        if (instanceToggle.Tag.ToString() == "LineDelete")
1826
                        {
1827
                            //HiddenInterval.Visibility = Visibility.Visible;
1828
                        }
1829
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.SingleLine;
1830
                        break;
1831
                    #endregion
1832
                    #region ChainLine
1833
                    case "ChainLine":
1834
                        Common.ViewerDataModel.Instance.SelectedControl = "ChainLine";
1835
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1836
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ChainLine;
1837
                        break;
1838
                    #endregion
1839
                    #region DimLine
1840
                    case "DimLine":
1841
                        Common.ViewerDataModel.Instance.SelectedControl = "DimLine";
1842
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1843
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.DimLine;
1844
                        break;
1845
                    #endregion
1846
                    #region TwinLine
1847
                    case "TwinLine":
1848
                        Common.ViewerDataModel.Instance.SelectedControl = "TwinLine";
1849
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1850
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TwinLine;
1851
                        break;
1852
                    #endregion
1853
                    #region CancelLine
1854
                    case "CancelLine":
1855
                        Common.ViewerDataModel.Instance.SelectedControl = "CancelLine";
1856
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1857
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.CancelLine;
1858
                        break;
1859
                    #endregion
1860
                    #region PolygonCloud
1861
                    case "PolygonCloud":
1862
                        Common.ViewerDataModel.Instance.SelectedControl = "PolygonCloud";
1863
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1864
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PolygonCloud;
1865
                        break;
1866
                    #endregion
1867
                    #region RectCloud
1868
                    case "RectCloud":
1869
                        Common.ViewerDataModel.Instance.SelectedControl = "RectCloud";
1870
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1871
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.RectCloud;
1872
                        break;
1873
                    #endregion
1874
                    #region Rectangle
1875
                    case "Rectangle":
1876
                        Common.ViewerDataModel.Instance.SelectedControl = "Rectangle";
1877
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1878
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Rectangle;
1879
                        break;
1880
                    #endregion
1881
                    #region Triangle
1882
                    case "Triangle":
1883
                        Common.ViewerDataModel.Instance.SelectedControl = "Triangle";
1884
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1885
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Triangle;
1886
                        break;
1887
                    #endregion
1888
                    #region RectCloud
1889
                    case "Circle":
1890
                        Common.ViewerDataModel.Instance.SelectedControl = "Circle";
1891
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1892
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Circle;
1893
                        break;
1894
                    #endregion
1895
                    #region Symbol
1896
                    case "Symbol":
1897
                        Common.ViewerDataModel.Instance.SelectedControl = "Symbol";
1898
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
1899
                        break;
1900
                    #endregion
1901
                    #region SymbolN
1902
                    case "SymbolN":
1903
                        Common.ViewerDataModel.Instance.SelectedControl = "SymbolN";
1904
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Stamp;
1905
                        break;
1906
                    #endregion
1907
                    #region Text
1908
                    case "Text":
1909
                        Common.ViewerDataModel.Instance.SelectedControl = "Text";
1910
                        TaskMessage("Text 도구는 텍스트 영역을 더블 클릭하여 텍스트를 재 편집 할 수 있습니다", TaskMessageType.Normal);
1911
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TextControl;
1912
                        break;
1913
                    #endregion
1914
                    #region TextBorder
1915
                    case "TextBorder":
1916
                        Common.ViewerDataModel.Instance.SelectedControl = "TextBorder";
1917
                        TaskMessage("Text 도구는 텍스트 영역을 더블 클릭하여 텍스트를 재 편집 할 수 있습니다", TaskMessageType.Normal);
1918
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TextBorder;
1919
                        break;
1920
                    #endregion
1921
                    #region TextCloud
1922
                    case "TextCloud":
1923
                        Common.ViewerDataModel.Instance.SelectedControl = "TextCloud";
1924
                        TaskMessage("Text 도구는 텍스트 영역을 더블 클릭하여 텍스트를 재 편집 할 수 있습니다", TaskMessageType.Normal);
1925
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.TextCloud;
1926
                        break;
1927
                    #endregion
1928
                    #region Date
1929
                    case "Date":
1930
                        Common.ViewerDataModel.Instance.SelectedControl = "Date";
1931
                        TaskMessage("날짜 컨트롤을 더블 클릭하면 날짜를 변경할 수 있습니다", TaskMessageType.Normal);
1932
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Date;
1933
                        break;
1934
                    #endregion
1935
                    #region ArrowText
1936
                    case "ArrowText":
1937
                        TaskMessage("ArrowText 컨트롤은 그린 후 컨트롤을 선택하였을 시 중간점을 조정할 수 있습니다", TaskMessageType.Normal);
1938
                        if (instanceToggle.Tag.ToString() == "ArrowText_Cloud")
1939
                        {
1940
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowText_Cloud";
1941
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl;
1942
                        }
1943
                        else if (instanceToggle.Tag.ToString() == "ArrowText_Border")
1944
                        {
1945
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTextBorderControl";
1946
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl;
1947
                        }
1948
                        else if (instanceToggle.Tag.ToString() == "ArrowTextFix_Normal")
1949
                        {
1950
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTransTextControl";
1951
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl;
1952
                        }
1953
                        else if (instanceToggle.Tag.ToString() == "ArrowTextFix_Border")
1954
                        {
1955
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTransTextBorderControl";
1956
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl;
1957
                        }
1958
                        else if (instanceToggle.Tag.ToString() == "ArrowTextFix_Cloud")
1959
                        {
1960
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowTransTextCloudControl";
1961
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl;
1962
                        }
1963
                        else
1964
                        {
1965
                            Common.ViewerDataModel.Instance.SelectedControl = "ArrowText";
1966
                            instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowTextControl;
1967
                            //HiddenAxisLock.Visibility = Visibility.Visible;
1968
                        }
1969
                        break;
1970
                    #endregion
1971
                    #region Arrow
1972
                    case "Arrow":
1973
                        Common.ViewerDataModel.Instance.SelectedControl = "Arrow";
1974
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1975
                        //HiddenDimSize.Visibility = Visibility.Visible;
1976
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowLine;
1977
                        break;
1978
                    #endregion
1979
                    #region Shape
1980
                    case "Shape":
1981
                        Common.ViewerDataModel.Instance.SelectedControl = "Shape";
1982
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Mark;
1983
                        break;
1984
                    #endregion
1985
                    #region Polygon
1986
                    case "Polygon":
1987
                        Common.ViewerDataModel.Instance.SelectedControl = "Polygon";
1988
                        TaskMessage("자유형 코멘트 도구는 오른쪽 마우스 클릭을 통해 그리기를 마칠 수 있습니다", TaskMessageType.Normal);
1989
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1990
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PolygonControl;
1991
                        break;
1992
                    #endregion
1993
                    #region Arc
1994
                    case "Arc":
1995
                        Common.ViewerDataModel.Instance.SelectedControl = "Arc";
1996
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArcLine;
1997
                        //HiddenAxisLock.Visibility = Visibility.Visible;
1998
                        TaskMessage("Arc 코멘트 도구는 오른쪽 마우스를 사용해 좌우 반전을 사용하실 수 있습니다", TaskMessageType.Normal);
1999
                        break;
2000
                    #endregion
2001
                    #region ArrowArc
2002
                    case "ArrowArc":
2003
                        Common.ViewerDataModel.Instance.SelectedControl = "ArrowArc";
2004
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArcArrow;
2005
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2006
                        TaskMessage("ArcArrow 코멘트 도구는 오른쪽 마우스를 사용해 좌우 반전을 사용하실 수 있습니다", TaskMessageType.Normal);
2007
                        break;
2008
                    #endregion
2009
                    #region ArrowMulti
2010
                    case "ArrowMulti":
2011
                        Common.ViewerDataModel.Instance.SelectedControl = "ArrowMulti";
2012
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ArrowMultiLine;
2013
                        //HiddenAxisLock.Visibility = Visibility.Visible;
2014
                        break;
2015
                    #endregion
2016
                    #region Etc
2017
                    case "Etc":
2018
                        Common.ViewerDataModel.Instance.SelectedControl = "Etc";
2019
                        break;
2020
                    #endregion
2021
                    #region Ink
2022
                    case "Ink":
2023
                        if (instanceToggle.Tag.ToString() == "EraserClear")
2024
                        {
2025
                            TaskMessage("해당 컨트롤은 점 단위로 그려진 펜을 지웁니다", TaskMessageType.Normal);
2026
                            //instanceMain.dzMainMenu.inkDrawingCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
2027
                            instanceMain.dzMainMenu.inkBoard.Tag = "EraseByPoint";
2028
                        }
2029
                        else if (instanceToggle.Tag.ToString() == "Eraser")
2030
                        {
2031
                            TaskMessage("해당 컨트롤은 선 단위로 그려진 펜을 지웁니다", TaskMessageType.Normal);
2032
                            instanceMain.dzMainMenu.inkBoard.Tag = "EraseByStroke";
2033
                            //instanceMain.dzMainMenu.inkDrawingCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
2034
                        }
2035
                        else
2036
                        {
2037
                            instanceMain.dzMainMenu.inkBoard.Tag = "Ink";
2038
                            //instanceMain.dzMainMenu.inkDrawingCanvas.EditingMode = InkCanvasEditingMode.Ink;
2039
                        }
2040

    
2041
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = true;
2042

    
2043
                        Common.ViewerDataModel.Instance.SelectedControl = "Ink";
2044
                        Common.ViewerDataModel.Instance.LineSize = (double)cbLineSize.Value;
2045
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.PenControl;
2046
                        break;
2047
                    #endregion
2048
                    #region Select
2049
                    case "Select":
2050
                        if(this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2051
                        {
2052
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2053
                            this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2054
                        }
2055
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
2056
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2057
                        instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2058
                        break;
2059
                    #endregion
2060
                    #region Image
2061
                    case "Image":
2062
                        Common.ViewerDataModel.Instance.SelectedControl = "ImgControl";
2063
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
2064
                        ImageConverter(instanceToggle);
2065
                        break;
2066
                    #endregion
2067
                    #region Sign
2068
                    case "Sign":
2069
                        Common.ViewerDataModel.Instance.SelectedControl = "Sign";
2070
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2071
                        //강인구 추가
2072
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Sign;
2073
                        //instanceMain.BaseClient.GetUserSignCompleted += (sen, ea) =>
2074
                        //{
2075
                        //    if (ea.Result == null)
2076
                        //    {
2077

    
2078
                        //        this.ParentOfType<MainPage>().DialogMessage_Alert("You Don't Have Sign Data", "Alert");
2079
                        //    }
2080
                        //    else
2081
                        //    {
2082
                        //        byte[] imageBytes = System.Convert.FromBase64String(ea.Result);
2083
                        //        using (MemoryStream ms = new MemoryStream(imageBytes))
2084
                        //        {
2085
                        //            BitmapImage im = new BitmapImage();
2086
                        //            im.SetSource(ms);
2087
                        //            instanceMain.DeepLayer.SignImage = im;
2088
                        //            ms.Close();
2089
                        //        }
2090
                        //    }
2091
                        //};
2092
                        //instanceMain.BaseClient.GetUserSignAsync(instanceMain._ViewInfo.UserID);
2093
                        break;
2094
                    #endregion
2095
                    #region Check
2096
                    case "Check":
2097
                        Common.ViewerDataModel.Instance.SelectedControl = "Check";
2098
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2099
                        //강인구 추가
2100
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Symbol;
2101
                        break;
2102
                    #endregion
2103
                    #region Batch
2104
                    case "Batch":
2105
                        Common.ViewerDataModel.Instance.SelectedControl = "Batch";
2106
                        Common.ViewerDataModel.Instance.ControlTag = instanceMain.dzMainMenu._ViewInfo.UserID; //사번
2107
                        //강인구 추가
2108
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.Mark;
2109
                        instanceMain.dzMainMenu.txtBatch.Visibility = Visibility.Visible;
2110
                        instanceMain.dzMainMenu.txtBatch.Text = "Place Mark";
2111
                        break;
2112
                    #endregion
2113
                    #region Copy
2114
                    case "Copy":
2115
                        Copy_Start();
2116
                        instanceToggle.IsChecked = false;
2117
                        ViewerDataModel.Instance.SelectedControl = "";
2118
                        ViewerDataModel.Instance.ControlTag = null;
2119
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2120
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2121
                        break;
2122
                    #endregion
2123
                    #region Cut
2124
                    case "Cut":
2125
                        //Cut_Start();
2126
                        CutCommand.Instance.Execute();
2127
                        instanceToggle.IsChecked = false;
2128
                        ViewerDataModel.Instance.SelectedControl = "";
2129
                        ViewerDataModel.Instance.ControlTag = null;
2130
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2131
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2132
                        break;
2133
                    #endregion
2134
                    #region Paste
2135
                    case "Paste":
2136
                        Paste_Start();
2137
                        instanceToggle.IsChecked = false;
2138
                        ViewerDataModel.Instance.SelectedControl = "";
2139
                        ViewerDataModel.Instance.ControlTag = null;
2140
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2141
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;                        
2142
                        break;
2143
                    #endregion
2144
                    #region Delete
2145
                    case "Delete":
2146
                        DeleteCommand.Instance.Execute(SelectionSet.Instance.SelectedItems);
2147
                        this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Clear();
2148

    
2149
                        instanceToggle.IsChecked = false;
2150
                        ViewerDataModel.Instance.SelectedControl = "";
2151
                        ViewerDataModel.Instance.ControlTag = null;
2152
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2153
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2154
                        break;
2155
                    #endregion
2156
                    #region Undo
2157
                    case "Undo":
2158
                        UndoCommand.Instance.Execute();
2159
                        instanceToggle.IsChecked = false;
2160
                        ViewerDataModel.Instance.SelectedControl = "";
2161
                        ViewerDataModel.Instance.ControlTag = null;
2162
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2163
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2164
                        break;
2165
                    #endregion
2166
                    #region Redo
2167
                    case "Redo":
2168
                        RedoCommand.Instance.Execute();
2169
                        instanceToggle.IsChecked = false;
2170
                        ViewerDataModel.Instance.SelectedControl = "";
2171
                        ViewerDataModel.Instance.ControlTag = null;
2172
                        this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2173
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2174
                        break;
2175
                    #endregion
2176
                    #region DragZoom
2177
                    case "DragZoom":
2178
                        this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.DragZoom;
2179
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2180
                        instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2181
                        break;
2182
                    #endregion
2183
                    #region Grouping
2184
                    case "Group":
2185
                        //var GrouptoggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2186
                        //foreach (var togle in GrouptoggleList)
2187
                        //{
2188
                        //    togle.IsChecked = false;
2189
                        //}
2190

    
2191
                        //if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2192
                        //{
2193
                        //    ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2194
                        //    this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2195
                        //}
2196
                        //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2197
                        //instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2198
                        //instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2199
                        //if (ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
2200
                        //{
2201
                        //    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Please Select Controls", "Alert");
2202
                        //}
2203
                        //else//if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2204
                        //{
2205
                        //    // string MarkupData = "";
2206
                        //    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2207
                        //    {
2208
                        //        if (item.GetType().Name == "AdornerFinal" && (item as AdornerFinal).MemberSet.Count >= 2) // 얘가 2개 이상이여야 그룹가능 버튼도 막을거긴하지만 일단..
2209
                        //        {
2210
                        //            //MARKUP_DATA_GROUP INSERT
2211
                        //            MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2212
                        //            {
2213
                        //                SYMBOL_ID = null,//InnerItem.Symbol_ID
2214
                        //                STATE = 0,
2215
                        //            };
2216
                        //            long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
2217
                        //            Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
2218
                        //            if (group_id > 0)
2219
                        //            {
2220
                        //                foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
2221
                        //                {
2222
                        //                    if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2223
                        //                    {
2224
                        //                        //MARKUP_DATA UPDATE
2225
                        //                        //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupData((InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID, group_id, App.ViewInfo.ProjectNO);
2226
                        //                        //Logger.sendReqLog("UpdateMarkupData: ", "", 1);
2227
                        //                        ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().Group_ID = group_id;
2228
                        //                        ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().IsUpdate = true;
2229
                        //                    }
2230
                        //                }
2231
                        //            }
2232
                        //        }
2233
                        //    }
2234
                        //}
2235
                        break;
2236
                    case "UnGroup":
2237
                        //var UnGrouptoggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2238
                        //foreach (var togle in UnGrouptoggleList)
2239
                        //{
2240
                        //    togle.IsChecked = false;
2241
                        //}
2242
                        //if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2243
                        //{
2244
                        //    ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2245
                        //    this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2246
                        //}
2247
                        //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2248
                        //instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2249
                        //instanceMain.dzMainMenu.isLeftMouseButtonDownOnWindow = false;
2250

    
2251
                        //if (ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
2252
                        //{
2253
                        //    this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Please Select Controls", "Alert");
2254
                        //}
2255
                        //else//if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2256
                        //{
2257
                        //    // string MarkupData = "";
2258
                        //    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2259
                        //    {
2260
                        //        if (item.GetType().Name == "AdornerFinal" && (item as AdornerFinal).MemberSet.Count >= 1) // 1개 이상 
2261
                        //        {
2262
                        //            //MARKUP_DATA UPDATE
2263
                        //            foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
2264
                        //            {
2265
                        //                if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2266
                        //                {
2267
                        //                    long group_id = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault().Group_ID;
2268
                        //                    //MARKUP_DATA UPDATE
2269
                        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupData((InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo).CommentID, 0, App.ViewInfo.ProjectNO);
2270
                        //                    //Logger.sendReqLog("UpdateMarkupData: ", "", 1);
2271
                        //                    ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().Group_ID = 0;
2272
                        //                    ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (InnerItem.DrawingData as CommentUserInfo).CommentID).FirstOrDefault().IsUpdate = true;
2273

    
2274

    
2275
                        //                    //MARKUP_DATA_GROUP UPDATE
2276
                        //                    //bool value = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.UpdateMarkupDataGroup(group_id, App.ViewInfo.ProjectNO);
2277
                        //                    //Logger.sendReqLog("AddMarkupDataGroup: ", value.ToString(), 1);
2278
                        //                }
2279
                        //            }
2280
                        //        }
2281
                        //    }
2282
                        //}
2283
                        break;
2284
                    #endregion
2285
                    #region Capture
2286
                    case "Capture":
2287
                        SyncInit();
2288
                        //   instanceToggle.IsChecked = false;
2289
                        var CaptureList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2290
                        foreach (var togle in CaptureList)
2291
                        {
2292
                            togle.IsChecked = false;
2293
                        }
2294

    
2295
                        if (this.ParentOfType<MainWindow>().dzMainMenu.currentControl != null)
2296
                        {
2297
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.ParentOfType<MainWindow>().dzMainMenu.currentControl);
2298
                            this.ParentOfType<MainWindow>().dzMainMenu.currentControl = null;
2299
                        }
2300

    
2301
                        ViewerDataModel.Instance.SelectedControl = "ImgControl";
2302
                   //     ViewerDataModel.Instance.ControlTag = null;
2303
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
2304

    
2305
                        /*
2306
                        //캡쳐 하기 전에 코멘트 저장
2307
                        if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
2308
                        {
2309
                            var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
2310
                            menu.ReleaseAdorner();
2311
                            if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
2312
                            {
2313
                                (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
2314
                            }
2315
                            else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
2316
                            {
2317

    
2318
                            }
2319
                            else
2320
                            {
2321
                                (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
2322
                            }
2323
                        }*/
2324

    
2325
                        //Common.ViewerDataModel.Instance.CheckList_ID = ((e.Source as Telerik.Windows.Controls.RadButton).DataContext as Customer).ID;
2326
                        //Common.ViewerDataModel.Instance.CheckList_ID = ((e.Source as Image).DataContext as Customer).ID;
2327
                        //Common.ViewerDataModel.Instance.PageNumber = ((e.Source as Image).DataContext as Customer).PAGENUMBER;
2328
                        Application.Current.MainWindow.Focus();
2329
                        Common.ViewerDataModel.Instance.Capture_Opacity = 0.49;
2330
                        (Application.Current.MainWindow as MainWindow).dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture;
2331
                        break;
2332
                    #endregion
2333
                    #region Cad
2334
                    case "Inside":
2335
                        //instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2336
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2337
                        Common.ViewerDataModel.Instance.SelectedControl = "InsideWhite";
2338
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.InsideWhite;
2339
                        break;
2340
                    case "Overlap":
2341
                        //instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2342
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2343
                        Common.ViewerDataModel.Instance.SelectedControl = "OverlapWhite";
2344
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.OverlapWhite;
2345
                        break;
2346
                    case "Clip":
2347
                        //instanceMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Drawing;
2348
                        //instanceMain.dzMainMenu.inkDrawingCanvas.IsEnabled = false;
2349
                        Common.ViewerDataModel.Instance.SelectedControl = "ClipWhite";
2350
                        instanceMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ClipWhite;
2351
                        break;
2352
                    case "CadExport":
2353
                        //if (isClosed)
2354
                        //{
2355
                        //    //토글 및 마우스 상태 초기화
2356
                        //    var toggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2357
                        //    foreach (var togle in toggleList)
2358
                        //    {
2359
                        //        togle.IsChecked = false;
2360
                        //    }
2361
                        //    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2362

    
2363
                        //    isClosed = false;
2364
                        //    //Control 파일 먼저 생성
2365
                        //    CollapsedButton_Click();
2366
                        //    CadViewer check = new CadViewer();
2367
                        //    check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2368
                        //    check.Title = "Export Viewer";
2369
                        //    //check.Topmost = true;
2370
                        //    check.Show();
2371
                        //    check.Closed += Check_Closed;
2372
                        //    instanceToggle.IsChecked = false;
2373
                        //}
2374
                        //break;
2375
                    case "CadViewer":
2376
                        //if (isClosed)
2377
                        //{
2378
                        //    //토글 및 마우스 상태 초기화
2379
                        //    var toggleList = this.Parent.ChildrenOfType<RadRibbonToggleButton>();
2380
                        //    foreach (var togle in toggleList)
2381
                        //    {
2382
                        //        togle.IsChecked = false;
2383
                        //    }
2384
                        //    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2385

    
2386
                        //    isClosed = false;
2387
                        //    CadResultViewer check = new CadResultViewer();
2388
                        //    check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2389
                        //    check.Title = "Viewer";
2390
                        //    check.Show();
2391

    
2392
                        //    check.Closed += Check_Closed;
2393

    
2394
                        //}
2395
                        break;
2396
                    #endregion
2397
                    default:
2398
                        break;
2399
                }
2400
                #endregion
2401
            }
2402
            else
2403
            {
2404

    
2405
                if (!instanceMain.dzMainMenu.IsFreeSelectionMode)
2406
                {
2407
                    instanceMain.dzMainMenu.IsSwingMode = false;
2408
                    Common.ViewerDataModel.Instance.SelectedControl = "";
2409
                    Common.ViewerDataModel.Instance.ControlTag = null;
2410
                    this.ParentOfType<MainWindow>().dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
2411
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2412
                }
2413
            }
2414

    
2415
        }
2416

    
2417
        private void SyncInit()
2418
        {
2419
            try
2420
            {
2421
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden)
2422
                {
2423
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true;
2424
                    ViewerDataModel.Instance.PageBalanceMode = false;
2425
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
2426
                    ViewerDataModel.Instance.PageNumber = 0;
2427
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
2428
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed;
2429
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false;
2430
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false;
2431
                }
2432
            }
2433
            catch (Exception ex)
2434
            {
2435
                Logger.sendResLog("SyncInit", ex.Message, 0);
2436
            }
2437

    
2438
        }
2439

    
2440
        Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2441
        CommentUserInfo currentControl { get; set; }
2442
        private void Check_Closed(object sender, EventArgs e)
2443
        {
2444
            isClosed = true;
2445
            //this.ParentOfType<MainWindow>().dzMainMenu.PN_Navi.IsEnabled = true;
2446
            //토글 및 마우스 상태 초기화
2447
            var toggleList = this.Parent.ChildrenOfType<RadToggleButton>();
2448
            foreach (var togle in toggleList)
2449
            {
2450
                togle.IsChecked = false;
2451
            }
2452
            this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
2453
            ViewerDataModel.Instance.Capture_Opacity = 0;
2454

    
2455
        }
2456

    
2457
        /* public class test 
2458
         {
2459
             public double width { get; set; }
2460
             public double height { get; set; }
2461
         }
2462
         */
2463
        private async void CollapsedButton_Click()
2464
        {
2465
            this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null); // 저장하지 못한 데이터가 있다면 저장
2466

    
2467
            string[] data = new string[0];
2468

    
2469
            int cnt = 0;
2470
            var menu = this.ParentOfType<MainWindow>().dzMainMenu;
2471

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

    
2474
            foreach (var item in gridSelectionItem)
2475
            {
2476
                if ((item.UserID == App.ViewInfo.UserID) && (ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage != null))
2477
                {
2478
                    var instance = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber &&
2479
                    d.MarkupInfoID == item.MarkupInfoID).ToList();
2480
                    data = new string[instance.Count];
2481
                    foreach (var markup in instance)
2482
                    {
2483
                        data[cnt++] = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(markup.Data);
2484
                    }
2485
                }
2486
            }
2487

    
2488
            if (data != null && KCOM.Properties.Settings.Default.cad == 1)
2489
            {
2490
                string FilePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Cad");
2491
                string FileName = FilePath + "\\commentstring.json"; // Default file name
2492
                if (!File.Exists(FilePath))
2493
                {
2494
                    Directory.CreateDirectory(FilePath);
2495
                }
2496

    
2497
                if (!string.IsNullOrEmpty(FileName))
2498
                {
2499
                    //  File.WriteAllText(SaveDig.FileName, data);
2500
                    File.WriteAllLines(FileName, data);
2501
                }
2502
            }
2503
        }
2504

    
2505
        private double minHeight;
2506
        private double minWidth;
2507

    
2508
        private double maxHeight;
2509
        private double maxWidth;
2510

    
2511
        public bool CanVResize { get; private set; }
2512
        public bool CanHResize { get; private set; }
2513

    
2514
        public void DesignerComponent(FrameworkElement content)
2515
        {
2516
            this.InitializeComponent();
2517

    
2518
            if (!double.IsNaN(content.Width))
2519
            {
2520
                CanHResize = false;
2521
                this.Width = content.Width;
2522
            }
2523
            else
2524
            {
2525
                CanHResize = true;
2526
                this.Width = 23.0;
2527
            }
2528
            if (!double.IsNaN(content.Height))
2529
            {
2530
                CanVResize = false;
2531
                this.Height = content.Height; ;
2532
            }
2533
            else
2534
            {
2535
                CanVResize = true;
2536
                this.Height = 23.0;
2537
            }
2538

    
2539
            minWidth = content.MinWidth < 10.0 ? 10.0 : content.MinWidth;
2540
            minHeight = content.MinHeight < 10.0 ? 10.0 : content.MinHeight;
2541
            maxWidth = content.MaxWidth;
2542
            maxHeight = content.MaxHeight;
2543

    
2544
            double top = (double)content.GetValue(Canvas.TopProperty);
2545
            if (double.IsNaN(top))
2546
                top = 0.0;
2547
            double left = (double)content.GetValue(Canvas.LeftProperty);
2548
            if (double.IsNaN(left))
2549
                left = 0.0;
2550
            SetValue(Canvas.TopProperty, top);
2551
            SetValue(Canvas.LeftProperty, left);
2552

    
2553
            //Set the actual content. Note that "Content" property is a new property. See below
2554
            this.Content = content;
2555
        }
2556
        private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
2557
        {
2558
            string name = ((Thumb)sender).Name;
2559
            if (name.Contains("Top"))
2560
            {
2561
                double newHeight = this.Height - e.VerticalChange;
2562
                if (newHeight >= minHeight && newHeight <= maxHeight)
2563
                {
2564
                    this.Height = newHeight;
2565
                    SetValue(Canvas.TopProperty,
2566
                (double)GetValue(Canvas.TopProperty) + e.VerticalChange);
2567
                }
2568
            }
2569
            if (name.Contains("Right"))
2570
            {
2571
                double newWidth = this.Width + e.HorizontalChange;
2572
                if (newWidth >= minWidth && newWidth <= maxWidth)
2573
                    this.Width = newWidth;
2574
            }
2575
            if (name.Contains("Bottom"))
2576
            {
2577
                double newHeight = this.Height + e.VerticalChange;
2578
                if (newHeight >= minHeight && newHeight <= maxHeight)
2579
                    this.Height = newHeight;
2580
            }
2581
            if (name.Contains("Left"))
2582
            {
2583
                double newWidth = this.Width - e.HorizontalChange;
2584
                if (newWidth >= minWidth && newWidth <= maxWidth)
2585
                {
2586
                    this.Width = newWidth;
2587
                    SetValue(Canvas.LeftProperty,
2588
                (double)GetValue(Canvas.LeftProperty) + e.HorizontalChange);
2589
                }
2590
            }
2591
        }
2592

    
2593
        private void drawControlBorder(object sender)
2594
        {
2595
            System.Windows.Controls.Control control = (System.Windows.Controls.Control)sender;
2596
        }
2597

    
2598
        private void ResizeThumb_DragDelta(object sender, MouseButtonEventArgs e)
2599
        {
2600
            System.Windows.Controls.Control designerItem = (System.Windows.Controls.Control)sender;
2601
            if (designerItem != null)
2602
            {
2603
                double deltaVertical, deltaHorizontal;
2604

    
2605
                switch (VerticalAlignment)
2606
                {
2607
                    case VerticalAlignment.Bottom:
2608
                        deltaVertical = designerItem.ActualHeight - designerItem.MinHeight;
2609
                        designerItem.Height -= deltaVertical;
2610
                        break;
2611
                    case VerticalAlignment.Top:
2612
                        deltaVertical = designerItem.ActualHeight - designerItem.MinHeight;
2613
                        Canvas.SetTop(designerItem, Canvas.GetTop(designerItem) + deltaVertical);
2614
                        designerItem.Height -= deltaVertical;
2615
                        break;
2616
                    default:
2617
                        break;
2618
                }
2619

    
2620
                switch (HorizontalAlignment)
2621
                {
2622
                    case HorizontalAlignment.Left:
2623
                        deltaHorizontal = designerItem.ActualWidth - designerItem.MinWidth;
2624
                        Canvas.SetLeft(designerItem, Canvas.GetLeft(designerItem) + deltaHorizontal);
2625
                        designerItem.Width -= deltaHorizontal;
2626
                        break;
2627
                    case HorizontalAlignment.Right:
2628
                        deltaHorizontal = designerItem.ActualWidth - designerItem.MinWidth;
2629
                        designerItem.Width -= deltaHorizontal;
2630
                        break;
2631
                    default:
2632
                        break;
2633
                }
2634
            }
2635
            e.Handled = true;
2636
        }
2637

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

    
2640
        void ExportMethod()
2641
        {
2642
            //FileDialogFilter filterImage = new FileDialogFilter("Image Files", "*.jpg", "*.png");
2643
            SaveDig.Filter = "PDF file format|*.pdf";
2644
            SaveDig.Title = "Save an DWG File";
2645
            SaveDig.ShowDialog();
2646
        }
2647

    
2648
        private void cbAutoSave_Checked(object sender, RoutedEventArgs e)
2649
        {            
2650
            if (cbAutoSave.IsChecked == true)
2651
            {
2652
                SaveTime(true, (int)cbSaveInterval.Value);
2653
            }
2654
            else
2655
            {
2656
                SaveTime(false, (int)cbSaveInterval.Value);
2657
            }
2658
        }
2659
        private void cbSaveInterval_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
2660
        {
2661
            if(string.IsNullOrEmpty(cbSaveInterval.Value.ToString()))
2662
            {
2663
                cbSaveInterval.Value = cbSaveInterval.Minimum;
2664
            }
2665
            if (cbAutoSave.IsChecked == true)
2666
            {
2667
                SaveTime(true, (int)cbSaveInterval.Value);
2668
            }
2669

    
2670
            KCOM.Properties.Settings.Default.SaveInterval = (double)cbSaveInterval.Value;
2671
            Properties.Settings.Default.Save();
2672
        }
2673
        //강인구 자동 저장 추가
2674
        private void AutoSave(object sender, RoutedEventArgs e)
2675
        {
2676
            RadToggleButton instanceToggle = sender as RadToggleButton;
2677

    
2678
            if(instanceToggle.IsChecked == true)
2679
            {
2680
                SaveTime(true);
2681
            }
2682
            else
2683
            {
2684
                SaveTime(false);
2685
            }
2686
        }
2687

    
2688
        public void Copy_Start()
2689
        {
2690
            if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2691
            {
2692
                string MarkupData = "";
2693

    
2694
                foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2695
                {
2696
                    if (item.GetType().Name == "AdornerFinal")
2697
                    {
2698
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
2699

    
2700
                        {
2701
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2702
                            {
2703
                                MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn res = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
2704
                                MarkupData += "|OR|" + res.ConvertData;
2705
                            }
2706
                        }
2707
                        Clipboard.SetText(MarkupData);
2708
                    }
2709
                }
2710
            }
2711
        }
2712

    
2713
        public void Cut_Start()
2714
        {
2715
            if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
2716
            {
2717
                foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
2718
                {
2719
                    string MarkupData = "";
2720

    
2721
                    if (item.GetType().Name == "AdornerFinal")
2722
                    {
2723
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
2724
                        {
2725
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
2726
                            {
2727
                                MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn res = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
2728
                                MarkupData += "|OR|" + res.ConvertData;
2729
                            }
2730
                        }
2731
                        //클립보드에 넣음
2732
                        Clipboard.SetText(MarkupData);
2733
                    }
2734
                }
2735
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Clear();
2736
            }
2737
        }
2738

    
2739
        public async void Paste_Start()
2740
        {
2741
            //마크업 붙여넣기
2742
            if (Clipboard.GetText().Contains("|OR||DZ|"))
2743
            {
2744
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2745

    
2746
                string[] delimiterChars = { "|OR|" };
2747
                string[] data = Clipboard.GetText().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
2748

    
2749
                SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
2750

    
2751
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2752

    
2753
                //강인구 Undo/Redo 보류
2754
                MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
2755
                {
2756
                    IsUndo = false,
2757
                    Event = Event_Type.Create,
2758
                    EventTime = DateTime.Now,
2759
                    Markup_List = new List<Multi_Undo_data>()
2760
                };
2761

    
2762
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2763
                {
2764
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2765
                });
2766

    
2767
                foreach (string parse in data)
2768
                {
2769
                    if (parse != "")
2770
                    {
2771
                        System.Windows.Controls.Control item = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
2772
                        (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
2773

    
2774
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
2775
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
2776

    
2777
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
2778

    
2779
                        multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
2780

    
2781
                        UndoData.Markup_List.Add(multi_Undo_Data);
2782
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);                        
2783
                    }
2784
                }
2785
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2786

    
2787
                if(this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X < 0)
2788
                {
2789
                    Canvas.SetLeft(final, 0);
2790
                    Canvas.SetTop(final, 0);
2791
                }
2792
                else
2793
                {
2794
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
2795
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
2796
                    final.TranslateItems(realPointX, realPointY);
2797

    
2798
                    if (final.Members.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
2799
                    {
2800
                        final.TranslateItems(0.001, 0.001); //dummy
2801
                    }
2802
                }
2803

    
2804
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
2805
            }
2806
            //외부 이미지 붙여넣기
2807
            else if (Clipboard.GetImage() != null)
2808
            {
2809
                try
2810
                {
2811
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2812

    
2813
                    //강인구 Undo/Redo 보류
2814
                    MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
2815
                    {
2816
                        IsUndo = false,
2817
                        Event = Event_Type.Create,
2818
                        EventTime = DateTime.Now,
2819
                        Markup_List = new List<Multi_Undo_data>()
2820
                    };
2821

    
2822

    
2823
                    string temppath = System.IO.Path.GetTempPath();
2824
                    //string filename = KCOM.Events.Save.shortCommentKey();
2825
                    string filename = Commons.shortFileKey();
2826

    
2827
                    System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage();
2828
                    clipboardImage.Save(temppath + "\\" + filename);
2829

    
2830
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(temppath + "\\" + filename);
2831
                    String strFile = System.IO.Path.GetFileName(fileInfo.FullName);
2832
                    long numByte = fileInfo.Length;
2833
                    double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
2834
                    kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
2835

    
2836
                    if (dLen < 4)
2837
                    {
2838
                        System.IO.FileStream fStream = new System.IO.FileStream(fileInfo.FullName,
2839
                        System.IO.FileMode.Open, System.IO.FileAccess.Read);
2840
                        System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
2841
                        byte[] data = br.ReadBytes((int)numByte);
2842

    
2843
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, this.ParentOfType<MainWindow>().dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data);
2844
                        Check_Uri.UriCheck(filename);
2845
                        br.Close();
2846
                        fStream.Close();
2847
                        fStream.Dispose();
2848
                    }
2849
                    else
2850
                    {
2851
                        this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
2852
                        return;
2853
                    }
2854

    
2855
                    fileInfo.Delete();
2856

    
2857
                    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(clipboardImage);
2858
                    IntPtr hBitmap = bmp.GetHbitmap();
2859
                    System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
2860
                    Image img = new Image();
2861
                    if (filename.Contains(".svg"))
2862
                    {
2863
                        byte[] imageData = null;
2864
                        DrawingImage image = null;
2865
                        using (System.Net.WebClient web = new System.Net.WebClient())
2866
                        {
2867
                            imageData = web.DownloadData(new Uri(filename));
2868
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2869
                            image = SvgReader.Load(stream);
2870
                        }
2871
                        img.Source = image;
2872
                    }
2873
                    else
2874
                    {
2875
                        img.Source = new BitmapImage(new Uri(filename));
2876
                    }
2877

    
2878
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2879
                    {
2880
                        PointSet = new List<Point>(),
2881
                        FilePath = filename,
2882
                        ImageData = img.Source,
2883
                        StartPoint = new Point(100, 100),
2884
                        EndPoint = new Point(200, 200),
2885
                        TopRightPoint = new Point(100, 200),
2886
                        LeftBottomPoint = new Point(200, 100)
2887
                    };
2888

    
2889
                    currentControl.TopRightPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y);
2890
                    currentControl.LeftBottomPoint = new Point(currentControl.StartPoint.X, currentControl.StartPoint.Y + clipboardImage.Height);
2891
                    currentControl.EndPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y + clipboardImage.Height);
2892

    
2893
                    currentControl.PointSet = new List<Point>
2894
                                        {
2895
                                            currentControl.StartPoint,
2896
                                            currentControl.LeftBottomPoint,
2897
                                            currentControl.EndPoint,
2898
                                            currentControl.TopRightPoint,
2899
                                        };
2900

    
2901
                    multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2902
                    UndoData.Markup_List.Add(multi_Undo_Data);
2903
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2904

    
2905
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2906
                    currentControl.CommentID = Commons.shortGuid();
2907

    
2908
                    currentControl.ApplyTemplate();
2909
                    currentControl.SetImage();
2910

    
2911
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2912
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2913
                    this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
2914

    
2915
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
2916
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
2917
                    final.TranslateItems(realPointX, realPointY);
2918
                }
2919
                catch(Exception ex)
2920
                {
2921
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("" + ex, "Alert");
2922
                }
2923
            }
2924
        }
2925
    }
2926
}
클립보드 이미지 추가 (최대 크기: 500 MB)