프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 69f41aab

이력 | 보기 | 이력해설 | 다운로드 (251 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
        /// <summary>
263
        /// get image url
264
        /// </summary>
265
        /// <author>humkyung</author>
266
        /// <param name="sDocumentID"></param>
267
        /// <returns></returns>
268
        private string GetImageURL(string sDocumentID, int iPageNo)
269
        {
270
            string uri = string.Empty;
271

    
272
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
273
            if (userData.COMPANY != "EXT")
274
            {
275
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
276
            }
277
            else
278
            {
279
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
280
            }
281

    
282
            return uri;
283
        }
284

    
285
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
286
        {
287
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
288
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
289
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
290
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
291
            {
292
                return true;
293
            }
294

    
295
            return false;
296
        }
297

    
298
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
299
        {
300
            if (rotate.Angle == 90 || rotate.Angle == 270)
301
            {
302
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
303
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
304
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
305
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
306
                {
307
                    return true;
308
                }
309
            }
310
            else
311
            {
312
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
313
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
314
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
315
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
316
                {
317
                    return true;
318
                }
319
            }
320

    
321
            return false;
322
        }
323

    
324
        public void DeleteItem(MarkupInfoItem item)
325
        {
326
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
327
            {
328
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
329

    
330
            
331
            ViewerDataModel.Instance._markupInfoList.Remove(item);
332

    
333
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
334
            {
335
                ViewerDataModel.Instance.MarkupControls.Remove(a);
336
            });
337

    
338
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
339
            {
340
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
341
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
342
                null, Event_Type.Delete, a.CommentID, null);
343
            });
344

    
345
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
346
            {
347
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
348
                //임시파일에서도 삭제
349
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
350
            });
351

    
352
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
353

    
354
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
355
            {
356
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
357
                {
358
                    var infoId = Commons.shortGuid();
359
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
360
                    {
361
                        CreateTime = DateTime.Now,
362
                        Depatment = userData.DEPARTMENT,
363
                        UpdateTime = DateTime.Now,
364
                        DisplayColor = "#FFFF0000",
365
                        UserID = userData.ID,
366
                        UserName = userData.NAME,
367
                        PageCount = 1,
368
                        Description = "",
369
                        MarkupInfoID = infoId,
370
                        MarkupList = null,
371
                        MarkupVersionID = Commons.shortGuid(),
372
                        Consolidate = 0,
373
                        PartConsolidate = 0,
374
                        userDelete = true,
375
                        AvoidConsolidate = 0,
376
                        IsPreviewUser = true
377
                    };
378
                    App.Custom_ViewInfoId = infoId;
379
                }
380
            }
381
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
382
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);    
383
        }
384

    
385
        /// <summary>
386
        /// delete selected comments
387
        /// </summary>
388
        /// <param name="sender"></param>
389
        /// <param name="e"></param>
390
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
391
        {
392
            DialogParameters parameters = new DialogParameters()
393
            {
394
                Owner = Application.Current.MainWindow,
395
                Content = new TextBlock()
396
                { 
397
                    MinWidth = 400,
398
                    FontSize = 11,
399
                    Text = "정말 삭제 하시겠습니까?",
400
                    TextWrapping = System.Windows.TextWrapping.Wrap
401
                },
402
                Header = "Confirm",
403
                Theme = new VisualStudio2013Theme(),
404
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
405
                OkButtonContent = "Yes",
406
                CancelButtonContent = "No",
407
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
408
                {
409
                    if(wc.DialogResult == true)
410
                    {
411
                        //선택된 어도너가 있을시 삭제가 되지 않음
412
                        SelectionSet.Instance.UnSelect(this);
413

    
414
                        Button content = (sender as Button);
415
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
416

    
417
                        DeleteItem(item);
418
                    }
419
                }
420
            };
421
            RadWindow.Confirm(parameters);
422
        }
423

    
424
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
425

    
426
        private static Timer timer;
427
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
428
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
429
        {
430
            InitializeComponent();            
431
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
432

    
433
            if (App.ParameterMode)
434
            {
435
                App.splashString(ISplashMessage.MAINMENU_1);
436
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
437
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
438
                imageViewer_Compare = new Image();
439
                ViewerDataModel.Instance.Capture_Opacity = 0;
440
                da.From = 0.8;
441
                da.To = 0;
442
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
443
                da.AutoReverse = true;
444
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
445

    
446
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
447
                {
448
                    this.SymbolPane.Visibility = Visibility.Collapsed;
449
                    this.FavoritePane.Visibility = Visibility.Collapsed;
450
                    this.drawingRotateCanvas.IsHitTestVisible = false;
451
                }
452
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
453
            }
454
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
455
        }
456

    
457
        
458

    
459
        private void timercallback(Object o)
460
        {
461
            Stopwatch sw = new Stopwatch();
462
            sw.Start();
463
            TempFile.TempFileAdd();
464
            sw.Stop();
465

    
466
            Dispatcher.InvokeAsync(new Action(delegate
467
            {
468
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
469
                {
470
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
471
                }
472
            }));
473

    
474
            ////GC.Collect();
475
        }
476
        
477
        /// <summary>
478
        /// update my markuplist
479
        ///  - update existing markup data if already exist
480
        ///  - add new markup data if control is new
481
        /// </summary>
482
        public void UpdateMyMarkupList()
483
        {
484
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
485

    
486
            /// add or update markup list
487
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
488
            {
489
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
490

    
491
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
492
                if (exist != null) //신규 추가 된 코멘트
493
                {
494
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
495
                    {
496
                        exist.Data = root.ConvertData;
497
                        exist.IsUpdate = true;
498
                    }
499
                }
500
                else if (root.CommentID != null)
501
                {
502
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
503
                    {
504
                        ID = control.CommentID,
505
                        Data = root.ConvertData,
506
                        Data_Type = root.DATA_TYPE,
507
                        MarkupInfoID = App.Custom_ViewInfoId,
508
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
509
                        Symbol_ID = control.SymbolID,
510
                        //Group_ID = control.GroupID,
511
                    });
512
                }
513
            }
514

    
515
            /// delete markup list
516
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
517
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
518
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
519
                          select markup).ToList();
520
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
521
            /// up to here
522

    
523
            //if (modified)
524
            //{
525
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
526
            //    {
527
            //        ComingNewBieEnd = true;
528
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
529
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
530
            //        gridViewMarkup.ItemsSource = null;
531
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
532
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
533

    
534
            //        GroupDescriptor descriptor = new GroupDescriptor();
535
            //        descriptor.Member = "Depatment";
536
            //        descriptor.DisplayContent = "DEPT";
537
            //        descriptor.SortDirection = ListSortDirection.Ascending;
538
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
539
            //    }
540
            //}
541
        }
542

    
543
        DispatcherTimer renderTesttimer;
544

    
545
        /// <summary>
546
        /// start page changing
547
        ///  - save controls if page is modified
548
        ///  - starting download page image
549
        /// </summary>
550
        /// <param name="sender"></param>
551
        /// <param name="e"></param>
552
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
553
        {
554
            CompareMode.IsChecked = false;
555
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
556

    
557
            #region 페이지가 벗어난 경우
558

    
559
            if (BalancePoint < 1)
560
            {
561
                BalancePoint = 1;
562
                ViewerDataModel.Instance.PageBalanceNumber = 0;
563
            }
564

    
565
            if (pageNavigator.PageCount < BalancePoint)
566
            {
567
                BalancePoint = pageNavigator.PageCount;
568
                ViewerDataModel.Instance.PageBalanceNumber = 0;
569
            }
570

    
571
            #endregion
572

    
573
            ViewerDataModel.Instance.PageNumber = BalancePoint;
574

    
575
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
576
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
577
            var pageUri = pageNavigator.CurrentPage.PageUri;
578
            var contentScale = zoomAndPanControl.ContentScale;
579

    
580
            #region 페이지 이미지 로딩 수정
581

    
582
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
583
            try
584
            {
585
                ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
586
                
587
            }
588
            catch (Exception ex)
589
            {
590
                ViewerDataModel.Instance.ImageViewPath = null;
591
                string imgfailedmsg = string.Format(CommonLib.Common.GetAlertMessageString("GetImageResourceFailed", "MSG", "해당 문서의 {0} Page Convert가 정상적이지 않습니다. 관리자에게 문의해 주세요."), pageNavigator.CurrentPage.PageNumber);                
592
                DialogMessage_Alert(imgfailedmsg, "Warning");
593
                App.FileLogger.Fatal(ex);
594
            }
595
            ScaleImage(pageWidth, pageHeight);
596

    
597
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
598
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
599

    
600
            zoomAndPanCanvas.Width = pageWidth;
601
            zoomAndPanCanvas.Height = pageHeight;
602

    
603
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
604
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
605

    
606
            inkBoard.Width = pageWidth;
607
            inkBoard.Height = pageHeight;
608

    
609
            #endregion
610

    
611
            if (!testPanel2.IsHidden)
612
            {
613
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
614
                //PDF모드일때 잠시 대기(강인구)
615
                if (IsSyncPDFMode)
616
                {
617
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
618
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
619

    
620
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
621
                    if (pdfpath.IsDownloading)
622
                    {
623
                        pdfpath.DownloadCompleted += (ex, arg) =>
624
                        {
625
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
626
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
627
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
628
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
629
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
630
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
631
                        };
632
                    }
633
                    else
634
                    {
635
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
636
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
637
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
638
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
639

    
640
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
641
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
642
                    }
643
                }
644
                else
645
                {
646
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
647
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
648

    
649
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
650
                    var defaultBitmapImage_Compare = new BitmapImage();
651
                    defaultBitmapImage_Compare.BeginInit();
652
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
653
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
654
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
655
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
656
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
657
                    defaultBitmapImage_Compare.EndInit();
658

    
659
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
660

    
661
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
662
                    zoomAndPanControl.ZoomTo(new Rect
663
                    {
664
                        X = 0,
665
                        Y = 0,
666
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
667
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
668
                    });
669

    
670
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
671
                    if (defaultBitmapImage_Compare.IsDownloading)
672
                    {
673
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
674
                        {
675
                            defaultBitmapImage_Compare.Freeze();
676
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
677
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
678
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
679
                            ComparePanel.UpdateLayout();
680
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
681
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
682

    
683
                            zoomAndPanControl.ZoomTo(new Rect
684
                            {
685
                                X = 0,
686
                                Y = 0,
687
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
688
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
689
                            });
690

    
691
                            //defaultBitmapImage_Compare dispose
692
                            defaultBitmapImage_Compare = null;
693
                            GC.Collect();
694
                        };
695
                    }
696
                }
697
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
698
            }
699

    
700
            this.pageNavigator.ChangePage(e.PageNumber);
701
        }
