프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ ac4f1e13

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

1

2
using IKCOM;
3
using KCOM.Common;
4
using KCOM.Controls;
5
using KCOM.Events;
6
using KCOMDataModel.DataModel;
7
using MarkupToPDF.Common;
8
using MarkupToPDF.Controls.Cad;
9
using MarkupToPDF.Controls.Common;
10
using MarkupToPDF.Controls.Etc;
11
using MarkupToPDF.Controls.Line;
12
using MarkupToPDF.Controls.Parsing;
13
using MarkupToPDF.Controls.Polygon;
14
using MarkupToPDF.Controls.Shape;
15
using MarkupToPDF.Controls.Text;
16
using Svg2Xaml;
17
using System;
18
using System.Collections.Generic;
19
using System.Diagnostics;
20
using System.Linq;
21
using System.Reflection;
22
using System.Runtime.InteropServices;
23
using System.Text;
24
using System.Threading;
25
using System.Threading.Tasks;
26
using System.Web;
27
using System.Windows;
28
using System.Windows.Controls;
29
using System.Windows.Ink;
30
using System.Windows.Input;
31
using System.Windows.Media;
32
using System.Windows.Media.Imaging;
33
using System.Windows.Shapes;
34
using System.Windows.Threading;
35
using Telerik.Windows.Controls;
36
using Telerik.Windows.Data;
37
using static KCOM.TempFile;
38

    
39
namespace KCOM.Views
40
{
41
    public static class ControlExtensions
42
    {
43
        public static T Clone<T>(this T controlToClone)
44
            where T : System.Windows.Controls.Control
45
        {
46
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
47

    
48
            T instance = Activator.CreateInstance<T>();
49

    
50
            foreach (PropertyInfo propInfo in controlProperties)
51
            {
52
                if (propInfo.CanWrite)
53
                {
54
                    if (propInfo.Name != "WindowTarget")
55
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
56
                }
57
            }
58
            return instance;
59
        }
60
    }
61

    
62
    public class MyConsole
63
    {
64
        private readonly System.Threading.ManualResetEvent _readLineSignal;
65
        private string _lastLine;
66
        public MyConsole()
67
        {
68
            _readLineSignal = new System.Threading.ManualResetEvent(false);
69
            Gui = new TextBox();
70
            Gui.AcceptsReturn = true;
71
            Gui.KeyUp += OnKeyUp;
72
        }
73

    
74
        private void OnKeyUp(object sender, KeyEventArgs e)
75
        {
76
            // this is always fired on UI thread
77
            if (e.Key == Key.Enter)
78
            {
79
                // quick and dirty, but that is not relevant to your question
80
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
81
                // now, when you detected that user typed a line, set signal
82
                _readLineSignal.Set();
83
            }
84
        }
85

    
86
        public TextBox Gui { get; private set; }
87

    
88
        public string ReadLine()
89
        {
90
            // that should always be called from non-ui thread
91
            if (Gui.Dispatcher.CheckAccess())
92
                throw new Exception("Cannot be called on UI thread");
93
            // reset signal
94
            _readLineSignal.Reset();
95
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
96
            _readLineSignal.WaitOne();
97
            // we got signalled - return line user typed.
98
            return _lastLine;
99
        }
100

    
101
        public void WriteLine(string line)
102
        {
103
            if (!Gui.Dispatcher.CheckAccess())
104
            {
105
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
106
                return;
107
            }
108

    
109
            Gui.Text += line + Environment.NewLine;
110
        }
111
    }
112

    
113
    /// <summary>
114
    /// MainMenu.xaml에 대한 상호 작용 논리
115
    /// </summary>
116
    public partial class MainMenu : UserControl
117
    {
118
        #region 프로퍼티
119
        public CommentUserInfo currentControl { get; set; }
120
        public ControlType controlType { get; set; }
121
        private Move move = new Move();
122
        private double[] rotateValue = { 0, 90, 180, 270 };
123
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
124
        private static readonly double DragThreshold = 5;
125
        private System.Windows.Input.Cursor cursor { get; set; }
126

    
127
        /// <summary>
128
        ///  문서의 마우스 위치
129
        /// </summary>
130
        public Point CanvasDrawingMouseDownPoint;
131

    
132
        public string filename { get; set; }
133
        private Point canvasZoomPanningMouseDownPoint;
134
        public Point getCurrentPoint;
135
        private Point canvasZoommovingMouseDownPoint;
136
        List<object> ControlList = new List<object>();
137
        private ListBox listBox = new ListBox();
138
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
139
        private bool isDraggingSelectionRect = false;
140
        DrawingAttributes inkDA = new DrawingAttributes();
141
        private VPRevision CurrentRev { get; set; }
142
        public RadRibbonButton btnConsolidate { get; set; }
143
        public RadRibbonButton btnFinalPDF { get; set; }
144
        public RadRibbonButton btnTeamConsolidate { get; set; }
145
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
146

    
147
        public string Filename_ { get; set; }
148
        public double L_Size = 0;
149
        public AdornerFinal adorner_;
150
        public Multi_Undo_data multi_Undo_Data;
151
        public string Symbol_ID = "";
152
        /// <summary>
153
        /// Set to 'true' when the left mouse-button is down.
154
        /// </summary>
155
        public bool isLeftMouseButtonDownOnWindow = false;
156

    
157
        public InkPresenter _InkBoard = null;
158
        Stroke stroke;
159
        Boolean IsDrawing = false;
160
        StylusPointCollection strokePoints;
161
        //StylusPointCollection erasePoints;
162
        RenderTargetBitmap canvasImage;
163
        Point Sync_Offset_Point;
164

    
165
        //강인구 테스트
166
        private Path _SelectionPath { get; set; }
167
        public Path SelectionPath
168
        {
169
            get
170
            {
171
                return _SelectionPath;
172
            }
173
            set
174
            {
175
                if (_SelectionPath != value)
176
                {
177
                    _SelectionPath = value;
178
                    RaisePropertyChanged("SelectionPath");
179

    
180
                }
181
            }
182
        }
183

    
184
        private System.Windows.Controls.Image _imageViewer { get; set; }
185
        public System.Windows.Controls.Image imageViewer
186
        {
187
            get
188
            {
189
                if (_imageViewer == null)
190
                {
191
                    _imageViewer = new System.Windows.Controls.Image();
192
                    return _imageViewer;
193
                }
194
                else
195
                {
196
                    return _imageViewer;
197
                }
198
            }
199
            set
200
            {
201
                if (_imageViewer != value)
202
                {
203
                    _imageViewer = value;
204
                }
205
            }
206
        }
207

    
208
        public bool IsSyncPDFMode { get; set; }
209

    
210
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
211
        public System.Windows.Controls.Image imageViewer_Compare
212
        {
213
            get
214
            {
215
                if (_imageViewer_Compare == null)
216
                {
217
                    _imageViewer_Compare = new System.Windows.Controls.Image();
218
                    return _imageViewer_Compare;
219
                }
220
                else
221
                {
222
                    return _imageViewer_Compare;
223
                }
224
            }
225
            set
226
            {
227
                if (_imageViewer_Compare != value)
228
                {
229
                    _imageViewer_Compare = value;
230
                }
231
            }
232
        }
233

    
234
        #endregion
235

    
236
        public MainMenu()
237
        {
238
            //App.splashString(ISplashMessage.MAINMENU_0);            
239
           InitializeComponent();
240

    
241
            //List<testItem> testItems = new List<testItem>
242
            //{
243
            //    new testItem{Title = "test1"},
244
            //    new testItem{Title = "test2"},
245
            //    new testItem{Title = "test3"},
246
            //    new testItem{Title = "test4"},
247
            //};
248

    
249
            //lstSymbolPrivate.ItemsSource = testItems;
250

    
251
            this.Loaded += MainMenu_Loaded;
252
        }
253

    
254
        public class TempDt
255
        {
256
            public int PageNumber { get; set; }
257
            public string CommentID { get; set; }
258
            public string ConvertData { get; set; }
259
            public int DATA_TYPE { get; set; }
260
            public string MarkupInfoID { get; set; }
261
            public int IsUpdate { get; set; }
262
        }
263

    
264
        List<TempDt> tempDtList = new List<TempDt>();
265

    
266
        private void SetCursor()
267
        {
268
            this.Cursor = cursor;
269
        }
270

    
271
        /// <summary>
272
        /// get image url
273
        /// </summary>
274
        /// <author>humkyung</author>
275
        /// <param name="sDocumentID"></param>
276
        /// <returns></returns>
277
        public string GetImageURL(string sDocumentID, int iPageNo)
278
        {
279
            string uri = string.Empty;
280

    
281
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
282
            if (userData.COMPANY != "EXT")
283
            {
284
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
285
            }
286
            else
287
            {
288
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
289
            }
290

    
291
            return uri;
292
        }
293

    
294
        /// <summary>
295
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
296
        /// </summary>
297
        /// <returns></returns>
298
        public string GetOriginalPDFURL()
299
        {
300
            string uri = string.Empty;
301
            string sDocumentID = this._DocItem.DOCUMENT_ID;
302
            string filename = string.Empty;
303
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
304
            {
305
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
306
            }
307
            else
308
            {
309
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
310
            }
311

    
312
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
313
            if (userData.COMPANY != "EXT")
314
            {
315
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
316
            }
317
            else
318
            {
319
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
320
            }
321
            uri = uri.Replace(".png", "");
322
            return uri;
323
        }
324

    
325
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
326
        {
327
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
328
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
329
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
330
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
331
            {
332
                return true;
333
            }
334

    
335
            return false;
336
        }
337

    
338
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
339
        {
340
            if (rotate.Angle == 90 || rotate.Angle == 270)
341
            {
342
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
343
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
344
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
345
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
346
                {
347
                    return true;
348
                }
349
            }
350
            else
351
            {
352
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
353
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
354
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
355
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
356
                {
357
                    return true;
358
                }
359
            }
360

    
361
            return false;
362
        }
363

    
364
        public void DeleteItem(MarkupInfoItem item)
365
        {
366
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
367
            {
368
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
369

    
370
            
371
            ViewerDataModel.Instance._markupInfoList.Remove(item);
372

    
373
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
374
            {
375
                ViewerDataModel.Instance.MarkupControls.Remove(a);
376
            });
377

    
378
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
379
            {
380
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
381
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
382
                null, Event_Type.Delete, a.CommentID, null);
383
            });
384

    
385
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
386
            {
387
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
388
                //임시파일에서도 삭제
389
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
390
            });
391

    
392
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
393

    
394
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
395
            {
396
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
397
                {
398
                    var infoId = Commons.shortGuid();
399
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
400
                    {
401
                        CreateTime = DateTime.Now,
402
                        Depatment = userData.DEPARTMENT,
403
                        UpdateTime = DateTime.Now,
404
                        DisplayColor = "#FFFF0000",
405
                        UserID = userData.ID,
406
                        UserName = userData.NAME,
407
                        PageCount = 1,
408
                        Description = "",
409
                        MarkupInfoID = infoId,
410
                        MarkupList = null,
411
                        MarkupVersionID = Commons.shortGuid(),
412
                        Consolidate = 0,
413
                        PartConsolidate = 0,
414
                        userDelete = true,
415
                        AvoidConsolidate = 0,
416
                        IsPreviewUser = true
417
                    };
418
                    App.Custom_ViewInfoId = infoId;
419
                }
420
            }
421
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
422
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);    
423
        }
424

    
425
        /// <summary>
426
        /// delete selected comments
427
        /// </summary>
428
        /// <param name="sender"></param>
429
        /// <param name="e"></param>
430
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
431
        {
432
            //정말 삭제 하시겠습니까?
433
            DialogParameters parameters = new DialogParameters()
434
            {
435
                Owner = Application.Current.MainWindow,
436
                Content = new TextBlock()
437
                { 
438
                    MinWidth = 400,
439
                    FontSize = 11,
440
                    Text = "Are you sure you want to delete?",
441
                    TextWrapping = System.Windows.TextWrapping.Wrap
442
                },
443
                Header = "Confirm",
444
                Theme = new VisualStudio2013Theme(),
445
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
446
                OkButtonContent = "Yes",
447
                CancelButtonContent = "No",
448
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
449
                {
450
                    if(wc.DialogResult == true)
451
                    {
452
                        //선택된 어도너가 있을시 삭제가 되지 않음
453
                        SelectionSet.Instance.UnSelect(this);
454

    
455
                        Button content = (sender as Button);
456
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
457

    
458
                        DeleteItem(item);
459
                    }
460
                }
461
            };
462
            RadWindow.Confirm(parameters);
463
        }
464

    
465
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
466

    
467
        private static Timer timer;
468
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
469
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
470
        {
471
            //InitializeComponent();            
472
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
473

    
474
            if (App.ParameterMode)
475
            {
476
                App.splashString(ISplashMessage.MAINMENU_1);
477
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
478
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
479
                imageViewer_Compare = new Image();
480
                ViewerDataModel.Instance.Capture_Opacity = 0;
481
                da.From = 0.8;
482
                da.To = 0;
483
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
484
                da.AutoReverse = true;
485
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
486

    
487
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
488
                {
489
                    this.SymbolPane.Visibility = Visibility.Collapsed;
490
                    this.FavoritePane.Visibility = Visibility.Collapsed;
491
                    this.drawingRotateCanvas.IsHitTestVisible = false;
492
                }
493
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
494
            }
495

    
496
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
497

    
498
        }
499

    
500
        private async Task DownloadOriginalFileAsync()
501
        {
502
            try
503
            {
504
                using (System.Net.WebClient client = new System.Net.WebClient())
505
                {
506
                    string instnaceFile = System.IO.Path.GetTempFileName().Replace(".pdf", ".tmp");
507
                    string downloadurl = GetOriginalPDFURL();
508
                    
509
                    // canceltoken을 위해서 상위에 선언
510
                    var task = client.DownloadFileTaskAsync(new Uri(downloadurl), instnaceFile);
511

    
512
                    client.DownloadProgressChanged += (snd, evt) =>
513
                    {
514
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
515

    
516
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
517
                    };
518

    
519
                    await task;
520

    
521
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
522
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
523
                    ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
524
                }
525
            }
526
            catch (Exception ex)
527
            {
528
                Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0);
529
            }
530
        }
531

    
532
        private void timercallback(Object o)
533
        {
534
            Stopwatch sw = new Stopwatch();
535
            sw.Start();
536
            TempFile.TempFileAdd();
537
            sw.Stop();
538

    
539
            Dispatcher.InvokeAsync(new Action(delegate
540
            {
541
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
542
                {
543
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
544
                }
545
            }));
546

    
547
            ////GC.Collect();
548
        }
549
        
550
        /// <summary>
551
        /// update my markuplist
552
        ///  - update existing markup data if already exist
553
        ///  - add new markup data if control is new
554
        /// </summary>
555
        public void UpdateMyMarkupList()
556
        {
557
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
558

    
559
            /// add or update markup list
560
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
561
            {
562
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
563

    
564
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
565
                if (exist != null) //신규 추가 된 코멘트
566
                {
567
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
568
                    {
569
                        exist.Data = root.ConvertData;
570
                        exist.IsUpdate = true;
571
                    }
572
                }
573
                else if (root.CommentID != null)
574
                {
575
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
576
                    {
577
                        ID = control.CommentID,
578
                        Data = root.ConvertData,
579
                        Data_Type = root.DATA_TYPE,
580
                        MarkupInfoID = App.Custom_ViewInfoId,
581
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
582
                        Symbol_ID = control.SymbolID,
583
                        //Group_ID = control.GroupID,
584
                    });
585
                }
586
            }
587

    
588
            /// delete markup list
589
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
590

    
591
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
592
                          where (markup.PageNumber == iPageNo) 
593
                          && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
594
                          select markup).ToList();
595

    
596
            foreach (var markup in deleted)
597
            {
598
                ViewerDataModel.Instance.MyMarkupList.Remove(markup);
599
            }
600
            /// up to here
601

    
602
            //if (modified)
603
            //{
604
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
605
            //    {
606
            //        ComingNewBieEnd = true;
607
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
608
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
609
            //        gridViewMarkup.ItemsSource = null;
610
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
611
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
612

    
613
            //        GroupDescriptor descriptor = new GroupDescriptor();
614
            //        descriptor.Member = "Depatment";
615
            //        descriptor.DisplayContent = "DEPT";
616
            //        descriptor.SortDirection = ListSortDirection.Ascending;
617
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
618
            //    }
619
            //}
620
        }
621

    
622
        DispatcherTimer renderTesttimer;
623

    
624
        /// <summary>
625
        /// start page changing
626
        ///  - save controls if page is modified
627
        ///  - starting download page image
628
        /// </summary>
629
        /// <param name="sender"></param>
630
        /// <param name="e"></param>
631
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
632
        {
633
            // 마크업 로드
634
            await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
635

    
636

    
637
            // 페이지 이미지 변경
638
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
639
        }
