프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 55d4f382

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

1

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

    
46
namespace KCOM.Views
47
{
48
    public static class ControlExtensions
49
    {
50
        public static T Clone<T>(this T controlToClone)
51
            where T : System.Windows.Controls.Control
52
        {
53
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
54

    
55
            T instance = Activator.CreateInstance<T>();
56

    
57
            foreach (PropertyInfo propInfo in controlProperties)
58
            {
59
                if (propInfo.CanWrite)
60
                {
61
                    if (propInfo.Name != "WindowTarget")
62
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
63
                }
64
            }
65
            return instance;
66
        }
67
    }
68

    
69
    public class MyConsole
70
    {
71
        private readonly System.Threading.ManualResetEvent _readLineSignal;
72
        private string _lastLine;
73
        public MyConsole()
74
        {
75
            _readLineSignal = new System.Threading.ManualResetEvent(false);
76
            Gui = new TextBox();
77
            Gui.AcceptsReturn = true;
78
            Gui.KeyUp += OnKeyUp;
79
        }
80

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

    
93
        public TextBox Gui { get; private set; }
94

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

    
108
        public void WriteLine(string line)
109
        {
110
            if (!Gui.Dispatcher.CheckAccess())
111
            {
112
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
113
                return;
114
            }
115

    
116
            Gui.Text += line + Environment.NewLine;
117
        }
118
    }
119

    
120
    /// <summary>
121
    /// MainMenu.xaml에 대한 상호 작용 논리
122
    /// </summary>
123
    public partial class MainMenu : UserControl
124
    {
125
        #region 프로퍼티
126
        public CommentUserInfo currentControl { get; set; }
127
        public ControlType controlType { get; set; }
128
        private Move move = new Move();
129
        private double[] rotateValue = { 0, 90, 180, 270 };
130
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
131
        private static readonly double DragThreshold = 5;
132
        private System.Windows.Input.Cursor cursor { get; set; }
133
        private Point canvasDrawingMouseDownPoint;
134
        public string filename { get; set; }
135
        private Point canvasZoomPanningMouseDownPoint;
136
        public Point getCurrentPoint;
137
        private Point canvasZoommovingMouseDownPoint;
138
        List<object> ControlList = new List<object>();
139
        private ListBox listBox = new ListBox();
140
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
141
        private bool isDraggingSelectionRect = false;
142
        DrawingAttributes inkDA = new DrawingAttributes();
143
        private VPRevision CurrentRev { get; set; }
144
        public RadRibbonButton btnConsolidate { get; set; }
145
        public RadRibbonButton btnFinalPDF { get; set; }
146
        public RadRibbonButton btnTeamConsolidate { get; set; }
147
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
148

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

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

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

    
182
                }
183
            }
184
        }
185

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

    
210
        public bool IsSyncPDFMode { get; set; }
211

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

    
236
        #endregion
237

    
238
        public MainMenu()
239
        {
240
            App.splashString(ISplashMessage.MAINMENU_0);            
241
            //InitializeComponent();    
242
            this.Loaded += MainMenu_Loaded;
243
        }
244

    
245
        public class TempDt
246
        {
247
            public int PageNumber { get; set; }
248
            public string CommentID { get; set; }
249
            public string ConvertData { get; set; }
250
            public int DATA_TYPE { get; set; }
251
            public string MarkupInfoID { get; set; }
252
            public int IsUpdate { get; set; }
253
        }
254

    
255
        List<TempDt> tempDtList = new List<TempDt>();
256

    
257
        private void SetCursor()
258
        {
259
            this.Cursor = cursor;
260
        }
261

    
262
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
263
        {
264
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
265
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
266
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
267
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
268
            {
269
                return true;
270
            }
271

    
272
            return false;
273
        }
274

    
275
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
276
        {
277
            if (rotate.Angle == 90 || rotate.Angle == 270)
278
            {
279
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
280
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
281
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
282
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
283
                {
284
                    return true;
285
                }
286
            }
287
            else
288
            {
289
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
290
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
291
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
292
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
293
                {
294
                    return true;
295
                }
296
            }
297

    
298
            return false;
299
        }
300

    
301
        public void DeleteItem(MarkupInfoItem item)
302
        {
303
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
304
            {
305
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
306

    
307
            
308
            ViewerDataModel.Instance._markupInfoList.Remove(item);
309

    
310
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
311
            {
312
                ViewerDataModel.Instance.MarkupControls.Remove(a);
313
            });
314

    
315
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
316
            {
317
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
318
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
319
                null, Event_Type.Delete, a.CommentID, null);
320
            });
321

    
322
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
323
            {
324
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
325
                //임시파일에서도 삭제
326
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
327
            });
328

    
329
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
330

    
331
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
332
            {
333
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
334
                {
335
                    var infoId = Commons.shortGuid();
336
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
337
                    {
338
                        CreateTime = DateTime.Now,
339
                        Depatment = userData.DEPARTMENT,
340
                        UpdateTime = DateTime.Now,
341
                        DisplayColor = "#FFFF0000",
342
                        UserID = userData.ID,
343
                        UserName = userData.NAME,
344
                        PageCount = 1,
345
                        Description = "",
346
                        MarkupInfoID = infoId,
347
                        MarkupList = null,
348
                        MarkupVersionID = Commons.shortGuid(),
349
                        Consolidate = 0,
350
                        PartConsolidate = 0,
351
                        userDelete = true,
352
                        AvoidConsolidate = 0,
353
                        IsPreviewUser = true
354
                    };
355
                    App.Custom_ViewInfoId = infoId;
356
                }
357
            }
358
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
359
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);    
360
        }
361

    
362
        /// <summary>
363
        /// delete selected comments
364
        /// </summary>
365
        /// <param name="sender"></param>
366
        /// <param name="e"></param>
367
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
368
        {
369
            DialogParameters parameters = new DialogParameters()
370
            {
371
                Owner = Application.Current.MainWindow,
372
                Content = new TextBlock()
373
                { 
374
                    MinWidth = 400,
375
                    FontSize = 11,
376
                    Text = "정말 삭제 하시겠습니까?",
377
                    TextWrapping = System.Windows.TextWrapping.Wrap
378
                },
379
                Header = "Confirm",
380
                Theme = new VisualStudio2013Theme(),
381
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
382
                OkButtonContent = "Yes",
383
                CancelButtonContent = "No",
384
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
385
                {
386
                    if(wc.DialogResult == true)
387
                    {
388
                        //선택된 어도너가 있을시 삭제가 되지 않음
389
                        SelectionSet.Instance.UnSelect(this);
390

    
391
                        Button content = (sender as Button);
392
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
393

    
394
                        DeleteItem(item);
395
                    }
396
                }
397
            };
398
            RadWindow.Confirm(parameters);
399
        }
400

    
401
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
402

    
403
        private static Timer timer;
404
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
405
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
406
        {
407
            InitializeComponent();            
408
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
409

    
410
            if (App.ParameterMode)
411
            {
412
                App.splashString(ISplashMessage.MAINMENU_1);
413
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
414
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
415
                imageViewer_Compare = new Image();
416
                ViewerDataModel.Instance.Capture_Opacity = 0;
417
                da.From = 0.8;
418
                da.To = 0;
419
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
420
                da.AutoReverse = true;
421
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
422

    
423
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
424
                {
425
                    this.SymbolPane.Visibility = Visibility.Collapsed;
426
                    this.FavoritePane.Visibility = Visibility.Collapsed;
427
                    this.drawingRotateCanvas.IsHitTestVisible = false;
428
                }
429
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
430
            }
431
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
432
        }
433

    
434
        
435

    
436
        private void timercallback(Object o)
437
        {
438
            Stopwatch sw = new Stopwatch();
439
            sw.Start();
440
            TempFile.TempFileAdd();
441
            sw.Stop();
442

    
443
            Dispatcher.InvokeAsync(new Action(delegate
444
            {
445
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
446
                {
447
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
448
                }
449
            }));
450

    
451
            ////GC.Collect();
452
        }
453
        
454
        /// <summary>
455
        /// update my markuplist
456
        ///  - update existing markup data if already exist
457
        ///  - add new markup data if control is new
458
        /// </summary>
459
        public void UpdateMyMarkupList()
460
        {
461
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
462

    
463
            /// add or update markup list
464
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
465
            {
466
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
467

    
468
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
469
                if (exist != null) //신규 추가 된 코멘트
470
                {
471
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
472
                    {
473
                        exist.Data = root.ConvertData;
474
                        exist.IsUpdate = true;
475
                    }
476
                }
477
                else if (root.CommentID != null)
478
                {
479
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
480
                    {
481
                        ID = control.CommentID,
482
                        Data = root.ConvertData,
483
                        Data_Type = root.DATA_TYPE,
484
                        MarkupInfoID = App.Custom_ViewInfoId,
485
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
486
                        Symbol_ID = control.SymbolID,
487
                        //Group_ID = control.GroupID,
488
                    });
489
                }
490
            }
491

    
492
            /// delete markup list
493
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
494
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
495
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
496
                          select markup).ToList();
497
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
498
            /// up to here
499

    
500
            //if (modified)
501
            //{
502
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
503
            //    {
504
            //        ComingNewBieEnd = true;
505
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
506
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
507
            //        gridViewMarkup.ItemsSource = null;
508
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
509
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
510

    
511
            //        GroupDescriptor descriptor = new GroupDescriptor();
512
            //        descriptor.Member = "Depatment";
513
            //        descriptor.DisplayContent = "DEPT";
514
            //        descriptor.SortDirection = ListSortDirection.Ascending;
515
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
516
            //    }
517
            //}
518
        }
519

    
520
        DispatcherTimer renderTesttimer;
521

    
522
        /// <summary>
523
        /// start page changing
524
        ///  - save controls if page is modified
525
        ///  - starting download page image
526
        /// </summary>
527
        /// <param name="sender"></param>
528
        /// <param name="e"></param>
529
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
530
        {
531
            CompareMode.IsChecked = false;
532
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
533

    
534
            #region 페이지가 벗어난 경우
535

    
536
            if (BalancePoint < 1)
537
            {
538
                BalancePoint = 1;
539
                ViewerDataModel.Instance.PageBalanceNumber = 0;
540
            }
541

    
542
            if (pageNavigator.PageCount < BalancePoint)
543
            {
544
                BalancePoint = pageNavigator.PageCount;
545
                ViewerDataModel.Instance.PageBalanceNumber = 0;
546
            }
547

    
548
            #endregion
549

    
550
            ViewerDataModel.Instance.PageNumber = BalancePoint;
551

    
552
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
553
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
554
            var pageUri = pageNavigator.CurrentPage.PageUri;
555
            var contentScale = zoomAndPanControl.ContentScale;
556

    
557
            #region 페이지 이미지 로딩 수정
558

    
559
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
560
            try
561
            {
562
                ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
563
                ScaleImage(pageWidth, pageHeight);
564

    
565
                ViewerDataModel.Instance.ImageViewWidth = pageWidth;
566
                ViewerDataModel.Instance.ImageViewHeight = pageHeight;
567

    
568
                zoomAndPanCanvas.Width = pageWidth;
569
                zoomAndPanCanvas.Height = pageHeight;
570

    
571
                Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
572
                Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
573

    
574
                inkBoard.Width = pageWidth;
575
                inkBoard.Height = pageHeight;
576
            }
577
            catch (Exception ex)
578
            {
579
                string failedmsg = CommonLib.Common.GetAlertMessageString("GetConversionStateFailed", "MSG", "Too Many V/P Files are uploading instantaneously, This V/P file can not be open now. Please feel free to re-open wait a moment again!\n\n현재 일시적으로 많은 양의 V/P가 등록되고 있어 이 문서를 열람할 수 없습니다.\n잠시만 기다려 주신 후 다시 열람하여 주시기 바랍니다");
580
                DialogMessage_Alert(failedmsg, "Warning");
581
                App.FileLogger.Fatal(ex);
582
            }
583
            
584

    
585
            #endregion
586

    
587
            if (!testPanel2.IsHidden)
588
            {
589
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
590
                //PDF모드일때 잠시 대기(강인구)
591
                if (IsSyncPDFMode)
592
                {
593
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
594
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
595

    
596
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
597
                    if (pdfpath.IsDownloading)
598
                    {
599
                        pdfpath.DownloadCompleted += (ex, arg) =>
600
                        {
601
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
602
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
603
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
604
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
605
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
606
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
607
                        };
608
                    }
609
                    else
610
                    {
611
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
612
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
613
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
614
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
615

    
616
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
617
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
618
                    }
619
                }
620
                else
621
                {
622
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
623
                    string uri2 = "";
624
                    if (userData.COMPANY != "EXT")
625
                    {
626
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
627
                    }
628
                    else
629
                    {
630
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
631
                    }
632

    
633
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
634
                    var defaultBitmapImage_Compare = new BitmapImage();
635
                    defaultBitmapImage_Compare.BeginInit();
636
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
637
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
638
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
639
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
640
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
641
                    defaultBitmapImage_Compare.EndInit();
642

    
643
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
644

    
645
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
646
                    zoomAndPanControl.ZoomTo(new Rect
647
                    {
648
                        X = 0,
649
                        Y = 0,
650
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
651
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
652
                    });
653

    
654
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
655
                    if (defaultBitmapImage_Compare.IsDownloading)
656
                    {
657
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
658
                        {
659
                            defaultBitmapImage_Compare.Freeze();
660
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
661
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
662
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
663
                            ComparePanel.UpdateLayout();
664
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
665
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
666

    
667
                            zoomAndPanControl.ZoomTo(new Rect
668
                            {
669
                                X = 0,
670
                                Y = 0,
671
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
672
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
673
                            });
674

    
675
                            //defaultBitmapImage_Compare dispose
676
                            defaultBitmapImage_Compare = null;
677
                            GC.Collect();
678
                        };
679
                    }
680
                }
681
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
682
            }
683

    
684
            this.pageNavigator.ChangePage(e.PageNumber);
685
        }
686

    
687
        /// <summary>
688
        /// called after page is changed
689
        /// </summary>
690
        /// <param name="sender"></param>
691
        /// <param name="e"></param>
692
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
693
        {
694
            if (zoomAndPanCanvas2.Width.IsNaN())
695
            {
696
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
697
            }
698

    
699
            /// 컨트롤을 새로 생성한다.
700
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
701
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
702
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == ViewerDataModel.Instance.PageNumber))
703
            { 
704
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).First();
705
                if (info != null)
706
                {
707
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
708
                    if (info.UserID == App.ViewInfo.UserID)
709
                    {
710
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
711
                                        markup.MarkupInfoID, markup.ID);
712
                        control.Visibility = Visibility.Hidden;
713
                    }
714
                    else
715
                    {
716
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
717
                                                                markup.MarkupInfoID, markup.ID);
718
                        control.Visibility = Visibility.Hidden;
719
                    }
720
                }
721
            };
722
            /// up to here
723

    
724
            /// fire selection event
725
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
726
            this.gridViewMarkup.UnselectAll();
727
            this.gridViewMarkup.Select(gridSelectionItem);
728

    
729
            if (!testPanel2.IsHidden)
730
            {
731
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
732
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
733
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
734

    
735
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
736
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
737

    
738

    
739
                foreach (var item in gridSelectionRevItem)
740
                {
741
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
742
                    {
743
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
744
                    });
745
                }
746
            }
747

    
748
            var instanceMain = this.ParentOfType<MainWindow>();
749
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
750
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
751

    
752
            instanceMain.dzTopMenu.rotateOffSet = 0;
753
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
754
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
755
            
756
            SetCommentPages(true);
757
        }
758

    
759
        public void SetCommentPages(bool onlyMe = false)
760
        {
761
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
762
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
763
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
764
            {
765
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
766
                if(item.MarkupList != null)
767
                {
768
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
769
                    instance.UserName = item.UserName;
770
                    instance.Depart = item.Depatment;
771
                    instance.MarkupInfoID = item.MarkupInfoID;
772
                    instance.IsSelected = true;
773
                    instance.isConSolidation = item.Consolidate;
774
                    instance.SetColor = item.DisplayColor;
775
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
776
                    {
777
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
778
                    }
779
                    else
780
                    {
781
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
782
                    }
783
                    _pages.Add(instance);
784
                }                   
785
            }
786
            
787
            this.pageNavigator.SetCommentList(_pages.ToList());
788
        }
789

    
790
        public void MarkupitemViewUpdate(string markupinfo_id)