702

    
703
        /// <summary>
704
        /// called after page is changed
705
        /// </summary>
706
        /// <param name="sender"></param>
707
        /// <param name="e"></param>
708
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
709
        {
710
            if (zoomAndPanCanvas2.Width.IsNaN())
711
            {
712
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
713
            }
714

    
715
            /// 컨트롤을 새로 생성한다.
716
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
717
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
718
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == ViewerDataModel.Instance.PageNumber))
719
            { 
720
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
721
                if (info != null)
722
                {
723
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
724
                    if (info.UserID == App.ViewInfo.UserID)
725
                    {
726
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
727
                                        markup.MarkupInfoID, markup.ID);
728
                        control.Visibility = Visibility.Hidden;
729
                    }
730
                    else
731
                    {
732
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
733
                                                                markup.MarkupInfoID, markup.ID);
734
                        control.Visibility = Visibility.Hidden;
735
                    }
736
                }
737
            };
738
            /// up to here
739

    
740
            /// fire selection event
741
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
742
            this.gridViewMarkup.UnselectAll();
743
            this.gridViewMarkup.Select(gridSelectionItem);
744

    
745
            if (!testPanel2.IsHidden)
746
            {
747
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
748
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
749
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
750

    
751
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
752
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
753

    
754

    
755
                foreach (var item in gridSelectionRevItem)
756
                {
757
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
758
                    {
759
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
760
                    });
761
                }
762
            }
763

    
764
            var instanceMain = this.ParentOfType<MainWindow>();
765
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
766
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
767

    
768
            instanceMain.dzTopMenu.rotateOffSet = 0;
769
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
770
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
771
            
772
            SetCommentPages(true);
773
        }
774

    
775
        public void SetCommentPages(bool onlyMe = false)
776
        {
777
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
778
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
779
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
780
            {
781
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
782
                if(item.MarkupList != null)
783
                {
784
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
785
                    instance.UserName = item.UserName;
786
                    instance.Depart = item.Depatment;
787
                    instance.MarkupInfoID = item.MarkupInfoID;
788
                    instance.IsSelected = true;
789
                    instance.isConSolidation = item.Consolidate;
790
                    instance.SetColor = item.DisplayColor;
791
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
792
                    {
793
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
794
                    }
795
                    else
796
                    {
797
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
798
                    }
799
                    _pages.Add(instance);
800
                }                   
801
            }
802
            
803
            this.pageNavigator.SetCommentList(_pages.ToList());
804
        }
805

    
806
        public void MarkupitemViewUpdate(string markupinfo_id)
807
        {
808
            //db에 업데이트 한 list 를 view 에 업데이트
809
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
810
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
811
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
812
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
813
            if (dbinfo.MarkupList.Count > 0)
814
            {
815
                if (viewinfo.MarkupList != null)
816
                {
817
                    viewinfo.MarkupList.Clear();
818
                    viewinfo.MarkupList = null;
819
                }
820
                viewinfo.MarkupList = new List<MarkupItem>();
821
                foreach (var item in dbinfo.MarkupList)
822
                {
823
                    viewinfo.MarkupList.Add(item);
824
                }
825
            }
826
        }
827

    
828
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
829
        {
830
            if (e.MiddleButton == MouseButtonState.Pressed)
831
            {
832

    
833
            }
834
            e.Handled = true;
835
            if (e.Delta > 0)
836
            {
837
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
838
                ZoomIn(currentContentMousePoint);
839
            }
840
            else
841
            {
842
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
843
                ZoomOut(currentContentMousePoint);
844
            }
845
        }
846

    
847
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
848
        {
849
            e.Handled = true;
850
            if (e.Delta > 0)
851
            {
852
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
853
                ZoomIn_Sync(currentContentMousePoint);
854
            }
855
            else
856
            {
857
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
858
                ZoomOut_Sync(currentContentMousePoint);
859
            }
860
        }
861

    
862
        #region ZoomIn & ZoomOut
863

    
864
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
865
        {
866
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
867
                zoomAndPanControl.ContentZoomFocusY));
868
        }
869

    
870
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
871
        {
872
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
873
                zoomAndPanControl.ContentZoomFocusY));
874
        }
875

    
876

    
877
        //강인구 추가 (줌 인아웃 수치 변경)
878
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
879
        private void ZoomOut(Point contentZoomCenter)