640

    
641
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber)
642
        { 
643
            CompareMode.IsChecked = false;
644
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
645
           
646
            #region 페이지가 벗어난 경우
647

    
648
            if (BalancePoint < 1)
649
            {
650
                BalancePoint = 1;
651
                ViewerDataModel.Instance.PageBalanceNumber = 0;
652
            }
653

    
654
            if (pageNavigator.PageCount < BalancePoint)
655
            {
656
                BalancePoint = pageNavigator.PageCount;
657
                ViewerDataModel.Instance.PageBalanceNumber = 0;
658
            }
659

    
660
            #endregion
661

    
662
            ViewerDataModel.Instance.PageNumber = BalancePoint;
663

    
664
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
665
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
666
            var contentScale = zoomAndPanControl.ContentScale;
667

    
668
            #region 페이지 이미지 로딩 수정
669

    
670
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageAsync(changePageNumber);
671
       
672
            ScaleImage(pageWidth, pageHeight);
673

    
674
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
675
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
676

    
677
            zoomAndPanCanvas.Width = pageWidth;
678
            zoomAndPanCanvas.Height = pageHeight;
679

    
680
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
681
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
682

    
683
            inkBoard.Width = pageWidth;
684
            inkBoard.Height = pageHeight;
685

    
686
            #endregion
687

    
688
            if (!testPanel2.IsHidden)
689
            {
690
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
691
                //PDF모드일때 잠시 대기(강인구)
692
                if (IsSyncPDFMode)
693
                {
694
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
695
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
696

    
697
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
698
                    if (pdfpath.IsDownloading)
699
                    {
700
                        pdfpath.DownloadCompleted += (ex, arg) =>
701
                        {
702
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
703
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
704
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
705
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
706
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
707
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
708
                        };
709
                    }
710
                    else
711
                    {
712
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
713
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
714
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
715
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
716

    
717
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
718
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
719
                    }
720
                }
721
                else
722
                {
723
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
724
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
725

    
726
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
727
                    var defaultBitmapImage_Compare = new BitmapImage();
728
                    defaultBitmapImage_Compare.BeginInit();
729
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
730
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
731
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
732
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
733
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
734
                    defaultBitmapImage_Compare.EndInit();
735

    
736
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
737

    
738
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
739
                    zoomAndPanControl.ZoomTo(new Rect
740
                    {
741
                        X = 0,
742
                        Y = 0,
743
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
744
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
745
                    });
746

    
747
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
748
                    if (defaultBitmapImage_Compare.IsDownloading)
749
                    {
750
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
751
                        {
752
                            defaultBitmapImage_Compare.Freeze();
753
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
754
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
755
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
756
                            ComparePanel.UpdateLayout();
757
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
758
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
759

    
760
                            zoomAndPanControl.ZoomTo(new Rect
761
                            {
762
                                X = 0,
763
                                Y = 0,
764
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
765
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
766
                            });
767

    
768
                            //defaultBitmapImage_Compare dispose
769
                            defaultBitmapImage_Compare = null;
770
                            GC.Collect();
771
                        };
772
                    }
773
                }
774
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
775
            }
776

    
777
            SearchFocusBorder.Visibility = Visibility.Collapsed;
778

    
779
            this.pageNavigator.ChangePage(changePageNumber);
780
        }
781

    
782
        /// <summary>
783
        /// called after page is changed
784
        /// </summary>
785
        /// <param name="sender"></param>
786
        /// <param name="e"></param>
787
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
788
        {
789
            //if (zoomAndPanCanvas.Width.IsNaN())
790
            //{
791

    
792
            await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
793
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
794
                );
795
            //}
796

    
797

    
798
            var instanceMain = ViewerDataModel.Instance.SystemMain;
799

    
800
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
801
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
802

    
803
            instanceMain.dzTopMenu.rotateOffSet = 0;
804
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
805
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
806

    
807
            /// 페이지의 모든 마크업을 로드한 후 호출
808
            /// 좌측 마크업 list의 아이템을 클릭하는 경우 MarkupControls_USER가 0으로 나와서 추가함.
809
            ViewerDataModel.Instance.LoadPageMarkup();
810
        }
811

    
812
        private async void MarkupLoad(int pageNumber)
813
        {
814
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
815
            stopwatch.Start();
816

    
817
            /// 컨트롤을 새로 생성한다.
818
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
819
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
820

    
821
            System.Diagnostics.Debug.WriteLine("MarkupLoad - Clear " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
822

    
823
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
824
            { 
825
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
826
                if (info != null)
827
                {
828
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
829
                    if (info.UserID == App.ViewInfo.UserID)
830
                    {
831
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
832
                                        markup.MarkupInfoID, markup.ID);
833
                        control.Visibility = Visibility.Hidden;
834
                    }
835
                    else
836
                    {
837
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
838
                                                                markup.MarkupInfoID, markup.ID);
839
                        control.Visibility = Visibility.Hidden;
840
                    }
841
                }
842
            };
843
            /// up to here
844

    
845
            System.Diagnostics.Debug.WriteLine("MarkupLoad - MarkupParser " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
846

    
847
            /// fire selection event
848
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
849
            this.gridViewMarkup.UnselectAll();
850
            this.gridViewMarkup.Select(gridSelectionItem);
851

    
852
            if (!testPanel2.IsHidden)
853
            {
854
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
855
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
856
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
857

    
858
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
859
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
860

    
861

    
862
                foreach (var item in gridSelectionRevItem)
863
                {
864
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
865

    
866
                    foreach (var markupitem in markupitems)
867
                    {
868
                        await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
869
                    }
870
                }
871
            }
872

    
873
            System.Diagnostics.Debug.WriteLine("MarkupLoad - MarkupParser 2 " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
874

    
875
            SetCommentPages();
876

    
877
            System.Diagnostics.Debug.WriteLine("MarkupLoad - SetCommentPages " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
878
        }
879

    
880
        public void SetCommentPages()
881
        {
882
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
883
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
884
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
885
            {
886
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
887
                if(item.MarkupList != null)
888
                {
889
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
890
                    instance.UserName = item.UserName;
891
                    instance.Depart = item.Depatment;
892
                    instance.MarkupInfoID = item.MarkupInfoID;
893
                    instance.IsSelected = true;
894
                    instance.isConSolidation = item.Consolidate;
895
                    instance.SetColor = item.DisplayColor;
896
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
897
                    {
898
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
899
                    }
900
                    else
901
                    {
902
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
903
                    }
904
                    _pages.Add(instance);
905
                }                   
906
            }
907
            
908
            this.pageNavigator.SetCommentList(_pages.ToList());
909
        }
910

    
911
        public void MarkupitemViewUpdate(string markupinfo_id)
912
        {
913
            //db에 업데이트 한 list 를 view 에 업데이트
914
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
915
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
916
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
917
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
918
            if (dbinfo.MarkupList.Count > 0)
919
            {
920
                if (viewinfo.MarkupList != null)
921
                {
922
                    viewinfo.MarkupList.Clear();
923
                    viewinfo.MarkupList = null;
924
                }
925
                viewinfo.MarkupList = new List<MarkupItem>();
926
                foreach (var item in dbinfo.MarkupList)
927
                {
928
                    viewinfo.MarkupList.Add(item);
929
                }
930
            }
931
        }
932

    
933
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
934
        {
935
            var instance = ViewerDataModel.Instance;
936

    
937
            if(instance.IsWheelPageChanage)
938
            {
939
                return;
940
            }
941

    
942
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
943
            {
944
       
945
                int changePage = 0;
946
                
947
                if (e.Delta > 0)
948
                {
949
                    if (0 < instance.ContentOffsetY)
950
                    {
951
                        Vector dragOffset = new Vector(0, e.Delta);
952
                        MoveZoomAndPanControl(dragOffset);
953
                    }
954
                    //else
955
                    //{
956
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
957
                    //    {
958
                    //        instance.IsWheelPageChanage = true;
959
                    //        changePage -= 1;
960
                    //    }
961
                    //}
962
                }
963
                else if(e.Delta < 0)
964
                {
965
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
966
                    {
967
                        Vector dragOffset = new Vector(0,e.Delta);
968
                        MoveZoomAndPanControl(dragOffset);
969
                    }
970
                    //else
971
                    //{
972
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
973
                    //    {
974
                    //        instance.IsWheelPageChanage = true;
975
                    //        changePage += 1;
976
                    //    }
977
                    //}
978
                }
979

    
980
                //if (changePage != 0)
981
                //{
982
                //    await Task.Factory.StartNew(() =>
983
                //    {
984
                //        double beforeScale = instance.ContentScale;
985

    
986
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
987

    
988
                //        handler = (snd, evt) =>
989
                //        {
990
                //            /// 최상단으로 이전 zoomScale로 위치한다
991
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
992
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
993
                //            instance.IsWheelPageChanage = false;
994
                //            pageNavigator.PageChanged -= handler;
995
                //        };
996

    
997
                //        pageNavigator.PageChanged += handler;
998

    
999
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1000
                //    });
1001
                    
1002

    
1003
                //}
1004
            }
1005
            else
1006
            {
1007
                e.Handled = true;
1008
                if (e.Delta > 0)
1009
                {
1010
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1011
                    ZoomIn(currentContentMousePoint);
1012
                }
1013
                else
1014
                {
1015
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1016
                    ZoomOut(currentContentMousePoint);
1017
                }
1018
            }
1019
        }
1020

    
1021
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1022
        {
1023
            e.Handled = true;
1024
            if (e.Delta > 0)
1025
            {
1026
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1027
                ZoomIn_Sync(currentContentMousePoint);
1028
            }
1029
            else
1030
            {
1031
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1032
                ZoomOut_Sync(currentContentMousePoint);
1033
            }
1034
        }
1035

    
1036
        #region ZoomIn & ZoomOut
1037

    
1038
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1039
        {
1040
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1041
                zoomAndPanControl.ContentZoomFocusY));
1042
        }
1043

    
1044
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1045
        {
1046
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1047
                zoomAndPanControl.ContentZoomFocusY));
1048
        }
1049

    
1050

    
1051
        //강인구 추가 (줌 인아웃 수치 변경)
1052
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1053
        private void ZoomOut(Point contentZoomCenter)
1054
        {
1055
            if (zoomAndPanControl.ContentScale > 0.39)
1056
            {
1057
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1058
            }
1059
            else
1060
            {
1061
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1062
            }
1063

    
1064
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1065
            {
1066
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1067
            }
1068
        }
1069

    
1070
        private void ZoomIn(Point contentZoomCenter)
1071
        {
1072
            if (zoomAndPanControl.ContentScale > 0.19)
1073
            {
1074
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1075
            }
1076
            else
1077
            {
1078
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1079
            }
1080

    
1081
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1082
            {
1083
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1084
            }
1085

    
1086
        }
1087

    
1088
        private void ZoomOut_Sync(Point contentZoomCenter)
1089
        {
1090
            if (zoomAndPanControl2.ContentScale > 0.39)
1091
            {
1092
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1093
            }
1094
            else
1095
            {
1096
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1097
            }
1098

    
1099
            if (Sync.IsChecked)
1100
            {
1101
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1102
            }
1103
        }
1104

    
1105
        private void ZoomIn_Sync(Point contentZoomCenter)
1106
        {
1107
            if (zoomAndPanControl2.ContentScale > 0.19)
1108
            {
1109
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1110
            }
1111
            else
1112
            {
1113
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1114
            }
1115

    
1116
            if (Sync.IsChecked)
1117
            {
1118
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1119
            }
1120
        }
1121

    
1122
        private void ZoomOut()
1123
        {
1124
            zoomAndPanControl.ContentScale -= 0.1;
1125
            //if (zoomAndPanControl2 != null)
1126
            //{
1127
            //    zoomAndPanControl2.ContentScale -= 0.1;
1128
            //}
1129
        }
1130

    
1131
        private void ZoomIn()
1132
        {
1133
            zoomAndPanControl.ContentScale += 0.1;
1134
            //if (zoomAndPanControl2 != null)
1135
            //{
1136
            //    zoomAndPanControl2.ContentScale += 0.1;
1137
            //}
1138
        }
1139

    
1140
        #endregion
1141

    
1142
        private void init()
1143
        {
1144
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1145
            {
1146

    
1147
                ControlList.Clear();
1148
                listBox.Items.Clear();
1149
                selected_item.Clear();
1150

    
1151
                (item as IMarkupCommonData).IsSelected = false;
1152
            }
1153

    
1154
        }
1155

    
1156
        private HitTestResultBehavior MyCallback(HitTestResult result)
1157
        {
1158
            //this.cursor = Cursors.UpArrow;
1159
            var element = result.VisualHit;
1160
            while (element != null && !(element is CommentUserInfo))
1161
                element = VisualTreeHelper.GetParent(element);
1162

    
1163
            if (element == null)
1164
            {
1165
                return HitTestResultBehavior.Stop;
1166
            }
1167
            else
1168
            {
1169
                if (element is CommentUserInfo)
1170
                {
1171
                    if (!hitList.Contains(element))
1172
                    {
1173
                        hitList.Add((CommentUserInfo)element);
1174
                    }
1175
                    else
1176
                    {
1177
                        return HitTestResultBehavior.Stop;
1178
                    }
1179
                }
1180
            }
1181
            return HitTestResultBehavior.Continue;
1182
        }
1183

    
1184
        public void ReleaseSelectPath()
1185
        {
1186
            if (SelectionPath == null)
1187
            {
1188
                SelectionPath = new Path();
1189
                SelectionPath.Name = "";
1190
            }
1191
            if (SelectionPath.Name != "")
1192
            {
1193
                SelectionPath.Name = "None";
1194
            }
1195
            SelectionPath.Opacity = 0.01;
1196
            SelectionPath.RenderTransform = null;
1197
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1198
        }
1199

    
1200
        #region 컨트롤 초기화 
1201
        public void Control_Init(object control)
1202
        {
1203
            if (L_Size != 0 && (control as IPath) != null)
1204
            {
1205
                (control as IPath).LineSize = L_Size;
1206
                L_Size = 0;
1207
            }
1208

    
1209
            switch (control.GetType().Name)
1210
            {
1211
                case "RectangleControl":
1212
                    {
1213
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1214
                    }
1215
                    break;
1216
                case "CircleControl":
1217
                    {
1218
                        (control as CircleControl).StrokeColor = Brushes.Red;
1219
                    }
1220
                    break;
1221
                case "TriControl":
1222
                    {
1223
                        (control as TriControl).StrokeColor = Brushes.Red;
1224
                    }
1225
                    break;
1226
                case "RectCloudControl":
1227
                    {
1228
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1229
                    }
1230
                    break;
1231
                case "CloudControl":
1232
                    {
1233
                        (control as CloudControl).StrokeColor = Brushes.Red;
1234
                    }
1235
                    break;
1236
                case "PolygonControl":
1237
                    {
1238
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1239
                    }
1240
                    break;
1241
                case "ArcControl":
1242
                    {
1243
                        (control as ArcControl).StrokeColor = Brushes.Red;
1244
                    }
1245
                    break;
1246
                case "ArrowArcControl":
1247
                    {
1248
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1249
                    }
1250
                    break;
1251
                case "LineControl":
1252
                    {
1253
                        (control as LineControl).StrokeColor = Brushes.Red;
1254
                    }
1255
                    break;
1256
                case "ArrowControl_Multi":
1257
                    {
1258
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1259
                    }
1260
                    break;
1261
                case "TextControl":
1262
                    {
1263
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1264
                    }
1265
                    break;
1266
                case "ArrowTextControl":
1267
                    {
1268
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1269
                    }
1270
                    break;
1271
                case "InsideWhiteControl":
1272
                    {
1273
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1274
                    }
1275
                    break;
1276
                case "OverlapWhiteControl":
1277
                    {
1278
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1279
                    }
1280
                    break;
1281
                case "ClipWhiteControl":
1282
                    {
1283
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1284
                    }
1285
                    break;
1286
                case "CoordinateControl":
1287
                    {
1288
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1289
                    }
1290
                    break;
1291
            }
1292
        }
1293
        #endregion
1294

    
1295
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1296
        {
1297
            //Control_Init(e.Source);
1298
        }
1299
        //private Window _dragdropWindow = null;
1300

    
1301
        [DllImport("user32.dll")]
1302
        [return: MarshalAs(UnmanagedType.Bool)]
1303
        internal static extern bool GetCursorPos(ref Win32Point pt);
1304

    
1305
        [StructLayout(LayoutKind.Sequential)]
1306
        internal struct Win32Point
1307
        {
1308
            public Int32 X;
1309
            public Int32 Y;
1310
        };
1311
        /*
1312
       public string symbol_id = null;
1313
       public long symbol_group_id;
1314
       public int symbol_SelectedIndex;
1315
       public ImageSource symbol_img;
1316
       public string symbol_Data = null;
1317
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1318
       {
1319
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1320
               zoomAndPanCanvas.ActualHeight / 2));
1321

    
1322

    
1323
               if (this._dragdropWindow != null)
1324
               {
1325
                   this._dragdropWindow.Close();
1326
                   this._dragdropWindow = null;
1327
               }
1328

    
1329
               symbol_id = id;
1330
               symbol_group_id = group_id;
1331
               symbol_SelectedIndex = SelectedIndex;
1332
               symbol_Data = Data_;
1333
               symbol_img = img;
1334

    
1335

    
1336
               CreateDragDropWindow2(img);
1337
              
1338
    }
1339

    
1340
    private void CreateDragDropWindow2(ImageSource image)
1341
        {
1342
            this._dragdropWindow = new Window();
1343
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1344
            _dragdropWindow.WindowStyle = WindowStyle.None;
1345
            _dragdropWindow.AllowsTransparency = true;           
1346
            _dragdropWindow.AllowDrop = false;
1347
            _dragdropWindow.Background = null;
1348
            _dragdropWindow.IsHitTestVisible = false;
1349
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1350
            _dragdropWindow.Topmost = true;
1351
            _dragdropWindow.ShowInTaskbar = false;
1352
            
1353
            Rectangle r = new Rectangle();
1354
            r.Width = image.Width;
1355
            r.Height = image.Height;
1356
            r.Opacity = 0.5;            
1357
            r.Fill = new ImageBrush(image);
1358
            this._dragdropWindow.Content = r;
1359

    
1360
            Win32Point w32Mouse = new Win32Point();
1361
            GetCursorPos(ref w32Mouse);
1362

    
1363
            //w32Mouse.X = getCurrentPoint.X;
1364
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1365
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1366
            this._dragdropWindow.Show();
1367
        }
1368

    
1369
        
1370

    
1371
         */