791
        {
792
            //db에 업데이트 한 list 를 view 에 업데이트
793
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
794
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
795
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
796
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
797
            if (dbinfo.MarkupList.Count > 0)
798
            {
799
                if (viewinfo.MarkupList != null)
800
                {
801
                    viewinfo.MarkupList.Clear();
802
                    viewinfo.MarkupList = null;
803
                }
804
                viewinfo.MarkupList = new List<MarkupItem>();
805
                foreach (var item in dbinfo.MarkupList)
806
                {
807
                    viewinfo.MarkupList.Add(item);
808
                }
809
            }
810
        }
811

    
812
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
813
        {
814
            if (e.MiddleButton == MouseButtonState.Pressed)
815
            {
816

    
817
            }
818
            e.Handled = true;
819
            if (e.Delta > 0)
820
            {
821
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
822
                ZoomIn(currentContentMousePoint);
823
            }
824
            else
825
            {
826
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
827
                ZoomOut(currentContentMousePoint);
828
            }
829
        }
830

    
831
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
832
        {
833
            e.Handled = true;
834
            if (e.Delta > 0)
835
            {
836
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
837
                ZoomIn_Sync(currentContentMousePoint);
838
            }
839
            else
840
            {
841
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
842
                ZoomOut_Sync(currentContentMousePoint);
843
            }
844
        }
845

    
846
        #region ZoomIn & ZoomOut
847

    
848
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
849
        {
850
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
851
                zoomAndPanControl.ContentZoomFocusY));
852
        }
853

    
854
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
855
        {
856
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
857
                zoomAndPanControl.ContentZoomFocusY));
858
        }
859

    
860

    
861
        //강인구 추가 (줌 인아웃 수치 변경)
862
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
863
        private void ZoomOut(Point contentZoomCenter)
864
        {
865
            if (zoomAndPanControl.ContentScale > 0.39)
866
            {
867
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
868
            }
869
            else
870
            {
871
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
872
            }
873

    
874
            if (zoomAndPanControl2 != null && Sync.IsChecked)
875
            {
876
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
877
            }
878
        }
879

    
880
        private void ZoomIn(Point contentZoomCenter)
881
        {
882
            if (zoomAndPanControl.ContentScale > 0.19)
883
            {
884
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
885
            }
886
            else
887
            {
888
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
889
            }
890

    
891
            if (zoomAndPanControl2 != null && Sync.IsChecked)
892
            {
893
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
894
            }
895

    
896
        }
897

    
898
        private void ZoomOut_Sync(Point contentZoomCenter)
899
        {
900
            if (zoomAndPanControl2.ContentScale > 0.39)
901
            {
902
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
903
            }
904
            else
905
            {
906
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
907
            }
908

    
909
            if (Sync.IsChecked)
910
            {
911
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
912
            }
913
        }
914

    
915
        private void ZoomIn_Sync(Point contentZoomCenter)
916
        {
917
            if (zoomAndPanControl2.ContentScale > 0.19)
918
            {
919
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
920
            }
921
            else
922
            {
923
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
924
            }
925

    
926
            if (Sync.IsChecked)
927
            {
928
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
929
            }
930
        }
931

    
932
        private void ZoomOut()
933
        {
934
            zoomAndPanControl.ContentScale -= 0.1;
935
            //if (zoomAndPanControl2 != null)
936
            //{
937
            //    zoomAndPanControl2.ContentScale -= 0.1;
938
            //}
939
        }
940

    
941
        private void ZoomIn()
942
        {
943
            zoomAndPanControl.ContentScale += 0.1;
944
            //if (zoomAndPanControl2 != null)
945
            //{
946
            //    zoomAndPanControl2.ContentScale += 0.1;
947
            //}
948
        }
949

    
950
        #endregion
951

    
952
        private void init()
953
        {
954
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
955
            {
956

    
957
                ControlList.Clear();
958
                listBox.Items.Clear();
959
                selected_item.Clear();
960

    
961
                (item as IMarkupCommonData).IsSelected = false;
962
            }
963

    
964
        }
965

    
966
        private HitTestResultBehavior MyCallback(HitTestResult result)
967
        {
968
            //this.cursor = Cursors.UpArrow;
969
            var element = result.VisualHit;
970
            while (element != null && !(element is CommentUserInfo))
971
                element = VisualTreeHelper.GetParent(element);
972

    
973
            if (element == null)
974
            {
975
                return HitTestResultBehavior.Stop;
976
            }
977
            else
978
            {
979
                if (element is CommentUserInfo)
980
                {
981
                    if (!hitList.Contains(element))
982
                    {
983
                        hitList.Add((CommentUserInfo)element);
984
                    }
985
                    else
986
                    {
987
                        return HitTestResultBehavior.Stop;
988
                    }
989
                }
990
            }
991
            return HitTestResultBehavior.Continue;
992
        }
993

    
994
        public void ReleaseSelectPath()
995
        {
996
            if (SelectionPath == null)
997
            {
998
                SelectionPath = new Path();
999
                SelectionPath.Name = "";
1000
            }
1001
            if (SelectionPath.Name != "")
1002
            {
1003
                SelectionPath.Name = "None";
1004
            }
1005
            SelectionPath.Opacity = 0.01;
1006
            SelectionPath.RenderTransform = null;
1007
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1008
        }
1009

    
1010
        #region 컨트롤 초기화 
1011
        public void Control_Init(object control)
1012
        {
1013
            if (L_Size != 0 && (control as IPath) != null)
1014
            {
1015
                (control as IPath).LineSize = L_Size;
1016
                L_Size = 0;
1017
            }
1018

    
1019
            switch (control.GetType().Name)
1020
            {
1021
                case "RectangleControl":
1022
                    {
1023
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1024
                    }
1025
                    break;
1026
                case "CircleControl":
1027
                    {
1028
                        (control as CircleControl).StrokeColor = Brushes.Red;
1029
                    }
1030
                    break;
1031
                case "TriControl":
1032
                    {
1033
                        (control as TriControl).StrokeColor = Brushes.Red;
1034
                    }
1035
                    break;
1036
                case "RectCloudControl":
1037
                    {
1038
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1039
                    }
1040
                    break;
1041
                case "CloudControl":
1042
                    {
1043
                        (control as CloudControl).StrokeColor = Brushes.Red;
1044
                    }
1045
                    break;
1046
                case "PolygonControl":
1047
                    {
1048
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1049
                    }
1050
                    break;
1051
                case "ArcControl":
1052
                    {
1053
                        (control as ArcControl).StrokeColor = Brushes.Red;
1054
                    }
1055
                    break;
1056
                case "ArrowArcControl":
1057
                    {
1058
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1059
                    }
1060
                    break;
1061
                case "LineControl":
1062
                    {
1063
                        (control as LineControl).StrokeColor = Brushes.Red;
1064
                    }
1065
                    break;
1066
                case "ArrowControl_Multi":
1067
                    {
1068
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1069
                    }
1070
                    break;
1071
                case "TextControl":
1072
                    {
1073
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1074
                    }
1075
                    break;
1076
                case "ArrowTextControl":
1077
                    {
1078
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1079
                    }
1080
                    break;
1081
                case "InsideWhiteControl":
1082
                    {
1083
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1084
                    }
1085
                    break;
1086
                case "OverlapWhiteControl":
1087
                    {
1088
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1089
                    }
1090
                    break;
1091
                case "ClipWhiteControl":
1092
                    {
1093
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1094
                    }
1095
                    break;
1096
                case "CoordinateControl":
1097
                    {
1098
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1099
                    }
1100
                    break;
1101
            }
1102
        }
1103
        #endregion
1104

    
1105
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1106
        {
1107
            //Control_Init(e.Source);
1108
        }
1109
        //private Window _dragdropWindow = null;
1110

    
1111
        [DllImport("user32.dll")]
1112
        [return: MarshalAs(UnmanagedType.Bool)]
1113
        internal static extern bool GetCursorPos(ref Win32Point pt);
1114

    
1115
        [StructLayout(LayoutKind.Sequential)]
1116
        internal struct Win32Point
1117
        {
1118
            public Int32 X;
1119
            public Int32 Y;
1120
        };
1121
        /*
1122
       public string symbol_id = null;
1123
       public long symbol_group_id;
1124
       public int symbol_SelectedIndex;
1125
       public ImageSource symbol_img;
1126
       public string symbol_Data = null;
1127
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1128
       {
1129
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1130
               zoomAndPanCanvas.ActualHeight / 2));
1131

    
1132

    
1133
               if (this._dragdropWindow != null)
1134
               {
1135
                   this._dragdropWindow.Close();
1136
                   this._dragdropWindow = null;
1137
               }
1138

    
1139
               symbol_id = id;
1140
               symbol_group_id = group_id;
1141
               symbol_SelectedIndex = SelectedIndex;
1142
               symbol_Data = Data_;
1143
               symbol_img = img;
1144

    
1145

    
1146
               CreateDragDropWindow2(img);
1147
              
1148
    }
1149

    
1150
    private void CreateDragDropWindow2(ImageSource image)
1151
        {
1152
            this._dragdropWindow = new Window();
1153
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1154
            _dragdropWindow.WindowStyle = WindowStyle.None;
1155
            _dragdropWindow.AllowsTransparency = true;           
1156
            _dragdropWindow.AllowDrop = false;
1157
            _dragdropWindow.Background = null;
1158
            _dragdropWindow.IsHitTestVisible = false;
1159
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1160
            _dragdropWindow.Topmost = true;
1161
            _dragdropWindow.ShowInTaskbar = false;
1162
            
1163
            Rectangle r = new Rectangle();
1164
            r.Width = image.Width;
1165
            r.Height = image.Height;
1166
            r.Opacity = 0.5;            
1167
            r.Fill = new ImageBrush(image);
1168
            this._dragdropWindow.Content = r;
1169

    
1170
            Win32Point w32Mouse = new Win32Point();
1171
            GetCursorPos(ref w32Mouse);
1172

    
1173
            //w32Mouse.X = getCurrentPoint.X;
1174
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1175
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1176
            this._dragdropWindow.Show();
1177
        }
1178
         */
1179
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1180
        {
1181
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1182
            {
1183
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1184

    
1185
                Point currentPos = e.GetPosition(rect);
1186

    
1187
                floatingTip.HorizontalOffset = currentPos.X + 20;
1188
                floatingTip.VerticalOffset = currentPos.Y;
1189
            }
1190

    
1191
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1192
            
1193
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1194
            {
1195
                SetCursor();
1196
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1197
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1198

    
1199
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1200
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1201
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1202

    
1203
                if (Sync.IsChecked)
1204
                {
1205
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1206
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1207
                }
1208
            }
1209

    
1210
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1211
            {
1212
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1213
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1214
                SetCursor();
1215

    
1216
                if (currentControl != null)
1217
                {
1218
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1219
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1220
                    //강인구 추가
1221
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1222

    
1223
                    if ((currentControl as IPath) != null)
1224
                    {
1225
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1226
                    }
1227
                    if ((currentControl as LineControl) != null)
1228
                    {
1229
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1230
                    }
1231

    
1232
                    if ((currentControl as IShapeControl) != null)
1233
                    {
1234
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1235
                    }
1236
                    if ((currentControl as TextControl) != null)
1237
                    {
1238
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1239
                        {
1240
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1241
                        }
1242
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1243
                        {
1244
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1245
                        }
1246
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1247
                        {
1248
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1249
                        }
1250
                    }
1251
                    else if ((currentControl as ArrowTextControl) != null)
1252
                    {
1253
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1254
                        {
1255
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1256
                        }
1257
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1258
                        {
1259
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1260
                        }
1261
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1262
                        {
1263
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1264
                        }
1265
                    }
1266
                    else if ((currentControl as RectCloudControl) != null)
1267
                    {
1268
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1269
                    }
1270
                    else if ((currentControl as CloudControl) != null)
1271
                    {
1272
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1273
                    }
1274

    
1275
                    switch (controlType)
1276
                    {
1277
                        case (ControlType.Coordinate):
1278
                            {
1279
                                var control = currentControl as CoordinateControl;
1280
                                if (control != null)
1281
                                {
1282
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1283
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1284
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1285
                                }
1286
                            }
1287
                            break;
1288
                        case (ControlType.InsideWhite):
1289
                            {
1290
                                var control = currentControl as InsideWhiteControl;
1291
                                if (control != null)
1292
                                {
1293
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1294
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1295
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1296
                                    control.Paint = PaintSet.Fill;
1297
                                }
1298
                            }
1299
                            break;
1300
                        case ControlType.OverlapWhite:
1301
                            {
1302
                                var control = currentControl as OverlapWhiteControl;
1303
                                if (control != null)
1304
                                {
1305
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1306
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1307
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1308
                                    control.Paint = PaintSet.Fill;
1309
                                }
1310
                            }
1311
                            break;
1312
                        case ControlType.ClipWhite:
1313
                            {
1314
                                var control = currentControl as ClipWhiteControl;
1315
                                if (control != null)
1316
                                {
1317
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1318
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1319
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1320
                                    control.Paint = PaintSet.Fill;
1321
                                }
1322
                            }
1323
                            break;
1324
                        case ControlType.RectCloud:
1325
                            {
1326
                                var control = currentControl as RectCloudControl;
1327
                                if (control != null)
1328
                                {
1329
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1330
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1331
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1332
                                }
1333
                            }
1334
                            break;
1335
                        case ControlType.SingleLine:
1336
                        case ControlType.CancelLine:
1337
                        case ControlType.ArrowLine:
1338
                        case ControlType.TwinLine:
1339
                        case ControlType.DimLine:
1340
                            {
1341
                                var control = currentControl as LineControl;
1342
                                if (control != null)
1343
                                {
1344
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1345
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1346
                                }
1347
                            }
1348
                            break;
1349

    
1350
                        case ControlType.ArcLine:
1351
                            {
1352
                                var control = currentControl as ArcControl;
1353
                                if (control != null)
1354
                                {
1355
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1356
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1357
                                }
1358
                            }
1359
                            break;
1360

    
1361
                        case ControlType.ArcArrow:
1362
                            {
1363
                                var control = currentControl as ArrowArcControl;
1364
                                if (control != null)
1365
                                {
1366
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1367
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1368
                                }
1369
                            }
1370
                            break;
1371

    
1372
                        case ControlType.ArrowMultiLine:
1373
                            {
1374
                                var control = currentControl as ArrowControl_Multi;
1375
                                if (control != null)
1376
                                {
1377
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1378
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1379
                                }
1380
                            }
1381
                            break;
1382

    
1383
                        case ControlType.Circle:
1384
                            {
1385
                                if (currentControl != null)
1386
                                {
1387
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1388
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1389
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1390
                                }
1391
                            }
1392
                            break;
1393

    
1394
                        case ControlType.PolygonCloud:
1395
                            {
1396
                                var control = currentControl as CloudControl;
1397
                                if (control != null)
1398
                                {
1399
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1400
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1401
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1402
                                }
1403
                            }
1404
                            break;
1405

    
1406
                        case ControlType.Triangle:
1407
                            {
1408
                                var control = currentControl as TriControl;
1409
                                if (control != null)
1410
                                {
1411
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1412
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1413
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1414
                                }
1415
                            }
1416
                            break;
1417

    
1418
                        case ControlType.ImgControl:
1419
                            {
1420
                                var control = currentControl as ImgControl;
1421
                                if (control != null)
1422
                                {
1423
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1424
                                }
1425
                            }
1426
                            break;
1427

    
1428
                        case ControlType.Date:
1429
                            {
1430
                                var control = currentControl as DateControl;
1431
                                if (control != null)
1432
                                {
1433
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1434
                                }
1435
                            }
1436
                            break;
1437

    
1438
                        case ControlType.ArrowTextControl:
1439
                        case ControlType.ArrowTransTextControl:
1440
                        case ControlType.ArrowTextBorderControl:
1441
                        case ControlType.ArrowTransTextBorderControl:
1442
                        case ControlType.ArrowTextCloudControl:
1443
                        case ControlType.ArrowTransTextCloudControl:
1444
                            {
1445
                                var control = currentControl as ArrowTextControl;
1446
                                if (control != null)
1447
                                {
1448
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1449
                                }
1450
                            }
1451
                            break;
1452
                        case ControlType.PolygonControl:
1453
                        case ControlType.ChainLine:
1454
                            {
1455
                                var control = currentControl as PolygonControl;
1456
                                if (control != null)
1457
                                {
1458
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1459
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1460
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1461
                                }
1462
                            }
1463
                            break;
1464
                        case ControlType.Sign:
1465
                            {
1466
                                var control = currentControl as SignControl;
1467
                                if (control != null)
1468
                                {
1469
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1470
                                }
1471
                            }
1472
                            break;
1473
                        case ControlType.Symbol:
1474
                            {
1475
                                var control = currentControl as SymControl;
1476
                                if (control != null)
1477
                                {
1478
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1479
                                }
1480
                            }
1481
                            break;
1482
                        case ControlType.Stamp:
1483
                            {
1484
                                var control = currentControl as SymControlN;
1485
                                if (control != null)
1486
                                {
1487
                                    if (control.STAMP != null)
1488
                                    {
1489
                                        control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1490
                                    }
1491
                                    else
1492
                                    {
1493
                                        currentControl = null;
1494
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1495
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1496
                                    }
1497
                                }                                    
1498
                            }
1499
                            break;
1500
                        case ControlType.Rectangle:
1501
                        case ControlType.Mark:
1502
                            {
1503
                                var control = currentControl as RectangleControl;
1504
                                if (control != null)
1505
                                {
1506
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1507
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1508
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1509
                                }
1510
                            }
1511
                            break;
1512
                        case ControlType.PenControl:
1513
                            {
1514
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1515
                                //inkBoard.Strokes.Add(stroke);
1516
                            }
1517
                            break;
1518
                        default:
1519
                            break;
1520
                    }
1521
                }
1522
            }
1523
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1524
            {
1525
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1526
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1527
                SetCursor();
1528
                if (currentControl == null)
1529
                {
1530
                    switch (controlType)
1531
                    {
1532
                        case ControlType.PenControl:
1533
                            {
1534
                                if (inkBoard.Tag.ToString() == "Ink")
1535
                                {
1536
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1537
                                }
1538
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1539
                                {
1540
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1541
                                }
1542
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1543
                                {
1544
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1545
                                }
1546

    
1547
                                //inkBoard.Strokes.Add(stroke);
1548
                            }
1549
                            break;
1550
                    }
1551
                    return;
1552
                }
1553
            }
1554
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1555
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1556
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1557
            {
1558
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1559

    
1560
                if (isDraggingSelectionRect)
1561
                {
1562
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1563
                    e.Handled = true;
1564
                }
1565
                else if (isLeftMouseButtonDownOnWindow)
1566
                {
1567
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1568
                    double dragDistance = Math.Abs(dragDelta.Length);
1569

    
1570
                    if (dragDistance > DragThreshold)
1571
                    {
1572
                        isDraggingSelectionRect = true;
1573
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1574
                    }
1575

    
1576
                    e.Handled = true;
1577
                }
1578

    
1579
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1580
                {
1581
                }
1582
                else
1583
                {
1584
                    e.Handled = true;
1585
                }
1586
            }
1587
            /*
1588
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1589
            { //symbol      
1590
                if(_dragdropWindow != null)
1591
                {
1592
                    Win32Point w32Mouse = new Win32Point();
1593
                    GetCursorPos(ref w32Mouse);
1594

    
1595
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1596
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1597
                }                
1598
            }
1599
            */
1600
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1601
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1602
            {
1603
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1604
                if(control != null)
1605
                {
1606
                    this.cursor = Cursors.Hand;
1607
                    SetCursor();
1608
                }
1609
                else
1610
                {
1611
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1612
                    SetCursor();
1613
                }
1614
            }
1615
            else
1616
            {
1617
            }
1618
        }