880
        {
881
            if (zoomAndPanControl.ContentScale > 0.39)
882
            {
883
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
884
            }
885
            else
886
            {
887
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
888
            }
889

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

    
896
        private void ZoomIn(Point contentZoomCenter)
897
        {
898
            if (zoomAndPanControl.ContentScale > 0.19)
899
            {
900
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
901
            }
902
            else
903
            {
904
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
905
            }
906

    
907
            if (zoomAndPanControl2 != null && Sync.IsChecked)
908
            {
909
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
910
            }
911

    
912
        }
913

    
914
        private void ZoomOut_Sync(Point contentZoomCenter)
915
        {
916
            if (zoomAndPanControl2.ContentScale > 0.39)
917
            {
918
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
919
            }
920
            else
921
            {
922
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
923
            }
924

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

    
931
        private void ZoomIn_Sync(Point contentZoomCenter)
932
        {
933
            if (zoomAndPanControl2.ContentScale > 0.19)
934
            {
935
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
936
            }
937
            else
938
            {
939
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
940
            }
941

    
942
            if (Sync.IsChecked)
943
            {
944
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
945
            }
946
        }
947

    
948
        private void ZoomOut()
949
        {
950
            zoomAndPanControl.ContentScale -= 0.1;
951
            //if (zoomAndPanControl2 != null)
952
            //{
953
            //    zoomAndPanControl2.ContentScale -= 0.1;
954
            //}
955
        }
956

    
957
        private void ZoomIn()
958
        {
959
            zoomAndPanControl.ContentScale += 0.1;
960
            //if (zoomAndPanControl2 != null)
961
            //{
962
            //    zoomAndPanControl2.ContentScale += 0.1;
963
            //}
964
        }
965

    
966
        #endregion
967

    
968
        private void init()
969
        {
970
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
971
            {
972

    
973
                ControlList.Clear();
974
                listBox.Items.Clear();
975
                selected_item.Clear();
976

    
977
                (item as IMarkupCommonData).IsSelected = false;
978
            }
979

    
980
        }
981

    
982
        private HitTestResultBehavior MyCallback(HitTestResult result)
983
        {
984
            //this.cursor = Cursors.UpArrow;
985
            var element = result.VisualHit;
986
            while (element != null && !(element is CommentUserInfo))
987
                element = VisualTreeHelper.GetParent(element);
988

    
989
            if (element == null)
990
            {
991
                return HitTestResultBehavior.Stop;
992
            }
993
            else
994
            {
995
                if (element is CommentUserInfo)
996
                {
997
                    if (!hitList.Contains(element))
998
                    {
999
                        hitList.Add((CommentUserInfo)element);
1000
                    }
1001
                    else
1002
                    {
1003
                        return HitTestResultBehavior.Stop;
1004
                    }
1005
                }
1006
            }
1007
            return HitTestResultBehavior.Continue;
1008
        }
1009

    
1010
        public void ReleaseSelectPath()
1011
        {
1012
            if (SelectionPath == null)
1013
            {
1014
                SelectionPath = new Path();
1015
                SelectionPath.Name = "";
1016
            }
1017
            if (SelectionPath.Name != "")
1018
            {
1019
                SelectionPath.Name = "None";
1020
            }
1021
            SelectionPath.Opacity = 0.01;
1022
            SelectionPath.RenderTransform = null;
1023
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1024
        }
1025

    
1026
        #region 컨트롤 초기화 
1027
        public void Control_Init(object control)
1028
        {
1029
            if (L_Size != 0 && (control as IPath) != null)
1030
            {
1031
                (control as IPath).LineSize = L_Size;
1032
                L_Size = 0;
1033
            }
1034

    
1035
            switch (control.GetType().Name)
1036
            {
1037
                case "RectangleControl":
1038
                    {
1039
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1040
                    }
1041
                    break;
1042
                case "CircleControl":
1043
                    {
1044
                        (control as CircleControl).StrokeColor = Brushes.Red;
1045
                    }
1046
                    break;
1047
                case "TriControl":
1048
                    {
1049
                        (control as TriControl).StrokeColor = Brushes.Red;
1050
                    }
1051
                    break;
1052
                case "RectCloudControl":
1053
                    {
1054
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1055
                    }
1056
                    break;
1057
                case "CloudControl":
1058
                    {
1059
                        (control as CloudControl).StrokeColor = Brushes.Red;
1060
                    }
1061
                    break;
1062
                case "PolygonControl":
1063
                    {
1064
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1065
                    }
1066
                    break;
1067
                case "ArcControl":
1068
                    {
1069
                        (control as ArcControl).StrokeColor = Brushes.Red;
1070
                    }
1071
                    break;
1072
                case "ArrowArcControl":
1073
                    {
1074
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1075
                    }
1076
                    break;
1077
                case "LineControl":
1078
                    {
1079
                        (control as LineControl).StrokeColor = Brushes.Red;
1080
                    }
1081
                    break;
1082
                case "ArrowControl_Multi":
1083
                    {
1084
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1085
                    }
1086
                    break;
1087
                case "TextControl":
1088
                    {
1089
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1090
                    }
1091
                    break;
1092
                case "ArrowTextControl":
1093
                    {
1094
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1095
                    }
1096
                    break;
1097
                case "InsideWhiteControl":
1098
                    {
1099
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1100
                    }
1101
                    break;
1102
                case "OverlapWhiteControl":
1103
                    {
1104
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1105
                    }
1106
                    break;
1107
                case "ClipWhiteControl":
1108
                    {
1109
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1110
                    }
1111
                    break;
1112
                case "CoordinateControl":
1113
                    {
1114
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1115
                    }
1116
                    break;
1117
            }
1118
        }
1119
        #endregion
1120

    
1121
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1122
        {
1123
            //Control_Init(e.Source);
1124
        }
1125
        //private Window _dragdropWindow = null;
1126

    
1127
        [DllImport("user32.dll")]
1128
        [return: MarshalAs(UnmanagedType.Bool)]
1129
        internal static extern bool GetCursorPos(ref Win32Point pt);
1130

    
1131
        [StructLayout(LayoutKind.Sequential)]
1132
        internal struct Win32Point
1133
        {
1134
            public Int32 X;
1135
            public Int32 Y;
1136
        };
1137
        /*
1138
       public string symbol_id = null;
1139
       public long symbol_group_id;
1140
       public int symbol_SelectedIndex;
1141
       public ImageSource symbol_img;
1142
       public string symbol_Data = null;
1143
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1144
       {
1145
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1146
               zoomAndPanCanvas.ActualHeight / 2));
1147

    
1148

    
1149
               if (this._dragdropWindow != null)
1150
               {
1151
                   this._dragdropWindow.Close();
1152
                   this._dragdropWindow = null;
1153
               }
1154

    
1155
               symbol_id = id;
1156
               symbol_group_id = group_id;
1157
               symbol_SelectedIndex = SelectedIndex;
1158
               symbol_Data = Data_;
1159
               symbol_img = img;
1160

    
1161

    
1162
               CreateDragDropWindow2(img);
1163
              
1164
    }
1165

    
1166
    private void CreateDragDropWindow2(ImageSource image)
1167
        {
1168
            this._dragdropWindow = new Window();
1169
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1170
            _dragdropWindow.WindowStyle = WindowStyle.None;
1171
            _dragdropWindow.AllowsTransparency = true;           
1172
            _dragdropWindow.AllowDrop = false;
1173
            _dragdropWindow.Background = null;
1174
            _dragdropWindow.IsHitTestVisible = false;
1175
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1176
            _dragdropWindow.Topmost = true;
1177
            _dragdropWindow.ShowInTaskbar = false;
1178
            
1179
            Rectangle r = new Rectangle();
1180
            r.Width = image.Width;
1181
            r.Height = image.Height;
1182
            r.Opacity = 0.5;            
1183
            r.Fill = new ImageBrush(image);
1184
            this._dragdropWindow.Content = r;
1185

    
1186
            Win32Point w32Mouse = new Win32Point();
1187
            GetCursorPos(ref w32Mouse);
1188

    
1189
            //w32Mouse.X = getCurrentPoint.X;
1190
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1191
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1192
            this._dragdropWindow.Show();
1193
        }
1194
         */
1195
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1196
        {
1197
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1198
            {
1199
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1200

    
1201
                Point currentPos = e.GetPosition(rect);
1202

    
1203
                floatingTip.HorizontalOffset = currentPos.X + 20;
1204
                floatingTip.VerticalOffset = currentPos.Y;
1205
            }
1206

    
1207
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1208
            
1209
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1210
            {
1211
                SetCursor();
1212
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1213
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1214

    
1215
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1216
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1217
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1218

    
1219
                if (Sync.IsChecked)
1220
                {
1221
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1222
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1223
                }
1224
            }
1225

    
1226
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1227
            {
1228
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1229
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1230
                SetCursor();
1231

    
1232
                if (currentControl != null)
1233
                {
1234
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1235
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1236
                    //강인구 추가
1237
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1238

    
1239
                    if ((currentControl as IPath) != null)
1240
                    {
1241
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1242
                    }
1243
                    if ((currentControl as LineControl) != null)
1244
                    {
1245
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1246
                    }
1247

    
1248
                    if ((currentControl as IShapeControl) != null)
1249
                    {
1250
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1251
                    }
1252
                    if ((currentControl as TextControl) != null)
1253
                    {
1254
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1255
                        {
1256
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1257
                        }
1258
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1259
                        {
1260
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1261
                        }
1262
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1263
                        {
1264
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1265
                        }
1266
                    }
1267
                    else if ((currentControl as ArrowTextControl) != null)
1268
                    {
1269
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1270
                        {
1271
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1272
                        }
1273
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1274
                        {
1275
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1276
                        }
1277
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1278
                        {
1279
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1280
                        }
1281
                    }
1282
                    else if ((currentControl as RectCloudControl) != null)
1283
                    {
1284
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1285
                    }
1286
                    else if ((currentControl as CloudControl) != null)
1287
                    {
1288
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1289
                    }
1290

    
1291
                    switch (controlType)
1292
                    {
1293
                        case (ControlType.Coordinate):
1294
                            {
1295
                                var control = currentControl as CoordinateControl;
1296
                                if (control != null)
1297
                                {
1298
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1299
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1300
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1301
                                }
1302
                            }
1303
                            break;
1304
                        case (ControlType.InsideWhite):
1305
                            {
1306
                                var control = currentControl as InsideWhiteControl;
1307
                                if (control != null)
1308
                                {
1309
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1310
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1311
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1312
                                    control.Paint = PaintSet.Fill;
1313
                                }
1314
                            }
1315
                            break;
1316
                        case ControlType.OverlapWhite:
1317
                            {
1318
                                var control = currentControl as OverlapWhiteControl;
1319
                                if (control != null)
1320
                                {
1321
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1322
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1323
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1324
                                    control.Paint = PaintSet.Fill;
1325
                                }
1326
                            }
1327
                            break;
1328
                        case ControlType.ClipWhite:
1329
                            {
1330
                                var control = currentControl as ClipWhiteControl;
1331
                                if (control != null)
1332
                                {
1333
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1334
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1335
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1336
                                    control.Paint = PaintSet.Fill;
1337
                                }
1338
                            }
1339
                            break;
1340
                        case ControlType.RectCloud:
1341
                            {
1342
                                var control = currentControl as RectCloudControl;
1343
                                if (control != null)
1344
                                {
1345
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1346
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1347
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1348
                                }
1349
                            }
1350
                            break;
1351
                        case ControlType.SingleLine:
1352
                        case ControlType.CancelLine:
1353
                        case ControlType.ArrowLine:
1354
                        case ControlType.TwinLine:
1355
                        case ControlType.DimLine:
1356
                            {
1357
                                var control = currentControl as LineControl;
1358
                                if (control != null)
1359
                                {
1360
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1361
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1362
                                }
1363
                            }
1364
                            break;
1365

    
1366
                        case ControlType.ArcLine:
1367
                            {
1368
                                var control = currentControl as ArcControl;
1369
                                if (control != null)
1370
                                {
1371
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1372
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1373
                                }
1374
                            }
1375
                            break;
1376

    
1377
                        case ControlType.ArcArrow:
1378
                            {
1379
                                var control = currentControl as ArrowArcControl;
1380
                                if (control != null)
1381
                                {
1382
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1383
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1384
                                }
1385
                            }
1386
                            break;
1387

    
1388
                        case ControlType.ArrowMultiLine:
1389
                            {
1390
                                var control = currentControl as ArrowControl_Multi;
1391
                                if (control != null)
1392
                                {
1393
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1394
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1395
                                }
1396
                            }
1397
                            break;
1398

    
1399
                        case ControlType.Circle:
1400
                            {
1401
                                if (currentControl != null)
1402
                                {
1403
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1404
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1405
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1406
                                }
1407
                            }
1408
                            break;
1409

    
1410
                        case ControlType.PolygonCloud:
1411
                            {
1412
                                var control = currentControl as CloudControl;
1413
                                if (control != null)
1414
                                {
1415
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1416
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1417
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1418
                                }
1419
                            }
1420
                            break;
1421

    
1422
                        case ControlType.Triangle:
1423
                            {
1424
                                var control = currentControl as TriControl;
1425
                                if (control != null)
1426
                                {
1427
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1428
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1429
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1430
                                }
1431
                            }
1432
                            break;
1433

    
1434
                        case ControlType.ImgControl:
1435
                            {
1436
                                var control = currentControl as ImgControl;
1437
                                if (control != null)
1438
                                {
1439
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1440
                                }
1441
                            }
1442
                            break;
1443

    
1444
                        case ControlType.Date:
1445
                            {
1446
                                var control = currentControl as DateControl;
1447
                                if (control != null)
1448
                                {
1449
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1450
                                }
1451
                            }
1452
                            break;
1453

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

    
1563
                                //inkBoard.Strokes.Add(stroke);
1564
                            }
1565
                            break;
1566
                    }
1567
                    return;
1568
                }
1569
            }
1570
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1571
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1572
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1573
            {
1574
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1575

    
1576
                if (isDraggingSelectionRect)
1577
                {
1578
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1579
                    e.Handled = true;
1580
                }
1581
                else if (isLeftMouseButtonDownOnWindow)
1582
                {
1583
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1584
                    double dragDistance = Math.Abs(dragDelta.Length);
1585

    
1586
                    if (dragDistance > DragThreshold)
1587
                    {
1588
                        isDraggingSelectionRect = true;
1589
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1590
                    }
1591

    
1592
                    e.Handled = true;
1593
                }
1594

    
1595
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1596
                {
1597
                }
1598
                else
1599
                {
1600
                    e.Handled = true;
1601
                }
1602
            }
1603
            /*
1604
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1605
            { //symbol      
1606
                if(_dragdropWindow != null)
1607
                {
1608
                    Win32Point w32Mouse = new Win32Point();
1609
                    GetCursorPos(ref w32Mouse);
1610

    
1611
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1612
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1613
                }                
1614
            }
1615
            */
1616
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1617
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1618
            {
1619
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1620
                if(control != null)
1621
                {
1622
                    this.cursor = Cursors.Hand;
1623
                    SetCursor();
1624
                }
1625
                else
1626
                {
1627
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1628
                    SetCursor();
1629
                }
1630
            }
1631
            else
1632
            {
1633
            }
1634
        }
1635

    
1636
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1637
        {
1638
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1639
            {
1640
                SetCursor();
1641
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1642
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1643

    
1644
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1645

    
1646
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1647
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1648

    
1649
                if (Sync.IsChecked)
1650
                {
1651
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1652
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1653
                }
1654
            }
1655
        }
1656

    
1657
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1658

    
1659
        private EllipseGeometry hitArea = new EllipseGeometry();
1660

    
1661
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1662
        {
1663
            IsDrawing = false;
1664

    
1665
            if (mouseHandlingMode != MouseHandlingMode.None)
1666
            {
1667
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1668
                {
1669
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1670

    
1671
                    SetCursor();
1672

    
1673
                    switch (controlType)
1674
                    {
1675
                        case ControlType.None:
1676
                            break;
1677
                        case ControlType.Rectangle:
1678
                            {
1679

    
1680
                            }
1681
                            break;
1682
                        case ControlType.PenControl:
1683
                            {
1684

    
1685
                            }
1686
                            break;
1687
                        default:
1688
                            break;
1689
                    }                    
1690
                }
1691
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1692
                {
1693
                    if (isLeftMouseButtonDownOnWindow)
1694
                    {
1695
                        bool wasDragSelectionApplied = false;
1696

    
1697
                        if (isDraggingSelectionRect)
1698
                        {
1699
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1700
                            {
1701
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1702
                                mouseHandlingMode = MouseHandlingMode.None;
1703
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1704
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1705
                                Set_Symbol_Capture(endPoint);
1706
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1707
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1708
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1709
                            }
1710
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1711
                            {
1712
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1713
                                mouseHandlingMode = MouseHandlingMode.None;
1714
                                Set_Capture();
1715

    
1716
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1717
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1718
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1719
                            }
1720
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1721
                            {
1722
                                ApplyDragSelectionRect();
1723
                            }
1724
                            else
1725
                            {
1726
                                double x = Canvas.GetLeft(dragZoomBorder);
1727
                                double y = Canvas.GetTop(dragZoomBorder);
1728
                                double width = dragZoomBorder.Width;
1729
                                double height = dragZoomBorder.Height;
1730
                                Rect dragRect = new Rect(x, y, width, height);
1731

    
1732
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1733

    
1734
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1735
                            }
1736

    
1737
                            isDraggingSelectionRect = false;
1738
                            e.Handled = true;
1739
                            wasDragSelectionApplied = true;
1740
                        }
1741

    
1742
                        if (isLeftMouseButtonDownOnWindow)
1743
                        {
1744
                            isLeftMouseButtonDownOnWindow = false;
1745
                            this.ReleaseMouseCapture();
1746
                            e.Handled = true;
1747
                        }
1748

    
1749
                        if (!wasDragSelectionApplied)
1750
                        {
1751
                            init();
1752
                        }
1753
                    }
1754
                }
1755
                else if (e.RightButton == MouseButtonState.Pressed)
1756
                {
1757
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1758
                    SetCursor();
1759
                }
1760

    
1761
                zoomAndPanControl.ReleaseMouseCapture();
1762

    
1763

    
1764
                e.Handled = true;
1765
            }
1766
            else
1767
            {
1768
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1769
                SetCursor();
1770
            }
1771

    
1772
            ///mouseButtonDown = MouseButton.Left;
1773
            //controlType = ControlType.SingleLine;
1774
        }
1775

    
1776
        public void Set_Symbol_Capture(Point endPoint)
1777
        {       
1778
            double x = canvasDrawingMouseDownPoint.X;
1779
            double y = canvasDrawingMouseDownPoint.Y;
1780
            if(x > endPoint.X)
1781
            {
1782
                x = endPoint.X;
1783
                y = endPoint.Y;
1784
            }
1785

    
1786
            double width = dragCaptureBorder.Width;
1787
            double height = dragCaptureBorder.Height;
1788

    
1789
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1790

    
1791
            if (x < 0)
1792
            {
1793
                width += x;
1794
                x = 0;
1795
            }
1796
            if (y < 0)
1797
            {
1798
                height += y;
1799
                y = 0;
1800

    
1801
                width = (int)canvasImage.PixelWidth - x;
1802
            }
1803
            if (x + width > canvasImage.PixelWidth)
1804
            {
1805
                width = (int)canvasImage.PixelWidth - x;
1806
            }
1807
            if (y + height > canvasImage.PixelHeight)
1808
            {
1809
                height = (int)canvasImage.PixelHeight - y;
1810
            }
1811
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1812

    
1813
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1814
            var defaultBitmapImage = new BitmapImage();
1815
            defaultBitmapImage.BeginInit();
1816
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1817
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1818
            defaultBitmapImage.UriSource = new Uri(uri);
1819
            defaultBitmapImage.EndInit();
1820

    
1821
            //GC.Collect();
1822

    
1823
            if (defaultBitmapImage.IsDownloading)
1824
            {
1825
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1826
                {
1827
                    defaultBitmapImage.Freeze();
1828
                    //GC.Collect();
1829
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1830
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1831
                };
1832
            }
1833
        }
1834

    
1835
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1836
        {
1837
            ///mouseButtonDown = MouseButton.Left;
1838
        }
1839

    
1840
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1841
        {
1842
            ///mouseButtonDown = MouseButton.Left;
1843
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1844
        }
1845

    
1846
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1847
        {
1848

    
1849
        }
1850

    
1851
        /// <summary>
1852
        /// select items by dragging
1853
        /// </summary>
1854
        private void ApplyDragSelectionRect()
1855
        {
1856
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1857

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

    
1866
            Rect dragRect = new Rect(x, y, width, height);
1867
            ///dragRect.Inflate(width / 10, height / 10);
1868

    
1869
            foreach (var item in Items)
1870
            {
1871
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1872

    
1873
                if (Flag)
1874
                {
1875
                    adornerSet.Add(item);
1876
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1877
                    Control_Style(item);
1878
                }
1879
            }
1880
            if (adornerSet.Count > 0)
1881
            {
1882
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1883
                SelectLayer.Children.Add(final);
1884
            }
1885
        }
1886

    
1887
        private void InitDragSelectionRect(Point pt1, Point pt2)
1888
        {
1889
            //캡쳐 중
1890
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1891
            {
1892
                dragCaptureBorder.Visibility = Visibility.Visible;
1893
            }
1894
            //선택 중
1895
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1896
            {
1897

    
1898
                dragSelectionBorder.Visibility = Visibility.Visible;
1899
            }
1900
            else
1901
            {
1902
                dragZoomBorder.Visibility = Visibility.Visible;
1903
            }
1904
            UpdateDragSelectionRect(pt1, pt2);
1905
        }
1906

    
1907
        /// <summary>
1908
        /// Update the position and size of the rectangle used for drag selection.
1909
        /// </summary>
1910
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1911
        {
1912
            double x, y, width, height;
1913

    
1914
            //
1915
            // Determine x,y,width and height of the rect inverting the points if necessary.
1916
            // 
1917

    
1918
            if (pt2.X < pt1.X)
1919
            {
1920
                x = pt2.X;
1921
                width = pt1.X - pt2.X;
1922
            }
1923
            else
1924
            {
1925
                x = pt1.X;
1926
                width = pt2.X - pt1.X;
1927
            }
1928

    
1929
            if (pt2.Y < pt1.Y)
1930
            {
1931
                y = pt2.Y;
1932
                height = pt1.Y - pt2.Y;
1933
            }
1934
            else
1935
            {
1936
                y = pt1.Y;
1937
                height = pt2.Y - pt1.Y;
1938
            }
1939

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

    
1968
        private void drawingPannelRotate(double angle)
1969
        {
1970
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1971
            rotate.Angle = angle;
1972
            var rotationNum = Math.Abs((rotate.Angle / 90));
1973

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

    
2001
            zoomAndPanControl.RotationAngle = rotate.Angle;
2002

    
2003

    
2004
            if (!testPanel2.IsHidden)
2005
            {
2006
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2007
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2008
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2009
            }
2010

    
2011
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2012
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2013
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2014
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2015
            ViewerDataModel.Instance.Angle = rotate.Angle;
2016
        }
2017

    
2018
        private void syncPannelRotate(double angle)
2019
        {
2020
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2021
            rotate.Angle = angle;
2022
            var rotationNum = Math.Abs((rotate.Angle / 90));
2023

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

    
2051
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2052
        }
2053

    
2054
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2055
        {
2056
            string Data_ = "";
2057

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

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

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

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

    
2131
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2132
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2133
                    UndoData.Markup_List.Add(multi_Undo_Data);
2134
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2135

    
2136
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2137
                    currentControl.CommentID = Commons.shortGuid();
2138
                    currentControl.SymbolID = id;
2139
                    currentControl.GroupID = group_id;
2140
                    currentControl.ApplyTemplate();
2141
                    currentControl.SetImage();
2142

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

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

    
2164
            ConvertInkControlToPolygon();
2165

    
2166
            ///TODO:
2167
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2168
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2169

    
2170
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2171
            {
2172
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2173
            }
2174
            /// up to here
2175

    
2176
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2177
            {
2178
                if (item as ArrowTextControl != null)
2179
                {
2180
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2181
                }
2182
                else if (item as TextControl != null)
2183
                {
2184
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2185
                }
2186
            }
2187

    
2188
            //if (currentControl != null)
2189
            {
2190
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2191
                if (text_item_ != null)
2192
                {
2193
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2194
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2195
                    (text_item_ as TextControl).IsEditingMode = false;                    
2196
                    currentControl = null;
2197
                }
2198

    
2199
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2200
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2201
                {
2202
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2203
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2204
                    currentControl = null;
2205
                }
2206
            }
2207

    
2208
            double Ang = 0;                                          
2209
            if (rotate.Angle != 0)
2210
            {
2211
                Ang = 360 - rotate.Angle;
2212
            }
2213

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

    
2228
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2229
            {
2230
                if (this._dragdropWindow != null)
2231
                {
2232
                    this._dragdropWindow.Close();
2233
                    this._dragdropWindow = null;
2234
                    symbol_id = null;
2235
                }
2236
            }
2237
            */
2238

    
2239
            if (e.LeftButton == MouseButtonState.Pressed)
2240
            {
2241
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2242
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2243

    
2244
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2245
                SetCursor();
2246

    
2247
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2248
            }
2249

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

    
2269
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2270

    
2271
            }
2272
            else if (e.XButton2 == MouseButtonState.Pressed)
2273
            {
2274
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2275
                {
2276
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2277
                }
2278
            }
2279

    
2280
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2281
            {
2282
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2283
                {
2284
                    if (SelectLayer.Children.Count == 0)
2285
                    {
2286
                        isLeftMouseButtonDownOnWindow = true;
2287
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2288
                    }
2289

    
2290
                    if (controlType == ControlType.None)
2291
                    {
2292
                        isLeftMouseButtonDownOnWindow = true;
2293
                    }
2294
                }
2295

    
2296
                /// 캡쳐 모드 설정
2297
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2298
                {
2299
                    dragCaptureBorder.Visibility = Visibility.Visible;
2300
                    isLeftMouseButtonDownOnWindow = true;
2301
                }
2302

    
2303
                /// 줌 모드 설정
2304
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2305
                {
2306
                    isLeftMouseButtonDownOnWindow = true;
2307
                }
2308

    
2309
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2310
                if (control != null)
2311
                {
2312
                    AdornerFinal final = null;
2313

    
2314
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2315
                    {
2316
                        /// 기존 selection 해제
2317
                        SelectionSet.Instance.UnSelect(this);
2318

    
2319
                        final = new AdornerFinal(control);
2320

    
2321
                        this.Control_Style(control);
2322

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

    
2348
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2349

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

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

    
2431
                        Control_Style(control);
2432

    
2433
                        final = new AdornerFinal(comment);
2434
                    }
2435

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

    
2479
                switch (controlType)
2480
                {
2481
                    case ControlType.Coordinate:
2482
                        {
2483
                            if (e.LeftButton == MouseButtonState.Pressed)
2484
                            {
2485
                                if (currentControl is CoordinateControl)
2486
                                {
2487
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2488
                                    {
2489
                                        return;
2490
                                    }
2491

    
2492
                                    CreateCommand.Instance.Execute(currentControl);
2493

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

    
2517
                                        currentControl.CommentID = Commons.shortGuid();
2518
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2519
                                        currentControl.IsNew = true;
2520

    
2521
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2522

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

    
2540
                                    CreateCommand.Instance.Execute(currentControl);
2541

    
2542
                                    currentControl = null;
2543
                                    this.cursor = Cursors.Arrow;
2544
                                }
2545
                                else
2546
                                {
2547
                                    currentControl = new InsideWhiteControl
2548
                                    {
2549
                                        Background = new SolidColorBrush(Colors.Black),
2550
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2551
                                        ControlType = ControlType.InsideWhite
2552
                                    };
2553

    
2554
                                    currentControl.CommentID = Commons.shortGuid();
2555
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2556
                                    currentControl.IsNew = true;
2557
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2558

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

    
2575
                                    CreateCommand.Instance.Execute(currentControl);
2576

    
2577
                                    currentControl = null;
2578
                                    this.cursor = Cursors.Arrow;
2579
                                }
2580
                                else
2581
                                {
2582
                                    currentControl = new OverlapWhiteControl
2583
                                    {
2584
                                        Background = new SolidColorBrush(Colors.Black),
2585
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2586
                                        ControlType = ControlType.OverlapWhite
2587
                                    };
2588

    
2589
                                    currentControl.CommentID = Commons.shortGuid();
2590
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2591
                                    currentControl.IsNew = true;
2592
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2593

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

    
2610
                                    CreateCommand.Instance.Execute(currentControl);
2611

    
2612
                                    currentControl = null;
2613
                                    this.cursor = Cursors.Arrow;
2614
                                }
2615
                                else
2616
                                {
2617
                                    currentControl = new ClipWhiteControl
2618
                                    {
2619
                                        Background = new SolidColorBrush(Colors.Black),
2620
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2621
                                        ControlType = ControlType.ClipWhite
2622
                                    };
2623

    
2624
                                    currentControl.CommentID = Commons.shortGuid();
2625
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2626
                                    currentControl.IsNew = true;
2627
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2628

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

    
2646
                                    CreateCommand.Instance.Execute(currentControl);
2647
                                    currentControl = null;
2648
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2649
                                }
2650
                                else
2651
                                {
2652
                                    currentControl = new RectangleControl
2653
                                    {
2654
                                        Background = new SolidColorBrush(Colors.Black),
2655
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2656
                                        ControlType = ControlType.Rectangle
2657
                                    };
2658

    
2659
                                    currentControl.CommentID = Commons.shortGuid();
2660
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2661
                                    currentControl.IsNew = true;
2662
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2663

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

    
2681
                                    CreateCommand.Instance.Execute(currentControl);
2682

    
2683
                                    currentControl = null;
2684
                                
2685
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2686
                                }
2687
                                else
2688
                                {
2689
                                    currentControl = new RectCloudControl
2690
                                    {
2691
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2692
                                        ControlType = ControlType.RectCloud,
2693
                                        Background = new SolidColorBrush(Colors.Black)
2694
                                    };
2695

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

    
2716
                                    CreateCommand.Instance.Execute(currentControl);
2717

    
2718
                                    currentControl = null;
2719
                                }
2720
                                else
2721
                                {
2722
                                    currentControl = new CircleControl
2723
                                    {
2724
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2725
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2726
                                        Background = new SolidColorBrush(Colors.Black)
2727
                                    };
2728

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

    
2756
                                        CreateCommand.Instance.Execute(currentControl);
2757

    
2758
                                        currentControl = null;
2759
                                    }
2760
                                }
2761
                                else
2762
                                {
2763
                                    currentControl = new TriControl
2764
                                    {
2765
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2766
                                        Background = new SolidColorBrush(Colors.Black),
2767
                                    };
2768

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

    
2793
                                    CreateCommand.Instance.Execute(currentControl);
2794
                                    currentControl = null;
2795
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2796
                                }
2797
                                else
2798
                                {
2799
                                    currentControl = new LineControl
2800
                                    {
2801
                                        ControlType = this.controlType,
2802
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2803
                                        Background = new SolidColorBrush(Colors.Black)
2804
                                    };
2805

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

    
2821
                                if (e.RightButton == MouseButtonState.Pressed)
2822
                                {
2823
                                    control.IsCompleted = true;
2824
                                }
2825

    
2826
                                if (!control.IsCompleted)
2827
                                {
2828
                                    control.PointSet.Add(control.EndPoint);
2829
                                }
2830
                                else
2831
                                {
2832
                                    //20180906 LJY TEST IsRotationDrawingEnable
2833
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2834
                                    {
2835
                                        return;
2836
                                    }
2837

    
2838
                                    var firstPoint = control.PointSet.First();
2839
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2840
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2841
                                    control.PointSet.Add(firstPoint);
2842

    
2843
                                    control.ApplyOverViewData();
2844

    
2845
                                    CreateCommand.Instance.Execute(currentControl);
2846
                                    control.UpdateControl();
2847
                                    currentControl = null;
2848
                                }
2849
                            }
2850
                            else
2851
                            {
2852
                                if (e.LeftButton == MouseButtonState.Pressed)
2853
                                {
2854
                                    currentControl = new PolygonControl
2855
                                    {
2856
                                        PointSet = new List<Point>(),
2857
                                    };
2858

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

    
2880
                                if (e.RightButton == MouseButtonState.Pressed)
2881
                                {
2882
                                    //20180906 LJY TEST IsRotationDrawingEnable
2883
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2884
                                    {
2885
                                        return;
2886
                                    }
2887

    
2888
                                    CreateCommand.Instance.Execute(currentControl);
2889

    
2890
                                    currentControl = null;
2891
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2892
                                    return;
2893
                                }
2894

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

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

    
2945
                                    CreateCommand.Instance.Execute(currentControl);
2946

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

    
2988
                                    CreateCommand.Instance.Execute(currentControl);
2989

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

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

    
3048
                                            CreateCommand.Instance.Execute(currentControl);
3049

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

    
3081
                                if (!control.IsCompleted)
3082
                                {
3083
                                    control.PointSet.Add(control.EndPoint);
3084
                                }
3085
                                else
3086
                                {
3087
                                    //20180906 LJY TEST IsRotationDrawingEnable
3088
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3089
                                    {
3090
                                        return;
3091
                                    }
3092

    
3093
                                    CreateCommand.Instance.Execute(currentControl);
3094

    
3095
                                    control.isTransOn = true;
3096
                                    var firstPoint = control.PointSet.First();
3097

    
3098
                                    control.PointSet.Add(firstPoint);
3099
                                    control.DrawingCloud();
3100
                                    control.ApplyOverViewData();
3101

    
3102
                                    currentControl = null;
3103
                                }
3104
                            }
3105
                            else
3106
                            {
3107
                                if (e.LeftButton == MouseButtonState.Pressed)
3108
                                {
3109
                                    currentControl = new CloudControl
3110
                                    {
3111
                                        PointSet = new List<Point>(),
3112
                                        PointC = new StylusPointSet()
3113
                                    };
3114

    
3115
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3116
                                    //{
3117
                                        var polygonControl = (currentControl as CloudControl);
3118
                                        currentControl.CommentID = Commons.shortGuid();
3119
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3120
                                        currentControl.IsNew = true;
3121
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3122

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

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

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

    
3186
                                        
3187
                                                currentControl.CommentID = Commons.shortGuid();                                            
3188
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3189
                                                currentControl.IsNew = true;
3190
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3191

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

    
3214
                                        CreateCommand.Instance.Execute(currentControl);
3215
                                        currentControl = null;
3216

    
3217
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3218
                                        {
3219
                                            controlType = ControlType.None;
3220
                                            IsSwingMode = false;
3221
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3222
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3223
                                            mouseHandlingMode = MouseHandlingMode.None;
3224
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3225
                                            txtBatch.Visibility = Visibility.Collapsed;
3226

    
3227
                                        }
3228
                                    }
3229
                                    else
3230
                                    {
3231
                                        currentControl = new DateControl
3232
                                        {
3233
                                            StartPoint = canvasDrawingMouseDownPoint,
3234
                                            Background = new SolidColorBrush(Colors.Black)
3235
                                        };
3236
                                        currentControl.CommentID = Commons.shortGuid();
3237
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3238
                                        currentControl.IsNew = true;
3239
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3240

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

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

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

    
3321
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3322
                                    currentControl.CommentID = Commons.shortGuid();
3323
                                    currentControl.IsNew = true;
3324
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3325
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3326

    
3327
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3328
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3329
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3330

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

    
3355
                                    CreateCommand.Instance.Execute(currentControl);
3356

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

    
3372
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3373
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3374
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3375
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3376
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3377

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

    
3381
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3382
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3383
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3384
                                        this.MainAngle.Visibility = Visibility.Visible;
3385

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

    
3404
                                    CreateCommand.Instance.Execute(currentControl);
3405

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

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

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

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

    
3473
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3474

    
3475
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3476

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

    
3507
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3508
                                }
3509
                                else
3510
                                {
3511
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3512
                                    //{
3513
                                    
3514

    
3515
                                    currentControl = new ArrowTextControl()
3516
                                    {
3517
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3518
                                        ControlType = ControlType.ArrowTransTextBorderControl
3519

    
3520
                                    };
3521
                                        currentControl.CommentID = Commons.shortGuid();
3522
                                        currentControl.IsNew = true;
3523
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3524
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3525

    
3526
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3527

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

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

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

    
3623
                                        };
3624
                                        currentControl.CommentID = Commons.shortGuid();
3625
                                        currentControl.IsNew = true; 
3626
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3627
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3628
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3629

    
3630
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3631
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3632
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3633
                                        (currentControl as ArrowTextControl).isFixed = true;
3634
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3635

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

    
3659
                                    if (_sign == null)
3660
                                    {
3661
                                        txtBatch.Visibility = Visibility.Collapsed;
3662
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3663
                                        controlType = ControlType.None;
3664

    
3665
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3666
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3667
                                        return;
3668
                                    }
3669

    
3670
                                    if (currentControl is SignControl)
3671
                                    {
3672
                                        //20180906 LJY TEST IsRotationDrawingEnable
3673
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3674
                                        {
3675
                                            return;
3676
                                        }
3677

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

    
3698
                                        currentControl.CommentID = Commons.shortGuid();
3699
                                        currentControl.IsNew = true;
3700
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3701
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3702

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

    
3724
                                        CreateCommand.Instance.Execute(currentControl);
3725
                                        (currentControl as RectangleControl).ApplyOverViewData();
3726
                                        currentControl = null;
3727
                                    
3728
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3729

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

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

    
3782
                                    currentControl.IsNew = true;
3783
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3784
                                    currentControl.CommentID = Commons.shortGuid();
3785
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3786

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

    
3808
                                        CreateCommand.Instance.Execute(currentControl);
3809
                                        currentControl = null;
3810
                                   
3811

    
3812
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3813
                                    }
3814
                                    else
3815
                                    {
3816
                                        currentControl = new SymControlN
3817
                                        {
3818
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3819
                                            Background = new SolidColorBrush(Colors.Black),
3820
                                            STAMP = App.SystemInfo.STAMP,                                            
3821
                                            ControlType = ControlType.Stamp
3822
                                        };
3823

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

    
3872
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3873
                            if (over != null)
3874
                            {
3875
                                mouseOff = true;
3876
                            }
3877
                        }
3878
                    }
3879

    
3880
                    if (!mouseOff)
3881
                    {
3882
                        SelectionSet.Instance.UnSelect(this);
3883
                    }
3884
                }
3885
                zoomAndPanControl.CaptureMouse();
3886
                e.Handled = true;
3887
            }
3888
          
3889
        }
3890

    
3891
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3892
        {
3893
            ///mouseButtonDown = e.ChangedButton;
3894
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3895
        }
3896

    
3897
        private void RemoveLineStroke(Point P)
3898
        {
3899
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3900
            if (control != null)
3901
            {
3902
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3903
            }
3904
        }
3905

    
3906
        private void RemovePointStroke(Point P)
3907
        {
3908
            foreach (Stroke hits in inkBoard.Strokes)
3909
            {
3910
                foreach (StylusPoint sty in hits.StylusPoints)
3911
                {
3912

    
3913
                }
3914
                if (hits.HitTest(P))
3915
                {
3916
                    inkBoard.Strokes.Remove(hits);
3917
                    return;
3918
                }
3919
            }
3920
        }
3921

    
3922
        private void StartNewStroke(Point P)
3923
        {
3924
            strokePoints = new StylusPointCollection();
3925
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3926
            strokePoints.Add(segment1Start);
3927
            stroke = new Stroke(strokePoints);
3928

    
3929
            stroke.DrawingAttributes.Color = Colors.Red;
3930
            stroke.DrawingAttributes.Width = 4;
3931
            stroke.DrawingAttributes.Height = 4;
3932

    
3933
            inkBoard.Strokes.Add(stroke);
3934
        }
3935

    
3936
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3937
        {
3938
            ConsolidationMethod();
3939
        }
3940

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

    
3954
                ViewerDataModel.Instance.IsConsolidate = true;
3955
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3956

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

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

    
3993
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3994
        {
3995
            if (App.ViewInfo != null)
3996
            {
3997
                btnConsolidate = (sender as RadRibbonButton);
3998
                if (!App.ViewInfo.NewCommentPermission)
3999
                {
4000
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4001
                }
4002
            }
4003
        }
4004

    
4005
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4006
        {
4007
            TeamConsolidationMethod();
4008
        }
4009

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

    
4022
                    if (!App.ViewInfo.NewCommentPermission)
4023
                    {
4024
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4025
                    }
4026
                }
4027
                else
4028
                {
4029
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4030
                }
4031
            }
4032
        }
4033

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

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

    
4071
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4072
        {
4073
            UpdateMyMarkupList();
4074

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

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

    
4098
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4099
                if (item2 != null)
4100
                {
4101
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4102

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

    
4113
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4114
        {
4115
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4116

    
4117
            if (App.ViewInfo != null)
4118
            {
4119
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4120
                {
4121
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4122
                }
4123
            }
4124
        }
4125

    
4126
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4127
        {
4128
            if (CompareMode.IsChecked)
4129
            {
4130
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4131
                {
4132
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4133
                }
4134
                if (ViewerDataModel.Instance.PageNumber == 0)
4135
                {
4136
                    ViewerDataModel.Instance.PageNumber = 1;
4137
                }
4138

    
4139
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4140
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4141
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4142

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

    
4156
        private void Sync_Click(object sender, RoutedEventArgs e)
4157
        {
4158
            if (Sync.IsChecked)
4159
            {
4160
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4161
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4162
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4163
            }
4164
        }
4165

    
4166
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4167
        {
4168
            if (UserList.IsChecked)
4169
            {
4170
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4171
            }
4172
            else
4173
            {
4174
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4175
            }
4176
        }
4177

    
4178
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4179
        {
4180

    
4181
            if (BalanceMode.IsChecked)
4182
            {
4183
                ViewerDataModel.Instance.PageBalanceMode = true;
4184
            }
4185
            else
4186
            {
4187
                ViewerDataModel.Instance.PageBalanceMode = false;
4188
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4189
            }
4190
        }
4191

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

    
4205
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4206
        {
4207
            if ((sender as System.Windows.Controls.Control).Tag != null)
4208
            {
4209
                //Compare 초기화
4210
                CompareMode.IsChecked = false;
4211
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4212

    
4213
                if (ViewerDataModel.Instance.PageNumber == 0)
4214
                {
4215
                    ViewerDataModel.Instance.PageNumber = 1;
4216
                }
4217

    
4218
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4219
                {
4220
                }
4221
                else
4222
                {
4223
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4224
                }
4225

    
4226
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4227
                {
4228

    
4229
                }
4230
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4231
                {
4232
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4233
                }
4234

    
4235
                if (!testPanel2.IsHidden)
4236
                {
4237
                    if (IsSyncPDFMode)
4238
                    {
4239
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4240
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4241

    
4242
                        if (pdfpath.IsDownloading)
4243
                        {
4244
                            pdfpath.DownloadCompleted += (ex, arg) =>
4245
                            {
4246
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4247
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4248
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4249
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4250
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4251
                            };
4252
                        }
4253
                        else
4254
                        {
4255
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4256
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4257
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4258

    
4259
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4260
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4261
                        }
4262

    
4263
                    }
4264
                    else
4265
                    {
4266
                        string uri = this.GetImageURL(_ViewInfo.ProjectNO, ViewerDataModel.Instance.PageNumber);
4267

    
4268
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4269

    
4270
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4271
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4272
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4273

    
4274
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4275
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4276

    
4277
                        if (defaultBitmapImage_Compare.IsDownloading)
4278
                        {
4279
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4280
                            {
4281
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4282
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4283
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4284

    
4285
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4286
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4287
                            };
4288
                        }
4289
                    }
4290

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

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

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

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

    
4314
                }
4315
            }
4316
        }
4317

    
4318
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4319
        {
4320
            if (MarkupMode.IsChecked)
4321
            {
4322
                IsSyncPDFMode = true;
4323

    
4324
                var uri = CurrentRev.TO_VENDOR;
4325

    
4326
                if (ViewerDataModel.Instance.PageNumber == 0)
4327
                {
4328
                    ViewerDataModel.Instance.PageNumber = 1;
4329
                }
4330

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

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

    
4352
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4353
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4354
                }
4355
            }
4356
            else
4357
            {
4358
                IsSyncPDFMode = false;
4359
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4360

    
4361
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4362

    
4363
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4364
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4365
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4366

    
4367
                if (defaultBitmapImage_Compare.IsDownloading)
4368
                {
4369
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4370
                    {
4371
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4372
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4373
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4374
                    };
4375
                }
4376
                zoomAndPanControl2.ApplyTemplate();
4377
                zoomAndPanControl2.UpdateLayout();
4378
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4379
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4380
            }
4381
        }
4382

    
4383
        private void RadButton_Click(object sender, RoutedEventArgs e)
4384
        {
4385
            gridViewHistory_Busy.IsBusy = true;
4386

    
4387
            RadButton instance = sender as RadButton;
4388
            if (instance.CommandParameter != null)
4389
            {
4390
                CurrentRev = instance.CommandParameter as VPRevision;
4391
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4392
                {
4393
                    if (ea.Error == null && ea.Result != null)
4394
                    {
4395
                        testPanel2.IsHidden = false;
4396

    
4397
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4398
                        foreach(var info in ea.Result)
4399
                        {
4400
                            if(info.UserID == App.ViewInfo.UserID)
4401
                            {
4402
                                info.userDelete = true;
4403
                                info.DisplayColor = "FFFF0000";
4404
                            }
4405
                            else
4406
                            {
4407
                                info.userDelete = false;
4408
                            }
4409
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4410
                        }
4411
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4412

    
4413
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4414

    
4415
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4416

    
4417
                        var defaultBitmapImage_Compare = new BitmapImage();
4418
                        defaultBitmapImage_Compare.BeginInit();
4419
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4420
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4421
                        defaultBitmapImage_Compare.EndInit();
4422

    
4423
                        if (defaultBitmapImage_Compare.IsDownloading)
4424
                        {
4425
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4426
                            {
4427
                                defaultBitmapImage_Compare.Freeze();
4428
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4429
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4430
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4431
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4432
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4433
                            };
4434
                        }                        
4435
                        zoomAndPanControl2.ApplyTemplate();
4436
                        zoomAndPanControl2.UpdateLayout();
4437
                        //syncPannelRotate(zoomAndPanControl.RotationAngle);
4438
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4439
                        {
4440
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4441
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4442
                        }
4443

    
4444
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4445
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4446
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4447

    
4448
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4449
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4450
                        gridViewHistory_Busy.IsBusy = false;
4451
                    }
4452

    
4453
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4454
                };
4455
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4456
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4457
            }
4458
        }
4459

    
4460
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4461
        {
4462
            try
4463
            {
4464
                if (sender is RadButton)
4465
                {
4466
                    if ((sender as RadButton).Tag != null)
4467
                    {
4468
                        var url = (sender as RadButton).Tag.ToString();
4469
                        System.Diagnostics.Process.Start(url);
4470
                    }
4471
                    else
4472
                    {
4473
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4474
                    }
4475
                }
4476
            }
4477
            catch (Exception ex)
4478
            {
4479
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4480
            }
4481
        }
4482

    
4483
        public void Sync_Event(VPRevision Currnet_Rev)
4484
        {
4485
            CurrentRev = Currnet_Rev;
4486

    
4487
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4488
            {
4489
                if (ea.Error == null && ea.Result != null)
4490
                {
4491
                    testPanel2.IsHidden = false;
4492

    
4493
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4494
                    foreach(var info in ea.Result)
4495
                    {
4496
                        if(info.UserID == App.ViewInfo.UserID)
4497
                        {
4498
                            info.userDelete = true;
4499
                            info.DisplayColor = "FFFF0000";
4500
                        }
4501
                        else
4502
                        {
4503
                            info.userDelete = false;
4504
                        }
4505
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4506
                    }
4507
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4508

    
4509
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4510

    
4511
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4512

    
4513
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4514

    
4515
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4516
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4517
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4518

    
4519
                    if (defaultBitmapImage_Compare.IsDownloading)
4520
                    {
4521
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4522
                        {
4523
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4524
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4525
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4526
                        };
4527
                    }
4528

    
4529

    
4530
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4531
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4532
                    zoomAndPanControl2.ApplyTemplate();
4533
                    zoomAndPanControl2.UpdateLayout();
4534

    
4535
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4536
                    {
4537
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4538
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4539
                    }
4540
                    //}
4541

    
4542
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4543
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4544
                    gridViewHistory_Busy.IsBusy = false;
4545
                }
4546
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4547

    
4548
            };
4549
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4550
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4551
        }
4552

    
4553
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4554
        {
4555
            if (sender is Image)
4556
            {
4557
                if ((sender as Image).Tag != null)
4558
                {
4559
                    var pdfUrl = (sender as Image).Tag.ToString();
4560
                    System.Diagnostics.Process.Start(pdfUrl);
4561
                }
4562
                else
4563
                {
4564
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4565
                }
4566
            }
4567
        }
4568

    
4569
        private void Create_Symbol(object sender, RoutedEventArgs e)
4570
        {
4571
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4572

    
4573
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4574
            {
4575
                DialogMessage_Alert("Please Select Controls", "Alert");
4576
            }
4577
            else //선택된 것이 있으면
4578
            {
4579
                string MarkupData = "";
4580
                adorner_ = new AdornerFinal();
4581

    
4582
                foreach (var item in SelectLayer.Children)
4583
                {
4584
                    if (item.GetType().Name == "AdornerFinal")
4585
                    {
4586
                        adorner_ = (item as Controls.AdornerFinal);
4587
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4588
                        {
4589
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4590
                            {
4591
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4592
                                MarkupData += markupReturn.ConvertData;
4593
                            }
4594
                        }
4595
                    }
4596
                }
4597
                DialogParameters parameters = new DialogParameters()
4598
                {
4599
                    Owner = Application.Current.MainWindow,
4600
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4601
                    DefaultPromptResultValue = "Custom State",
4602
                    Content = "Name :",
4603
                    Header = "Insert Custom Symbol Name",
4604
                    Theme = new VisualStudio2013Theme(),
4605
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4606
                };
4607
                RadWindow.Prompt(parameters);
4608
            }
4609

    
4610
        }
4611
        public int symbolselectindex = 0;
4612
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4613
        {
4614
            //Save save = new Save();
4615
            try
4616
            {
4617
                string svgfilename = null;
4618
                if (symbolname != null)
4619
                {
4620
                    if (symbolpng == true || symbolsvg == true)
4621
                    {
4622
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4623
                        string guid = Commons.shortGuid();
4624

    
4625
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4626
                        //Check_Uri.UriCheck();
4627
                        fileUploader.RunCompleted += (ex, arg) =>
4628
                        {
4629
                            filename = arg.Result;
4630
                            if (symbolpng == true)
4631
                            {
4632
                                if (filename != null)
4633
                                { 
4634
                                    if (symbolselectindex == 0)
4635
                                    {
4636
                                        SymbolSave(symbolname, filename, data);
4637
                                    }
4638
                                    else
4639
                                    {
4640
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4641
                                    }
4642
                                    DataBind();
4643
                                }                                
4644
                            }
4645

    
4646
                            if (symbolsvg == true)
4647
                            {
4648
                                try
4649
                                {
4650
                                    var defaultBitmapImage = new BitmapImage();
4651
                                    defaultBitmapImage.BeginInit();
4652
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4653
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4654
                                    Check_Uri.UriCheck(filename);
4655
                                    defaultBitmapImage.UriSource = new Uri(filename);
4656
                                    defaultBitmapImage.EndInit();
4657

    
4658
                                    System.Drawing.Bitmap image;
4659

    
4660
                                    if (defaultBitmapImage.IsDownloading)
4661
                                    {
4662
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4663
                                        {
4664
                                            defaultBitmapImage.Freeze();
4665
                                            image = GetBitmap(defaultBitmapImage);
4666
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4667
                                            Process potrace = new Process
4668
                                            {
4669
                                                StartInfo = new ProcessStartInfo
4670
                                                {
4671
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4672
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4673
                                                    RedirectStandardInput = true,
4674
                                                    RedirectStandardOutput = true,
4675
                                                    RedirectStandardError = true,
4676
                                                    UseShellExecute = false,
4677
                                                    CreateNoWindow = true,
4678
                                                    WindowStyle = ProcessWindowStyle.Hidden
4679
                                                },
4680
                                            };
4681

    
4682
                                            StringBuilder svgBuilder = new StringBuilder();
4683
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4684
                                            {
4685
                                                svgBuilder.AppendLine(e2.Data);
4686
                                            };
4687

    
4688
                                            potrace.EnableRaisingEvents = true;
4689
                                            potrace.Start();
4690
                                            potrace.Exited += (sender, e) =>
4691
                                            {
4692
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4693
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4694
                                                Check_Uri.UriCheck(svgfilename);
4695
                                                if (symbolselectindex == 0)
4696
                                                {
4697
                                                    SymbolSave(symbolname, svgfilename, data);
4698
                                                }
4699
                                                else
4700
                                                {
4701
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4702
                                                }
4703

    
4704
                                                DataBind();
4705
                                            };
4706
                                            potrace.WaitForExit();
4707
                                        };
4708
                                    }
4709
                                    else
4710
                                    {
4711
                                        //GC.Collect();
4712
                                    }
4713
                                }
4714
                                catch(Exception ee)
4715
                                {
4716
                                    DialogMessage_Alert("" + ee, "Alert");
4717
                                }
4718
                            }
4719
                        };                                             
4720
                    }
4721
                }
4722
            }
4723
            catch (Exception e)
4724
            {
4725
                //DialogMessage_Alert(e + "", "Alert");
4726
            }            
4727
        }
4728

    
4729
        public void SymbolSave(string Name, string Url, string Data)
4730
        {
4731
            try
4732
            {
4733
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4734
                {
4735
                    ID = Commons.shortGuid(),
4736
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4737
                    NAME = Name,
4738
                    IMAGE_URL = Url,
4739
                    DATA = Data
4740
                };
4741

    
4742
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4743
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4744
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4745
            }
4746
            catch (Exception)
4747
            {
4748
                throw;
4749
            }
4750
        }
4751

    
4752
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4753
        {
4754
            try
4755
            {
4756
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4757
                {
4758
                    ID = Commons.shortGuid(),
4759
                    DEPARTMENT = Department,
4760
                    NAME = Name,
4761
                    IMAGE_URL = Url,
4762
                    DATA = Data
4763
                };
4764
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4765
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4766
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4767
            }
4768
            catch (Exception)
4769
            {
4770
                throw;
4771
            }
4772
        }
4773

    
4774
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4775
        {           
4776
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4777
            DataBind();
4778
        }
4779

    
4780
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4781
        {
4782
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4783
            DataBind();
4784
        }
4785
        private void DataBind()
4786
        {
4787
            try
4788
            {
4789
                Symbol_Custom Custom = new Symbol_Custom();
4790
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4791
                
4792
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4793
                foreach (var item in symbol_Private)
4794
                {
4795
                    Custom.Name = item.NAME;
4796
                    Custom.ImageUri = item.IMAGE_URL;
4797
                    Custom.ID = item.ID;
4798
                    Custom_List.Add(Custom);
4799
                    Custom = new Symbol_Custom();
4800
                }
4801
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4802
                
4803
                Custom = new Symbol_Custom();
4804
                Custom_List = new List<Symbol_Custom>();
4805

    
4806
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4807

    
4808
                List<SYMBOL_PUBLIC> symbol_Public;
4809

    
4810
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4811
                {
4812
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4813
                }
4814
                else
4815
                {
4816
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4817
                }
4818
                foreach (var item in symbol_Public)
4819
                {
4820
                    Custom.Name = item.NAME;
4821
                    Custom.ImageUri = item.IMAGE_URL;
4822
                    Custom.ID = item.ID;
4823
                    Custom_List.Add(Custom);
4824
                    Custom = new Symbol_Custom();
4825
                }
4826
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4827
                BaseClient.Close();                
4828
            }
4829
            catch(Exception e)
4830
            {
4831
                //DialogMessage_Alert("DataBind", "Alert");
4832
            }
4833
            
4834
        }
4835
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4836
        {
4837
            try
4838
            {
4839
                if (args.PromptResult != null)
4840
                {
4841
                    if (args.DialogResult.Value)
4842
                    {
4843
                        PngBitmapEncoder _Encoder = symImage(data);
4844

    
4845
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4846
                        _Encoder.Save(fs);
4847
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4848

    
4849
                        byte[] Img_byte = fs.ToArray();
4850

    
4851
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4852
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4853
                        Check_Uri.UriCheck(filename);
4854
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4855
                        {
4856
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4857
                        }
4858
                        else
4859
                        {
4860
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4861
                        }
4862
                        DataBind();
4863
                    }
4864
                }
4865
            }
4866
            catch(Exception ex)
4867
            {
4868
                DialogMessage_Alert("" + ex, "Alert");
4869
            }
4870
        }
4871

    
4872
        public PngBitmapEncoder symImage(string data)
4873
        {
4874

    
4875
            Canvas _canvas = new Canvas();
4876
            _canvas.Background = Brushes.White;
4877
            _canvas.Width = adorner_.BorderSize.Width;
4878
            _canvas.Height = adorner_.BorderSize.Height;
4879
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4880

    
4881
            BitmapEncoder encoder = new PngBitmapEncoder();
4882

    
4883

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

    
4886
            DrawingVisual dv = new DrawingVisual();
4887

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

    
4891
            using (DrawingContext ctx = dv.RenderOpen())
4892
            {
4893
                VisualBrush vb = new VisualBrush(_canvas);
4894
                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)));
4895
            }
4896

    
4897
            try
4898
            {
4899
                renderBitmap.Render(dv);
4900

    
4901
                //GC.Collect();
4902
                GC.WaitForPendingFinalizers();
4903
                //GC.Collect();
4904
                // encode png data
4905
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4906
                // puch rendered bitmap into it
4907
                pngEncoder.Interlace = PngInterlaceOption.Off;
4908
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4909
                return pngEncoder;
4910

    
4911
            }
4912
            catch //(Exception ex)
4913
            {
4914
                return null;
4915
            }
4916

    
4917
        }
4918

    
4919
        public void DialogMessage_Alert(string content, string header)
4920
        {
4921
            DialogParameters parameters = new DialogParameters()
4922
            {
4923
                Owner = this.ParentOfType<MainWindow>(),
4924
                Content = new TextBlock()
4925
                { 
4926
                    MinWidth = 400,
4927
                    FontSize = 11,
4928
                    Text = content,
4929
                    TextWrapping = System.Windows.TextWrapping.Wrap
4930
                },
4931
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
4932
                Header = header,
4933
                Theme = new VisualStudio2013Theme(),
4934
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4935
            };            
4936
            RadWindow.Alert(parameters);
4937
        }
4938

    
4939
        #region 캡쳐 기능
4940

    
4941
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4942
        {
4943
            if (x < 0)
4944
            {
4945
                width += x;
4946
                x = 0;
4947
            }
4948
            if (y < 0)
4949
            {
4950
                height += y;
4951
                y = 0;
4952

    
4953
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4954
            }
4955
            if (x + width > zoomAndPanCanvas.ActualWidth)
4956
            {
4957
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4958
            }
4959
            if (y + height > zoomAndPanCanvas.ActualHeight)
4960
            {
4961
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4962
            }
4963

    
4964
            byte[] pixels = CopyPixels(x, y, width, height);
4965

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

    
4968
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4969
        }
4970

    
4971
        public byte[] CopyPixels(int x, int y, int width, int height)
4972
        {
4973
            byte[] pixels = new byte[width * height * 4];
4974
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4975

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

    
4979
            return pixels;
4980
        }
4981

    
4982
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4983
        {
4984
            DrawingVisual drawingVisual = new DrawingVisual();
4985
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4986

    
4987
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4988
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4989
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4990
            drawingContext.Close();
4991

    
4992
            // 비트맵으로 변환합니다.
4993
            RenderTargetBitmap target =
4994
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4995
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4996

    
4997
            target.Render(drawingVisual);
4998
            return target;
4999
        }
5000

    
5001
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5002
        {
5003
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5004
            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);
5005
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5006
            bmp.UnlockBits(data);
5007
            return bmp;
5008
        }