1372

    
1373
        public void MoveZoomAndPanControl(Vector dragOffset)
1374
        {
1375
   
1376
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1377
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1378

    
1379
            if (Sync.IsChecked)
1380
            {
1381
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1382
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1383
            }
1384
        }
1385

    
1386
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1387
        {
1388
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1389
            {
1390
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1391

    
1392
                Point currentPos = e.GetPosition(rect);
1393

    
1394
                floatingTip.HorizontalOffset = currentPos.X + 20;
1395
                floatingTip.VerticalOffset = currentPos.Y;
1396
            }
1397

    
1398
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1399
            
1400
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1401
            {
1402
                SetCursor();
1403
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1404
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1405

    
1406
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1407

    
1408
                MoveZoomAndPanControl(dragOffset);
1409
            }
1410

    
1411
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1412
            {
1413
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1414
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1415
                SetCursor();
1416

    
1417
                if (currentControl != null)
1418
                {
1419
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1420
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1421
                    //강인구 추가
1422
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1423

    
1424
                    if ((currentControl as IPath) != null)
1425
                    {
1426
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1427
                    }
1428
                    if ((currentControl as LineControl) != null)
1429
                    {
1430
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1431
                    }
1432

    
1433
                    if ((currentControl as IShapeControl) != null)
1434
                    {
1435
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1436
                    }
1437
                    if ((currentControl as TextControl) != null)
1438
                    {
1439
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1440
                        {
1441
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1442
                        }
1443
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1444
                        {
1445
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1446
                        }
1447
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1448
                        {
1449
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1450
                        }
1451
                    }
1452
                    else if ((currentControl as ArrowTextControl) != null)
1453
                    {
1454
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1455
                        {
1456
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1457
                        }
1458
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1459
                        {
1460
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1461
                        }
1462
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1463
                        {
1464
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1465
                        }
1466
                    }
1467
                    else if ((currentControl as RectCloudControl) != null)
1468
                    {
1469
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1470
                    }
1471
                    else if ((currentControl as CloudControl) != null)
1472
                    {
1473
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1474
                    }
1475

    
1476

    
1477
                    #region // 모든 컨트롤의 공통기능 제어
1478
                    if (controlType != ControlType.PenControl)
1479
                    {
1480
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1481
                    }
1482

    
1483

    
1484
                    #endregion
1485

    
1486
                    #region // 각 컨트롤의 특별한 기능을 제어한다.
1487

    
1488
                    switch (controlType)
1489
                    {
1490
                        case (ControlType.Coordinate):
1491
                            {
1492
                                var control = currentControl as CoordinateControl;
1493
                                if (control != null)
1494
                                {
1495
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1496
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1497
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1498
                                }
1499
                            }
1500
                            break;
1501
                        case (ControlType.InsideWhite):
1502
                            {
1503
                                var control = currentControl as InsideWhiteControl;
1504
                                if (control != null)
1505
                                {
1506
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1507
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1508
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1509
                                    control.Paint = PaintSet.Fill;
1510
                                }
1511
                            }
1512
                            break;
1513
                        case ControlType.OverlapWhite:
1514
                            {
1515
                                var control = currentControl as OverlapWhiteControl;
1516
                                if (control != null)
1517
                                {
1518
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1519
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1520
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1521
                                    control.Paint = PaintSet.Fill;
1522
                                }
1523
                            }
1524
                            break;
1525
                        case ControlType.ClipWhite:
1526
                            {
1527
                                var control = currentControl as ClipWhiteControl;
1528
                                if (control != null)
1529
                                {
1530
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1531
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1532
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1533
                                    control.Paint = PaintSet.Fill;
1534
                                }
1535
                            }
1536
                            break;
1537
                        case ControlType.RectCloud:
1538
                            {
1539
                                var control = currentControl as RectCloudControl;
1540
                                if (control != null)
1541
                                {
1542
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1543
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1544
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1545
                                }
1546
                            }
1547
                            break;
1548
                        case ControlType.SingleLine:
1549
                        case ControlType.CancelLine:
1550
                        case ControlType.ArrowLine:
1551
                        case ControlType.TwinLine:
1552
                        case ControlType.DimLine:
1553
                            {
1554
                                var control = currentControl as LineControl;
1555
                                if (control != null)
1556
                                {
1557
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1558
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1559
                                }
1560

    
1561
                            }
1562
                            break;
1563

    
1564
                        case ControlType.ArcLine:
1565
                            {
1566
                                var control = currentControl as ArcControl;
1567
                                if (control != null)
1568
                                {
1569
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1570
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1571
                                }
1572
                            }
1573
                            break;
1574

    
1575
                        case ControlType.ArcArrow:
1576
                            {
1577
                                var control = currentControl as ArrowArcControl;
1578
                                if (control != null)
1579
                                {
1580
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1581
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1582
                                }
1583
                            }
1584
                            break;
1585

    
1586
                        case ControlType.ArrowMultiLine:
1587
                            {
1588
                                var control = currentControl as ArrowControl_Multi;
1589
                                if (control != null)
1590
                                {
1591
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1592
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1593
                                }
1594
                            }
1595
                            break;
1596

    
1597
                        case ControlType.Circle:
1598
                            {
1599
                                var control = currentControl as CircleControl;
1600

    
1601
                                if (control != null)
1602
                                {
1603
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1604
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1605
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1606
                                }
1607
                            }
1608
                            break;
1609

    
1610
                        case ControlType.PolygonCloud:
1611
                            {
1612
                                var control = currentControl as CloudControl;
1613
                                if (control != null)
1614
                                {
1615
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1616
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1617
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1618
                                }
1619
                            }
1620
                            break;
1621

    
1622
                        case ControlType.Triangle:
1623
                            {
1624
                                var control = currentControl as TriControl;
1625
                                if (control != null)
1626
                                {
1627
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1628
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1629
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1630
                                }
1631
                            }
1632
                            break;
1633

    
1634
                        case ControlType.ImgControl:
1635
                            {
1636
                                var control = currentControl as ImgControl;
1637
                                if (control != null)
1638
                                {
1639
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1640
                                }
1641
                            }
1642
                            break;
1643

    
1644
                        case ControlType.Date:
1645
                            {
1646
                                var control = currentControl as DateControl;
1647
                                if (control != null)
1648
                                {
1649
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1650
                                }
1651
                            }
1652
                            break;
1653

    
1654
                        case ControlType.ArrowTextControl:
1655
                        case ControlType.ArrowTransTextControl:
1656
                        case ControlType.ArrowTextBorderControl:
1657
                        case ControlType.ArrowTransTextBorderControl:
1658
                        case ControlType.ArrowTextCloudControl:
1659
                        case ControlType.ArrowTransTextCloudControl:
1660
                            {
1661
                                var control = currentControl as ArrowTextControl;
1662
                                if (control != null)
1663
                                {
1664
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1665
                                }
1666
                            }
1667
                            break;
1668
                        case ControlType.PolygonControl:
1669
                        case ControlType.ChainLine:
1670
                            {
1671
                                var control = currentControl as PolygonControl;
1672
                                if (control != null)
1673
                                {
1674
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1675
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1676
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1677
                                }
1678
                            }
1679
                            break;
1680
                        case ControlType.Sign:
1681
                            {
1682
                                var control = currentControl as SignControl;
1683
                                if (control != null)
1684
                                {
1685
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1686
                                }
1687
                            }
1688
                            break;
1689
                        case ControlType.Symbol:
1690
                            {
1691
                                var control = currentControl as SymControl;
1692
                                if (control != null)
1693
                                {
1694
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1695
                                }
1696
                            }
1697
                            break;
1698
                        case ControlType.Stamp:
1699
                            {
1700
                                var control = currentControl as SymControlN;
1701
                                if (control != null)
1702
                                {
1703
                                    if (control.STAMP != null)
1704
                                    {
1705
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1706
                                    }
1707
                                    else
1708
                                    {
1709
                                        currentControl = null;
1710
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1711
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1712
                                    }
1713
                                }
1714
                            }
1715
                            break;
1716
                        case ControlType.Rectangle:
1717
                        case ControlType.Mark:
1718
                            {
1719
                                var control = currentControl as RectangleControl;
1720
                                if (control != null)
1721
                                {
1722
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1723
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1724
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1725
                                }
1726
                            }
1727
                            break;
1728
                        case ControlType.PenControl:
1729
                            {
1730
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1731
                                //inkBoard.Strokes.Add(stroke);
1732
                            }
1733
                            break;
1734
                        default:
1735
                            break;
1736
                    }
1737

    
1738
                    #endregion
1739
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
1740
                    {
1741
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
1742
                    }
1743
                }
1744
            }
1745
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1746
            {
1747
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1748
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1749
                SetCursor();
1750
                if (currentControl == null)
1751
                {
1752
                    switch (controlType)
1753
                    {
1754
                        case ControlType.PenControl:
1755
                            {
1756
                                if (inkBoard.Tag.ToString() == "Ink")
1757
                                {
1758
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1759
                                }
1760
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1761
                                {
1762
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1763
                                }
1764
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1765
                                {
1766
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1767
                                }
1768

    
1769
                                //inkBoard.Strokes.Add(stroke);
1770
                            }
1771
                            break;
1772
                    }
1773
                    return;
1774
                }
1775
            }
1776
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1777
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1778
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1779
            {
1780
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1781

    
1782
                if (isDraggingSelectionRect)
1783
                {
1784
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1785
                    e.Handled = true;
1786
                }
1787
                else if (isLeftMouseButtonDownOnWindow)
1788
                {
1789
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1790
                    double dragDistance = Math.Abs(dragDelta.Length);
1791

    
1792
                    if (dragDistance > DragThreshold)
1793
                    {
1794
                        isDraggingSelectionRect = true;
1795
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1796
                    }
1797

    
1798
                    e.Handled = true;
1799
                }
1800

    
1801
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1802
                {
1803
                }
1804
                else
1805
                {
1806
                    e.Handled = true;
1807
                }
1808
            }
1809
            /*
1810
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1811
            { //symbol      
1812
                if(_dragdropWindow != null)
1813
                {
1814
                    Win32Point w32Mouse = new Win32Point();
1815
                    GetCursorPos(ref w32Mouse);
1816

    
1817
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1818
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1819
                }                
1820
            }
1821
            */
1822
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1823
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1824
            {
1825
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1826
                if(control != null)
1827
                {
1828
                    this.cursor = Cursors.Hand;
1829
                    SetCursor();
1830
                }
1831
                else
1832
                {
1833
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1834
                    SetCursor();
1835
                }
1836
            }
1837
            else
1838
            {
1839
            }
1840
        }
1841

    
1842
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1843
        {
1844
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1845
            {
1846
                SetCursor();
1847
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1848
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1849

    
1850
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1851

    
1852
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1853
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1854

    
1855
                if (Sync.IsChecked)
1856
                {
1857
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1858
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1859
                }
1860
            }
1861
        }
1862

    
1863
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1864

    
1865
        private EllipseGeometry hitArea = new EllipseGeometry();
1866

    
1867
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1868
        {
1869
            IsDrawing = false;
1870
    
1871
            if (mouseHandlingMode != MouseHandlingMode.None)
1872
            {
1873
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1874
                {
1875
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1876

    
1877
                    SetCursor();
1878

    
1879
                    switch (controlType)
1880
                    {
1881
                        case ControlType.None:
1882
                            break;
1883
                        case ControlType.Rectangle:
1884
                            {
1885

    
1886
                            }
1887
                            break;
1888
                        case ControlType.PenControl:
1889
                            {
1890

    
1891
                            }
1892
                            break;
1893
                        default:
1894
                            break;
1895
                    }                    
1896
                }
1897
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1898
                {
1899
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1900

    
1901
                    if (isLeftMouseButtonDownOnWindow)
1902
                    {
1903
                        bool wasDragSelectionApplied = false;
1904

    
1905
                        if (isDraggingSelectionRect)
1906
                        {
1907
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1908
                            {
1909
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1910
                                mouseHandlingMode = MouseHandlingMode.None;
1911
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1912
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1913
                                Set_Symbol_Capture(endPoint);
1914
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1915
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1916
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1917
                            }
1918
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1919
                            {
1920
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1921
                                mouseHandlingMode = MouseHandlingMode.None;
1922
                                Set_Capture();
1923

    
1924
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1925
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1926
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1927
                            }
1928
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1929
                            {
1930
                                ApplyDragSelectionRect();
1931
                            }
1932
                            else
1933
                            {
1934
                                double x = Canvas.GetLeft(dragZoomBorder);
1935
                                double y = Canvas.GetTop(dragZoomBorder);
1936
                                double width = dragZoomBorder.Width;
1937
                                double height = dragZoomBorder.Height;
1938
                                Rect dragRect = new Rect(x, y, width, height);
1939

    
1940
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1941

    
1942
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1943
                            }
1944

    
1945
                            isDraggingSelectionRect = false;
1946
                            e.Handled = true;
1947
                            wasDragSelectionApplied = true;
1948
                        }
1949

    
1950
                        if (isLeftMouseButtonDownOnWindow)
1951
                        {
1952
                            isLeftMouseButtonDownOnWindow = false;
1953
                            this.ReleaseMouseCapture();
1954
                            e.Handled = true;
1955
                        }
1956

    
1957
                        if (!wasDragSelectionApplied)
1958
                        {
1959
                            init();
1960
                        }
1961
                    }
1962
                }
1963
                else if (e.RightButton == MouseButtonState.Pressed)
1964
                {
1965
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1966
                    SetCursor();
1967
                }
1968

    
1969
                zoomAndPanControl.ReleaseMouseCapture();
1970

    
1971

    
1972
                e.Handled = true;
1973
            }
1974
            else
1975
            {
1976
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1977
                SetCursor();
1978
            }
1979

    
1980
            ///mouseButtonDown = MouseButton.Left;
1981
            //controlType = ControlType.SingleLine;
1982
        }
1983

    
1984
        public void Set_Symbol_Capture(Point endPoint)
1985
        {       
1986
            double x = CanvasDrawingMouseDownPoint.X;
1987
            double y = CanvasDrawingMouseDownPoint.Y;
1988
            if(x > endPoint.X)
1989
            {
1990
                x = endPoint.X;
1991
                y = endPoint.Y;
1992
            }
1993

    
1994
            double width = dragCaptureBorder.Width;
1995
            double height = dragCaptureBorder.Height;
1996

    
1997
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1998

    
1999
            if (x < 0)
2000
            {
2001
                width += x;
2002
                x = 0;
2003
            }
2004
            if (y < 0)
2005
            {
2006
                height += y;
2007
                y = 0;
2008

    
2009
                width = (int)canvasImage.PixelWidth - x;
2010
            }
2011
            if (x + width > canvasImage.PixelWidth)
2012
            {
2013
                width = (int)canvasImage.PixelWidth - x;
2014
            }
2015
            if (y + height > canvasImage.PixelHeight)
2016
            {
2017
                height = (int)canvasImage.PixelHeight - y;
2018
            }
2019
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2020

    
2021
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2022
            var defaultBitmapImage = new BitmapImage();
2023
            defaultBitmapImage.BeginInit();
2024
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2025
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2026
            defaultBitmapImage.UriSource = new Uri(uri);
2027
            defaultBitmapImage.EndInit();
2028

    
2029
            //GC.Collect();
2030

    
2031
            if (defaultBitmapImage.IsDownloading)
2032
            {
2033
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2034
                {
2035
                    defaultBitmapImage.Freeze();
2036
                    //GC.Collect();
2037
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2038
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2039
                };
2040
            }
2041
        }
2042

    
2043
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2044
        {
2045
            ///mouseButtonDown = MouseButton.Left;
2046
        }
2047

    
2048
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2049
        {
2050
            ///mouseButtonDown = MouseButton.Left;
2051
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2052
        }
2053

    
2054
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2055
        {
2056

    
2057
        }
2058

    
2059
        /// <summary>
2060
        /// select items by dragging
2061
        /// </summary>
2062
        private void ApplyDragSelectionRect()
2063
        {
2064
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2065

    
2066
            double x = Canvas.GetLeft(dragSelectionBorder);
2067
            double y = Canvas.GetTop(dragSelectionBorder);
2068
            double width = dragSelectionBorder.Width;
2069
            double height = dragSelectionBorder.Height;
2070
            Boolean Flag = false;
2071
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2072
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2073

    
2074
            Rect dragRect = new Rect(x, y, width, height);
2075
            ///dragRect.Inflate(width / 10, height / 10);
2076

    
2077
            foreach (var item in Items)
2078
            {
2079
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2080

    
2081
                if (Flag)
2082
                {
2083
                    adornerSet.Add(item);
2084
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2085
                    Control_Style(item);
2086
                }
2087
            }
2088
            if (adornerSet.Count > 0)
2089
            {
2090
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2091
                SelectLayer.Children.Add(final);
2092
            }
2093
        }
2094

    
2095
        private void InitDragSelectionRect(Point pt1, Point pt2)
2096
        {
2097
            //캡쳐 중
2098
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2099
            {
2100
                dragCaptureBorder.Visibility = Visibility.Visible;
2101
            }
2102
            //선택 중
2103
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2104
            {
2105

    
2106
                dragSelectionBorder.Visibility = Visibility.Visible;
2107
            }
2108
            else
2109
            {
2110
                dragZoomBorder.Visibility = Visibility.Visible;
2111
            }
2112
            UpdateDragSelectionRect(pt1, pt2);
2113
        }