1619

    
1620
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1621
        {
1622
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1623
            {
1624
                SetCursor();
1625
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1626
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1627

    
1628
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1629

    
1630
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1631
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1632

    
1633
                if (Sync.IsChecked)
1634
                {
1635
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1636
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1637
                }
1638
            }
1639
        }
1640

    
1641
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1642

    
1643
        private EllipseGeometry hitArea = new EllipseGeometry();
1644

    
1645
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1646
        {
1647
            IsDrawing = false;
1648

    
1649
            if (mouseHandlingMode != MouseHandlingMode.None)
1650
            {
1651
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1652
                {
1653
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1654

    
1655
                    SetCursor();
1656

    
1657
                    switch (controlType)
1658
                    {
1659
                        case ControlType.None:
1660
                            break;
1661
                        case ControlType.Rectangle:
1662
                            {
1663

    
1664
                            }
1665
                            break;
1666
                        case ControlType.PenControl:
1667
                            {
1668

    
1669
                            }
1670
                            break;
1671
                        default:
1672
                            break;
1673
                    }                    
1674
                }
1675
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1676
                {
1677
                    if (isLeftMouseButtonDownOnWindow)
1678
                    {
1679
                        bool wasDragSelectionApplied = false;
1680

    
1681
                        if (isDraggingSelectionRect)
1682
                        {
1683
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1684
                            {
1685
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1686
                                mouseHandlingMode = MouseHandlingMode.None;
1687
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1688
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1689
                                Set_Symbol_Capture(endPoint);
1690
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1691
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1692
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1693
                            }
1694
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1695
                            {
1696
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1697
                                mouseHandlingMode = MouseHandlingMode.None;
1698
                                Set_Capture();
1699

    
1700
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1701
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1702
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1703
                            }
1704
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1705
                            {
1706
                                ApplyDragSelectionRect();
1707
                            }
1708
                            else
1709
                            {
1710
                                double x = Canvas.GetLeft(dragZoomBorder);
1711
                                double y = Canvas.GetTop(dragZoomBorder);
1712
                                double width = dragZoomBorder.Width;
1713
                                double height = dragZoomBorder.Height;
1714
                                Rect dragRect = new Rect(x, y, width, height);
1715

    
1716
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1717

    
1718
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1719
                            }
1720

    
1721
                            isDraggingSelectionRect = false;
1722
                            e.Handled = true;
1723
                            wasDragSelectionApplied = true;
1724
                        }
1725

    
1726
                        if (isLeftMouseButtonDownOnWindow)
1727
                        {
1728
                            isLeftMouseButtonDownOnWindow = false;
1729
                            this.ReleaseMouseCapture();
1730
                            e.Handled = true;
1731
                        }
1732

    
1733
                        if (!wasDragSelectionApplied)
1734
                        {
1735
                            init();
1736
                        }
1737
                    }
1738
                }
1739
                else if (e.RightButton == MouseButtonState.Pressed)
1740
                {
1741
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1742
                    SetCursor();
1743
                }
1744

    
1745
                zoomAndPanControl.ReleaseMouseCapture();
1746

    
1747

    
1748
                e.Handled = true;
1749
            }
1750
            else
1751
            {
1752
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1753
                SetCursor();
1754
            }
1755

    
1756
            ///mouseButtonDown = MouseButton.Left;
1757
            //controlType = ControlType.SingleLine;
1758
        }
1759

    
1760
        public void Set_Symbol_Capture(Point endPoint)
1761
        {       
1762
            double x = canvasDrawingMouseDownPoint.X;
1763
            double y = canvasDrawingMouseDownPoint.Y;
1764
            if(x > endPoint.X)
1765
            {
1766
                x = endPoint.X;
1767
                y = endPoint.Y;
1768
            }
1769

    
1770
            double width = dragCaptureBorder.Width;
1771
            double height = dragCaptureBorder.Height;
1772

    
1773
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1774

    
1775
            if (x < 0)
1776
            {
1777
                width += x;
1778
                x = 0;
1779
            }
1780
            if (y < 0)
1781
            {
1782
                height += y;
1783
                y = 0;
1784

    
1785
                width = (int)canvasImage.PixelWidth - x;
1786
            }
1787
            if (x + width > canvasImage.PixelWidth)
1788
            {
1789
                width = (int)canvasImage.PixelWidth - x;
1790
            }
1791
            if (y + height > canvasImage.PixelHeight)
1792
            {
1793
                height = (int)canvasImage.PixelHeight - y;
1794
            }
1795
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1796

    
1797
            string uri = "";
1798
            if (userData.COMPANY != "EXT")
1799
            {
1800
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1801
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1802
            }
1803
            else
1804
            {
1805
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1806
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1807
            }
1808

    
1809
            var defaultBitmapImage = new BitmapImage();
1810
            defaultBitmapImage.BeginInit();
1811
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1812
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1813
            defaultBitmapImage.UriSource = new Uri(uri);
1814
            defaultBitmapImage.EndInit();
1815

    
1816
            //GC.Collect();
1817

    
1818
            if (defaultBitmapImage.IsDownloading)
1819
            {
1820
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1821
                {
1822
                    defaultBitmapImage.Freeze();
1823
                    //GC.Collect();
1824
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1825
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1826
                };
1827
            }
1828
        }
1829

    
1830
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1831
        {
1832
            ///mouseButtonDown = MouseButton.Left;
1833
        }
1834

    
1835
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1836
        {
1837
            ///mouseButtonDown = MouseButton.Left;
1838
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1839
        }
1840

    
1841
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1842
        {
1843

    
1844
        }
1845

    
1846
        /// <summary>
1847
        /// select items by dragging
1848
        /// </summary>
1849
        private void ApplyDragSelectionRect()
1850
        {
1851
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1852

    
1853
            double x = Canvas.GetLeft(dragSelectionBorder);
1854
            double y = Canvas.GetTop(dragSelectionBorder);
1855
            double width = dragSelectionBorder.Width;
1856
            double height = dragSelectionBorder.Height;
1857
            Boolean Flag = false;
1858
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1859
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1860

    
1861
            Rect dragRect = new Rect(x, y, width, height);
1862
            ///dragRect.Inflate(width / 10, height / 10);
1863

    
1864
            foreach (var item in Items)
1865
            {
1866
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1867

    
1868
                if (Flag)
1869
                {
1870
                    adornerSet.Add(item);
1871
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1872
                    Control_Style(item);
1873
                }
1874
            }
1875
            if (adornerSet.Count > 0)
1876
            {
1877
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1878
                SelectLayer.Children.Add(final);
1879
            }
1880
        }
1881

    
1882
        private void InitDragSelectionRect(Point pt1, Point pt2)
1883
        {
1884
            //캡쳐 중
1885
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1886
            {
1887
                dragCaptureBorder.Visibility = Visibility.Visible;
1888
            }
1889
            //선택 중
1890
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1891
            {
1892

    
1893
                dragSelectionBorder.Visibility = Visibility.Visible;
1894
            }
1895
            else
1896
            {
1897
                dragZoomBorder.Visibility = Visibility.Visible;
1898
            }
1899
            UpdateDragSelectionRect(pt1, pt2);
1900
        }
1901

    
1902
        /// <summary>
1903
        /// Update the position and size of the rectangle used for drag selection.
1904
        /// </summary>
1905
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1906
        {
1907
            double x, y, width, height;
1908

    
1909
            //
1910
            // Determine x,y,width and height of the rect inverting the points if necessary.
1911
            // 
1912

    
1913
            if (pt2.X < pt1.X)
1914
            {
1915
                x = pt2.X;
1916
                width = pt1.X - pt2.X;
1917
            }
1918
            else
1919
            {
1920
                x = pt1.X;
1921
                width = pt2.X - pt1.X;
1922
            }
1923

    
1924
            if (pt2.Y < pt1.Y)
1925
            {
1926
                y = pt2.Y;
1927
                height = pt1.Y - pt2.Y;
1928
            }
1929
            else
1930
            {
1931
                y = pt1.Y;
1932
                height = pt2.Y - pt1.Y;
1933
            }
1934

    
1935
            //
1936
            // Update the coordinates of the rectangle used for drag selection.
1937
            //
1938
            //캡쳐 중
1939
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1940
            {
1941
                Canvas.SetLeft(dragCaptureBorder, x);
1942
                Canvas.SetTop(dragCaptureBorder, y);
1943
                dragCaptureBorder.Width = width;
1944
                dragCaptureBorder.Height = height;
1945
            }
1946
            //선택 중
1947
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1948
            {
1949
                Canvas.SetLeft(dragSelectionBorder, x);
1950
                Canvas.SetTop(dragSelectionBorder, y);
1951
                dragSelectionBorder.Width = width;
1952
                dragSelectionBorder.Height = height;
1953
            }
1954
            else
1955
            {
1956
                Canvas.SetLeft(dragZoomBorder, x);
1957
                Canvas.SetTop(dragZoomBorder, y);
1958
                dragZoomBorder.Width = width;
1959
                dragZoomBorder.Height = height;
1960
            }
1961
        }
1962

    
1963
        private void drawingPannelRotate(double angle)
1964
        {
1965
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1966
            rotate.Angle = angle;
1967
            var rotationNum = Math.Abs((rotate.Angle / 90));
1968

    
1969
            if (angle == 90 || angle == 270)
1970
            {
1971
                double emptySize = zoomAndPanCanvas.Width;
1972
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1973
                zoomAndPanCanvas.Height = emptySize;
1974
            }
1975
            if (angle == 0)
1976
            {
1977
                translate.X = 0;
1978
                translate.Y = 0;
1979
            }
1980
            else if (angle == 90)
1981
            {
1982
                translate.X = zoomAndPanCanvas.Width;
1983
                translate.Y = 0;
1984
            }
1985
            else if (angle == 180)
1986
            {
1987
                translate.X = zoomAndPanCanvas.Width;
1988
                translate.Y = zoomAndPanCanvas.Height;
1989
            }
1990
            else
1991
            {
1992
                translate.X = 0;
1993
                translate.Y = zoomAndPanCanvas.Height;
1994
            }
1995

    
1996
            zoomAndPanControl.RotationAngle = rotate.Angle;
1997

    
1998

    
1999
            if (!testPanel2.IsHidden)
2000
            {
2001
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2002
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2003
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2004
            }
2005

    
2006
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2007
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2008
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2009
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2010
            ViewerDataModel.Instance.Angle = rotate.Angle;
2011
        }
2012

    
2013
        private void syncPannelRotate(double angle)
2014
        {
2015
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2016
            rotate.Angle = angle;
2017
            var rotationNum = Math.Abs((rotate.Angle / 90));
2018

    
2019
            if (angle == 90 || angle == 270)
2020
            {
2021
                double emptySize = zoomAndPanCanvas2.Width;
2022
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2023
                zoomAndPanCanvas2.Height = emptySize;
2024
            }
2025
            if (angle == 0)
2026
            {
2027
                translate2.X = 0;
2028
                translate2.Y = 0;
2029
            }
2030
            else if (angle == 90)
2031
            {
2032
                translate2.X = zoomAndPanCanvas2.Width;
2033
                translate2.Y = 0;
2034
            }
2035
            else if (angle == 180)
2036
            {
2037
                translate2.X = zoomAndPanCanvas2.Width;
2038
                translate2.Y = zoomAndPanCanvas2.Height;
2039
            }
2040
            else
2041
            {
2042
                translate2.X = 0;
2043
                translate2.Y = zoomAndPanCanvas2.Height;
2044
            }
2045

    
2046
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2047
        }
2048

    
2049
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2050
        {
2051
            string Data_ = "";
2052

    
2053
            try
2054
            {
2055
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2056
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2057
                if (Data_ != null || Data_ != "")
2058
                {
2059
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2060
                }
2061
                else
2062
                {
2063
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2064
                }
2065

    
2066
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2067
                //{
2068
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2069
                //    STATE = 0,
2070
                //};
2071
                if (Data_ != null)
2072
                {
2073
                    Image img = new Image();
2074
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2075
                    if (Data_.Contains(".svg"))
2076
                    {
2077
                        byte[] imageData = null;
2078
                        DrawingImage image = null;
2079
                        using (System.Net.WebClient web = new System.Net.WebClient())
2080
                        {
2081
                            imageData = web.DownloadData(new Uri(Data_));
2082
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2083
                            image = SvgReader.Load(stream);
2084
                        }
2085
                        img.Source = image;
2086
                    }
2087
                    else
2088
                    {
2089
                        img.Source = new BitmapImage(new Uri(Data_));
2090
                    }
2091

    
2092
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2093
                    {
2094
                        PointSet = new List<Point>(),
2095
                        FilePath = Data_,
2096
                        ImageData = img.Source,
2097
                        StartPoint = canvasZoomPanningMouseDownPoint,
2098
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2099
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2100
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2101
                        canvasZoomPanningMouseDownPoint.Y),
2102
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2103
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2104
                    };
2105

    
2106
                    currentControl.PointSet = new List<Point>
2107
                                        {
2108
                                            currentControl.StartPoint,
2109
                                            currentControl.LeftBottomPoint,
2110
                                            currentControl.EndPoint,
2111
                                            currentControl.TopRightPoint,
2112
                                        };
2113
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2114
                    UndoData = new Undo_data()
2115
                    {
2116
                        IsUndo = false,
2117
                        Event = Event_Type.Create,
2118
                        EventTime = DateTime.Now,
2119
                        Markup_List = new List<Multi_Undo_data>()
2120
                    };
2121
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2122
                    {
2123
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2124
                    });
2125

    
2126
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2127
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2128
                    UndoData.Markup_List.Add(multi_Undo_Data);
2129
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2130

    
2131
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2132
                    currentControl.CommentID = Commons.shortGuid();
2133
                    currentControl.SymbolID = id;
2134
                    currentControl.GroupID = group_id;
2135
                    currentControl.ApplyTemplate();
2136
                    currentControl.SetImage();
2137

    
2138
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2139
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2140
                    SelectLayer.Children.Add(final);
2141
                }