5009
        public string symbolname = null;
5010
        public bool symbolsvg = true;
5011
        public bool symbolpng = true;
5012

    
5013
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5014
        {
5015
            System.Drawing.Bitmap image = GetBitmap(source);
5016
            //흰색 제거
5017
            //image.MakeTransparent(System.Drawing.Color.White);
5018

    
5019
            var imageStream = new System.IO.MemoryStream();
5020
            byte[] imageBytes = null;
5021
            using (imageStream)
5022
            {
5023
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5024
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5025
                imageStream.Position = 0;
5026
                imageBytes = imageStream.ToArray();
5027
            }
5028

    
5029
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5030

    
5031
            RadWindow CheckPop = new RadWindow();
5032
            //Alert check = new Alert(Msg);
5033

    
5034
            CheckPop = new RadWindow
5035
            {
5036
                MinWidth = 400,
5037
                MinHeight = 100,
5038
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5039
                Header = "Alert",
5040
                Content = symbolPrompt,
5041
                //DialogResult = 
5042
                ResizeMode = System.Windows.ResizeMode.NoResize,
5043
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5044
                IsTopmost = true,
5045
            };
5046
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5047
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5048
            CheckPop.ShowDialog();
5049

    
5050
            /*
5051
            DialogParameters parameters = new DialogParameters()
5052
            {
5053
                Owner = Application.Current.MainWindow,
5054
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5055
                DefaultPromptResultValue = "Custom State",
5056
                Content = "Name :",
5057
                Header = "Insert Custom Symbol Name",
5058
                Theme = new VisualStudio2013Theme(),
5059
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5060
            };            
5061
            RadWindow.Prompt(parameters);
5062
            */
5063
        }