2114

    
2115
        /// <summary>
2116
        /// Update the position and size of the rectangle used for drag selection.
2117
        /// </summary>
2118
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2119
        {
2120
            double x, y, width, height;
2121

    
2122
            //
2123
            // Determine x,y,width and height of the rect inverting the points if necessary.
2124
            // 
2125

    
2126
            if (pt2.X < pt1.X)
2127
            {
2128
                x = pt2.X;
2129
                width = pt1.X - pt2.X;
2130
            }
2131
            else
2132
            {
2133
                x = pt1.X;
2134
                width = pt2.X - pt1.X;
2135
            }
2136

    
2137
            if (pt2.Y < pt1.Y)
2138
            {
2139
                y = pt2.Y;
2140
                height = pt1.Y - pt2.Y;
2141
            }
2142
            else
2143
            {
2144
                y = pt1.Y;
2145
                height = pt2.Y - pt1.Y;
2146
            }
2147

    
2148
            //
2149
            // Update the coordinates of the rectangle used for drag selection.
2150
            //
2151
            //캡쳐 중
2152
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2153
            {
2154
                Canvas.SetLeft(dragCaptureBorder, x);
2155
                Canvas.SetTop(dragCaptureBorder, y);
2156
                dragCaptureBorder.Width = width;
2157
                dragCaptureBorder.Height = height;
2158
            }
2159
            //선택 중
2160
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2161
            {
2162
                Canvas.SetLeft(dragSelectionBorder, x);
2163
                Canvas.SetTop(dragSelectionBorder, y);
2164
                dragSelectionBorder.Width = width;
2165
                dragSelectionBorder.Height = height;
2166
            }
2167
            else
2168
            {
2169
                Canvas.SetLeft(dragZoomBorder, x);
2170
                Canvas.SetTop(dragZoomBorder, y);
2171
                dragZoomBorder.Width = width;
2172
                dragZoomBorder.Height = height;
2173
            }
2174
        }
2175

    
2176
        private void drawingPannelRotate(double angle)
2177
        {
2178
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2179
            rotate.Angle = angle;
2180
            var rotationNum = Math.Abs((rotate.Angle / 90));
2181

    
2182
            if (angle == 90 || angle == 270)
2183
            {
2184
                double emptySize = zoomAndPanCanvas.Width;
2185
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2186
                zoomAndPanCanvas.Height = emptySize;
2187
            }
2188
            if (angle == 0)
2189
            {
2190
                translate.X = 0;
2191
                translate.Y = 0;
2192
            }
2193
            else if (angle == 90)
2194
            {
2195
                translate.X = zoomAndPanCanvas.Width;
2196
                translate.Y = 0;
2197
            }
2198
            else if (angle == 180)
2199
            {
2200
                translate.X = zoomAndPanCanvas.Width;
2201
                translate.Y = zoomAndPanCanvas.Height;
2202
            }
2203
            else
2204
            {
2205
                translate.X = 0;
2206
                translate.Y = zoomAndPanCanvas.Height;
2207
            }
2208

    
2209
            zoomAndPanControl.RotationAngle = rotate.Angle;
2210

    
2211

    
2212
            if (!testPanel2.IsHidden)
2213
            {
2214
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2215
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2216
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2217
            }
2218

    
2219
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2220
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2221
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2222
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2223
            ViewerDataModel.Instance.Angle = rotate.Angle;
2224
        }
2225

    
2226
        private void syncPannelRotate(double angle)
2227
        {
2228
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2229
            rotate.Angle = angle;
2230
            var rotationNum = Math.Abs((rotate.Angle / 90));
2231

    
2232
            if (angle == 90 || angle == 270)
2233
            {
2234
                double emptySize = zoomAndPanCanvas2.Width;
2235
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2236
                zoomAndPanCanvas2.Height = emptySize;
2237
            }
2238
            if (angle == 0)
2239
            {
2240
                translate2.X = 0;
2241
                translate2.Y = 0;
2242
            }
2243
            else if (angle == 90)
2244
            {
2245
                translate2.X = zoomAndPanCanvas2.Width;
2246
                translate2.Y = 0;
2247
            }
2248
            else if (angle == 180)
2249
            {
2250
                translate2.X = zoomAndPanCanvas2.Width;
2251
                translate2.Y = zoomAndPanCanvas2.Height;
2252
            }
2253
            else
2254
            {
2255
                translate2.X = 0;
2256
                translate2.Y = zoomAndPanCanvas2.Height;
2257
            }
2258

    
2259
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2260
        }
2261

    
2262
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2263
        {
2264
            string Data_ = "";
2265

    
2266
            try
2267
            {
2268
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2269
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2270
                if (Data_ != null || Data_ != "")
2271
                {
2272
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2273
                }
2274
                else
2275
                {
2276
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2277
                }
2278

    
2279
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2280
                //{
2281
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2282
                //    STATE = 0,
2283
                //};
2284
                if (Data_ != null)
2285
                {
2286
                    Image img = new Image();
2287
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2288
                    if (Data_.Contains(".svg"))
2289
                    {
2290
                        byte[] imageData = null;
2291
                        DrawingImage image = null;
2292
                        using (System.Net.WebClient web = new System.Net.WebClient())
2293
                        {
2294
                            imageData = web.DownloadData(new Uri(Data_));
2295
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2296
                            image = SvgReader.Load(stream);
2297
                        }
2298
                        img.Source = image;
2299
                    }
2300
                    else
2301
                    {
2302
                        img.Source = new BitmapImage(new Uri(Data_));
2303
                    }
2304

    
2305
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2306
                    {
2307
                        PointSet = new List<Point>(),
2308
                        FilePath = Data_,
2309
                        ImageData = img.Source,
2310
                        StartPoint = canvasZoomPanningMouseDownPoint,
2311
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2312
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2313
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2314
                        canvasZoomPanningMouseDownPoint.Y),
2315
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2316
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2317
                    };
2318

    
2319
                    currentControl.PointSet = new List<Point>
2320
                                        {
2321
                                            currentControl.StartPoint,
2322
                                            currentControl.LeftBottomPoint,
2323
                                            currentControl.EndPoint,
2324
                                            currentControl.TopRightPoint,
2325
                                        };
2326
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2327
                    UndoData = new Undo_data()
2328
                    {
2329
                        IsUndo = false,
2330
                        Event = Event_Type.Create,
2331
                        EventTime = DateTime.Now,
2332
                        Markup_List = new List<Multi_Undo_data>()
2333
                    };
2334
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2335
                    {
2336
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2337
                    });
2338

    
2339
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2340
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2341
                    UndoData.Markup_List.Add(multi_Undo_Data);
2342
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2343

    
2344
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2345
                    currentControl.CommentID = Commons.shortGuid();
2346
                    currentControl.SymbolID = id;
2347
                    currentControl.GroupID = group_id;
2348
                    currentControl.ApplyTemplate();
2349
                    currentControl.SetImage();
2350

    
2351
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2352
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2353
                    SelectLayer.Children.Add(final);
2354
                }
2355
            }
2356
            catch (Exception ex)
2357
            {
2358
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2359
            }
2360
        }