2142
            }
2143
            catch (Exception ex)
2144
            {
2145
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2146
            }
2147
        }
2148

    
2149
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2150
        {            
2151
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2152
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2153
            {
2154
                set_option.Value = double.Parse(set_option.ContentText);
2155
                //set_option.Focusable = false;
2156
                zoomAndPanControl.Focus();
2157
            }
2158

    
2159
            ConvertInkControlToPolygon();
2160

    
2161
            ///TODO:
2162
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2163
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2164

    
2165
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2166
            {
2167
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2168
            }
2169
            /// up to here
2170

    
2171
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2172
            {
2173
                if (item as ArrowTextControl != null)
2174
                {
2175
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2176
                }
2177
                else if (item as TextControl != null)
2178
                {
2179
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2180
                }
2181
            }
2182

    
2183
            //if (currentControl != null)
2184
            {
2185
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2186
                if (text_item_ != null)
2187
                {
2188
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2189
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2190
                    (text_item_ as TextControl).IsEditingMode = false;                    
2191
                    currentControl = null;
2192
                }
2193

    
2194
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2195
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2196
                {
2197
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2198
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2199
                    currentControl = null;
2200
                }
2201
            }
2202

    
2203
            double Ang = 0;                                          
2204
            if (rotate.Angle != 0)
2205
            {
2206
                Ang = 360 - rotate.Angle;
2207
            }
2208

    
2209
            if (e.OriginalSource is System.Windows.Controls.Image)
2210
            {
2211
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2212
            }
2213
            /*
2214
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2215
            {                
2216
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2217
                if(symbol_id != null)
2218
                {
2219
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2220
                }                
2221
            }
2222

    
2223
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2224
            {
2225
                if (this._dragdropWindow != null)
2226
                {
2227
                    this._dragdropWindow.Close();
2228
                    this._dragdropWindow = null;
2229
                    symbol_id = null;
2230
                }
2231
            }
2232
            */
2233

    
2234
            if (e.LeftButton == MouseButtonState.Pressed)
2235
            {
2236
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2237
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2238

    
2239
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2240
                SetCursor();
2241

    
2242
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2243
            }
2244

    
2245
            if (e.MiddleButton == MouseButtonState.Pressed)
2246
            {
2247
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2248
                cursor = Cursors.SizeAll;
2249
                SetCursor();
2250
            }
2251
            if (e.RightButton == MouseButtonState.Pressed)
2252
            {
2253
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2254
                cursor = Cursors.SizeAll;
2255
                SetCursor();
2256
            }
2257
            else if (e.XButton1 == MouseButtonState.Pressed)
2258
            {
2259
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2260
                {
2261
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2262
                }
2263

    
2264
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2265

    
2266
            }
2267
            else if (e.XButton2 == MouseButtonState.Pressed)
2268
            {
2269
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2270
                {
2271
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2272
                }
2273
            }
2274

    
2275
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2276
            {
2277
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2278
                {
2279
                    if (SelectLayer.Children.Count == 0)
2280
                    {
2281
                        isLeftMouseButtonDownOnWindow = true;
2282
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2283
                    }
2284

    
2285
                    if (controlType == ControlType.None)
2286
                    {
2287
                        isLeftMouseButtonDownOnWindow = true;
2288
                    }
2289
                }
2290

    
2291
                /// 캡쳐 모드 설정
2292
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2293
                {
2294
                    dragCaptureBorder.Visibility = Visibility.Visible;
2295
                    isLeftMouseButtonDownOnWindow = true;
2296
                }
2297

    
2298
                /// 줌 모드 설정
2299
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2300
                {
2301
                    isLeftMouseButtonDownOnWindow = true;
2302
                }
2303

    
2304
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2305
                if (control != null)
2306
                {
2307
                    AdornerFinal final = null;
2308

    
2309
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2310
                    {
2311
                        /// 기존 selection 해제
2312
                        SelectionSet.Instance.UnSelect(this);
2313

    
2314
                        final = new AdornerFinal(control);
2315

    
2316
                        this.Control_Style(control);
2317

    
2318
                        if ((control as IPath) != null)
2319
                        {
2320
                            if ((control as IPath).LineSize != 0)
2321
                            {
2322
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2323
                            }
2324
                        }
2325
                        if ((control as IShapeControl) != null)
2326
                        {
2327
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2328
                            {
2329
                                ViewerDataModel.Instance.checkHatchShape = true;
2330
                            }
2331
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2332
                            {
2333
                                ViewerDataModel.Instance.checkFillShape = true;
2334
                            }
2335
                            else
2336
                            {
2337
                                ViewerDataModel.Instance.checkHatchShape = false;
2338
                                ViewerDataModel.Instance.checkFillShape = false;
2339
                            }
2340
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2341
                        }
2342

    
2343
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2344

    
2345
                        if ((control as TextControl) != null)
2346
                        {
2347
                            if(!((control as TextControl).EnableEditing)) {
2348
                                (control as TextControl).EnableEditing = true;
2349
                            }
2350
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2351
                            {
2352
                                ViewerDataModel.Instance.checkTextStyle = true;
2353
                            }
2354
                            else
2355
                            {
2356
                                ViewerDataModel.Instance.checkTextStyle = false;
2357
                            }
2358
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2359
                            {
2360
                                ViewerDataModel.Instance.checkTextWeight = true;
2361
                            }
2362
                            else
2363
                            {
2364
                                ViewerDataModel.Instance.checkTextWeight = false;
2365
                            }
2366
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2367
                            {
2368
                                ViewerDataModel.Instance.checkUnderLine = true;
2369
                            }
2370
                            else
2371
                            {
2372
                                ViewerDataModel.Instance.checkUnderLine = false;
2373
                            }
2374
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2375
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2376

    
2377
                        }
2378
                        else if ((control as ArrowTextControl) != null)
2379
                        {
2380
                            if (!((control as ArrowTextControl).EnableEditing))
2381
                            {
2382
                                (control as ArrowTextControl).EnableEditing = true;
2383
                            }
2384
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2385
                            {
2386
                                ViewerDataModel.Instance.checkTextStyle = true;
2387
                            }
2388
                            else
2389
                            {
2390
                                ViewerDataModel.Instance.checkTextStyle = false;
2391
                            }
2392
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2393
                            {
2394
                                ViewerDataModel.Instance.checkTextWeight = true;
2395
                            }
2396
                            else
2397
                            {
2398
                                ViewerDataModel.Instance.checkTextWeight = false;
2399
                            }
2400
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2401
                            {
2402
                                ViewerDataModel.Instance.checkUnderLine = true;
2403
                            }
2404
                            else
2405
                            {
2406
                                ViewerDataModel.Instance.checkUnderLine = false;
2407
                            }
2408
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2409
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2410
                        }
2411
                        else if ((control as RectCloudControl) != null)
2412
                        {
2413
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2414
                        }
2415
                        else if ((control as CloudControl) != null)
2416
                        {
2417
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2418
                        }
2419
                    }
2420
                    else
2421
                    {
2422
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2423
                        SelectionSet.Instance.UnSelect(this);
2424
                        comment.Add(control);
2425

    
2426
                        Control_Style(control);
2427

    
2428
                        final = new AdornerFinal(comment);
2429
                    }
2430

    
2431
                    if (final != null)
2432
                    {
2433
                        this.SelectLayer.Children.Add(final);
2434
                    }
2435
                }              
2436
            }
2437
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2438
            {               
2439
                init();
2440
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2441
                if (cursor != Cursors.SizeAll)
2442
                {
2443
                    cursor = Cursors.Cross;
2444
                    SetCursor();
2445
                }
2446
                bool init_user = false;
2447
                foreach (var user in gridViewMarkup.Items)
2448
                {
2449
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2450
                    {
2451
                        init_user = true;
2452
                    }
2453
                }
2454
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2455
                {
2456
                    RadWindow.Alert(new DialogParameters
2457
                    {
2458
                        Owner = Application.Current.MainWindow,
2459
                        Theme = new VisualStudio2013Theme(),
2460
                        Header = "안내",
2461
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2462
                    });
2463
                    return;
2464
                }
2465
                else
2466
                {
2467
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2468
                    if (item != null)
2469
                    {
2470
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2471
                    }
2472
                }
2473

    
2474
                switch (controlType)
2475
                {
2476
                    case ControlType.Coordinate:
2477
                        {
2478
                            if (e.LeftButton == MouseButtonState.Pressed)
2479
                            {
2480
                                if (currentControl is CoordinateControl)
2481
                                {
2482
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2483
                                    {
2484
                                        return;
2485
                                    }
2486

    
2487
                                    CreateCommand.Instance.Execute(currentControl);
2488

    
2489
                                    currentControl = null;
2490
                                    this.cursor = Cursors.Arrow;
2491
                                }
2492
                                else
2493
                                {
2494
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2495
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2496
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2497
                                    {
2498
                                        currentControl = null;
2499
                                        this.cursor = Cursors.Arrow;
2500
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2501
                                        return;
2502
                                    }
2503
                                    else
2504
                                    {
2505
                                        currentControl = new CoordinateControl
2506
                                        {
2507
                                            Background = new SolidColorBrush(Colors.Black),
2508
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2509
                                            ControlType = ControlType.Coordinate
2510
                                        };
2511

    
2512
                                        currentControl.CommentID = Commons.shortGuid();
2513
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2514
                                        currentControl.IsNew = true;
2515

    
2516
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2517

    
2518
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2519
                                    }
2520
                                }
2521
                            }
2522
                        }
2523
                        break;
2524
                    case ControlType.InsideWhite:
2525
                        {
2526
                            if (e.LeftButton == MouseButtonState.Pressed)
2527
                            {
2528
                                if (currentControl is InsideWhiteControl)
2529
                                {
2530
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2531
                                    {
2532
                                        return;
2533
                                    }
2534

    
2535
                                    CreateCommand.Instance.Execute(currentControl);
2536

    
2537
                                    currentControl = null;
2538
                                    this.cursor = Cursors.Arrow;
2539
                                }
2540
                                else
2541
                                {
2542
                                    currentControl = new InsideWhiteControl
2543
                                    {
2544
                                        Background = new SolidColorBrush(Colors.Black),
2545
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2546
                                        ControlType = ControlType.InsideWhite
2547
                                    };
2548

    
2549
                                    currentControl.CommentID = Commons.shortGuid();
2550
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2551
                                    currentControl.IsNew = true;
2552
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2553

    
2554
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2555
                                }
2556
                            }
2557
                        }
2558
                        break;
2559
                    case ControlType.OverlapWhite:
2560
                        {
2561
                            if (e.LeftButton == MouseButtonState.Pressed)
2562
                            {
2563
                                if (currentControl is OverlapWhiteControl)
2564
                                {
2565
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2566
                                    {
2567
                                        return;
2568
                                    }
2569

    
2570
                                    CreateCommand.Instance.Execute(currentControl);
2571

    
2572
                                    currentControl = null;
2573
                                    this.cursor = Cursors.Arrow;
2574
                                }
2575
                                else
2576
                                {
2577
                                    currentControl = new OverlapWhiteControl
2578
                                    {
2579
                                        Background = new SolidColorBrush(Colors.Black),
2580
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2581
                                        ControlType = ControlType.OverlapWhite
2582
                                    };
2583

    
2584
                                    currentControl.CommentID = Commons.shortGuid();
2585
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2586
                                    currentControl.IsNew = true;
2587
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2588

    
2589
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2590
                                }
2591
                            }
2592
                        }
2593
                        break;
2594
                    case ControlType.ClipWhite:
2595
                        {
2596
                            if (e.LeftButton == MouseButtonState.Pressed)
2597
                            {
2598
                                if (currentControl is ClipWhiteControl)
2599
                                {
2600
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2601
                                    {
2602
                                        return;
2603
                                    }
2604

    
2605
                                    CreateCommand.Instance.Execute(currentControl);
2606

    
2607
                                    currentControl = null;
2608
                                    this.cursor = Cursors.Arrow;
2609
                                }
2610
                                else
2611
                                {
2612
                                    currentControl = new ClipWhiteControl
2613
                                    {
2614
                                        Background = new SolidColorBrush(Colors.Black),
2615
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2616
                                        ControlType = ControlType.ClipWhite
2617
                                    };
2618

    
2619
                                    currentControl.CommentID = Commons.shortGuid();
2620
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2621
                                    currentControl.IsNew = true;
2622
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2623

    
2624
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2625
                                }
2626
                            }
2627
                        }
2628
                        break;
2629
                    case ControlType.Rectangle:
2630
                        {
2631
                            if (e.LeftButton == MouseButtonState.Pressed)
2632
                            {
2633
                                if (currentControl is RectangleControl)
2634
                                {
2635
                                    //20180906 LJY TEST IsRotationDrawingEnable
2636
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2637
                                    {
2638
                                        return;
2639
                                    }
2640

    
2641
                                    CreateCommand.Instance.Execute(currentControl);
2642
                                    currentControl = null;
2643
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2644
                                }
2645
                                else
2646
                                {
2647
                                    currentControl = new RectangleControl
2648
                                    {
2649
                                        Background = new SolidColorBrush(Colors.Black),
2650
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2651
                                        ControlType = ControlType.Rectangle
2652
                                    };
2653

    
2654
                                    currentControl.CommentID = Commons.shortGuid();
2655
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2656
                                    currentControl.IsNew = true;
2657
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2658

    
2659
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2660
                                }
2661
                            }
2662
                        }
2663
                        break;
2664
                    case ControlType.RectCloud:
2665
                        {
2666
                            if (e.LeftButton == MouseButtonState.Pressed)
2667
                            {
2668
                                if (currentControl is RectCloudControl)
2669
                                {
2670
                                    //20180906 LJY TEST IsRotationDrawingEnable
2671
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2672
                                    {
2673
                                        return;
2674
                                    }
2675

    
2676
                                    CreateCommand.Instance.Execute(currentControl);
2677

    
2678
                                    currentControl = null;
2679
                                
2680
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2681
                                }
2682
                                else
2683
                                {
2684
                                    currentControl = new RectCloudControl
2685
                                    {
2686
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2687
                                        ControlType = ControlType.RectCloud,
2688
                                        Background = new SolidColorBrush(Colors.Black)
2689
                                    };
2690

    
2691
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2692
                                    currentControl.CommentID = Commons.shortGuid();
2693
                                    currentControl.IsNew = true;
2694
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2695
                                }
2696
                            }
2697
                        }
2698
                        break;
2699
                    case ControlType.Circle:
2700
                        {
2701
                            if (e.LeftButton == MouseButtonState.Pressed)
2702
                            {
2703
                                if (currentControl is CircleControl)
2704
                                {
2705
                                    //20180906 LJY TEST IsRotationDrawingEnable
2706
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2707
                                    {
2708
                                        return;
2709
                                    }
2710

    
2711
                                    CreateCommand.Instance.Execute(currentControl);
2712

    
2713
                                    currentControl = null;
2714
                                }
2715
                                else
2716
                                {
2717
                                    currentControl = new CircleControl
2718
                                    {
2719
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2720
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2721
                                        Background = new SolidColorBrush(Colors.Black)
2722
                                    };
2723

    
2724
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2725
                                    currentControl.CommentID = Commons.shortGuid();
2726
                                    currentControl.IsNew = true;
2727
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2728
                                }
2729
                            }
2730
                        }
2731
                        break;
2732
                    case ControlType.Triangle:
2733
                        {
2734
                            if (e.LeftButton == MouseButtonState.Pressed)
2735
                            {
2736
                                if (currentControl is TriControl)
2737
                                {
2738
                                    var content = currentControl as TriControl;
2739
                                    if (content.MidPoint == new Point(0, 0))
2740
                                    {
2741
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2742
                                    }
2743
                                    else
2744
                                    {
2745
                                        //20180906 LJY TEST IsRotationDrawingEnable
2746
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2747
                                        {
2748
                                            return;
2749
                                        }
2750

    
2751
                                        CreateCommand.Instance.Execute(currentControl);
2752

    
2753
                                        currentControl = null;
2754
                                    }
2755
                                }
2756
                                else
2757
                                {
2758
                                    currentControl = new TriControl
2759
                                    {
2760
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2761
                                        Background = new SolidColorBrush(Colors.Black),
2762
                                    };
2763

    
2764
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2765
                                    currentControl.CommentID = Commons.shortGuid();
2766
                                    currentControl.IsNew = true;
2767
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2768
                                }
2769
                            }
2770
                        }
2771
                        break;
2772
                    case ControlType.CancelLine:
2773
                    case ControlType.SingleLine:
2774
                    case ControlType.ArrowLine:
2775
                    case ControlType.TwinLine:
2776
                    case ControlType.DimLine:
2777
                        {
2778
                            if (e.LeftButton == MouseButtonState.Pressed)
2779
                            {
2780
                                if (currentControl is LineControl)
2781
                                {
2782
                                    //20180906 LJY TEST IsRotationDrawingEnable
2783
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2784
                                    {
2785
                                        return;
2786
                                    }
2787

    
2788
                                    CreateCommand.Instance.Execute(currentControl);
2789
                                    currentControl = null;
2790
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2791
                                }
2792
                                else
2793
                                {
2794
                                    currentControl = new LineControl
2795
                                    {
2796
                                        ControlType = this.controlType,
2797
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2798
                                        Background = new SolidColorBrush(Colors.Black)
2799
                                    };
2800

    
2801
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2802
                                    currentControl.CommentID = Commons.shortGuid();
2803
                                    currentControl.IsNew = true;
2804
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2805
                                    this.MainAngle.Visibility = Visibility.Visible;
2806
                                }
2807
                            }
2808
                        }
2809
                        break;
2810
                    case ControlType.PolygonControl:
2811
                        {
2812
                            if (currentControl is PolygonControl)
2813
                            {
2814
                                var control = currentControl as PolygonControl;
2815

    
2816
                                if (e.RightButton == MouseButtonState.Pressed)
2817
                                {
2818
                                    control.IsCompleted = true;
2819
                                }
2820

    
2821
                                if (!control.IsCompleted)
2822
                                {
2823
                                    control.PointSet.Add(control.EndPoint);
2824
                                }
2825
                                else
2826
                                {
2827
                                    //20180906 LJY TEST IsRotationDrawingEnable
2828
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2829
                                    {
2830
                                        return;
2831
                                    }
2832

    
2833
                                    var firstPoint = control.PointSet.First();
2834
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2835
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2836
                                    control.PointSet.Add(firstPoint);
2837

    
2838
                                    control.ApplyOverViewData();
2839

    
2840
                                    CreateCommand.Instance.Execute(currentControl);
2841
                                    control.UpdateControl();
2842
                                    currentControl = null;
2843
                                }
2844
                            }
2845
                            else
2846
                            {
2847
                                if (e.LeftButton == MouseButtonState.Pressed)
2848
                                {
2849
                                    currentControl = new PolygonControl
2850
                                    {
2851
                                        PointSet = new List<Point>(),
2852
                                    };
2853

    
2854
                                    var polygonControl = (currentControl as PolygonControl);
2855
                                    currentControl.CommentID = Commons.shortGuid();
2856
                                    currentControl.IsNew = true;
2857
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2858
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2859
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2860
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2861
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2862
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2863
                                    polygonControl.ApplyTemplate();
2864
                                    polygonControl.Visibility = Visibility.Visible;
2865
                                }
2866
                            }
2867
                        }
2868
                        break;
2869
                    case ControlType.ChainLine:
2870
                        {
2871
                            if (currentControl is PolygonControl)
2872
                            {
2873
                                var control = currentControl as PolygonControl;
2874

    
2875
                                if (e.RightButton == MouseButtonState.Pressed)
2876
                                {
2877
                                    //20180906 LJY TEST IsRotationDrawingEnable
2878
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2879
                                    {
2880
                                        return;
2881
                                    }
2882

    
2883
                                    CreateCommand.Instance.Execute(currentControl);
2884

    
2885
                                    currentControl = null;
2886
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2887
                                    return;
2888
                                }
2889

    
2890
                                if (!control.IsCompleted)
2891
                                {
2892
                                    control.PointSet.Add(control.EndPoint);
2893
                                    this.MainAngle.Visibility = Visibility.Visible;
2894
                                }
2895
                            }
2896
                            else
2897
                            {
2898
                                if (e.LeftButton == MouseButtonState.Pressed)
2899
                                {
2900
                                    MainAngle.Visibility = Visibility.Visible;
2901
                                    currentControl = new PolygonControl
2902
                                    {
2903
                                        PointSet = new List<Point>(),
2904
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2905
                                        ControlType = ControlType.ChainLine,
2906
                                        DashSize = ViewerDataModel.Instance.DashSize,
2907
                                        LineSize = ViewerDataModel.Instance.LineSize,
2908
                                        //PointC = new StylusPointSet()
2909
                                    };
2910

    
2911
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2912
                                    //{
2913
                                        var polygonControl = (currentControl as PolygonControl);
2914
                                        currentControl.CommentID = Commons.shortGuid();
2915
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2916
                                        currentControl.IsNew = true;
2917
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2918
                                        //currentControl.OnApplyTemplate();
2919
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2920
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2921
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2922
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2923
                                    //}
2924
                                }
2925
                            }
2926
                        }
2927
                        break;
2928
                    case ControlType.ArcLine:
2929
                        {
2930
                            if (e.LeftButton == MouseButtonState.Pressed)
2931
                            {
2932
                                if (currentControl is ArcControl)
2933
                                {
2934
                                    //20180906 LJY TEST IsRotationDrawingEnable
2935
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2936
                                    {
2937
                                        return;
2938
                                    }
2939

    
2940
                                    CreateCommand.Instance.Execute(currentControl);
2941

    
2942
                                    currentControl = null;
2943
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2944
                                }
2945
                                else
2946
                                {
2947
                                    currentControl = new ArcControl
2948
                                    {
2949
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2950
                                        Background = new SolidColorBrush(Colors.Black)
2951
                                    };
2952
                                    currentControl.CommentID = Commons.shortGuid();
2953
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2954
                                    currentControl.IsNew = true;
2955
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2956
                                    this.MainAngle.Visibility = Visibility.Visible;
2957
                                }
2958
                            }
2959
                            else if (e.RightButton == MouseButtonState.Pressed)
2960
                            {
2961
                                if (currentControl != null)
2962
                                {
2963
                                    (currentControl as ArcControl).setClock();
2964
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2965
                                }
2966
                            }
2967
                        }
2968
                        break;
2969
                    case ControlType.ArcArrow:
2970
                        {
2971
                            if (e.LeftButton == MouseButtonState.Pressed)
2972
                            {
2973
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2974
                                //{
2975
                                if (currentControl is ArrowArcControl)
2976
                                {
2977
                                    //20180906 LJY TEST IsRotationDrawingEnable
2978
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2979
                                    {
2980
                                        return;
2981
                                    }
2982

    
2983
                                    CreateCommand.Instance.Execute(currentControl);
2984

    
2985
                                    currentControl = null;
2986
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2987
                                }
2988
                                else
2989
                                {
2990
                                    currentControl = new ArrowArcControl
2991
                                    {
2992
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2993
                                        Background = new SolidColorBrush(Colors.Black)
2994
                                    };
2995
                                    currentControl.CommentID = Commons.shortGuid();
2996
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2997
                                    currentControl.IsNew = true;
2998
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2999
                                    this.MainAngle.Visibility = Visibility.Visible;
3000
                                }
3001
                                //}
3002
                            }
3003
                            else if (e.RightButton == MouseButtonState.Pressed)
3004
                            {
3005
                                if (currentControl != null)
3006
                                {
3007
                                    (currentControl as ArrowArcControl).setClock();
3008
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3009
                                    //(currentControl as ArcControl).ApplyTemplate();
3010
                                }
3011
                            }
3012
                        }
3013
                        break;
3014
                    case ControlType.ArrowMultiLine:
3015
                        {
3016
                            if (e.LeftButton == MouseButtonState.Pressed)
3017
                            {
3018
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3019
                                //{
3020

    
3021
                                    if (currentControl is ArrowControl_Multi)
3022
                                    {
3023
                                        var content = currentControl as ArrowControl_Multi;
3024
                                        if (content.MiddlePoint == new Point(0, 0))
3025
                                        {
3026
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3027
                                            {
3028
                                                content.MiddlePoint = content.EndPoint;
3029
                                            }
3030
                                            else
3031
                                            {
3032
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3033
                                            }
3034
                                        }
3035
                                        else
3036
                                        {
3037
                                            //20180906 LJY TEST IsRotationDrawingEnable
3038
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3039
                                            {
3040
                                                return;
3041
                                            }
3042

    
3043
                                            CreateCommand.Instance.Execute(currentControl);
3044

    
3045
                                            currentControl = null;
3046
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3047
                                        }
3048
                                    }
3049
                                    else
3050
                                    {
3051
                                        currentControl = new ArrowControl_Multi
3052
                                        {
3053
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3054
                                            Background = new SolidColorBrush(Colors.Black)
3055
                                        };
3056
                                        currentControl.CommentID = Commons.shortGuid();
3057
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3058
                                        currentControl.IsNew = true;
3059
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3060
                                        this.MainAngle.Visibility = Visibility.Visible;
3061
                                    }
3062
                                //}
3063
                            }
3064
                        }
3065
                        break;
3066
                    case ControlType.PolygonCloud:
3067
                        {
3068
                            if (currentControl is CloudControl)
3069
                            {
3070
                                var control = currentControl as CloudControl;
3071
                                if (e.RightButton == MouseButtonState.Pressed)
3072
                                {
3073
                                    control.IsCompleted = true;
3074
                                }
3075

    
3076
                                if (!control.IsCompleted)
3077
                                {
3078
                                    control.PointSet.Add(control.EndPoint);
3079
                                }
3080
                                else
3081
                                {
3082
                                    //20180906 LJY TEST IsRotationDrawingEnable
3083
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3084
                                    {
3085
                                        return;
3086
                                    }
3087

    
3088
                                    CreateCommand.Instance.Execute(currentControl);
3089

    
3090
                                    control.isTransOn = true;
3091
                                    var firstPoint = control.PointSet.First();
3092

    
3093
                                    control.PointSet.Add(firstPoint);
3094
                                    control.DrawingCloud();
3095
                                    control.ApplyOverViewData();
3096

    
3097
                                    currentControl = null;
3098
                                }
3099
                            }
3100
                            else
3101
                            {
3102
                                if (e.LeftButton == MouseButtonState.Pressed)
3103
                                {
3104
                                    currentControl = new CloudControl
3105
                                    {
3106
                                        PointSet = new List<Point>(),
3107
                                        PointC = new StylusPointSet()
3108
                                    };
3109

    
3110
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3111
                                    //{
3112
                                        var polygonControl = (currentControl as CloudControl);
3113
                                        currentControl.CommentID = Commons.shortGuid();
3114
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3115
                                        currentControl.IsNew = true;
3116
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3117

    
3118
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3119
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3120
                                    
3121
                                    //}
3122
                                }
3123
                            }
3124
                        }
3125
                        break;
3126
                    case ControlType.ImgControl:
3127
                        {
3128
                            if (e.LeftButton == MouseButtonState.Pressed)
3129
                            {
3130
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3131
                                //{
3132
                                    if (currentControl is ImgControl)
3133
                                    {
3134
                                        //20180906 LJY TEST IsRotationDrawingEnable
3135
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3136
                                        {
3137
                                            return;
3138
                                        }
3139

    
3140
                                        CreateCommand.Instance.Execute(currentControl);
3141
                                        controlType = ControlType.ImgControl;
3142
                                        currentControl = null;
3143
                                    }
3144
                                    else
3145
                                    {
3146
                                        
3147
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3148
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3149
                                        {
3150
                                            Image img = new Image();
3151
                                            if (filename.Contains(".svg"))
3152
                                            {
3153
                                                byte[] imageData = null;
3154
                                                DrawingImage image = null;
3155
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3156
                                                {
3157
                                                    imageData = web.DownloadData(new Uri(filename));
3158
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3159
                                                    image = SvgReader.Load(stream);
3160
                                                }
3161
                                                img.Source = image;
3162
                                            }
3163
                                            else
3164
                                            {
3165
                                                img.Source = new BitmapImage(new Uri(filename));
3166
                                            }
3167

    
3168
                                            currentControl = new ImgControl
3169
                                            {
3170
                                                    Background = new SolidColorBrush(Colors.Black),
3171
                                                    PointSet = new List<Point>(),
3172
                                                    FilePath = filename,
3173
                                                    ImageData = img.Source,
3174
                                                    StartPoint = canvasDrawingMouseDownPoint,
3175
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3176
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3177
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3178
                                                    ControlType = ControlType.ImgControl
3179
                                                };
3180

    
3181
                                        
3182
                                                currentControl.CommentID = Commons.shortGuid();                                            
3183
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3184
                                                currentControl.IsNew = true;
3185
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3186

    
3187
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3188
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3189
                                        }
3190
                                    }
3191
                                //}
3192
                            }
3193
                        }
3194
                        break;
3195
                    case ControlType.Date:
3196
                        {
3197
                            if (e.LeftButton == MouseButtonState.Pressed)
3198
                            {
3199
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3200
                                //{
3201
                                    if (currentControl is DateControl)
3202
                                    {
3203
                                        //20180906 LJY TEST IsRotationDrawingEnable
3204
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3205
                                        {
3206
                                            return;
3207
                                        }
3208

    
3209
                                        CreateCommand.Instance.Execute(currentControl);
3210
                                        currentControl = null;
3211

    
3212
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3213
                                        {
3214
                                            controlType = ControlType.None;
3215
                                            IsSwingMode = false;
3216
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3217
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3218
                                            mouseHandlingMode = MouseHandlingMode.None;
3219
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3220
                                            txtBatch.Visibility = Visibility.Collapsed;
3221

    
3222
                                        }
3223
                                    }
3224
                                    else
3225
                                    {
3226
                                        currentControl = new DateControl
3227
                                        {
3228
                                            StartPoint = canvasDrawingMouseDownPoint,
3229
                                            Background = new SolidColorBrush(Colors.Black)
3230
                                        };
3231
                                        currentControl.CommentID = Commons.shortGuid();
3232
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3233
                                        currentControl.IsNew = true;
3234
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3235

    
3236
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3237
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3238
                                }
3239
                                //}
3240
                            }
3241
                        }
3242
                        break;
3243
                    case ControlType.TextControl:
3244
                        {
3245
                            if (e.LeftButton == MouseButtonState.Pressed)
3246
                            {
3247
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3248
                                {
3249
                                    currentControl = new TextControl
3250
                                    {
3251
                                        ControlType = controlType
3252
                                    };
3253
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3254
                                    currentControl.CommentID = Commons.shortGuid();
3255
                                    currentControl.IsNew = true;
3256
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3257
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3258
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3259

    
3260
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3261
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3262
                                    
3263
                                    (currentControl as TextControl).ControlType_No = 0;
3264
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3265
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3266
                                    (currentControl as TextControl).ApplyTemplate();
3267
                                    (currentControl as TextControl).Base_TextBox.Focus();
3268
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3269
                                    CreateCommand.Instance.Execute(currentControl);
3270
                                }
3271
                            }
3272
                        }
3273
                        break;
3274
                    case ControlType.TextBorder:
3275
                        {
3276
                            if (e.LeftButton == MouseButtonState.Pressed)
3277
                            {
3278
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3279
                                {
3280
                                    currentControl = new TextControl
3281
                                    {
3282
                                        ControlType = controlType
3283
                                    };
3284

    
3285
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3286
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3287
                                    currentControl.CommentID = Commons.shortGuid();
3288
                                    currentControl.IsNew = true;
3289
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3290
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3291
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3292
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3293
                                    
3294
                                    (currentControl as TextControl).ControlType_No = 1;
3295
                                    (currentControl as TextControl).Angle = Ang;
3296
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3297
                                    (currentControl as TextControl).ApplyTemplate();
3298
                                    (currentControl as TextControl).Base_TextBox.Focus();
3299
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3300
                                    CreateCommand.Instance.Execute(currentControl);
3301
                                }
3302
                            }
3303
                        }
3304
                        break;
3305
                    case ControlType.TextCloud:
3306
                        {
3307
                            if (e.LeftButton == MouseButtonState.Pressed)
3308
                            {
3309
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3310
                                {
3311
                                    currentControl = new TextControl
3312
                                    {
3313
                                        ControlType = controlType
3314
                                    };
3315

    
3316
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3317
                                    currentControl.CommentID = Commons.shortGuid();
3318
                                    currentControl.IsNew = true;
3319
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3320
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3321

    
3322
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3323
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3324
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3325

    
3326
                                    (currentControl as TextControl).Angle = Ang;
3327
                                    (currentControl as TextControl).ControlType_No = 2;
3328
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3329
                                    (currentControl as TextControl).ApplyTemplate();
3330
                                    (currentControl as TextControl).Base_TextBox.Focus();
3331
                                    CreateCommand.Instance.Execute(currentControl);
3332
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3333
                                    //currentControl = null;
3334
                                }
3335
                            }
3336
                        }
3337
                        break;
3338
                    case ControlType.ArrowTextControl:
3339
                         {
3340
                            if (e.LeftButton == MouseButtonState.Pressed)
3341
                            {
3342
                                if (currentControl is ArrowTextControl)
3343
                                {
3344
                                    //20180906 LJY TEST IsRotationDrawingEnable
3345
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3346
                                    {
3347
                                        return;
3348
                                    }
3349

    
3350
                                    CreateCommand.Instance.Execute(currentControl);
3351

    
3352
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3353
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3354
                                    (currentControl as ArrowTextControl).IsNew = false;
3355
                                    currentControl = null;
3356
                                }
3357
                                else
3358
                                {
3359
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3360
                                    //{
3361
                                        currentControl = new ArrowTextControl();
3362
                                        currentControl.CommentID = Commons.shortGuid();
3363
                                        currentControl.IsNew = true;
3364
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3365
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3366

    
3367
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3368
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3369
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3370
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3371
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3372

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

    
3376
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3377
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3378
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3379
                                        this.MainAngle.Visibility = Visibility.Visible;
3380

    
3381
                                    
3382
                                    //}
3383
                                }
3384
                            }
3385
                        }
3386
                        break;
3387
                    case ControlType.ArrowTransTextControl:
3388
                        {
3389
                            if (e.LeftButton == MouseButtonState.Pressed)
3390
                            {
3391
                                if (currentControl is ArrowTextControl)
3392
                                {
3393
                                    //20180906 LJY TEST IsRotationDrawingEnable
3394
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3395
                                    {
3396
                                        return;
3397
                                    }
3398

    
3399
                                    CreateCommand.Instance.Execute(currentControl);
3400

    
3401
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3402
                                    
3403
                                    currentControl.IsNew = false;
3404
                                    currentControl = null;
3405
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3406
                                }
3407
                                else
3408
                                {
3409
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3410
                                    //{
3411
                                    currentControl = new ArrowTextControl()
3412
                                    {
3413
                                        ControlType = ControlType.ArrowTransTextControl
3414
                                    };
3415
                                    currentControl.CommentID = Commons.shortGuid();
3416
                                    currentControl.IsNew = true;
3417
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3418
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3419
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3420
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3421
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3422
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3423
                                    (currentControl as ArrowTextControl).isFixed = true;
3424
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3425

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

    
3429
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3430
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3431
                                    (currentControl as ArrowTextControl).isTrans = true;
3432
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3433
                                }
3434
                            }
3435
                        }
3436
                        break;
3437
                    case ControlType.ArrowTextBorderControl:
3438
                         {
3439
                            if (e.LeftButton == MouseButtonState.Pressed)
3440
                            {
3441
                                if (currentControl is ArrowTextControl)
3442
                                {
3443
                                    //20180906 LJY TEST IsRotationDrawingEnable
3444
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3445
                                    {
3446
                                        return;
3447
                                    }
3448

    
3449
                                    CreateCommand.Instance.Execute(currentControl);
3450
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3451
                                    currentControl.IsNew = false;
3452
                                    currentControl = null;
3453
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3454
                                }
3455
                                else
3456
                                {
3457
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3458
                                    //{
3459
                                        currentControl = new ArrowTextControl()
3460
                                        {
3461
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3462
                                        };
3463
                                        currentControl.CommentID = Commons.shortGuid();
3464
                                        currentControl.IsNew = true;
3465
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3466
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3467

    
3468
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3469

    
3470
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3471

    
3472
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3473
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3474
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3475
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3476
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3477
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3478
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3479
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3480
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3481
                                    //}
3482
                                }
3483
                            }
3484
                        }
3485
                        break;
3486
                    case ControlType.ArrowTransTextBorderControl:
3487
                        {
3488
                            if (e.LeftButton == MouseButtonState.Pressed)
3489
                            {
3490
                                if (currentControl is ArrowTextControl)
3491
                                {
3492
                                    //20180906 LJY TEST IsRotationDrawingEnable
3493
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3494
                                    {
3495
                                        return;
3496
                                    }
3497
                                    CreateCommand.Instance.Execute(currentControl);
3498
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3499
                                    currentControl.IsNew = false;
3500
                                    currentControl = null;
3501

    
3502
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3503
                                }
3504
                                else
3505
                                {
3506
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3507
                                    //{
3508
                                    
3509

    
3510
                                    currentControl = new ArrowTextControl()
3511
                                    {
3512
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3513
                                        ControlType = ControlType.ArrowTransTextBorderControl
3514

    
3515
                                    };
3516
                                        currentControl.CommentID = Commons.shortGuid();
3517
                                        currentControl.IsNew = true;
3518
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3519
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3520

    
3521
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3522

    
3523
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3524
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3525
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3526
                                        (currentControl as ArrowTextControl).isFixed = true;
3527
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3528
                                     
3529
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3530
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3531
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3532
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3533
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3534
                                        this.MainAngle.Visibility = Visibility.Visible;
3535
                                    
3536
                                    //20180911 LJY
3537
                                        (currentControl as ArrowTextControl).isTrans = true;
3538
                                    
3539

    
3540
                                    //}
3541
                                }
3542
                            }
3543
                        }
3544
                        break;
3545
                    case ControlType.ArrowTextCloudControl:
3546
                        {
3547
                            if (e.LeftButton == MouseButtonState.Pressed)
3548
                            {
3549
                                if (currentControl is ArrowTextControl)
3550
                                {
3551
                                    //20180906 LJY TEST IsRotationDrawingEnable
3552
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3553
                                    {
3554
                                        return;
3555
                                    }
3556
                                    CreateCommand.Instance.Execute(currentControl);
3557
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3558
                                    currentControl.IsNew = false;
3559
                                    currentControl = null;
3560
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3561
                                }
3562
                                else
3563
                                {
3564
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3565
                                    //{
3566
                                        currentControl = new ArrowTextControl()
3567
                                        {
3568
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3569
                                        };
3570
                                        currentControl.CommentID = Commons.shortGuid();
3571
                                        currentControl.IsNew = true;
3572
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3573
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3574

    
3575
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3576
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3577
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3578
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3579
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3580
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3581
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3582
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3583
                                    
3584
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3585
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3586
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3587
                                    //}
3588
                                }
3589
                            }
3590
                        }
3591
                        break;
3592
                    case ControlType.ArrowTransTextCloudControl:
3593
                        {
3594
                            if (e.LeftButton == MouseButtonState.Pressed)
3595
                            {
3596
                                if (currentControl is ArrowTextControl)
3597
                                {
3598
                                    //20180906 LJY TEST IsRotationDrawingEnable
3599
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3600
                                    {
3601
                                        return;
3602
                                    }
3603
                                    CreateCommand.Instance.Execute(currentControl);
3604
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3605
                                    currentControl.IsNew = false;
3606
                                    currentControl = null;
3607
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3608
                                }
3609
                                else
3610
                                {
3611
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3612
                                    //{
3613
                                        currentControl = new ArrowTextControl()
3614
                                        {
3615
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3616
                                            ControlType = ControlType.ArrowTransTextCloudControl
3617

    
3618
                                        };
3619
                                        currentControl.CommentID = Commons.shortGuid();
3620
                                        currentControl.IsNew = true; 
3621
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3622
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3623
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3624

    
3625
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3626
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3627
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3628
                                        (currentControl as ArrowTextControl).isFixed = true;
3629
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3630

    
3631
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3632
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3633
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3634
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3635
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3636
                                        this.MainAngle.Visibility = Visibility.Visible;  
3637
                                    
3638
                                    //20180911 LJY
3639
                                        (currentControl as ArrowTextControl).isTrans = true;
3640
                                    //}
3641
                                }
3642
                            }
3643
                        }
3644
                        break;
3645
                    //강인구 추가
3646
                    case ControlType.Sign:
3647
                        {
3648
                            if (e.LeftButton == MouseButtonState.Pressed)
3649
                            {
3650
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3651
                                //{
3652
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO,App.isExternal);
3653

    
3654
                                    if (_sign == null)
3655
                                    {
3656
                                        txtBatch.Visibility = Visibility.Collapsed;
3657
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3658
                                        controlType = ControlType.None;
3659

    
3660
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3661
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3662
                                        return;
3663
                                    }
3664

    
3665
                                    if (currentControl is SignControl)
3666
                                    {
3667
                                        //20180906 LJY TEST IsRotationDrawingEnable
3668
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3669
                                        {
3670
                                            return;
3671
                                        }
3672

    
3673
                                        CreateCommand.Instance.Execute(currentControl);
3674
                                        currentControl = null;
3675
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3676
                                        {
3677
                                            txtBatch.Text = "Place Date";
3678
                                            controlType = ControlType.Date;
3679
                                        }
3680
                                    }
3681
                                    else
3682
                                    {
3683
                                        currentControl = new SignControl
3684
                                        {
3685
                                            Background = new SolidColorBrush(Colors.Black),
3686
                                            UserNumber = App.ViewInfo.UserID,
3687
                                            ProjectNO = App.ViewInfo.ProjectNO,
3688
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3689
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3690
                                            ControlType = ControlType.Sign
3691
                                        };
3692

    
3693
                                        currentControl.CommentID = Commons.shortGuid();
3694
                                        currentControl.IsNew = true;
3695
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3696
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3697

    
3698
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3699
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3700
                                }
3701
                                //}
3702
                            }
3703
                        }
3704
                        break;
3705
                    case ControlType.Mark:
3706
                        {
3707
                            if (e.LeftButton == MouseButtonState.Pressed)
3708
                            {
3709
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3710
                                //{
3711
                                    if (currentControl is RectangleControl)
3712
                                    {
3713
                                        //20180906 LJY TEST IsRotationDrawingEnable
3714
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3715
                                        {
3716
                                            return;
3717
                                        }
3718

    
3719
                                        CreateCommand.Instance.Execute(currentControl);
3720
                                        (currentControl as RectangleControl).ApplyOverViewData();
3721
                                        currentControl = null;
3722
                                    
3723
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3724

    
3725
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3726
                                        {
3727
                                            txtBatch.Text = "Place Signature";
3728
                                            controlType = ControlType.Sign;
3729
                                        }
3730
                                    }
3731
                                    else
3732
                                    {
3733
                                        currentControl = new RectangleControl
3734
                                        {
3735
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3736
                                            Background = new SolidColorBrush(Colors.Black),
3737
                                            ControlType = ControlType.Mark ,
3738
                                            Paint = PaintSet.Fill
3739
                                        };
3740

    
3741
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3742
                                        currentControl.CommentID = Commons.shortGuid();
3743
                                        currentControl.IsNew = true;
3744
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3745
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3746
                                    }
3747
                                //}
3748
                            }
3749
                        }
3750
                        break;
3751
                    case ControlType.Symbol:
3752
                        {
3753
                            if (e.LeftButton == MouseButtonState.Pressed)
3754
                            {
3755
                                if (currentControl is SymControl)
3756
                                {
3757
                                    //20180906 LJY TEST IsRotationDrawingEnable
3758
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3759
                                    {
3760
                                        return;
3761
                                    }
3762
                                    CreateCommand.Instance.Execute(currentControl);
3763
                                    currentControl = null;
3764
                                
3765
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3766
                                }
3767
                                else
3768
                                {
3769
                                    currentControl = new SymControl
3770
                                    {
3771
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3772
                                        Background = new SolidColorBrush(Colors.Black),
3773
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3774
                                        ControlType = ControlType.Symbol
3775
                                    };
3776

    
3777
                                    currentControl.IsNew = true;
3778
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3779
                                    currentControl.CommentID = Commons.shortGuid();
3780
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3781

    
3782
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3783
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3784
                                }
3785
                                //}
3786
                            }
3787
                        }
3788
                        break;
3789
                    case ControlType.Stamp:
3790
                        {
3791
                            if (e.LeftButton == MouseButtonState.Pressed)
3792
                            {
3793
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3794
                                //{
3795
                                    if (currentControl is SymControlN)
3796
                                    {
3797
                                        //20180906 LJY TEST IsRotationDrawingEnable
3798
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3799
                                        {
3800
                                            return;
3801
                                        }
3802

    
3803
                                        CreateCommand.Instance.Execute(currentControl);
3804
                                        currentControl = null;
3805
                                   
3806

    
3807
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3808
                                    }
3809
                                    else
3810
                                    {
3811
                                        currentControl = new SymControlN
3812
                                        {
3813
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3814
                                            Background = new SolidColorBrush(Colors.Black),
3815
                                            STAMP = App.SystemInfo.STAMP,                                            
3816
                                            ControlType = ControlType.Stamp
3817
                                        };
3818

    
3819
                                        currentControl.IsNew = true;
3820
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3821
                                        currentControl.CommentID = Commons.shortGuid();
3822
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3823
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3824
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3825
                                }                                    
3826
                                //}
3827
                            }
3828
                        }
3829
                        break;
3830
                    case ControlType.PenControl:
3831
                        {
3832
                            if (inkBoard.Tag.ToString() == "Ink")
3833
                            {
3834
                                inkBoard.IsEnabled = true;
3835
                                StartNewStroke(canvasDrawingMouseDownPoint);
3836
                            }
3837
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3838
                            {
3839
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3840
                            }
3841
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3842
                            {
3843
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3844
                            }
3845
                            IsDrawing = true;
3846
                            return;
3847
                        }
3848
                    default:
3849
                        if (currentControl != null)
3850
                        {
3851
                            currentControl.CommentID = null;
3852
                            currentControl.IsNew = false;
3853
                        }
3854
                        break;
3855
                }
3856
            }