5064

    
5065
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5066
        {
5067
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5068
            KCOMDataModel.DataModel.CHECK_LIST check_;
5069
            string Result = streamToBase64.ImageToBase64(source);
5070
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5071
            string projectno = App.ViewInfo.ProjectNO;
5072
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5073

    
5074
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5075
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5076
            if (Item != null)
5077
            {
5078
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5079
            }
5080
            else
5081
            {
5082
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5083
            }
5084

    
5085
            if (Item == null)
5086
            {
5087
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5088
                {
5089
                    ID = Commons.shortGuid(),
5090
                    USER_ID = App.ViewInfo.UserID,
5091
                    IMAGE_URL = Result,
5092
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5093
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5094
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5095
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5096
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5097
                    STATUS = "False",
5098
                    CREATE_TIME = DateTime.Now,
5099
                    UPDATE_TIME = DateTime.Now,
5100
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5101
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5102
                };
5103
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5104
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5105
                //this.BaseClient.AddCheckList(projectno, check_);
5106
            }
5107
            else
5108
            {
5109
                Item.IMAGE_URL = Result;
5110
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5111
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5112
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5113
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5114
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5115
            }
5116

    
5117
        }
5118

    
5119
        public void Set_Capture()
5120
        {
5121
            double x = canvasDrawingMouseDownPoint.X;
5122
            double y = canvasDrawingMouseDownPoint.Y;
5123
            double width = dragCaptureBorder.Width;
5124
            double height = dragCaptureBorder.Height;
5125

    
5126
            if (width > 5 || height > 5)
5127
            {
5128
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5129
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5130
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5131
            }
5132
        }