2361

    
2362
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2363
        {
2364
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2365
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2366
            {
2367
                set_option.Value = double.Parse(set_option.ContentText);
2368
                //set_option.Focusable = false;
2369
                zoomAndPanControl.Focus();
2370
            }
2371

    
2372
            ConvertInkControlToPolygon();
2373

    
2374
            ///TODO:
2375
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2376
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2377

    
2378
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2379
            {
2380
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2381
            }
2382
            /// up to here
2383

    
2384
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2385
            {
2386
                if (item as ArrowTextControl != null)
2387
                {
2388
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2389
                }
2390
                else if (item as TextControl != null)
2391
                {
2392
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2393
                }
2394
            }
2395

    
2396
            //if (currentControl != null)
2397
            {
2398
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2399
                if (text_item_ != null)
2400
                {
2401
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2402
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2403
                    (text_item_ as TextControl).IsEditingMode = false;                    
2404
                    currentControl = null;
2405
                }
2406

    
2407
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2408
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2409
                {
2410
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2411
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2412
                    currentControl = null;
2413
                }
2414
            }
2415

    
2416
            double Ang = 0;                                          
2417
            if (rotate.Angle != 0)
2418
            {
2419
                Ang = 360 - rotate.Angle;
2420
            }
2421

    
2422
            if (e.OriginalSource is System.Windows.Controls.Image)
2423
            {
2424
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2425
            }
2426
            /*
2427
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2428
            {                
2429
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2430
                if(symbol_id != null)
2431
                {
2432
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2433
                }                
2434
            }
2435

    
2436
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2437
            {
2438
                if (this._dragdropWindow != null)
2439
                {
2440
                    this._dragdropWindow.Close();
2441
                    this._dragdropWindow = null;
2442
                    symbol_id = null;
2443
                }
2444
            }
2445
            */
2446

    
2447
            if (e.LeftButton == MouseButtonState.Pressed)
2448
            {
2449
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2450
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2451

    
2452
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2453
                SetCursor();
2454

    
2455
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2456
            }
2457

    
2458
            if (e.MiddleButton == MouseButtonState.Pressed)
2459
            {
2460
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2461
                cursor = Cursors.SizeAll;
2462
                SetCursor();
2463
            }
2464
            if (e.RightButton == MouseButtonState.Pressed)
2465
            {
2466
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2467
                cursor = Cursors.SizeAll;
2468
                SetCursor();
2469
            }
2470
            else if (e.XButton1 == MouseButtonState.Pressed)
2471
            {
2472
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2473
                {
2474
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2475
                }
2476

    
2477
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2478

    
2479
            }
2480
            else if (e.XButton2 == MouseButtonState.Pressed)
2481
            {
2482
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2483
                {
2484
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2485
                }
2486
            }
2487

    
2488
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2489
            {
2490
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2491
                {
2492
                    if (SelectLayer.Children.Count == 0)
2493
                    {
2494
                        isLeftMouseButtonDownOnWindow = true;
2495
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2496
                    }
2497

    
2498
                    if (controlType == ControlType.None)
2499
                    {
2500
                        isLeftMouseButtonDownOnWindow = true;
2501
                    }
2502
                }
2503

    
2504
                /// 캡쳐 모드 설정
2505
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2506
                {
2507
                    dragCaptureBorder.Visibility = Visibility.Visible;
2508
                    isLeftMouseButtonDownOnWindow = true;
2509
                }
2510

    
2511
                /// 줌 모드 설정
2512
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2513
                {
2514
                    isLeftMouseButtonDownOnWindow = true;
2515
                }
2516

    
2517
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2518
                if (control != null)
2519
                {
2520
                    AdornerFinal final = null;
2521

    
2522
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2523
                    {
2524
                        /// 기존 selection 해제
2525
                        SelectionSet.Instance.UnSelect(this);
2526

    
2527
                        final = new AdornerFinal(control);
2528

    
2529
                        this.Control_Style(control);
2530

    
2531
                        if ((control as IPath) != null)
2532
                        {
2533
                            if ((control as IPath).LineSize != 0)
2534
                            {
2535
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2536
                            }
2537
                        }
2538
                        if ((control as IShapeControl) != null)
2539
                        {
2540
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2541
                            {
2542
                                ViewerDataModel.Instance.checkHatchShape = true;
2543
                            }
2544
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2545
                            {
2546
                                ViewerDataModel.Instance.checkFillShape = true;
2547
                            }
2548
                            else
2549
                            {
2550
                                ViewerDataModel.Instance.checkHatchShape = false;
2551
                                ViewerDataModel.Instance.checkFillShape = false;
2552
                            }
2553
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2554
                        }
2555

    
2556
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2557

    
2558
                        if ((control as TextControl) != null)
2559
                        {
2560
                            if(!((control as TextControl).EnableEditing)) {
2561
                                (control as TextControl).EnableEditing = true;
2562
                            }
2563
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2564
                            {
2565
                                ViewerDataModel.Instance.checkTextStyle = true;
2566
                            }
2567
                            else
2568
                            {
2569
                                ViewerDataModel.Instance.checkTextStyle = false;
2570
                            }
2571
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2572
                            {
2573
                                ViewerDataModel.Instance.checkTextWeight = true;
2574
                            }
2575
                            else
2576
                            {
2577
                                ViewerDataModel.Instance.checkTextWeight = false;
2578
                            }
2579
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2580
                            {
2581
                                ViewerDataModel.Instance.checkUnderLine = true;
2582
                            }
2583
                            else
2584
                            {
2585
                                ViewerDataModel.Instance.checkUnderLine = false;
2586
                            }
2587
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2588
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2589

    
2590
                        }
2591
                        else if ((control as ArrowTextControl) != null)
2592
                        {
2593
                            if (!((control as ArrowTextControl).EnableEditing))
2594
                            {
2595
                                (control as ArrowTextControl).EnableEditing = true;
2596
                            }
2597
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2598
                            {
2599
                                ViewerDataModel.Instance.checkTextStyle = true;
2600
                            }
2601
                            else
2602
                            {
2603
                                ViewerDataModel.Instance.checkTextStyle = false;
2604
                            }
2605
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2606
                            {
2607
                                ViewerDataModel.Instance.checkTextWeight = true;
2608
                            }
2609
                            else
2610
                            {
2611
                                ViewerDataModel.Instance.checkTextWeight = false;
2612
                            }
2613
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2614
                            {
2615
                                ViewerDataModel.Instance.checkUnderLine = true;
2616
                            }
2617
                            else
2618
                            {
2619
                                ViewerDataModel.Instance.checkUnderLine = false;
2620
                            }
2621
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2622
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2623
                        }
2624
                        else if ((control as RectCloudControl) != null)
2625
                        {
2626
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2627
                        }
2628
                        else if ((control as CloudControl) != null)
2629
                        {
2630
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2631
                        }
2632
                    }
2633
                    else
2634
                    {
2635
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2636
                        SelectionSet.Instance.UnSelect(this);
2637
                        comment.Add(control);
2638

    
2639
                        Control_Style(control);
2640

    
2641
                        final = new AdornerFinal(comment);
2642
                    }
2643

    
2644
                    if (final != null)
2645
                    {
2646
                        this.SelectLayer.Children.Add(final);
2647
                    }
2648
                }              
2649
            }
2650
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2651
            {               
2652
                init();
2653
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2654
                if (cursor != Cursors.SizeAll)
2655
                {
2656
                    cursor = Cursors.Cross;
2657
                    SetCursor();
2658
                }
2659
                bool init_user = false;
2660
                foreach (var user in gridViewMarkup.Items)
2661
                {
2662
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2663
                    {
2664
                        init_user = true;
2665
                    }
2666
                }
2667
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2668
                {
2669
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
2670
                    RadWindow.Alert(new DialogParameters
2671
                    {
2672
                        Owner = Application.Current.MainWindow,
2673
                        Theme = new VisualStudio2013Theme(),
2674
                        Header = "Info",
2675
                        Content = "Existing comments already existed. Select from the user list first",
2676
                    });
2677
                    return;
2678
                }
2679
                else
2680
                {
2681
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2682
                    if (item != null)
2683
                    {
2684
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2685
                    }
2686
                }
2687

    
2688
                switch (controlType)
2689
                {
2690
                    case ControlType.Coordinate:
2691
                        {
2692
                            if (e.LeftButton == MouseButtonState.Pressed)
2693
                            {
2694
                                if (currentControl is CoordinateControl)
2695
                                {
2696
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2697
                                    {
2698
                                        return;
2699
                                    }
2700

    
2701
                                    CreateCommand.Instance.Execute(currentControl);
2702

    
2703
                                    currentControl = null;
2704
                                    this.cursor = Cursors.Arrow;
2705
                                }
2706
                                else
2707
                                {
2708
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2709
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2710
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2711
                                    {
2712
                                        currentControl = null;
2713
                                        this.cursor = Cursors.Arrow;
2714
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2715
                                        return;
2716
                                    }
2717
                                    else
2718
                                    {
2719
                                        currentControl = new CoordinateControl
2720
                                        {
2721
                                            Background = new SolidColorBrush(Colors.Black),
2722
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
2723
                                            ControlType = ControlType.Coordinate
2724
                                        };
2725

    
2726
                                        currentControl.CommentID = Commons.shortGuid();
2727
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2728
                                        currentControl.IsNew = true;
2729

    
2730
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2731

    
2732
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2733
                                    }
2734
                                }
2735
                            }
2736
                        }
2737
                        break;
2738
                    case ControlType.InsideWhite:
2739
                        {
2740
                            if (e.LeftButton == MouseButtonState.Pressed)
2741
                            {
2742
                                if (currentControl is InsideWhiteControl)
2743
                                {
2744
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2745
                                    {
2746
                                        return;
2747
                                    }
2748

    
2749
                                    CreateCommand.Instance.Execute(currentControl);
2750

    
2751
                                    currentControl = null;
2752
                                    this.cursor = Cursors.Arrow;
2753
                                }
2754
                                else
2755
                                {
2756
                                    currentControl = new InsideWhiteControl
2757
                                    {
2758
                                        Background = new SolidColorBrush(Colors.Black),
2759
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2760
                                        ControlType = ControlType.InsideWhite
2761
                                    };
2762

    
2763
                                    currentControl.CommentID = Commons.shortGuid();
2764
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2765
                                    currentControl.IsNew = true;
2766
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2767

    
2768
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2769
                                }
2770
                            }
2771
                        }
2772
                        break;
2773
                    case ControlType.OverlapWhite:
2774
                        {
2775
                            if (e.LeftButton == MouseButtonState.Pressed)
2776
                            {
2777
                                if (currentControl is OverlapWhiteControl)
2778
                                {
2779
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2780
                                    {
2781
                                        return;
2782
                                    }
2783

    
2784
                                    CreateCommand.Instance.Execute(currentControl);
2785

    
2786
                                    currentControl = null;
2787
                                    this.cursor = Cursors.Arrow;
2788
                                }
2789
                                else
2790
                                {
2791
                                    currentControl = new OverlapWhiteControl
2792
                                    {
2793
                                        Background = new SolidColorBrush(Colors.Black),
2794
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2795
                                        ControlType = ControlType.OverlapWhite
2796
                                    };
2797

    
2798
                                    currentControl.CommentID = Commons.shortGuid();
2799
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2800
                                    currentControl.IsNew = true;
2801
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2802

    
2803
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2804
                                }
2805
                            }
2806
                        }
2807
                        break;
2808
                    case ControlType.ClipWhite:
2809
                        {
2810
                            if (e.LeftButton == MouseButtonState.Pressed)
2811
                            {
2812
                                if (currentControl is ClipWhiteControl)
2813
                                {
2814
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2815
                                    {
2816
                                        return;
2817
                                    }
2818

    
2819
                                    CreateCommand.Instance.Execute(currentControl);
2820

    
2821
                                    currentControl = null;
2822
                                    this.cursor = Cursors.Arrow;
2823
                                }
2824
                                else
2825
                                {
2826
                                    currentControl = new ClipWhiteControl
2827
                                    {
2828
                                        Background = new SolidColorBrush(Colors.Black),
2829
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2830
                                        ControlType = ControlType.ClipWhite
2831
                                    };
2832

    
2833
                                    currentControl.CommentID = Commons.shortGuid();
2834
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2835
                                    currentControl.IsNew = true;
2836
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2837

    
2838
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2839
                                }
2840
                            }
2841
                        }
2842
                        break;
2843
                    case ControlType.Rectangle:
2844
                        {
2845
                            if (e.LeftButton == MouseButtonState.Pressed)
2846
                            {
2847
                                if (currentControl is RectangleControl)
2848
                                {
2849
                                    //20180906 LJY TEST IsRotationDrawingEnable
2850
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2851
                                    {
2852
                                        return;
2853
                                    }
2854

    
2855
                                    CreateCommand.Instance.Execute(currentControl);
2856
                                    currentControl = null;
2857
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2858
                                }
2859
                                else
2860
                                {
2861
                                    currentControl = new RectangleControl
2862
                                    {
2863
                                        Background = new SolidColorBrush(Colors.Black),
2864
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2865
                                        ControlType = ControlType.Rectangle
2866
                                    };
2867

    
2868
                                    currentControl.CommentID = Commons.shortGuid();
2869
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2870
                                    currentControl.IsNew = true;
2871
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2872

    
2873
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2874
                                }
2875
                            }
2876
                        }
2877
                        break;
2878
                    case ControlType.RectCloud:
2879
                        {
2880
                            if (e.LeftButton == MouseButtonState.Pressed)
2881
                            {
2882
                                if (currentControl is RectCloudControl)
2883
                                {
2884
                                    //20180906 LJY TEST IsRotationDrawingEnable
2885
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2886
                                    {
2887
                                        return;
2888
                                    }
2889

    
2890
                                    CreateCommand.Instance.Execute(currentControl);
2891

    
2892
                                    currentControl = null;
2893
                                
2894
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2895
                                }
2896
                                else
2897
                                {
2898
                                    currentControl = new RectCloudControl
2899
                                    {
2900
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2901
                                        ControlType = ControlType.RectCloud,
2902
                                        Background = new SolidColorBrush(Colors.Black)
2903
                                    };
2904

    
2905
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2906
                                    currentControl.CommentID = Commons.shortGuid();
2907
                                    currentControl.IsNew = true;
2908
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2909
                                }
2910
                            }
2911
                        }
2912
                        break;
2913
                    case ControlType.Circle:
2914
                        {
2915
                            if (e.LeftButton == MouseButtonState.Pressed)
2916
                            {
2917
                                if (currentControl is CircleControl)
2918
                                {
2919
                                    //20180906 LJY TEST IsRotationDrawingEnable
2920
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2921
                                    {
2922
                                        return;
2923
                                    }
2924

    
2925
                                    CreateCommand.Instance.Execute(currentControl);
2926

    
2927
                                    currentControl = null;
2928
                                }
2929
                                else
2930
                                {
2931
                                    currentControl = new CircleControl
2932
                                    {
2933
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2934
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2935
                                        Background = new SolidColorBrush(Colors.Black)
2936
                                    };
2937

    
2938
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2939
                                    currentControl.CommentID = Commons.shortGuid();
2940
                                    currentControl.IsNew = true;
2941
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2942
                                }
2943
                            }
2944
                        }
2945
                        break;
2946
                    case ControlType.Triangle:
2947
                        {
2948
                            if (e.LeftButton == MouseButtonState.Pressed)
2949
                            {
2950
                                if (currentControl is TriControl)
2951
                                {
2952
                                    var content = currentControl as TriControl;
2953
                                    if (content.MidPoint == new Point(0, 0))
2954
                                    {
2955
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
2956
                                    }
2957
                                    else
2958
                                    {
2959
                                        //20180906 LJY TEST IsRotationDrawingEnable
2960
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2961
                                        {
2962
                                            return;
2963
                                        }
2964

    
2965
                                        CreateCommand.Instance.Execute(currentControl);
2966

    
2967
                                        currentControl = null;
2968
                                    }
2969
                                }
2970
                                else
2971
                                {
2972
                                    currentControl = new TriControl
2973
                                    {
2974
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2975
                                        Background = new SolidColorBrush(Colors.Black),
2976
                                    };
2977

    
2978
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2979
                                    currentControl.CommentID = Commons.shortGuid();
2980
                                    currentControl.IsNew = true;
2981
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2982
                                }
2983
                            }
2984
                        }
2985
                        break;
2986
                    case ControlType.CancelLine:
2987
                    case ControlType.SingleLine:
2988
                    case ControlType.ArrowLine:
2989
                    case ControlType.TwinLine:
2990
                    case ControlType.DimLine:
2991
                        {
2992
                            if (e.LeftButton == MouseButtonState.Pressed)
2993
                            {
2994
                                if (currentControl is LineControl)
2995
                                {
2996
                                    //20180906 LJY TEST IsRotationDrawingEnable
2997
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2998
                                    {
2999
                                        return;
3000
                                    }
3001

    
3002
                                    CreateCommand.Instance.Execute(currentControl);
3003
                                    currentControl = null;
3004
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3005
                                }
3006
                                else
3007
                                {
3008
                                    currentControl = new LineControl
3009
                                    {
3010
                                        ControlType = this.controlType,
3011
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3012
                                        Background = new SolidColorBrush(Colors.Black)
3013
                                    };
3014

    
3015
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3016
                                    currentControl.CommentID = Commons.shortGuid();
3017
                                    currentControl.IsNew = true;
3018
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3019
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3020
                                }
3021
                            }
3022
                        }
3023
                        break;
3024
                    case ControlType.PolygonControl:
3025
                        {
3026
                            if (currentControl is PolygonControl)
3027
                            {
3028
                                var control = currentControl as PolygonControl;
3029

    
3030
                                if (e.RightButton == MouseButtonState.Pressed)
3031
                                {
3032
                                    control.IsCompleted = true;
3033
                                }
3034

    
3035
                                if (!control.IsCompleted)
3036
                                {
3037
                                    control.PointSet.Add(control.EndPoint);
3038
                                }
3039
                                else
3040
                                {
3041
                                    //20180906 LJY TEST IsRotationDrawingEnable
3042
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3043
                                    {
3044
                                        return;
3045
                                    }
3046

    
3047
                                    var firstPoint = control.PointSet.First();
3048
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3049
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3050
                                    control.PointSet.Add(firstPoint);
3051

    
3052
                                    control.ApplyOverViewData();
3053

    
3054
                                    CreateCommand.Instance.Execute(currentControl);
3055
                                    control.UpdateControl();
3056
                                    currentControl = null;
3057
                                }
3058
                            }
3059
                            else
3060
                            {
3061
                                if (e.LeftButton == MouseButtonState.Pressed)
3062
                                {
3063
                                    currentControl = new PolygonControl
3064
                                    {
3065
                                        PointSet = new List<Point>(),
3066
                                    };
3067

    
3068
                                    var polygonControl = (currentControl as PolygonControl);
3069
                                    currentControl.CommentID = Commons.shortGuid();
3070
                                    currentControl.IsNew = true;
3071
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3072
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3073
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3074
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3075
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3076
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3077
                                    polygonControl.ApplyTemplate();
3078
                                    polygonControl.Visibility = Visibility.Visible;
3079
                                }
3080
                            }
3081
                        }
3082
                        break;
3083
                    case ControlType.ChainLine:
3084
                        {
3085
                            if (currentControl is PolygonControl)
3086
                            {
3087
                                var control = currentControl as PolygonControl;
3088

    
3089
                                if (e.RightButton == MouseButtonState.Pressed)
3090
                                {
3091
                                    //20180906 LJY TEST IsRotationDrawingEnable
3092
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3093
                                    {
3094
                                        return;
3095
                                    }
3096

    
3097
                                    CreateCommand.Instance.Execute(currentControl);
3098

    
3099
                                    currentControl = null;
3100
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3101
                                    return;
3102
                                }
3103

    
3104
                                if (!control.IsCompleted)
3105
                                {
3106
                                    control.PointSet.Add(control.EndPoint);
3107
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3108
                                }
3109
                            }
3110
                            else
3111
                            {
3112
                                if (e.LeftButton == MouseButtonState.Pressed)
3113
                                {
3114
                                    MainAngle.Visibility = Visibility.Visible;
3115
                                    currentControl = new PolygonControl
3116
                                    {
3117
                                        PointSet = new List<Point>(),
3118
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3119
                                        ControlType = ControlType.ChainLine,
3120
                                        DashSize = ViewerDataModel.Instance.DashSize,
3121
                                        LineSize = ViewerDataModel.Instance.LineSize,
3122
                                        //PointC = new StylusPointSet()
3123
                                    };
3124

    
3125
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3126
                                    //{
3127
                                        var polygonControl = (currentControl as PolygonControl);
3128
                                        currentControl.CommentID = Commons.shortGuid();
3129
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3130
                                        currentControl.IsNew = true;
3131
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3132
                                        //currentControl.OnApplyTemplate();
3133
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3134
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3135
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3136
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3137
                                    //}
3138
                                }
3139
                            }
3140
                        }
3141
                        break;
3142
                    case ControlType.ArcLine:
3143
                        {
3144
                            if (e.LeftButton == MouseButtonState.Pressed)
3145
                            {
3146
                                if (currentControl is ArcControl)
3147
                                {
3148
                                    //20180906 LJY TEST IsRotationDrawingEnable
3149
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3150
                                    {
3151
                                        return;
3152
                                    }
3153

    
3154
                                    CreateCommand.Instance.Execute(currentControl);
3155

    
3156
                                    currentControl = null;
3157
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3158
                                }
3159
                                else
3160
                                {
3161
                                    currentControl = new ArcControl
3162
                                    {
3163
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3164
                                        Background = new SolidColorBrush(Colors.Black)
3165
                                    };
3166
                                    currentControl.CommentID = Commons.shortGuid();
3167
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3168
                                    currentControl.IsNew = true;
3169
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3170
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3171
                                }
3172
                            }
3173
                            else if (e.RightButton == MouseButtonState.Pressed)
3174
                            {
3175
                                if (currentControl != null)
3176
                                {
3177
                                    (currentControl as ArcControl).setClock();
3178
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3179
                                }
3180
                            }
3181
                        }
3182
                        break;
3183
                    case ControlType.ArcArrow:
3184
                        {
3185
                            if (e.LeftButton == MouseButtonState.Pressed)
3186
                            {
3187
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3188
                                //{
3189
                                if (currentControl is ArrowArcControl)
3190
                                {
3191
                                    //20180906 LJY TEST IsRotationDrawingEnable
3192
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3193
                                    {
3194
                                        return;
3195
                                    }
3196

    
3197
                                    CreateCommand.Instance.Execute(currentControl);
3198

    
3199
                                    currentControl = null;
3200
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3201
                                }
3202
                                else
3203
                                {
3204
                                    currentControl = new ArrowArcControl
3205
                                    {
3206
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3207
                                        Background = new SolidColorBrush(Colors.Black)
3208
                                    };
3209
                                    currentControl.CommentID = Commons.shortGuid();
3210
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3211
                                    currentControl.IsNew = true;
3212
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3213
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3214
                                }
3215
                                //}
3216
                            }
3217
                            else if (e.RightButton == MouseButtonState.Pressed)
3218
                            {
3219
                                if (currentControl != null)
3220
                                {
3221
                                    (currentControl as ArrowArcControl).setClock();
3222
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3223
                                    //(currentControl as ArcControl).ApplyTemplate();
3224
                                }
3225
                            }
3226
                        }
3227
                        break;
3228
                    case ControlType.ArrowMultiLine:
3229
                        {
3230
                            if (e.LeftButton == MouseButtonState.Pressed)
3231
                            {
3232
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3233
                                //{
3234

    
3235
                                    if (currentControl is ArrowControl_Multi)
3236
                                    {
3237
                                        var content = currentControl as ArrowControl_Multi;
3238
                                        if (content.MiddlePoint == new Point(0, 0))
3239
                                        {
3240
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3241
                                            {
3242
                                                content.MiddlePoint = content.EndPoint;
3243
                                            }
3244
                                            else
3245
                                            {
3246
                                                content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3247
                                            }
3248
                                        }
3249
                                        else
3250
                                        {
3251
                                            //20180906 LJY TEST IsRotationDrawingEnable
3252
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3253
                                            {
3254
                                                return;
3255
                                            }
3256

    
3257
                                            CreateCommand.Instance.Execute(currentControl);
3258

    
3259
                                            currentControl = null;
3260
                                            ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3261
                                        }
3262
                                    }
3263
                                    else
3264
                                    {
3265
                                        currentControl = new ArrowControl_Multi
3266
                                        {
3267
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3268
                                            Background = new SolidColorBrush(Colors.Black)
3269
                                        };
3270
                                        currentControl.CommentID = Commons.shortGuid();
3271
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3272
                                        currentControl.IsNew = true;
3273
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3274
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3275
                                    }
3276
                                //}
3277
                            }
3278
                        }
3279
                        break;
3280
                    case ControlType.PolygonCloud:
3281
                        {
3282
                            if (currentControl is CloudControl)
3283
                            {
3284
                                var control = currentControl as CloudControl;
3285
                                if (e.RightButton == MouseButtonState.Pressed)
3286
                                {
3287
                                    control.IsCompleted = true;
3288
                                }
3289

    
3290
                                if (!control.IsCompleted)
3291
                                {
3292
                                    control.PointSet.Add(control.EndPoint);
3293
                                }
3294
                                else
3295
                                {
3296
                                    //20180906 LJY TEST IsRotationDrawingEnable
3297
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3298
                                    {
3299
                                        return;
3300
                                    }
3301

    
3302
                                    CreateCommand.Instance.Execute(currentControl);
3303

    
3304
                                    control.isTransOn = true;
3305
                                    var firstPoint = control.PointSet.First();
3306

    
3307
                                    control.PointSet.Add(firstPoint);
3308
                                    control.DrawingCloud();
3309
                                    control.ApplyOverViewData();
3310

    
3311
                                    currentControl = null;
3312
                                }
3313
                            }
3314
                            else
3315
                            {
3316
                                if (e.LeftButton == MouseButtonState.Pressed)
3317
                                {
3318
                                    currentControl = new CloudControl
3319
                                    {
3320
                                        PointSet = new List<Point>(),
3321
                                        PointC = new StylusPointSet()
3322
                                    };
3323

    
3324
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3325
                                    //{
3326
                                        var polygonControl = (currentControl as CloudControl);
3327
                                        currentControl.CommentID = Commons.shortGuid();
3328
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3329
                                        currentControl.IsNew = true;
3330
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3331

    
3332
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3333
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3334
                                    
3335
                                    //}
3336
                                }
3337
                            }
3338
                        }
3339
                        break;
3340
                    case ControlType.ImgControl:
3341
                        {
3342
                            if (e.LeftButton == MouseButtonState.Pressed)
3343
                            {
3344
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3345
                                //{
3346
                                    if (currentControl is ImgControl)
3347
                                    {
3348
                                        //20180906 LJY TEST IsRotationDrawingEnable
3349
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3350
                                        {
3351
                                            return;
3352
                                        }
3353

    
3354
                                        CreateCommand.Instance.Execute(currentControl);
3355
                                        controlType = ControlType.ImgControl;
3356
                                        currentControl = null;
3357
                                    }
3358
                                    else
3359
                                    {
3360
                                        
3361
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3362
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3363
                                        {
3364
                                            Image img = new Image();
3365
                                            if (filename.Contains(".svg"))
3366
                                            {
3367
                                                byte[] imageData = null;
3368
                                                DrawingImage image = null;
3369
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3370
                                                {
3371
                                                    imageData = web.DownloadData(new Uri(filename));
3372
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3373
                                                    image = SvgReader.Load(stream);
3374
                                                }
3375
                                                img.Source = image;
3376
                                            }
3377
                                            else
3378
                                            {
3379
                                                img.Source = new BitmapImage(new Uri(filename));
3380
                                            }
3381

    
3382
                                            currentControl = new ImgControl
3383
                                            {
3384
                                                    Background = new SolidColorBrush(Colors.Black),
3385
                                                    PointSet = new List<Point>(),
3386
                                                    FilePath = filename,
3387
                                                    ImageData = img.Source,
3388
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3389
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3390
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3391
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3392
                                                    ControlType = ControlType.ImgControl
3393
                                                };
3394

    
3395
                                        
3396
                                                currentControl.CommentID = Commons.shortGuid();                                            
3397
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3398
                                                currentControl.IsNew = true;
3399
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3400

    
3401
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3402
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3403
                                    }
3404
                                    }
3405
                                //}
3406
                            }
3407
                        }
3408
                        break;
3409
                    case ControlType.Date:
3410
                        {
3411
                            if (e.LeftButton == MouseButtonState.Pressed)
3412
                            {
3413
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3414
                                //{
3415
                                if (currentControl is DateControl)
3416
                                {
3417
                                    //20180906 LJY TEST IsRotationDrawingEnable
3418
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3419
                                    {
3420
                                        return;
3421
                                    }
3422

    
3423
                                    CreateCommand.Instance.Execute(currentControl);
3424
                                    currentControl = null;
3425

    
3426
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3427
                                    {
3428
                                        controlType = ControlType.None;
3429
                                        IsSwingMode = false;
3430
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3431
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3432
                                        mouseHandlingMode = MouseHandlingMode.None;
3433
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3434
                                        txtBatch.Visibility = Visibility.Collapsed;
3435

    
3436
                                    }
3437
                                }
3438
                                else
3439
                                {
3440
                                    currentControl = new DateControl
3441
                                    {
3442
                                        StartPoint = CanvasDrawingMouseDownPoint,
3443
                                        Background = new SolidColorBrush(Colors.Black)
3444
                                    };
3445
                                    currentControl.CommentID = Commons.shortGuid();
3446
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3447
                                    currentControl.IsNew = true;
3448
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3449

    
3450
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3451
                                    if (currentControl is ImgControl)
3452
                                    {
3453
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3454
                                    }
3455
                                }
3456
                                //}
3457
                            }
3458
                        }
3459
                        break;
3460
                    case ControlType.TextControl:
3461
                        {
3462
                            if (e.LeftButton == MouseButtonState.Pressed)
3463
                            {
3464
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3465
                                {
3466
                                    currentControl = new TextControl
3467
                                    {
3468
                                        ControlType = controlType
3469
                                    };
3470
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3471
                                    currentControl.CommentID = Commons.shortGuid();
3472
                                    currentControl.IsNew = true;
3473
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3474
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3475
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3476

    
3477
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3478
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3479
                                    
3480
                                    (currentControl as TextControl).ControlType_No = 0;
3481
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3482
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3483
                                    (currentControl as TextControl).ApplyTemplate();
3484
                                    (currentControl as TextControl).Base_TextBox.Focus();
3485
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3486
                                    CreateCommand.Instance.Execute(currentControl);
3487
                                }
3488
                            }
3489
                        }
3490
                        break;
3491
                    case ControlType.TextBorder:
3492
                        {
3493
                            if (e.LeftButton == MouseButtonState.Pressed)
3494
                            {
3495
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3496
                                {
3497
                                    currentControl = new TextControl
3498
                                    {
3499
                                        ControlType = controlType
3500
                                    };
3501

    
3502
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3503
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3504
                                    currentControl.CommentID = Commons.shortGuid();
3505
                                    currentControl.IsNew = true;
3506
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3507
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3508
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3509
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3510
                                    
3511
                                    (currentControl as TextControl).ControlType_No = 1;
3512
                                    (currentControl as TextControl).CommentAngle = Ang;
3513
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3514
                                    (currentControl as TextControl).ApplyTemplate();
3515
                                    (currentControl as TextControl).Base_TextBox.Focus();
3516
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3517
                                    CreateCommand.Instance.Execute(currentControl);
3518
                                }
3519
                            }
3520
                        }
3521
                        break;
3522
                    case ControlType.TextCloud:
3523
                        {
3524
                            if (e.LeftButton == MouseButtonState.Pressed)
3525
                            {
3526
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3527
                                {
3528
                                    currentControl = new TextControl
3529
                                    {
3530
                                        ControlType = controlType
3531
                                    };
3532

    
3533
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3534
                                    currentControl.CommentID = Commons.shortGuid();
3535
                                    currentControl.IsNew = true;
3536
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3537
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3538

    
3539
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3540
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3541
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3542

    
3543
                                    (currentControl as TextControl).CommentAngle = Ang;
3544
                                    (currentControl as TextControl).ControlType_No = 2;
3545
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3546
                                    (currentControl as TextControl).ApplyTemplate();
3547
                                    (currentControl as TextControl).Base_TextBox.Focus();
3548
                                    CreateCommand.Instance.Execute(currentControl);
3549
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3550
                                    //currentControl = null;
3551
                                }
3552
                            }
3553
                        }
3554
                        break;
3555
                    case ControlType.ArrowTextControl:
3556
                         {
3557
                            if (e.LeftButton == MouseButtonState.Pressed)
3558
                            {
3559
                                if (currentControl is ArrowTextControl)
3560
                                {
3561
                                    //20180906 LJY TEST IsRotationDrawingEnable
3562
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3563
                                    {
3564
                                        return;
3565
                                    }
3566

    
3567
                                    CreateCommand.Instance.Execute(currentControl);
3568

    
3569
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3570
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3571
                                    (currentControl as ArrowTextControl).IsNew = false;
3572
                                    currentControl = null;
3573
                                }
3574
                                else
3575
                                {
3576
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3577
                                    //{
3578
                                        currentControl = new ArrowTextControl();
3579
                                        currentControl.CommentID = Commons.shortGuid();
3580
                                        currentControl.IsNew = true;
3581
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3582
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3583

    
3584
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3585
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3586
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3587
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3588
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3589

    
3590
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3591
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3592

    
3593
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3594
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3595
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3596
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3597

    
3598
                                    
3599
                                    //}
3600
                                }
3601
                            }
3602
                        }
3603
                        break;
3604
                    case ControlType.ArrowTransTextControl:
3605
                        {
3606
                            if (e.LeftButton == MouseButtonState.Pressed)
3607
                            {
3608
                                if (currentControl is ArrowTextControl)
3609
                                {
3610
                                    //20180906 LJY TEST IsRotationDrawingEnable
3611
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3612
                                    {
3613
                                        return;
3614
                                    }
3615

    
3616
                                    CreateCommand.Instance.Execute(currentControl);
3617

    
3618
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3619
                                    
3620
                                    currentControl.IsNew = false;
3621
                                    currentControl = null;
3622
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3623
                                }
3624
                                else
3625
                                {
3626
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3627
                                    //{
3628
                                    currentControl = new ArrowTextControl()
3629
                                    {
3630
                                        ControlType = ControlType.ArrowTransTextControl
3631
                                    };
3632
                                    currentControl.CommentID = Commons.shortGuid();
3633
                                    currentControl.IsNew = true;
3634
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3635
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3636
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3637
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3638
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                  
3639
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3640
                                    (currentControl as ArrowTextControl).isFixed = true;
3641
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3642

    
3643
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3644
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3645

    
3646
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3647
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3648
                                    (currentControl as ArrowTextControl).isTrans = true;
3649
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3650
                                }
3651
                            }
3652
                        }
3653
                        break;
3654
                    case ControlType.ArrowTextBorderControl:
3655
                         {
3656
                            if (e.LeftButton == MouseButtonState.Pressed)
3657
                            {
3658
                                if (currentControl is ArrowTextControl)
3659
                                {
3660
                                    //20180906 LJY TEST IsRotationDrawingEnable
3661
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3662
                                    {
3663
                                        return;
3664
                                    }
3665

    
3666
                                    CreateCommand.Instance.Execute(currentControl);
3667
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3668
                                    currentControl.IsNew = false;
3669
                                    currentControl = null;
3670
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3671
                                }
3672
                                else
3673
                                {
3674
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3675
                                    //{
3676
                                        currentControl = new ArrowTextControl()
3677
                                        {
3678
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3679
                                        };
3680
                                        currentControl.CommentID = Commons.shortGuid();
3681
                                        currentControl.IsNew = true;
3682
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3683
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3684

    
3685
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3686

    
3687
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3688

    
3689
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3690
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3691
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3692
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3693
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3694
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3695
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3696
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3697
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                    
3698
                                    //}
3699
                                }
3700
                            }
3701
                        }
3702
                        break;
3703
                    case ControlType.ArrowTransTextBorderControl:
3704
                        {
3705
                            if (e.LeftButton == MouseButtonState.Pressed)
3706
                            {
3707
                                if (currentControl is ArrowTextControl)
3708
                                {
3709
                                    //20180906 LJY TEST IsRotationDrawingEnable
3710
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3711
                                    {
3712
                                        return;
3713
                                    }
3714
                                    CreateCommand.Instance.Execute(currentControl);
3715
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3716
                                    currentControl.IsNew = false;
3717
                                    currentControl = null;
3718

    
3719
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3720
                                }
3721
                                else
3722
                                {
3723
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3724
                                    //{
3725
                                    
3726

    
3727
                                    currentControl = new ArrowTextControl()
3728
                                    {
3729
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3730
                                        ControlType = ControlType.ArrowTransTextBorderControl
3731

    
3732
                                    };
3733
                                        currentControl.CommentID = Commons.shortGuid();
3734
                                        currentControl.IsNew = true;
3735
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3736
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3737

    
3738
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3739

    
3740
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3741
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                    
3742
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3743
                                        (currentControl as ArrowTextControl).isFixed = true;
3744
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3745
                                     
3746
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3747
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3748
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3749
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3750
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3751
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3752
                                    
3753
                                    //20180911 LJY
3754
                                        (currentControl as ArrowTextControl).isTrans = true;
3755
                                    
3756

    
3757
                                    //}
3758
                                }
3759
                            }
3760
                        }
3761
                        break;
3762
                    case ControlType.ArrowTextCloudControl:
3763
                        {
3764
                            if (e.LeftButton == MouseButtonState.Pressed)
3765
                            {
3766
                                if (currentControl is ArrowTextControl)
3767
                                {
3768
                                    //20180906 LJY TEST IsRotationDrawingEnable
3769
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3770
                                    {
3771
                                        return;
3772
                                    }
3773
                                    CreateCommand.Instance.Execute(currentControl);
3774
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3775
                                    currentControl.IsNew = false;
3776
                                    currentControl = null;
3777
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3778
                                }
3779
                                else
3780
                                {
3781
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3782
                                    //{
3783
                                        currentControl = new ArrowTextControl()
3784
                                        {
3785
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3786
                                        };
3787
                                        currentControl.CommentID = Commons.shortGuid();
3788
                                        currentControl.IsNew = true;
3789
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3790
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3791

    
3792
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3793
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3794
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                 
3795
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3796
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3797
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3798
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3799
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3800
                                    
3801
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3802
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3803
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;                                        
3804
                                    //}
3805
                                }
3806
                            }
3807
                        }
3808
                        break;
3809
                    case ControlType.ArrowTransTextCloudControl:
3810
                        {
3811
                            if (e.LeftButton == MouseButtonState.Pressed)
3812
                            {
3813
                                if (currentControl is ArrowTextControl)
3814
                                {
3815
                                    //20180906 LJY TEST IsRotationDrawingEnable
3816
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3817
                                    {
3818
                                        return;
3819
                                    }
3820
                                    CreateCommand.Instance.Execute(currentControl);
3821
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3822
                                    currentControl.IsNew = false;
3823
                                    currentControl = null;
3824
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3825
                                }
3826
                                else
3827
                                {
3828
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3829
                                    //{
3830
                                        currentControl = new ArrowTextControl()
3831
                                        {
3832
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3833
                                            ControlType = ControlType.ArrowTransTextCloudControl
3834

    
3835
                                        };
3836
                                        currentControl.CommentID = Commons.shortGuid();
3837
                                        currentControl.IsNew = true; 
3838
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3839
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3840
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3841

    
3842
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3843
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3844
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3845
                                        (currentControl as ArrowTextControl).isFixed = true;
3846
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3847

    
3848
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3849
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3850
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3851
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3852
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3853
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;  
3854
                                    
3855
                                    //20180911 LJY
3856
                                        (currentControl as ArrowTextControl).isTrans = true;
3857
                                    //}
3858
                                }
3859
                            }
3860
                        }
3861
                        break;
3862
                    //강인구 추가
3863
                    case ControlType.Sign:
3864
                        {
3865
                            if (e.LeftButton == MouseButtonState.Pressed)
3866
                            {
3867
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3868
                                //{
3869
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
3870

    
3871
                                if (_sign == null)
3872
                                    {
3873
                                        txtBatch.Visibility = Visibility.Collapsed;
3874
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3875
                                        controlType = ControlType.None;
3876

    
3877
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3878
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3879
                                        return;
3880
                                    }
3881

    
3882
                                    if (currentControl is SignControl)
3883
                                    {
3884
                                        //20180906 LJY TEST IsRotationDrawingEnable
3885
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3886
                                        {
3887
                                            return;
3888
                                        }
3889

    
3890
                                        CreateCommand.Instance.Execute(currentControl);
3891
                                        currentControl = null;
3892
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3893
                                        {
3894
                                            txtBatch.Text = "Place Date";
3895
                                            controlType = ControlType.Date;
3896
                                        }
3897
                                    }
3898
                                    else
3899
                                    {
3900
                                        currentControl = new SignControl
3901
                                        {
3902
                                            Background = new SolidColorBrush(Colors.Black),
3903
                                            UserNumber = App.ViewInfo.UserID,
3904
                                            ProjectNO = App.ViewInfo.ProjectNO,
3905
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3906
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3907
                                            ControlType = ControlType.Sign
3908
                                        };
3909

    
3910
                                        currentControl.CommentID = Commons.shortGuid();
3911
                                        currentControl.IsNew = true;
3912
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3913
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3914

    
3915
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3916
                                        (currentControl as SignControl).CommentAngle -= rotate.Angle;                                    
3917
                                }
3918
                                //}
3919
                            }
3920
                        }
3921
                        break;
3922
                    case ControlType.Mark:
3923
                        {
3924
                            if (e.LeftButton == MouseButtonState.Pressed)
3925
                            {
3926
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3927
                                //{
3928
                                    if (currentControl is RectangleControl)
3929
                                    {
3930
                                        //20180906 LJY TEST IsRotationDrawingEnable
3931
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3932
                                        {
3933
                                            return;
3934
                                        }
3935

    
3936
                                        CreateCommand.Instance.Execute(currentControl);
3937
                                        (currentControl as RectangleControl).ApplyOverViewData();
3938
                                        currentControl = null;
3939
                                    
3940
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3941

    
3942
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3943
                                        {
3944
                                            txtBatch.Text = "Place Signature";
3945
                                            controlType = ControlType.Sign;
3946
                                        }
3947
                                    }
3948
                                    else
3949
                                    {
3950
                                        currentControl = new RectangleControl
3951
                                        {
3952
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3953
                                            Background = new SolidColorBrush(Colors.Black),
3954
                                            ControlType = ControlType.Mark ,
3955
                                            Paint = PaintSet.Fill
3956
                                        };
3957

    
3958
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3959
                                        currentControl.CommentID = Commons.shortGuid();
3960
                                        currentControl.IsNew = true;
3961
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3962
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3963
                                    }
3964
                                //}
3965
                            }
3966
                        }
3967
                        break;
3968
                    case ControlType.Symbol:
3969
                        {
3970
                            if (e.LeftButton == MouseButtonState.Pressed)
3971
                            {
3972
                                if (currentControl is SymControl)
3973
                                {
3974
                                    //20180906 LJY TEST IsRotationDrawingEnable
3975
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3976
                                    {
3977
                                        return;
3978
                                    }
3979
                                    CreateCommand.Instance.Execute(currentControl);
3980
                                    currentControl = null;
3981
                                
3982
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3983
                                }
3984
                                else
3985
                                {
3986
                                    currentControl = new SymControl
3987
                                    {
3988
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3989
                                        Background = new SolidColorBrush(Colors.Black),
3990
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3991
                                        ControlType = ControlType.Symbol
3992
                                    };
3993

    
3994
                                    currentControl.IsNew = true;
3995
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3996
                                    currentControl.CommentID = Commons.shortGuid();
3997
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3998

    
3999
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4000
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4001
                                }
4002
                                //}
4003
                            }
4004
                        }
4005
                        break;
4006
                    case ControlType.Stamp:
4007
                        {
4008
                            if (e.LeftButton == MouseButtonState.Pressed)
4009
                            {
4010
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4011
                                //{
4012
                                    if (currentControl is SymControlN)
4013
                                    {
4014
                                        //20180906 LJY TEST IsRotationDrawingEnable
4015
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4016
                                        {
4017
                                            return;
4018
                                        }
4019

    
4020
                                        CreateCommand.Instance.Execute(currentControl);
4021
                                        currentControl = null;
4022
                                   
4023

    
4024
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4025
                                    }
4026
                                    else
4027
                                    {
4028
                                        currentControl = new SymControlN
4029
                                        {
4030
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4031
                                            Background = new SolidColorBrush(Colors.Black),
4032
                                            STAMP = App.SystemInfo.STAMP,                                            
4033
                                            ControlType = ControlType.Stamp
4034
                                        };
4035

    
4036
                                        currentControl.IsNew = true;
4037
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4038
                                        currentControl.CommentID = Commons.shortGuid();
4039
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4040
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4041
                                        (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4042
                                }                                    
4043
                                //}
4044
                            }
4045
                        }
4046
                        break;
4047
                    case ControlType.PenControl:
4048
                        {
4049
                            if (inkBoard.Tag.ToString() == "Ink")
4050
                            {
4051
                                inkBoard.IsEnabled = true;
4052
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4053
                            }
4054
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4055
                            {
4056
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4057
                            }
4058
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4059
                            {
4060
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4061
                            }
4062
                            IsDrawing = true;
4063
                            return;
4064
                        }
4065
                    default:
4066
                        if (currentControl != null)
4067
                        {
4068
                            currentControl.CommentID = null;
4069
                            currentControl.IsNew = false;
4070
                        }
4071
                        break;
4072
                }
4073

    
4074
                if (currentControl != null)
4075
                {
4076
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4077
                }
4078
            }
4079
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4080
            {
4081
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4082
                {
4083
                    bool mouseOff = false;
4084
                    foreach (var item in SelectLayer.Children)
4085
                    {
4086
                        if (item is AdornerFinal)
4087
                        {
4088

    
4089
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4090
                            if (over != null)
4091
                            {
4092
                                mouseOff = true;
4093
                            }
4094
                        }
4095
                    }
4096

    
4097
                    if (!mouseOff)
4098
                    {
4099
                        SelectionSet.Instance.UnSelect(this);
4100
                    }
4101
                }
4102
                zoomAndPanControl.CaptureMouse();
4103
                e.Handled = true;
4104
            }
4105
          
4106
        }
4107

    
4108
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4109
        {
4110
            ///mouseButtonDown = e.ChangedButton;
4111
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4112
        }
4113

    
4114
        private void RemoveLineStroke(Point P)
4115
        {
4116
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4117
            if (control != null)
4118
            {
4119
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4120
            }
4121
        }
4122

    
4123
        private void RemovePointStroke(Point P)
4124
        {
4125
            foreach (Stroke hits in inkBoard.Strokes)
4126
            {
4127
                foreach (StylusPoint sty in hits.StylusPoints)
4128
                {
4129

    
4130
                }
4131
                if (hits.HitTest(P))
4132
                {
4133
                    inkBoard.Strokes.Remove(hits);
4134
                    return;
4135
                }
4136
            }
4137
        }
4138

    
4139
        private void StartNewStroke(Point P)
4140
        {
4141
            strokePoints = new StylusPointCollection();
4142
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4143
            strokePoints.Add(segment1Start);
4144
            stroke = new Stroke(strokePoints);
4145

    
4146
            stroke.DrawingAttributes.Color = Colors.Red;
4147
            stroke.DrawingAttributes.Width = 4;
4148
            stroke.DrawingAttributes.Height = 4;
4149

    
4150
            inkBoard.Strokes.Add(stroke);
4151
        }
4152

    
4153
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4154
        {
4155
            ConsolidationMethod();
4156
        }
4157

    
4158
        /// <summary>
4159
        /// execute TeamConsolidationCommand
4160
        /// </summary>
4161
        public void TeamConsolidationMethod()
4162
        {
4163
            this.UpdateMyMarkupList();
4164
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4165
            {
4166
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4167
            }
4168
            else
4169
            {
4170

    
4171
                ViewerDataModel.Instance.IsConsolidate = true;
4172
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4173

    
4174
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4175
                {
4176
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4177
                    {
4178
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4179
                        return;
4180
                    }                    
4181
                }
4182
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4183
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4184
                {
4185
                    MarkupInfoList.Add(item);
4186
                }
4187
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4188
            }
4189
        }
4190

    
4191
        public void ConsolidationMethod()
4192
        {
4193
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4194
            {
4195
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4196
            }
4197
            else
4198
            {
4199
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4200
                foreach (var item in this.gridViewMarkup.SelectedItems)
4201
                {
4202
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4203
                }
4204
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4205
                
4206
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4207
            }
4208
        }
4209

    
4210
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4211
        {
4212
            if (App.ViewInfo != null)
4213
            {
4214
                btnConsolidate = (sender as RadRibbonButton);
4215
                if (!App.ViewInfo.NewCommentPermission)
4216
                {
4217
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4218
                }
4219
            }
4220
        }
4221

    
4222
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4223
        {
4224
            TeamConsolidationMethod();
4225
        }
4226

    
4227
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4228
        {
4229
            btnTeamConsolidate = sender as RadRibbonButton;
4230
            if (App.ViewInfo != null)
4231
            {
4232
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4233
                {
4234
                    if (btnConsolidate != null)
4235
                    {
4236
                        btnConsolidate.Visibility = Visibility.Collapsed;
4237
                    }
4238

    
4239
                    if (!App.ViewInfo.NewCommentPermission)
4240
                    {
4241
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4242
                    }
4243
                }
4244
                else
4245
                {
4246
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4247
                }
4248
            }
4249
        }
4250

    
4251
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4252
        {
4253
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4254
            if(item != null)
4255
            {
4256
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4257
                {
4258
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4259
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4260
                }
4261
                else
4262
                {
4263
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4264
                }
4265
            }else{
4266
                //Consolidate 가 없는 경우
4267
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4268
            }
4269
            
4270
        }
4271

    
4272
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4273
        {
4274
            btnFinalPDF = sender as RadRibbonButton;
4275
            if (App.ViewInfo != null)
4276
            {
4277
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4278
                {
4279
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4280
                    if (btnConsolidate != null)
4281
                    {
4282
                        btnConsolidate.Visibility = Visibility.Collapsed;
4283
                    }
4284
                }
4285
            }
4286
        }
4287

    
4288
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4289
        {
4290
            UpdateMyMarkupList();
4291

    
4292
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4293
            {
4294
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4295
            }
4296
            else
4297
            {
4298
                ViewerDataModel.Instance.IsConsolidate = true;
4299
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4300
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4301

    
4302
                string project_no = App.ViewInfo.ProjectNO;
4303
                string doc_id = _DocInfo.ID;
4304
                string user_id = App.ViewInfo.UserID;
4305
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4306
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4307
                {
4308
                    markupInfoItems.Add(item);
4309
                }
4310
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4311
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4312
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4313
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4314

    
4315
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4316
                if (item2 != null)
4317
                {
4318
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4319

    
4320
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4321
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4322
                }
4323
                else
4324
                {
4325
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4326
                }
4327
            }
4328
        }
4329

    
4330
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4331
        {
4332
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4333

    
4334
            if (App.ViewInfo != null)
4335
            {
4336
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4337
                {
4338
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4339
                }
4340
            }
4341
        }
4342

    
4343
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4344
        {
4345
            SetCompareRect();
4346
        }
4347

    
4348
        private void Sync_Click(object sender, RoutedEventArgs e)
4349
        {
4350
            if (Sync.IsChecked)
4351
            {
4352
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4353
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4354
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4355
            }
4356
        }
4357

    
4358
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4359
        {
4360
            if (UserList.IsChecked)
4361
            {
4362
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4363
            }
4364
            else
4365
            {
4366
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4367
            }
4368
        }
4369

    
4370
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4371
        {
4372

    
4373
            if (BalanceMode.IsChecked)
4374
            {
4375
                ViewerDataModel.Instance.PageBalanceMode = true;
4376
            }
4377
            else
4378
            {
4379
                ViewerDataModel.Instance.PageBalanceMode = false;
4380
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4381
            }
4382
        }
4383

    
4384
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4385
        {
4386
            //초기화
4387
            testPanel2.IsHidden = true;
4388
            ViewerDataModel.Instance.PageBalanceMode = false;
4389
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4390
            ViewerDataModel.Instance.PageNumber = 0;
4391
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4392
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4393
            UserList.IsChecked = false;
4394
            BalanceMode.IsChecked = false;
4395
        }
4396

    
4397
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4398
        {
4399
            if ((sender as System.Windows.Controls.Control).Tag != null)
4400
            {
4401
                //Compare 초기화
4402
                CompareMode.IsChecked = false;
4403
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4404

    
4405
                if (ViewerDataModel.Instance.PageNumber == 0)
4406
                {
4407
                    ViewerDataModel.Instance.PageNumber = 1;
4408
                }
4409

    
4410
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4411
                {
4412
                }
4413
                else
4414
                {
4415
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4416
                }
4417

    
4418

    
4419

    
4420
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4421
                {
4422

    
4423
                }
4424
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4425
                {
4426
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4427
                }
4428

    
4429
                pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4430

    
4431
                if (!testPanel2.IsHidden)
4432
                {
4433
                    if (IsSyncPDFMode)
4434
                    {
4435
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4436
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4437

    
4438
                        if (pdfpath.IsDownloading)
4439
                        {
4440
                            pdfpath.DownloadCompleted += (ex, arg) =>
4441
                            {
4442
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4443
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4444
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4445
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4446
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4447
                            };
4448
                        }
4449
                        else
4450
                        {
4451
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4452
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4453
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4454

    
4455
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4456
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4457
                        }
4458

    
4459
                    }
4460
                    else
4461
                    {
4462
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4463

    
4464
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4465

    
4466
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4467
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4468
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4469

    
4470
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4471
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4472

    
4473
                        if (defaultBitmapImage_Compare.IsDownloading)
4474
                        {
4475
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4476
                            {
4477
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4478
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4479
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4480

    
4481
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4482
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4483
                            };
4484
                        }
4485
                    }
4486

    
4487
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
4488
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4489
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
4490

    
4491
                    foreach (var item in gridSelectionRevItem)
4492
                    {
4493
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4494
                        foreach (var markupitem in markupitems)
4495
                        {
4496
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4497
                        }
4498
                    }
4499

    
4500
                    //강인구 추가
4501
                    zoomAndPanControl2.ZoomTo(new Rect
4502
                    {
4503
                        X = 0,
4504
                        Y = 0,
4505
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4506
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4507
                    });
4508

    
4509
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4510

    
4511
                }
4512
            }
4513
        }
4514

    
4515
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4516
        {
4517
            if (MarkupMode.IsChecked)
4518
            {
4519
                IsSyncPDFMode = true;
4520

    
4521
                var uri = CurrentRev.TO_VENDOR;
4522

    
4523
                if (ViewerDataModel.Instance.PageNumber == 0)
4524
                {
4525
                    ViewerDataModel.Instance.PageNumber = 1;
4526
                }
4527

    
4528
                //PDF모드 잠시 대기(강인구)
4529
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4530
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4531

    
4532
                if (pdfpath.IsDownloading)
4533
                {
4534
                    pdfpath.DownloadCompleted += (ex, arg) =>
4535
                    {
4536
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4537
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4538
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4539
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4540
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4541
                    };
4542
                }
4543
                else
4544
                {
4545
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4546
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4547
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4548

    
4549
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4550
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4551
                }
4552
            }
4553
            else
4554
            {
4555
                IsSyncPDFMode = false;
4556
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4557

    
4558
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4559

    
4560
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4561
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4562
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4563

    
4564
                if (defaultBitmapImage_Compare.IsDownloading)
4565
                {
4566
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4567
                    {
4568
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4569
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4570
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4571
                    };
4572
                }
4573
                zoomAndPanControl2.ApplyTemplate();
4574
                zoomAndPanControl2.UpdateLayout();
4575
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4576
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4577
            }
4578
        }
4579

    
4580
        /// <summary>
4581
        /// Compare된 영역을 초기화
4582
        /// </summary>
4583
        private void ClearCompareRect()
4584
        {
4585
            da.From = 1;
4586
            da.To = 1;
4587
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4588
            da.AutoReverse = false;
4589
            canvas_compareBorder.Children.Clear();
4590
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4591
        }
4592

    
4593
        /// <summary>
4594
        /// 문서 Comprare 
4595
        /// </summary>
4596
        private void SetCompareRect()
4597
        {
4598
            if (CompareMode.IsChecked)
4599
            {
4600
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4601
                {
4602
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4603
                }
4604
                if (ViewerDataModel.Instance.PageNumber == 0)
4605
                {
4606
                    ViewerDataModel.Instance.PageNumber = 1;
4607
                }
4608

    
4609
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4610
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4611
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4612

    
4613
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4614
            }
4615
            else
4616
            {
4617
                ClearCompareRect();
4618
            }
4619
        }
4620

    
4621
        private void RadButton_Click(object sender, RoutedEventArgs e)
4622
        {
4623
            gridViewHistory_Busy.IsBusy = true;
4624

    
4625
            RadButton instance = sender as RadButton;
4626
            if (instance.CommandParameter != null)
4627
            {
4628
                CurrentRev = instance.CommandParameter as VPRevision;
4629
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4630

    
4631
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4632
                {
4633
                    if (ea.Error == null && ea.Result != null)
4634
                    {
4635
                        testPanel2.IsHidden = false;
4636

    
4637
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4638
                        foreach(var info in ea.Result)
4639
                        {
4640
                            if(info.UserID == App.ViewInfo.UserID)
4641
                            {
4642
                                info.userDelete = true;
4643
                                info.DisplayColor = "FFFF0000";
4644
                            }
4645
                            else
4646
                            {
4647
                                info.userDelete = false;
4648
                            }
4649
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4650
                        }
4651
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4652

    
4653
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4654

    
4655
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4656

    
4657
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4658
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4659
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4660
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4661
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4662
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4663

    
4664
                        zoomAndPanControl2.ApplyTemplate();
4665
                        zoomAndPanControl2.UpdateLayout();
4666
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4667
                        {
4668
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4669
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4670
                        }
4671

    
4672
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4673
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4674
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4675

    
4676
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4677
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4678
                        gridViewHistory_Busy.IsBusy = false;
4679
                    }
4680

    
4681
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4682

    
4683
                    if (GetSyncMarkupInfoItemshandler != null)
4684
                    {
4685
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4686
                    }
4687

    
4688
                    ClearCompareRect();
4689
                    SetCompareRect();
4690
                };
4691

    
4692
                /// 중복 실행이 발생하여 수정함.
4693
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4694
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4695

    
4696
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4697
            }
4698
        }
4699

    
4700
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4701
        {
4702
            try
4703
            {
4704
                if (sender is RadButton)
4705
                {
4706
                    if ((sender as RadButton).Tag != null)
4707
                    {
4708
                        var url = (sender as RadButton).Tag.ToString();
4709
                        System.Diagnostics.Process.Start(url);
4710
                    }
4711
                    else
4712
                    {
4713
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4714
                    }
4715
                }
4716
            }
4717
            catch (Exception ex)
4718
            {
4719
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4720
            }
4721
        }
4722

    
4723
        public void Sync_Event(VPRevision Currnet_Rev)
4724
        {
4725
            CurrentRev = Currnet_Rev;
4726

    
4727
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4728
            {
4729
                if (ea.Error == null && ea.Result != null)
4730
                {
4731
                    testPanel2.IsHidden = false;
4732

    
4733
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4734
                    foreach(var info in ea.Result)
4735
                    {
4736
                        if(info.UserID == App.ViewInfo.UserID)
4737
                        {
4738
                            info.userDelete = true;
4739
                            info.DisplayColor = "FFFF0000";
4740
                        }
4741
                        else
4742
                        {
4743
                            info.userDelete = false;
4744
                        }
4745
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4746
                    }
4747
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4748

    
4749
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4750

    
4751
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4752

    
4753
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4754

    
4755
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4756
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4757
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4758

    
4759
                    if (defaultBitmapImage_Compare.IsDownloading)
4760
                    {
4761
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4762
                        {
4763
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4764
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4765
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4766
                        };
4767
                    }
4768

    
4769

    
4770
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4771
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4772
                    zoomAndPanControl2.ApplyTemplate();
4773
                    zoomAndPanControl2.UpdateLayout();
4774

    
4775
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4776
                    {
4777
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4778
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4779
                    }
4780
                    //}
4781

    
4782
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4783
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4784
                    gridViewHistory_Busy.IsBusy = false;
4785
                }
4786
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4787

    
4788
            };
4789
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4790
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4791
        }
4792

    
4793
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4794
        {
4795
            if (sender is Image)
4796
            {
4797
                if ((sender as Image).Tag != null)
4798
                {
4799
                    var pdfUrl = (sender as Image).Tag.ToString();
4800
                    System.Diagnostics.Process.Start(pdfUrl);
4801
                }
4802
                else
4803
                {
4804
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4805
                }
4806
            }
4807
        }
4808

    
4809
        private void Create_Symbol(object sender, RoutedEventArgs e)
4810
        {
4811
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4812

    
4813
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4814
            {
4815
                DialogMessage_Alert("Please Select Controls", "Alert");
4816
            }
4817
            else //선택된 것이 있으면
4818
            {
4819
                string MarkupData = "";
4820
                adorner_ = new AdornerFinal();
4821

    
4822
                foreach (var item in SelectLayer.Children)
4823
                {
4824
                    if (item.GetType().Name == "AdornerFinal")
4825
                    {
4826
                        adorner_ = (item as Controls.AdornerFinal);
4827
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4828
                        {
4829
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4830
                            {
4831
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4832
                                MarkupData += markupReturn.ConvertData;
4833
                            }
4834
                        }
4835
                    }
4836
                }
4837
                DialogParameters parameters = new DialogParameters()
4838
                {
4839
                    Owner = Application.Current.MainWindow,
4840
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4841
                    DefaultPromptResultValue = "Custom State",
4842
                    Content = "Name :",
4843
                    Header = "Insert Custom Symbol Name",
4844
                    Theme = new VisualStudio2013Theme(),
4845
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4846
                };
4847
                RadWindow.Prompt(parameters);
4848
            }
4849

    
4850
        }
4851
        public int symbolselectindex = 0;
4852
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4853
        {
4854
            //Save save = new Save();
4855
            try
4856
            {
4857
                string svgfilename = null;
4858
                if (symbolname != null)
4859
                {
4860
                    if (symbolpng == true || symbolsvg == true)
4861
                    {
4862
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4863
                        string guid = Commons.shortGuid();
4864

    
4865
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4866
                        //Check_Uri.UriCheck();
4867
                        fileUploader.RunCompleted += (ex, arg) =>
4868
                        {
4869
                            filename = arg.Result;
4870
                            if (symbolpng == true)
4871
                            {
4872
                                if (filename != null)
4873
                                { 
4874
                                    if (symbolselectindex == 0)
4875
                                    {
4876
                                        SymbolSave(symbolname, filename, data);
4877
                                    }
4878
                                    else
4879
                                    {
4880
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4881
                                    }
4882
                                    DataBind();
4883
                                }                                
4884
                            }
4885

    
4886
                            if (symbolsvg == true)
4887
                            {
4888
                                try
4889
                                {
4890
                                    var defaultBitmapImage = new BitmapImage();
4891
                                    defaultBitmapImage.BeginInit();
4892
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4893
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4894
                                    Check_Uri.UriCheck(filename);
4895
                                    defaultBitmapImage.UriSource = new Uri(filename);
4896
                                    defaultBitmapImage.EndInit();
4897

    
4898
                                    System.Drawing.Bitmap image;
4899

    
4900
                                    if (defaultBitmapImage.IsDownloading)
4901
                                    {
4902
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4903
                                        {
4904
                                            defaultBitmapImage.Freeze();
4905
                                            image = GetBitmap(defaultBitmapImage);
4906
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4907
                                            Process potrace = new Process
4908
                                            {
4909
                                                StartInfo = new ProcessStartInfo
4910
                                                {
4911
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4912
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4913
                                                    RedirectStandardInput = true,
4914
                                                    RedirectStandardOutput = true,
4915
                                                    RedirectStandardError = true,
4916
                                                    UseShellExecute = false,
4917
                                                    CreateNoWindow = true,
4918
                                                    WindowStyle = ProcessWindowStyle.Hidden
4919
                                                },
4920
                                            };
4921

    
4922
                                            StringBuilder svgBuilder = new StringBuilder();
4923
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4924
                                            {
4925
                                                svgBuilder.AppendLine(e2.Data);
4926
                                            };
4927

    
4928
                                            potrace.EnableRaisingEvents = true;
4929
                                            potrace.Start();
4930
                                            potrace.Exited += (sender, e) =>
4931
                                            {
4932
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4933
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4934
                                                Check_Uri.UriCheck(svgfilename);
4935
                                                if (symbolselectindex == 0)
4936
                                                {
4937
                                                    SymbolSave(symbolname, svgfilename, data);
4938
                                                }
4939
                                                else
4940
                                                {
4941
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4942
                                                }
4943

    
4944
                                                DataBind();
4945
                                            };
4946
                                            potrace.WaitForExit();
4947
                                        };
4948
                                    }
4949
                                    else
4950
                                    {
4951
                                        //GC.Collect();
4952
                                    }
4953
                                }
4954
                                catch(Exception ee)
4955
                                {
4956
                                    DialogMessage_Alert("" + ee, "Alert");
4957
                                }
4958
                            }
4959
                        };                                             
4960
                    }
4961
                }
4962
            }
4963
            catch (Exception e)
4964
            {
4965
                //DialogMessage_Alert(e + "", "Alert");
4966
            }            
4967
        }
4968

    
4969
        public void SymbolSave(string Name, string Url, string Data)
4970
        {
4971
            try
4972
            {
4973
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4974
                {
4975
                    ID = Commons.shortGuid(),
4976
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4977
                    NAME = Name,
4978
                    IMAGE_URL = Url,
4979
                    DATA = Data
4980
                };
4981

    
4982
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4983
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4984
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4985
            }
4986
            catch (Exception)
4987
            {
4988
                throw;
4989
            }
4990
        }
4991

    
4992
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4993
        {
4994
            try
4995
            {
4996
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4997
                {
4998
                    ID = Commons.shortGuid(),
4999
                    DEPARTMENT = Department,
5000
                    NAME = Name,
5001
                    IMAGE_URL = Url,
5002
                    DATA = Data
5003
                };
5004
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5005
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5006
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5007
            }
5008
            catch (Exception)
5009
            {
5010
                throw;
5011
            }
5012
        }
5013

    
5014
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5015
        {           
5016
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5017
            DataBind();
5018
        }
5019

    
5020
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5021
        {
5022
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5023
            DataBind();
5024
        }
5025
        private void DataBind()
5026
        {
5027
            try
5028
            {
5029
                Symbol_Custom Custom = new Symbol_Custom();
5030
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5031
                
5032
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5033
                foreach (var item in symbol_Private)
5034
                {
5035
                    Custom.Name = item.NAME;
5036
                    Custom.ImageUri = item.IMAGE_URL;
5037
                    Custom.ID = item.ID;
5038
                    Custom_List.Add(Custom);
5039
                    Custom = new Symbol_Custom();
5040
                }
5041
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5042
                
5043
                Custom = new Symbol_Custom();
5044
                Custom_List = new List<Symbol_Custom>();
5045

    
5046
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5047

    
5048
                List<SYMBOL_PUBLIC> symbol_Public;
5049

    
5050
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5051
                {
5052
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5053
                }
5054
                else
5055
                {
5056
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5057
                }
5058
                foreach (var item in symbol_Public)
5059
                {
5060
                    Custom.Name = item.NAME;
5061
                    Custom.ImageUri = item.IMAGE_URL;
5062
                    Custom.ID = item.ID;
5063
                    Custom_List.Add(Custom);
5064
                    Custom = new Symbol_Custom();
5065
                }
5066
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5067
                BaseClient.Close();                
5068
            }
5069
            catch(Exception e)
5070
            {
5071
                //DialogMessage_Alert("DataBind", "Alert");
5072
            }
5073
            
5074
        }
5075
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5076
        {
5077
            try
5078
            {
5079
                if (args.PromptResult != null)
5080
                {
5081
                    if (args.DialogResult.Value)
5082
                    {
5083
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5084

    
5085
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5086
                        _Encoder.Save(fs);
5087
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5088

    
5089
                        byte[] Img_byte = fs.ToArray();
5090

    
5091
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5092
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5093
                        Check_Uri.UriCheck(filename);
5094
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5095
                        {
5096
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5097
                        }
5098
                        else
5099
                        {
5100
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5101
                        }
5102
                        DataBind();
5103
                    }
5104
                }
5105
            }
5106
            catch(Exception ex)
5107
            {
5108
                DialogMessage_Alert("" + ex, "Alert");
5109
            }
5110
        }
5111

    
5112
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5113
        {
5114

    
5115
            Canvas _canvas = new Canvas();
5116
            _canvas.Background = Brushes.White;
5117
            _canvas.Width = adorner_.BorderSize.Width;
5118
            _canvas.Height = adorner_.BorderSize.Height;
5119
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5120

    
5121
            BitmapEncoder encoder = new PngBitmapEncoder();
5122

    
5123

    
5124
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
5125

    
5126
            DrawingVisual dv = new DrawingVisual();
5127

    
5128
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
5129
            _canvas.Arrange(new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X - 20, Y = -adorner_.BorderSize.Y - 20 }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
5130

    
5131
            using (DrawingContext ctx = dv.RenderOpen())
5132
            {
5133
                VisualBrush vb = new VisualBrush(_canvas);
5134
                ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X, Y = -adorner_.BorderSize.Y }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
5135
            }
5136

    
5137
            try
5138
            {
5139
                renderBitmap.Render(dv);
5140

    
5141
                //GC.Collect();
5142
                GC.WaitForPendingFinalizers();
5143
                //GC.Collect();
5144
                // encode png data
5145
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5146
                // puch rendered bitmap into it
5147
                pngEncoder.Interlace = PngInterlaceOption.Off;
5148
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5149
                return pngEncoder;
5150

    
5151
            }
5152
            catch //(Exception ex)
5153
            {
5154
                return null;
5155
            }
5156

    
5157
        }