3857
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3858
            {
3859
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3860
                {
3861
                    bool mouseOff = false;
3862
                    foreach (var item in SelectLayer.Children)
3863
                    {
3864
                        if (item is AdornerFinal)
3865
                        {
3866

    
3867
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3868
                            if (over != null)
3869
                            {
3870
                                mouseOff = true;
3871
                            }
3872
                        }
3873
                    }
3874

    
3875
                    if (!mouseOff)
3876
                    {
3877
                        SelectionSet.Instance.UnSelect(this);
3878
                    }
3879
                }
3880
                zoomAndPanControl.CaptureMouse();
3881
                e.Handled = true;
3882
            }
3883
          
3884
        }
3885

    
3886
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3887
        {
3888
            ///mouseButtonDown = e.ChangedButton;
3889
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3890
        }
3891

    
3892
        private void RemoveLineStroke(Point P)
3893
        {
3894
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3895
            if (control != null)
3896
            {
3897
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3898
            }
3899
        }
3900

    
3901
        private void RemovePointStroke(Point P)
3902
        {
3903
            foreach (Stroke hits in inkBoard.Strokes)
3904
            {
3905
                foreach (StylusPoint sty in hits.StylusPoints)
3906
                {
3907

    
3908
                }
3909
                if (hits.HitTest(P))
3910
                {
3911
                    inkBoard.Strokes.Remove(hits);
3912
                    return;
3913
                }
3914
            }
3915
        }