5133
        #endregion
5134

    
5135
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5136
        {
5137
            multi_Undo_Data = new Multi_Undo_data();
5138

    
5139
            multi_Undo_Data.Markup = control;
5140

    
5141
            if ((control as IShapeControl) != null)
5142
            {
5143
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5144
            }
5145
            if ((control as IDashControl) != null)
5146
            {
5147
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5148
            }
5149
            if ((control as IPath) != null)
5150
            {
5151
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5152
            }
5153
            if ((control as UIElement) != null)
5154
            {
5155
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5156
            }
5157

    
5158
            return multi_Undo_Data;
5159
        }
5160

    
5161
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5162
        {
5163
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5164
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5165
            {
5166
                if (items.UserID == Select_ID)
5167
                {
5168
                    foreach (var item in items.MarkupList)
5169
                    {
5170
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5171
                        {
5172
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5173
                                items.MarkupInfoID, Commons.shortGuid());
5174
                        }
5175
                    }
5176
                }
5177
            }
5178
        }
5179

    
5180
        /// <summary>
5181
        /// convert inkcontrol to polygoncontrol
5182
        /// </summary>
5183
        public void ConvertInkControlToPolygon()
5184
        {
5185
            if (inkBoard.Strokes.Count > 0)
5186
            {
5187
                inkBoard.Strokes.ToList().ForEach(stroke =>
5188
                {
5189
                    InkToPath ip = new InkToPath();
5190

    
5191
                    List<Point> inkPointSet = new List<Point>();
5192
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5193

    
5194
                    PolygonControl pc = new PolygonControl()
5195
                    {
5196
                        Angle = 0,
5197
                        PointSet = inkPointSet,
5198
                        ControlType = ControlType.Ink
5199
                    };
5200
                    pc.StartPoint = inkPointSet[0];
5201
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5202
                    pc.LineSize = 3;
5203
                    pc.CommentID = Commons.shortGuid();
5204
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5205

    
5206
                    if (pc.PointSet.Count > 0)
5207
                    {
5208
                        CreateCommand.Instance.Execute(pc);
5209
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5210
                    }
5211
                });
5212
                inkBoard.Strokes.Clear();
5213
            }
5214
        }