5158

    
5159
        public void DialogMessage_Alert(string content, string header)
5160
        {
5161
            DialogParameters parameters = new DialogParameters()
5162
            {
5163
                Owner = this.ParentOfType<MainWindow>(),
5164
                Content = new TextBlock()
5165
                { 
5166
                    MinWidth = 400,
5167
                    FontSize = 11,
5168
                    Text = content,
5169
                    TextWrapping = System.Windows.TextWrapping.Wrap
5170
                },
5171
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5172
                Header = header,
5173
                Theme = new VisualStudio2013Theme(),
5174
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5175
            };            
5176
            RadWindow.Alert(parameters);
5177
        }
5178

    
5179
        #region 캡쳐 기능
5180

    
5181
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5182
        {
5183
            if (x < 0)
5184
            {
5185
                width += x;
5186
                x = 0;
5187
            }
5188
            if (y < 0)
5189
            {
5190
                height += y;
5191
                y = 0;
5192

    
5193
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5194
            }
5195
            if (x + width > zoomAndPanCanvas.ActualWidth)
5196
            {
5197
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5198
            }
5199
            if (y + height > zoomAndPanCanvas.ActualHeight)
5200
            {
5201
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5202
            }
5203

    
5204
            byte[] pixels = CopyPixels(x, y, width, height);
5205

    
5206
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5207

    
5208
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5209
        }