3916

    
3917
        private void StartNewStroke(Point P)
3918
        {
3919
            strokePoints = new StylusPointCollection();
3920
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3921
            strokePoints.Add(segment1Start);
3922
            stroke = new Stroke(strokePoints);
3923

    
3924
            stroke.DrawingAttributes.Color = Colors.Red;
3925
            stroke.DrawingAttributes.Width = 4;
3926
            stroke.DrawingAttributes.Height = 4;
3927

    
3928
            inkBoard.Strokes.Add(stroke);
3929
        }
3930

    
3931
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3932
        {
3933
            ConsolidationMethod();
3934
        }
3935

    
3936
        /// <summary>
3937
        /// execute TeamConsolidationCommand
3938
        /// </summary>
3939
        public void TeamConsolidationMethod()
3940
        {
3941
            this.UpdateMyMarkupList();
3942
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3943
            {
3944
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3945
            }
3946
            else
3947
            {
3948

    
3949
                ViewerDataModel.Instance.IsConsolidate = true;
3950
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3951

    
3952
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3953
                {
3954
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3955
                    {
3956
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3957
                        return;
3958
                    }                    
3959
                }
3960
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3961
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3962
                {
3963
                    MarkupInfoList.Add(item);
3964
                }
3965
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3966
            }
3967
        }