5215

    
5216
        /// <summary>
5217
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5218
        /// </summary>
5219
        /// <author>ingu</author>
5220
        /// <date>2018.06.05</date>
5221
        /// <param name="getPoint"></param>
5222
        /// <returns></returns>
5223
        private bool IsGetoutpoint(Point getPoint)
5224
        {
5225
            if (getPoint == new Point())
5226
            {
5227
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5228
                currentControl = null;
5229
                return true;
5230
            }
5231

    
5232
            return false;
5233
        }
5234

    
5235
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5236
        {
5237
            e.Effects = DragDropEffects.Copy;
5238
        }
5239

    
5240
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5241
        {
5242
            e.Effects = DragDropEffects.Copy;
5243
        }
5244

    
5245
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5246
        {
5247
            e.Effects = DragDropEffects.None;
5248
        }
5249

    
5250
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5251
        {
5252
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5253
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5254

    
5255
            ScaleImage(pageWidth, pageHeight);
5256
        }
5257

    
5258
        /// <summary>
5259
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5260
        /// </summary>
5261
        /// <param name="pageWidth">원본 사이즈</param>
5262
        /// <param name="pageHeight">원본 사이즈</param>
5263
        /// <returns></returns>
5264
        private void ScaleImage(double pageWidth,double pageHeight)
5265
        {
5266
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5267
        }
5268

    
5269
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5270
        {
5271
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5272
        }
5273

    
5274

    
5275
        /*
5276
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5277
        {
5278
            try
5279
            {
5280
                if (e.Data.GetDataPresent(typeof(string)))
5281
                {
5282
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5283
                    string dragData = e.Data.GetData(typeof(string)) as string;
5284
                    Move_Symbol(sender, dragData);
5285
                }
5286
            }
5287
            catch (Exception ex)
5288
            {
5289
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5290
            }            
5291
        }
5292
        */
5293
    }
5294
}
클립보드 이미지 추가 (최대 크기: 500 MB)