5210

    
5211
        public byte[] CopyPixels(int x, int y, int width, int height)
5212
        {
5213
            byte[] pixels = new byte[width * height * 4];
5214
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5215

    
5216
            // Canvas 이미지에서 객체 역역만큼 픽셀로 복사
5217
            canvasImage.CopyPixels(new Int32Rect(x, y, width, height), pixels, stride, 0);
5218

    
5219
            return pixels;
5220
        }
5221

    
5222
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5223
        {
5224
            DrawingVisual drawingVisual = new DrawingVisual();
5225
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5226

    
5227
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5228
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5229
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5230
            drawingContext.Close();
5231

    
5232
            // 비트맵으로 변환합니다.
5233
            RenderTargetBitmap target =
5234
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5235
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5236

    
5237
            target.Render(drawingVisual);
5238
            return target;
5239
        }
5240

    
5241
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5242
        {
5243
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5244
            System.Drawing.Imaging.BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5245
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5246
            bmp.UnlockBits(data);
5247
            return bmp;
5248
        }
5249
        public string symbolname = null;
5250
        public bool symbolsvg = true;
5251
        public bool symbolpng = true;
5252

    
5253
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5254
        {
5255
            System.Drawing.Bitmap image = GetBitmap(source);
5256
            //흰색 제거
5257
            //image.MakeTransparent(System.Drawing.Color.White);
5258

    
5259
            var imageStream = new System.IO.MemoryStream();
5260
            byte[] imageBytes = null;
5261
            using (imageStream)
5262
            {
5263
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5264
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5265
                imageStream.Position = 0;
5266
                imageBytes = imageStream.ToArray();
5267
            }
5268

    
5269
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5270

    
5271
            RadWindow CheckPop = new RadWindow();
5272
            //Alert check = new Alert(Msg);
5273

    
5274
            CheckPop = new RadWindow
5275
            {
5276
                MinWidth = 400,
5277
                MinHeight = 100,
5278
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5279
                Header = "Alert",
5280
                Content = symbolPrompt,
5281
                //DialogResult = 
5282
                ResizeMode = System.Windows.ResizeMode.NoResize,
5283
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5284
                IsTopmost = true,
5285
            };
5286
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5287
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5288
            CheckPop.ShowDialog();
5289

    
5290
            /*
5291
            DialogParameters parameters = new DialogParameters()
5292
            {
5293
                Owner = Application.Current.MainWindow,
5294
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5295
                DefaultPromptResultValue = "Custom State",
5296
                Content = "Name :",
5297
                Header = "Insert Custom Symbol Name",
5298
                Theme = new VisualStudio2013Theme(),
5299
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5300
            };            
5301
            RadWindow.Prompt(parameters);
5302
            */
5303
        }