3968

    
3969
        public void ConsolidationMethod()
3970
        {
3971
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3972
            {
3973
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3974
            }
3975
            else
3976
            {
3977
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3978
                foreach (var item in this.gridViewMarkup.SelectedItems)
3979
                {
3980
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3981
                }
3982
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3983
                
3984
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3985
            }
3986
        }
3987

    
3988
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3989
        {
3990
            if (App.ViewInfo != null)
3991
            {
3992
                btnConsolidate = (sender as RadRibbonButton);
3993
                if (!App.ViewInfo.NewCommentPermission)
3994
                {
3995
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3996
                }
3997
            }
3998
        }
3999

    
4000
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4001
        {
4002
            TeamConsolidationMethod();
4003
        }
4004

    
4005
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4006
        {
4007
            btnTeamConsolidate = sender as RadRibbonButton;
4008
            if (App.ViewInfo != null)
4009
            {
4010
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4011
                {
4012
                    if (btnConsolidate != null)
4013
                    {
4014
                        btnConsolidate.Visibility = Visibility.Collapsed;
4015
                    }
4016

    
4017
                    if (!App.ViewInfo.NewCommentPermission)
4018
                    {
4019
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4020
                    }
4021
                }
4022
                else
4023
                {
4024
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4025
                }
4026
            }
4027
        }
4028

    
4029
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4030
        {
4031
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4032
            if(item != null)
4033
            {
4034
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4035
                {
4036
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4037
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4038
                }
4039
                else
4040
                {
4041
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4042
                }
4043
            }else{
4044
                //Consolidate 가 없는 경우
4045
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4046
            }
4047
            
4048
        }
4049

    
4050
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4051
        {
4052
            btnFinalPDF = sender as RadRibbonButton;
4053
            if (App.ViewInfo != null)
4054
            {
4055
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4056
                {
4057
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4058
                    if (btnConsolidate != null)
4059
                    {
4060
                        btnConsolidate.Visibility = Visibility.Collapsed;
4061
                    }
4062
                }
4063
            }
4064
        }
4065

    
4066
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4067
        {
4068
            UpdateMyMarkupList();
4069

    
4070
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4071
            {
4072
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4073
            }
4074
            else
4075
            {
4076
                ViewerDataModel.Instance.IsConsolidate = true;
4077
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4078
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4079

    
4080
                string project_no = App.ViewInfo.ProjectNO;
4081
                string doc_id = _DocInfo.ID;
4082
                string user_id = App.ViewInfo.UserID;
4083
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4084
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4085
                {
4086
                    markupInfoItems.Add(item);
4087
                }
4088
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4089
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4090
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4091
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4092

    
4093
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4094
                if (item2 != null)
4095
                {
4096
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4097

    
4098
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4099
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4100
                }
4101
                else
4102
                {
4103
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4104
                }
4105
            }
4106
        }
4107

    
4108
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4109
        {
4110
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4111

    
4112
            if (App.ViewInfo != null)
4113
            {
4114
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4115
                {
4116
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4117
                }
4118
            }
4119
        }
4120

    
4121
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4122
        {
4123
            if (CompareMode.IsChecked)
4124
            {
4125
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4126
                {
4127
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4128
                }
4129
                if (ViewerDataModel.Instance.PageNumber == 0)
4130
                {
4131
                    ViewerDataModel.Instance.PageNumber = 1;
4132
                }
4133

    
4134
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4135
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4136
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4137

    
4138
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4139
            }
4140
            else
4141
            {
4142
                da.From = 1;
4143
                da.To = 1;
4144
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4145
                da.AutoReverse = false;
4146
                canvas_compareBorder.Children.Clear();
4147
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4148
            }
4149
        }
4150

    
4151
        private void Sync_Click(object sender, RoutedEventArgs e)
4152
        {
4153
            if (Sync.IsChecked)
4154
            {
4155
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4156
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4157
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4158
            }
4159
        }
4160

    
4161
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4162
        {
4163
            if (UserList.IsChecked)
4164
            {
4165
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4166
            }
4167
            else
4168
            {
4169
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4170
            }
4171
        }
4172

    
4173
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4174
        {
4175

    
4176
            if (BalanceMode.IsChecked)
4177
            {
4178
                ViewerDataModel.Instance.PageBalanceMode = true;
4179
            }
4180
            else
4181
            {
4182
                ViewerDataModel.Instance.PageBalanceMode = false;
4183
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4184
            }
4185
        }
4186

    
4187
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4188
        {
4189
            //초기화
4190
            testPanel2.IsHidden = true;
4191
            ViewerDataModel.Instance.PageBalanceMode = false;
4192
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4193
            ViewerDataModel.Instance.PageNumber = 0;
4194
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4195
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4196
            UserList.IsChecked = false;
4197
            BalanceMode.IsChecked = false;
4198
        }
4199

    
4200
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4201
        {
4202
            if ((sender as System.Windows.Controls.Control).Tag != null)
4203
            {
4204
                //Compare 초기화
4205
                CompareMode.IsChecked = false;
4206
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4207

    
4208
                if (ViewerDataModel.Instance.PageNumber == 0)
4209
                {
4210
                    ViewerDataModel.Instance.PageNumber = 1;
4211
                }
4212

    
4213
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4214
                {
4215
                }
4216
                else
4217
                {
4218
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4219
                }
4220

    
4221
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4222
                {
4223

    
4224
                }
4225
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4226
                {
4227
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4228
                }
4229

    
4230
                if (!testPanel2.IsHidden)
4231
                {
4232
                    if (IsSyncPDFMode)
4233
                    {
4234
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4235
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4236

    
4237
                        if (pdfpath.IsDownloading)
4238
                        {
4239
                            pdfpath.DownloadCompleted += (ex, arg) =>
4240
                            {
4241
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4242
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4243
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4244
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4245
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4246
                            };
4247
                        }
4248
                        else
4249
                        {
4250
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4251
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4252
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4253

    
4254
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4255
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4256
                        }
4257

    
4258
                    }
4259
                    else
4260
                    {
4261
                        string uri = "";
4262

    
4263
                        if (userData.COMPANY != "EXT")
4264
                        {
4265
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4266
                        }
4267
                        else
4268
                        {
4269
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4270
                        }
4271

    
4272
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4273

    
4274
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4275
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4276
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4277

    
4278
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4279
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4280

    
4281
                        if (defaultBitmapImage_Compare.IsDownloading)
4282
                        {
4283
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4284
                            {
4285
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4286
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4287
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4288

    
4289
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4290
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4291
                            };
4292
                        }
4293
                    }
4294

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

    
4299
                    foreach (var item in gridSelectionRevItem)
4300
                    {
4301
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4302
                        {
4303
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4304
                        });
4305
                    }
4306

    
4307
                    //강인구 추가
4308
                    zoomAndPanControl2.ZoomTo(new Rect
4309
                    {
4310
                        X = 0,
4311
                        Y = 0,
4312
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4313
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4314
                    });
4315

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

    
4318
                }
4319
            }
4320
        }
4321

    
4322
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4323
        {
4324
            if (MarkupMode.IsChecked)
4325
            {
4326
                IsSyncPDFMode = true;
4327

    
4328
                var uri = CurrentRev.TO_VENDOR;
4329

    
4330
                if (ViewerDataModel.Instance.PageNumber == 0)
4331
                {
4332
                    ViewerDataModel.Instance.PageNumber = 1;
4333
                }
4334

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

    
4339
                if (pdfpath.IsDownloading)
4340
                {
4341
                    pdfpath.DownloadCompleted += (ex, arg) =>
4342
                    {
4343
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4344
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4345
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4346
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4347
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4348
                    };
4349
                }
4350
                else
4351
                {
4352
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4353
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4354
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4355

    
4356
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4357
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4358
                }
4359
            }
4360
            else
4361
            {
4362
                IsSyncPDFMode = false;
4363
                string uri = "";
4364
                if (userData.COMPANY != "EXT")
4365
                {
4366
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4367
                }
4368
                else
4369
                {
4370
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4371
                }
4372

    
4373
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4374

    
4375
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4376
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4377
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4378

    
4379
                if (defaultBitmapImage_Compare.IsDownloading)
4380
                {
4381
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4382
                    {
4383
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4384
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4385
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4386
                    };
4387
                }
4388
                zoomAndPanControl2.ApplyTemplate();
4389
                zoomAndPanControl2.UpdateLayout();
4390
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4391
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4392
            }
4393
        }
4394

    
4395
        private void RadButton_Click(object sender, RoutedEventArgs e)
4396
        {
4397
            gridViewHistory_Busy.IsBusy = true;
4398

    
4399
            RadButton instance = sender as RadButton;
4400
            if (instance.CommandParameter != null)
4401
            {
4402
                CurrentRev = instance.CommandParameter as VPRevision;
4403
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4404
                {
4405
                    if (ea.Error == null && ea.Result != null)
4406
                    {
4407
                        testPanel2.IsHidden = false;
4408

    
4409
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4410
                        foreach(var info in ea.Result)
4411
                        {
4412
                            if(info.UserID == App.ViewInfo.UserID)
4413
                            {
4414
                                info.userDelete = true;
4415
                                info.DisplayColor = "FFFF0000";
4416
                            }
4417
                            else
4418
                            {
4419
                                info.userDelete = false;
4420
                            }
4421
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4422
                        }
4423
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4424

    
4425
                        string uri = "";
4426
                        if (userData.COMPANY != "EXT")
4427
                        {
4428
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4429
                        }
4430
                        else
4431
                        {
4432
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4433
                        }
4434

    
4435
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4436

    
4437
                        var defaultBitmapImage_Compare = new BitmapImage();
4438
                        defaultBitmapImage_Compare.BeginInit();
4439
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4440
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4441
                        defaultBitmapImage_Compare.EndInit();
4442

    
4443
                        if (defaultBitmapImage_Compare.IsDownloading)
4444
                        {
4445
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4446
                            {
4447
                                defaultBitmapImage_Compare.Freeze();
4448
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4449
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4450
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4451
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4452
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4453
                            };
4454
                        }                        
4455
                        zoomAndPanControl2.ApplyTemplate();
4456
                        zoomAndPanControl2.UpdateLayout();
4457
                        //syncPannelRotate(zoomAndPanControl.RotationAngle);
4458
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4459
                        {
4460
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4461
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4462
                        }
4463

    
4464
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4465
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4466
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4467

    
4468
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4469
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4470
                        gridViewHistory_Busy.IsBusy = false;
4471
                    }
4472

    
4473
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4474
                };
4475
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4476
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4477
            }
4478
        }
4479

    
4480
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4481
        {
4482
            try
4483
            {
4484
                if (sender is RadButton)
4485
                {
4486
                    if ((sender as RadButton).Tag != null)
4487
                    {
4488
                        var url = (sender as RadButton).Tag.ToString();
4489
                        System.Diagnostics.Process.Start(url);
4490
                    }
4491
                    else
4492
                    {
4493
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4494
                    }
4495
                }
4496
            }
4497
            catch (Exception ex)
4498
            {
4499
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4500
            }
4501
        }
4502

    
4503
        public void Sync_Event(VPRevision Currnet_Rev)
4504
        {
4505
            CurrentRev = Currnet_Rev;
4506

    
4507
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4508
            {
4509
                if (ea.Error == null && ea.Result != null)
4510
                {
4511
                    testPanel2.IsHidden = false;
4512

    
4513
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4514
                    foreach(var info in ea.Result)
4515
                    {
4516
                        if(info.UserID == App.ViewInfo.UserID)
4517
                        {
4518
                            info.userDelete = true;
4519
                            info.DisplayColor = "FFFF0000";
4520
                        }
4521
                        else
4522
                        {
4523
                            info.userDelete = false;
4524
                        }
4525
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4526
                    }
4527
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4528

    
4529
                    string uri = "";
4530
                    if (userData.COMPANY != "EXT")
4531
                    {
4532
                        uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4533
                    }
4534
                    else
4535
                    {
4536
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4537
                    }
4538

    
4539
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4540

    
4541
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4542

    
4543
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4544
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4545
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4546

    
4547
                    if (defaultBitmapImage_Compare.IsDownloading)
4548
                    {
4549
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4550
                        {
4551
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4552
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4553
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4554
                        };
4555
                    }
4556

    
4557

    
4558
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4559
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4560
                    zoomAndPanControl2.ApplyTemplate();
4561
                    zoomAndPanControl2.UpdateLayout();
4562

    
4563
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4564
                    {
4565
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4566
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4567
                    }
4568
                    //}
4569

    
4570
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4571
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4572
                    gridViewHistory_Busy.IsBusy = false;
4573
                }
4574
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4575

    
4576
            };
4577
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4578
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4579
        }
4580

    
4581
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4582
        {
4583
            if (sender is Image)
4584
            {
4585
                if ((sender as Image).Tag != null)
4586
                {
4587
                    var pdfUrl = (sender as Image).Tag.ToString();
4588
                    System.Diagnostics.Process.Start(pdfUrl);
4589
                }
4590
                else
4591
                {
4592
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4593
                }
4594
            }
4595
        }
4596

    
4597
        private void Create_Symbol(object sender, RoutedEventArgs e)
4598
        {
4599
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4600

    
4601
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4602
            {
4603
                DialogMessage_Alert("Please Select Controls", "Alert");
4604
            }
4605
            else //선택된 것이 있으면
4606
            {
4607
                string MarkupData = "";
4608
                adorner_ = new AdornerFinal();
4609

    
4610
                foreach (var item in SelectLayer.Children)
4611
                {
4612
                    if (item.GetType().Name == "AdornerFinal")
4613
                    {
4614
                        adorner_ = (item as Controls.AdornerFinal);
4615
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4616
                        {
4617
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4618
                            {
4619
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4620
                                MarkupData += markupReturn.ConvertData;
4621
                            }
4622
                        }
4623
                    }
4624
                }
4625
                DialogParameters parameters = new DialogParameters()
4626
                {
4627
                    Owner = Application.Current.MainWindow,
4628
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4629
                    DefaultPromptResultValue = "Custom State",
4630
                    Content = "Name :",
4631
                    Header = "Insert Custom Symbol Name",
4632
                    Theme = new VisualStudio2013Theme(),
4633
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4634
                };
4635
                RadWindow.Prompt(parameters);
4636
            }
4637

    
4638
        }
4639
        public int symbolselectindex = 0;
4640
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4641
        {
4642
            //Save save = new Save();
4643
            try
4644
            {
4645
                string svgfilename = null;
4646
                if (symbolname != null)
4647
                {
4648
                    if (symbolpng == true || symbolsvg == true)
4649
                    {
4650
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4651
                        string guid = Commons.shortGuid();
4652

    
4653
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4654
                        //Check_Uri.UriCheck();
4655
                        fileUploader.RunCompleted += (ex, arg) =>
4656
                        {
4657
                            filename = arg.Result;
4658
                            if (symbolpng == true)
4659
                            {
4660
                                if (filename != null)
4661
                                { 
4662
                                    if (symbolselectindex == 0)
4663
                                    {
4664
                                        SymbolSave(symbolname, filename, data);
4665
                                    }
4666
                                    else
4667
                                    {
4668
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4669
                                    }
4670
                                    DataBind();
4671
                                }                                
4672
                            }
4673

    
4674
                            if (symbolsvg == true)
4675
                            {
4676
                                try
4677
                                {
4678
                                    var defaultBitmapImage = new BitmapImage();
4679
                                    defaultBitmapImage.BeginInit();
4680
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4681
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4682
                                    Check_Uri.UriCheck(filename);
4683
                                    defaultBitmapImage.UriSource = new Uri(filename);
4684
                                    defaultBitmapImage.EndInit();
4685

    
4686
                                    System.Drawing.Bitmap image;
4687

    
4688
                                    if (defaultBitmapImage.IsDownloading)
4689
                                    {
4690
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4691
                                        {
4692
                                            defaultBitmapImage.Freeze();
4693
                                            image = GetBitmap(defaultBitmapImage);
4694
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4695
                                            Process potrace = new Process
4696
                                            {
4697
                                                StartInfo = new ProcessStartInfo
4698
                                                {
4699
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4700
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4701
                                                    RedirectStandardInput = true,
4702
                                                    RedirectStandardOutput = true,
4703
                                                    RedirectStandardError = true,
4704
                                                    UseShellExecute = false,
4705
                                                    CreateNoWindow = true,
4706
                                                    WindowStyle = ProcessWindowStyle.Hidden
4707
                                                },
4708
                                            };
4709

    
4710
                                            StringBuilder svgBuilder = new StringBuilder();
4711
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4712
                                            {
4713
                                                svgBuilder.AppendLine(e2.Data);
4714
                                            };
4715

    
4716
                                            potrace.EnableRaisingEvents = true;
4717
                                            potrace.Start();
4718
                                            potrace.Exited += (sender, e) =>
4719
                                            {
4720
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4721
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4722
                                                Check_Uri.UriCheck(svgfilename);
4723
                                                if (symbolselectindex == 0)
4724
                                                {
4725
                                                    SymbolSave(symbolname, svgfilename, data);
4726
                                                }
4727
                                                else
4728
                                                {
4729
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4730
                                                }
4731

    
4732
                                                DataBind();
4733
                                            };
4734
                                            potrace.WaitForExit();
4735
                                        };
4736
                                    }
4737
                                    else
4738
                                    {
4739
                                        //GC.Collect();
4740
                                    }
4741
                                }
4742
                                catch(Exception ee)
4743
                                {
4744
                                    DialogMessage_Alert("" + ee, "Alert");
4745
                                }
4746
                            }
4747
                        };                                             
4748
                    }
4749
                }
4750
            }
4751
            catch (Exception e)
4752
            {
4753
                //DialogMessage_Alert(e + "", "Alert");
4754
            }            
4755
        }
4756

    
4757
        public void SymbolSave(string Name, string Url, string Data)
4758
        {
4759
            try
4760
            {
4761
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4762
                {
4763
                    ID = Commons.shortGuid(),
4764
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4765
                    NAME = Name,
4766
                    IMAGE_URL = Url,
4767
                    DATA = Data
4768
                };
4769

    
4770
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4771
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4772
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4773
            }
4774
            catch (Exception)
4775
            {
4776
                throw;
4777
            }
4778
        }
4779

    
4780
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4781
        {
4782
            try
4783
            {
4784
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4785
                {
4786
                    ID = Commons.shortGuid(),
4787
                    DEPARTMENT = Department,
4788
                    NAME = Name,
4789
                    IMAGE_URL = Url,
4790
                    DATA = Data
4791
                };
4792
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4793
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4794
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4795
            }
4796
            catch (Exception)
4797
            {
4798
                throw;
4799
            }
4800
        }
4801

    
4802
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4803
        {           
4804
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4805
            DataBind();
4806
        }
4807

    
4808
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4809
        {
4810
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4811
            DataBind();
4812
        }
4813
        private void DataBind()
4814
        {
4815
            try
4816
            {
4817
                Symbol_Custom Custom = new Symbol_Custom();
4818
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4819
                
4820
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4821
                foreach (var item in symbol_Private)
4822
                {
4823
                    Custom.Name = item.NAME;
4824
                    Custom.ImageUri = item.IMAGE_URL;
4825
                    Custom.ID = item.ID;
4826
                    Custom_List.Add(Custom);
4827
                    Custom = new Symbol_Custom();
4828
                }
4829
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4830
                
4831
                Custom = new Symbol_Custom();
4832
                Custom_List = new List<Symbol_Custom>();
4833

    
4834
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4835

    
4836
                List<SYMBOL_PUBLIC> symbol_Public;
4837

    
4838
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4839
                {
4840
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4841
                }
4842
                else
4843
                {
4844
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4845
                }
4846
                foreach (var item in symbol_Public)
4847
                {
4848
                    Custom.Name = item.NAME;
4849
                    Custom.ImageUri = item.IMAGE_URL;
4850
                    Custom.ID = item.ID;
4851
                    Custom_List.Add(Custom);
4852
                    Custom = new Symbol_Custom();
4853
                }
4854
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4855
                BaseClient.Close();                
4856
            }
4857
            catch(Exception e)
4858
            {
4859
                //DialogMessage_Alert("DataBind", "Alert");
4860
            }
4861
            
4862
        }
4863
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4864
        {
4865
            try
4866
            {
4867
                if (args.PromptResult != null)
4868
                {
4869
                    if (args.DialogResult.Value)
4870
                    {
4871
                        PngBitmapEncoder _Encoder = symImage(data);
4872

    
4873
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4874
                        _Encoder.Save(fs);
4875
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4876

    
4877
                        byte[] Img_byte = fs.ToArray();
4878

    
4879
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4880
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4881
                        Check_Uri.UriCheck(filename);
4882
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4883
                        {
4884
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4885
                        }
4886
                        else
4887
                        {
4888
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4889
                        }
4890
                        DataBind();
4891
                    }
4892
                }
4893
            }
4894
            catch(Exception ex)
4895
            {
4896
                DialogMessage_Alert("" + ex, "Alert");
4897
            }
4898
        }
4899

    
4900
        public PngBitmapEncoder symImage(string data)
4901
        {
4902

    
4903
            Canvas _canvas = new Canvas();
4904
            _canvas.Background = Brushes.White;
4905
            _canvas.Width = adorner_.BorderSize.Width;
4906
            _canvas.Height = adorner_.BorderSize.Height;
4907
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4908

    
4909
            BitmapEncoder encoder = new PngBitmapEncoder();
4910

    
4911

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

    
4914
            DrawingVisual dv = new DrawingVisual();
4915

    
4916
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
4917
            _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)));
4918

    
4919
            using (DrawingContext ctx = dv.RenderOpen())
4920
            {
4921
                VisualBrush vb = new VisualBrush(_canvas);
4922
                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)));
4923
            }
4924

    
4925
            try
4926
            {
4927
                renderBitmap.Render(dv);
4928

    
4929
                //GC.Collect();
4930
                GC.WaitForPendingFinalizers();
4931
                //GC.Collect();
4932
                // encode png data
4933
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4934
                // puch rendered bitmap into it
4935
                pngEncoder.Interlace = PngInterlaceOption.Off;
4936
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4937
                return pngEncoder;
4938

    
4939
            }
4940
            catch //(Exception ex)
4941
            {
4942
                return null;
4943
            }
4944

    
4945
        }
4946

    
4947
        public void DialogMessage_Alert(string content, string header)
4948
        {
4949
            DialogParameters parameters = new DialogParameters()
4950
            {
4951
                Owner = Application.Current.MainWindow,
4952
                Content = new TextBlock()
4953
                { 
4954
                    MinWidth = 400,
4955
                    FontSize = 11,
4956
                    Text = content,
4957
                    TextWrapping = System.Windows.TextWrapping.Wrap
4958
                },
4959
                Header = header,
4960
                Theme = new VisualStudio2013Theme(),
4961
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4962
            };            
4963
            RadWindow.Alert(parameters);
4964
        }
4965

    
4966
        #region 캡쳐 기능
4967

    
4968
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4969
        {
4970
            if (x < 0)
4971
            {
4972
                width += x;
4973
                x = 0;
4974
            }
4975
            if (y < 0)
4976
            {
4977
                height += y;
4978
                y = 0;
4979

    
4980
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4981
            }
4982
            if (x + width > zoomAndPanCanvas.ActualWidth)
4983
            {
4984
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4985
            }
4986
            if (y + height > zoomAndPanCanvas.ActualHeight)
4987
            {
4988
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4989
            }
4990

    
4991
            byte[] pixels = CopyPixels(x, y, width, height);
4992

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

    
4995
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4996
        }
4997

    
4998
        public byte[] CopyPixels(int x, int y, int width, int height)
4999
        {
5000
            byte[] pixels = new byte[width * height * 4];
5001
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5002

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

    
5006
            return pixels;
5007
        }
5008

    
5009
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5010
        {
5011
            DrawingVisual drawingVisual = new DrawingVisual();
5012
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5013

    
5014
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5015
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5016
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5017
            drawingContext.Close();
5018

    
5019
            // 비트맵으로 변환합니다.
5020
            RenderTargetBitmap target =
5021
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5022
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5023

    
5024
            target.Render(drawingVisual);
5025
            return target;
5026
        }
5027

    
5028
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5029
        {
5030
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5031
            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);
5032
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5033
            bmp.UnlockBits(data);
5034
            return bmp;
5035
        }
5036
        public string symbolname = null;
5037
        public bool symbolsvg = true;
5038
        public bool symbolpng = true;
5039

    
5040
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5041
        {
5042
            System.Drawing.Bitmap image = GetBitmap(source);
5043
            //흰색 제거
5044
            //image.MakeTransparent(System.Drawing.Color.White);
5045

    
5046
            var imageStream = new System.IO.MemoryStream();
5047
            byte[] imageBytes = null;
5048
            using (imageStream)
5049
            {
5050
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5051
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5052
                imageStream.Position = 0;
5053
                imageBytes = imageStream.ToArray();
5054
            }
5055

    
5056
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5057

    
5058
            RadWindow CheckPop = new RadWindow();
5059
            //Alert check = new Alert(Msg);
5060

    
5061
            CheckPop = new RadWindow
5062
            {
5063
                MinWidth = 400,
5064
                MinHeight = 100,
5065
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5066
                Header = "Alert",
5067
                Content = symbolPrompt,
5068
                //DialogResult = 
5069
                ResizeMode = System.Windows.ResizeMode.NoResize,
5070
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5071
                IsTopmost = true,
5072
            };
5073
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5074
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5075
            CheckPop.ShowDialog();
5076

    
5077
            /*
5078
            DialogParameters parameters = new DialogParameters()
5079
            {
5080
                Owner = Application.Current.MainWindow,
5081
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5082
                DefaultPromptResultValue = "Custom State",
5083
                Content = "Name :",
5084
                Header = "Insert Custom Symbol Name",
5085
                Theme = new VisualStudio2013Theme(),
5086
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5087
            };            
5088
            RadWindow.Prompt(parameters);
5089
            */
5090
        }
5091

    
5092
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5093
        {
5094
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5095
            KCOMDataModel.DataModel.CHECK_LIST check_;
5096
            string Result = streamToBase64.ImageToBase64(source);
5097
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5098
            string projectno = App.ViewInfo.ProjectNO;
5099
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5100

    
5101
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5102
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5103
            if (Item != null)
5104
            {
5105
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5106
            }
5107
            else
5108
            {
5109
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5110
            }
5111

    
5112
            if (Item == null)
5113
            {
5114
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5115
                {
5116
                    ID = Commons.shortGuid(),
5117
                    USER_ID = App.ViewInfo.UserID,
5118
                    IMAGE_URL = Result,
5119
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5120
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5121
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5122
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5123
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5124
                    STATUS = "False",
5125
                    CREATE_TIME = DateTime.Now,
5126
                    UPDATE_TIME = DateTime.Now,
5127
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5128
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5129
                };
5130
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5131
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5132
                //this.BaseClient.AddCheckList(projectno, check_);
5133
            }
5134
            else
5135
            {
5136
                Item.IMAGE_URL = Result;
5137
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5138
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5139
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5140
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5141
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5142
            }
5143

    
5144
        }
5145

    
5146
        public void Set_Capture()
5147
        {
5148
            double x = canvasDrawingMouseDownPoint.X;
5149
            double y = canvasDrawingMouseDownPoint.Y;
5150
            double width = dragCaptureBorder.Width;
5151
            double height = dragCaptureBorder.Height;
5152

    
5153
            if (width > 5 || height > 5)
5154
            {
5155
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5156
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5157
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5158
            }
5159
        }
5160
        #endregion
5161

    
5162
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5163
        {
5164
            multi_Undo_Data = new Multi_Undo_data();
5165

    
5166
            multi_Undo_Data.Markup = control;
5167

    
5168
            if ((control as IShapeControl) != null)
5169
            {
5170
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5171
            }
5172
            if ((control as IDashControl) != null)
5173
            {
5174
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5175
            }
5176
            if ((control as IPath) != null)
5177
            {
5178
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5179
            }
5180
            if ((control as UIElement) != null)
5181
            {
5182
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5183
            }
5184

    
5185
            return multi_Undo_Data;
5186
        }
5187

    
5188
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5189
        {
5190
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5191
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5192
            {
5193
                if (items.UserID == Select_ID)
5194
                {
5195
                    foreach (var item in items.MarkupList)
5196
                    {
5197
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5198
                        {
5199
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5200
                                items.MarkupInfoID, Commons.shortGuid());
5201
                        }
5202
                    }
5203
                }
5204
            }
5205
        }
5206

    
5207
        /// <summary>
5208
        /// convert inkcontrol to polygoncontrol
5209
        /// </summary>
5210
        public void ConvertInkControlToPolygon()
5211
        {
5212
            if (inkBoard.Strokes.Count > 0)
5213
            {
5214
                inkBoard.Strokes.ToList().ForEach(stroke =>
5215
                {
5216
                    InkToPath ip = new InkToPath();
5217

    
5218
                    List<Point> inkPointSet = new List<Point>();
5219
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5220

    
5221
                    PolygonControl pc = new PolygonControl()
5222
                    {
5223
                        Angle = 0,
5224
                        PointSet = inkPointSet,
5225
                        ControlType = ControlType.Ink
5226
                    };
5227
                    pc.StartPoint = inkPointSet[0];
5228
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5229
                    pc.LineSize = 3;
5230
                    pc.CommentID = Commons.shortGuid();
5231
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5232

    
5233
                    if (pc.PointSet.Count > 0)
5234
                    {
5235
                        CreateCommand.Instance.Execute(pc);
5236
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5237
                    }
5238
                });
5239
                inkBoard.Strokes.Clear();
5240
            }
5241
        }
5242

    
5243
        /// <summary>
5244
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5245
        /// </summary>
5246
        /// <author>ingu</author>
5247
        /// <date>2018.06.05</date>
5248
        /// <param name="getPoint"></param>
5249
        /// <returns></returns>
5250
        private bool IsGetoutpoint(Point getPoint)
5251
        {
5252
            if (getPoint == new Point())
5253
            {
5254
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5255
                currentControl = null;
5256
                return true;
5257
            }
5258

    
5259
            return false;
5260
        }
5261

    
5262
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5263
        {
5264
            e.Effects = DragDropEffects.Copy;
5265
        }
5266

    
5267
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5268
        {
5269
            e.Effects = DragDropEffects.Copy;
5270
        }
5271

    
5272
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5273
        {
5274
            e.Effects = DragDropEffects.None;
5275
        }
5276

    
5277
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5278
        {
5279
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5280
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5281

    
5282
            ScaleImage(pageWidth, pageHeight);
5283
        }
5284

    
5285
        /// <summary>
5286
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5287
        /// </summary>
5288
        /// <param name="pageWidth">원본 사이즈</param>
5289
        /// <param name="pageHeight">원본 사이즈</param>
5290
        /// <returns></returns>
5291
        private void ScaleImage(double pageWidth,double pageHeight)
5292
        {
5293
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5294
        }
5295

    
5296
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5297
        {
5298
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5299
        }
5300

    
5301

    
5302
        /*
5303
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5304
        {
5305
            try
5306
            {
5307
                if (e.Data.GetDataPresent(typeof(string)))
5308
                {
5309
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5310
                    string dragData = e.Data.GetData(typeof(string)) as string;
5311
                    Move_Symbol(sender, dragData);
5312
                }
5313
            }
5314
            catch (Exception ex)
5315
            {
5316
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5317
            }            
5318
        }
5319
        */
5320
    }
5321
}
클립보드 이미지 추가 (최대 크기: 500 MB)