5304

    
5305
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5306
        {
5307
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5308
            KCOMDataModel.DataModel.CHECK_LIST check_;
5309
            string Result = streamToBase64.ImageToBase64(source);
5310
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5311
            string projectno = App.ViewInfo.ProjectNO;
5312
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5313

    
5314
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5315
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5316
            if (Item != null)
5317
            {
5318
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5319
            }
5320
            else
5321
            {
5322
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5323
            }
5324

    
5325
            if (Item == null)
5326
            {
5327
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5328
                {
5329
                    ID = Commons.shortGuid(),
5330
                    USER_ID = App.ViewInfo.UserID,
5331
                    IMAGE_URL = Result,
5332
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5333
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5334
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5335
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5336
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5337
                    STATUS = "False",
5338
                    CREATE_TIME = DateTime.Now,
5339
                    UPDATE_TIME = DateTime.Now,
5340
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5341
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5342
                };
5343
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5344
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5345
                //this.BaseClient.AddCheckList(projectno, check_);
5346
            }
5347
            else
5348
            {
5349
                Item.IMAGE_URL = Result;
5350
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5351
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5352
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5353
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5354
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5355
            }
5356

    
5357
        }
5358

    
5359
        public void Set_Capture()
5360
        {
5361
            double x = CanvasDrawingMouseDownPoint.X;
5362
            double y = CanvasDrawingMouseDownPoint.Y;
5363
            double width = dragCaptureBorder.Width;
5364
            double height = dragCaptureBorder.Height;
5365

    
5366
            if (width > 5 || height > 5)
5367
            {
5368
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5369
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5370
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5371
            }
5372
        }
5373
        #endregion
5374

    
5375
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5376
        {
5377
            multi_Undo_Data = new Multi_Undo_data();
5378

    
5379
            multi_Undo_Data.Markup = control;
5380

    
5381
            if ((control as IShapeControl) != null)
5382
            {
5383
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5384
            }
5385
            if ((control as IDashControl) != null)
5386
            {
5387
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5388
            }
5389
            if ((control as IPath) != null)
5390
            {
5391
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5392
            }
5393
            if ((control as UIElement) != null)
5394
            {
5395
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5396
            }
5397

    
5398
            return multi_Undo_Data;
5399
        }
5400

    
5401
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5402
        {
5403
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5404
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5405
            {
5406
                if (items.UserID == Select_ID)
5407
                {
5408
                    foreach (var item in items.MarkupList)
5409
                    {
5410
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5411
                        {
5412
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5413
                                items.MarkupInfoID, Commons.shortGuid());
5414
                        }
5415
                    }
5416
                }
5417
            }
5418
        }
5419

    
5420
        /// <summary>
5421
        /// convert inkcontrol to polygoncontrol
5422
        /// </summary>
5423
        public void ConvertInkControlToPolygon()
5424
        {
5425
            if (inkBoard.Strokes.Count > 0)
5426
            {
5427
                inkBoard.Strokes.ToList().ForEach(stroke =>
5428
                {
5429
                    InkToPath ip = new InkToPath();
5430

    
5431
                    List<Point> inkPointSet = new List<Point>();
5432
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5433

    
5434
                    PolygonControl pc = new PolygonControl()
5435
                    {
5436
                        CommentAngle = 0,
5437
                        PointSet = inkPointSet,
5438
                        ControlType = ControlType.Ink
5439
                    };
5440
                    pc.StartPoint = inkPointSet[0];
5441
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5442
                    pc.LineSize = 3;
5443
                    pc.CommentID = Commons.shortGuid();
5444
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5445

    
5446
                    if (pc.PointSet.Count > 0)
5447
                    {
5448
                        CreateCommand.Instance.Execute(pc);
5449
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5450
                    }
5451
                });
5452
                inkBoard.Strokes.Clear();
5453
            }
5454
        }
5455

    
5456
        /// <summary>
5457
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5458
        /// </summary>
5459
        /// <author>ingu</author>
5460
        /// <date>2018.06.05</date>
5461
        /// <param name="getPoint"></param>
5462
        /// <returns></returns>
5463
        private bool IsGetoutpoint(Point getPoint)
5464
        {
5465
            if (getPoint == new Point())
5466
            {
5467
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5468
                currentControl = null;
5469
                return true;
5470
            }
5471

    
5472
            return false;
5473
        }
5474

    
5475
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5476
        {
5477
            e.Effects = DragDropEffects.Copy;
5478
        }
5479

    
5480
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5481
        {
5482
            e.Effects = DragDropEffects.Copy;
5483
        }
5484

    
5485
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5486
        {
5487
            e.Effects = DragDropEffects.None;
5488
        }
5489

    
5490
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5491
        {
5492
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5493
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5494

    
5495
            ScaleImage(pageWidth, pageHeight);
5496
        }
5497

    
5498
        /// <summary>
5499
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5500
        /// </summary>
5501
        /// <param name="pageWidth">원본 사이즈</param>
5502
        /// <param name="pageHeight">원본 사이즈</param>
5503
        /// <returns></returns>
5504
        private void ScaleImage(double pageWidth,double pageHeight)
5505
        {
5506
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5507
        }
5508

    
5509
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5510
        {
5511
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5512
        }
5513

    
5514

    
5515
        /*
5516
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5517
        {
5518
            try
5519
            {
5520
                if (e.Data.GetDataPresent(typeof(string)))
5521
                {
5522
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5523
                    string dragData = e.Data.GetData(typeof(string)) as string;
5524
                    Move_Symbol(sender, dragData);
5525
                }
5526
            }
5527
            catch (Exception ex)
5528
            {
5529
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5530
            }            
5531
        }
5532
        */
5533
    }
5534

    
5535
    public class testItem
5536
    {
5537
        public string Title { get; set; }
5538
    }
5539
}
클립보드 이미지 추가 (최대 크기: 500 MB)