프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
180
                }
181
            }
182
        }
183

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

    
208
        public bool IsSyncPDFMode { get; set; }
209

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

    
234
        #endregion
235

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

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

    
249
            //lstSymbolPrivate.ItemsSource = testItems;
250

    
251
            this.Loaded += MainMenu_Loaded;
252
        }
253

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

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

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

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

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

    
291
            return uri;
292
        }
293

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

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

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

    
335
            return false;
336
        }
337

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

    
361
            return false;
362
        }
363

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
499
        }
500

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

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

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

    
520
                    await task;
521

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

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

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

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

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

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

    
589
            if(this.pageNavigator.CurrentPage != null)
590
            { 
591
                /// delete markup list
592
                int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
593

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

    
599
                foreach (var markup in deleted)
600
                {
601
                    ViewerDataModel.Instance.MyMarkupList.Remove(markup);
602
                }
603
            }
604
            else
605
            {
606
                System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
607
            }
608

    
609
            /// up to here
610

    
611
            //if (modified)
612
            //{
613
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
614
            //    {
615
            //        ComingNewBieEnd = true;
616
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
617
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
618
            //        gridViewMarkup.ItemsSource = null;
619
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
620
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
621

    
622
            //        GroupDescriptor descriptor = new GroupDescriptor();
623
            //        descriptor.Member = "Depatment";
624
            //        descriptor.DisplayContent = "DEPT";
625
            //        descriptor.SortDirection = ListSortDirection.Ascending;
626
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
627
            //    }
628
            //}
629
        }
630

    
631
        DispatcherTimer renderTesttimer;
632

    
633
        /// <summary>
634
        /// start page changing
635
        ///  - save controls if page is modified
636
        ///  - starting download page image
637
        /// </summary>
638
        /// <param name="sender"></param>
639
        /// <param name="e"></param>
640
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
641
        {
642
            await Task.Delay(10);
643

    
644
            // 마크업 로드
645
            //await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
646
            await MarkupLoadAsync(e.PageNumber);
647

    
648
            // 페이지 이미지 변경
649
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
650
        }
651

    
652
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber)
653
        { 
654
            CompareMode.IsChecked = false;
655
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
656
           
657
            #region 페이지가 벗어난 경우
658

    
659
            if (BalancePoint < 1)
660
            {
661
                BalancePoint = 1;
662
                ViewerDataModel.Instance.PageBalanceNumber = 0;
663
            }
664

    
665
            if (pageNavigator.PageCount < BalancePoint)
666
            {
667
                BalancePoint = pageNavigator.PageCount;
668
                ViewerDataModel.Instance.PageBalanceNumber = 0;
669
            }
670

    
671
            #endregion
672

    
673
            ViewerDataModel.Instance.PageNumber = BalancePoint;
674

    
675
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
676
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
677
            var contentScale = zoomAndPanControl.ContentScale;
678

    
679
            #region 페이지 이미지 로딩 수정
680

    
681
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(changePageNumber);
682
       
683
            ScaleImage(pageWidth, pageHeight);
684

    
685
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
686
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
687

    
688
            zoomAndPanCanvas.Width = pageWidth;
689
            zoomAndPanCanvas.Height = pageHeight;
690

    
691
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
692
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
693

    
694
            inkBoard.Width = pageWidth;
695
            inkBoard.Height = pageHeight;
696

    
697
            #endregion
698

    
699
            if (!testPanel2.IsHidden)
700
            {
701
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
702
                //PDF모드일때 잠시 대기(강인구)
703
                if (IsSyncPDFMode)
704
                {
705
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
706
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
707

    
708
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
709
                    if (pdfpath.IsDownloading)
710
                    {
711
                        pdfpath.DownloadCompleted += (ex, arg) =>
712
                        {
713
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
714
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
715
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
716
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
717
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
718
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
719
                        };
720
                    }
721
                    else
722
                    {
723
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
724
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
725
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
726
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
727

    
728
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
729
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
730
                    }
731
                }
732
                else
733
                {
734
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
735
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
736

    
737
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
738
                    var defaultBitmapImage_Compare = new BitmapImage();
739
                    defaultBitmapImage_Compare.BeginInit();
740
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
741
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
742
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
743
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
744
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
745
                    defaultBitmapImage_Compare.EndInit();
746

    
747
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
748

    
749
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
750
                    zoomAndPanControl.ZoomTo(new Rect
751
                    {
752
                        X = 0,
753
                        Y = 0,
754
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
755
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
756
                    });
757

    
758
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
759
                    if (defaultBitmapImage_Compare.IsDownloading)
760
                    {
761
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
762
                        {
763
                            defaultBitmapImage_Compare.Freeze();
764
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
765
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
766
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
767
                            ComparePanel.UpdateLayout();
768
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
769
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
770

    
771
                            zoomAndPanControl.ZoomTo(new Rect
772
                            {
773
                                X = 0,
774
                                Y = 0,
775
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
776
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
777
                            });
778

    
779
                            //defaultBitmapImage_Compare dispose
780
                            defaultBitmapImage_Compare = null;
781
                            GC.Collect();
782
                        };
783
                    }
784
                }
785
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
786
            }
787

    
788
            SearchFocusBorder.Visibility = Visibility.Collapsed;
789

    
790
            this.pageNavigator.ChangePage(changePageNumber);
791
        }
792

    
793
        /// <summary>
794
        /// called after page is changed
795
        /// </summary>
796
        /// <param name="sender"></param>
797
        /// <param name="e"></param>
798
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
799
        {
800
            //if (zoomAndPanCanvas.Width.IsNaN())
801
            //{
802

    
803
            await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
804
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
805
                );
806
            //}
807
            
808
            var instanceMain = ViewerDataModel.Instance.SystemMain;
809

    
810
            instanceMain.dzMainMenu.CanvasDrawingMouseDownPoint = new Point(ViewerDataModel.Instance.ImageViewWidth / 2, ViewerDataModel.Instance.ImageViewHeight / 2);
811

    
812
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
813
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
814

    
815
            instanceMain.dzTopMenu.rotateOffSet = 0;
816
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
817
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
818

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

    
823
            //Point startPoint = new Point(15, 15);
824

    
825
            
826
            //var markupinfo = ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID).First();
827

    
828
            ////var rect = GetRectControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID, startPoint);
829

    
830
            ////var txtApproved = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID,
831
            ////                             "APPROVED",30, FontWeights.Bold, TextAlignment.Center, rect.ItemRect, 15);
832

    
833
            ////var txtCreator = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
834
            ////                , "By HYOSUNG", 18, FontWeights.Bold, TextAlignment.Center, rect.ItemRect, txtApproved.StartPoint.Y + txtApproved.BoxHeight + 3);
835

    
836
            //var symCtrl = GetSymNControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID, startPoint);
837

    
838
            //var bottom = Rect.Offset(symCtrl.ItemRect, new Vector(0, symCtrl.ItemRect.Height));
839

    
840
            //var txtOriginator = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
841
            //               , App.ViewInfo.UserID, 18, FontWeights.Bold, TextAlignment.Left, bottom, bottom.Top + 3);
842

    
843
            //var dtfi = new System.Globalization.DateTimeFormatInfo { DateSeparator = "-", ShortDatePattern = @"yyyy/MM/dd" };
844

    
845
            //var txtDate = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
846
            //               , DateTime.Now.ToString("d", dtfi), 18, FontWeights.Bold, TextAlignment.Left, bottom, txtOriginator.StartPoint.Y + txtOriginator.BoxHeight + 2);
847

    
848
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
849
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
850
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
851
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
852
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
853

    
854
            //symCtrl.ApplyTemplate();
855
            ////txtApproved.ApplyTemplate();
856
            ////txtCreator.ApplyTemplate();
857
            //txtOriginator.ApplyTemplate();
858
            //txtDate.ApplyTemplate();
859

    
860
            ////SetTextControl(txtApproved);
861
            ////SetTextControl(txtCreator);
862
            //SetTextControl(txtOriginator);
863
            //SetTextControl(txtDate);
864

    
865
            //multi_Undo_Data = new Multi_Undo_data();
866

    
867
            //MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
868
            //{
869
            //    IsUndo = false,
870
            //    Event = Event_Type.Create,
871
            //    EventTime = DateTime.Now,
872
            //    Markup_List = new List<Multi_Undo_data>()
873
            //};
874

    
875
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
876
            //UndoData.Markup_List.Add(multi_Undo_Data);
877

    
878
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtApproved as MarkupToPDF.Common.CommentUserInfo);
879
            ////UndoData.Markup_List.Add(multi_Undo_Data);
880

    
881
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
882
            ////UndoData.Markup_List.Add(multi_Undo_Data);
883

    
884
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
885
            //UndoData.Markup_List.Add(multi_Undo_Data);
886

    
887
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
888
            //UndoData.Markup_List.Add(multi_Undo_Data);
889

    
890
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
891

    
892
            //System.Diagnostics.Debug.WriteLine(symCtrl.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
893
            ////System.Diagnostics.Debug.WriteLine(txtApproved.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
894
            ////System.Diagnostics.Debug.WriteLine(txtCreator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
895
            //System.Diagnostics.Debug.WriteLine(txtOriginator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
896
            //System.Diagnostics.Debug.WriteLine(txtDate.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
897
        }
898

    
899
        private void SetTextControl(TextControl textControl)
900
        {
901
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
902
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
903
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
904

    
905
        }
906

    
907
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
908
        {
909
            SymControlN result = null;
910

    
911
            try
912
            {
913
                double height = 80;
914
                double itemWidth = 180;
915

    
916
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
917
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
918
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
919
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
920

    
921
                result = new SymControlN
922
                {
923
                    CommentID = Commons.shortGuid(),
924
                    MarkupInfoID = markupInfoId,
925
                    UserID = userId,
926
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
927
                    StartPoint = startPoint,
928
                    EndPoint = endPoint,
929
                    CommentAngle = 0,
930
                    LeftBottomPoint = leftBottomPoint,
931
                    TopRightPoint = topRightPoint,
932
                    Opacity = 1,
933
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
934
                    Memo = null
935
                };
936

    
937
            }
938
            catch (Exception ex)
939
            {
940
                System.Diagnostics.Debug.WriteLine(ex.ToString());
941
            }
942

    
943
            return result;
944
        }
945

    
946
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId,string markupInfoId, Point startPosition)
947
        {
948
            RectangleControl result = null;
949

    
950
            try
951
            {
952
                double height = 80;
953
                double itemWidth = 180;
954

    
955
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
956
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
957
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
958
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
959

    
960
                result = new RectangleControl
961
                {
962
                    CommentID = Commons.shortGuid(),
963
                    MarkupInfoID = markupInfoId,
964
                    LineSize = 5,
965
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
966
                    StartPoint = startPoint,
967
                    EndPoint = endPoint,
968
                    CommentAngle = 0,
969
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
970
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
971
                    FillColor = null,
972
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
973
                    Opacity = 1,
974
                    LeftBottomPoint = leftBottomPoint,
975
                    TopRightPoint = topRightPoint,
976
                    PointSet = new List<Point> { startPoint,leftBottomPoint,endPoint,topRightPoint },
977
                    UserID = userId,
978
                    Memo = null
979
                };
980

    
981
            }
982
            catch (Exception ex)
983
            {
984
                System.Diagnostics.Debug.WriteLine(ex.ToString());
985
            }
986

    
987
            return result;
988
        }
989

    
990

    
991

    
992
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text,double fontSize, FontWeight fontWeight,TextAlignment textAlignment, Rect parentRect,double positionY)
993
        {
994
            TextControl result = null;
995

    
996
            try
997
            {
998

    
999
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight,FontFamily = new FontFamily("Tahoma") });
1000

    
1001
                double startPositionX = parentRect.X;
1002

    
1003
                switch (textAlignment)
1004
                {
1005
                    case TextAlignment.Right:
1006
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1007
                        break;
1008
                    case TextAlignment.Center:
1009
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1010
                        break;
1011
                }
1012

    
1013
                Point startPosition = new Point
1014
                {
1015
                    X = startPositionX,
1016
                    Y = positionY
1017
                };
1018
                
1019
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1020
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1021
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1022
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1023

    
1024
                result = new TextControl
1025
                {
1026
                    CommentID = Commons.shortGuid(),
1027
                    MarkupInfoID = markupInfoId,
1028
                    Text = Text,
1029
                    StartPoint = startPoint,
1030
                    EndPoint = endPoint,
1031
                    CanvasX = startPosition.X,
1032
                    CanvasY = startPosition.Y,
1033
                    BoxWidth = txtSize.Width,
1034
                    BoxHeight = txtSize.Height,
1035
                    ControlType_No = 0,
1036
                    LineSize = new Thickness(5),
1037
                    TextSize = fontSize,
1038
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1039
                    FontSize = 10,
1040
                    UserID = userId,
1041
                    IsHighLight = false,
1042
                    CommentAngle = 0,
1043
                    PointSet = new List<Point>(),
1044
                    Opacity = 1,
1045
                    IsSelected = false,
1046
                    TextFamily = new FontFamily("Tahoma"),
1047
                    TextStyle = FontStyles.Normal,
1048
                    TextWeight = FontWeights.Bold
1049
                };
1050
          
1051
            }
1052
            catch (Exception ex)
1053
            {
1054

    
1055
            }
1056

    
1057
            return result;
1058
        }
1059
        public static Size ShapeMeasure(UIElement e)
1060
        {
1061
            // Measured Size is bounded to be less than maxSize
1062
            Size maxSize = new Size(
1063
                 double.PositiveInfinity,
1064
                 double.PositiveInfinity);
1065
            e.Measure(maxSize);
1066
            return e.DesiredSize;
1067
        }
1068

    
1069
        private async Task MarkupLoadAsync(int pageNumber)
1070
        {
1071
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1072
            stopwatch.Start();
1073

    
1074
            /// 컨트롤을 새로 생성한다.
1075
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1076
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1077

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

    
1080
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1081
            { 
1082
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
1083
                if (info != null)
1084
                {
1085
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1086
                    if (info.UserID == App.ViewInfo.UserID)
1087
                    {
1088
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
1089
                                        markup.MarkupInfoID, markup.ID);
1090
                        control.Visibility = Visibility.Hidden;
1091
                    }
1092
                    else
1093
                    {
1094
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
1095
                                                                markup.MarkupInfoID, markup.ID);
1096
                        control.Visibility = Visibility.Hidden;
1097
                    }
1098
                }
1099
            };
1100
            /// up to here
1101

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

    
1104
            /// fire selection event
1105
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1106
            this.gridViewMarkup.UnselectAll();
1107
            this.gridViewMarkup.Select(gridSelectionItem);
1108

    
1109
            if (!testPanel2.IsHidden)
1110
            {
1111
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1112
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1113
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1114

    
1115
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1116
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1117

    
1118

    
1119
                foreach (var item in gridSelectionRevItem)
1120
                {
1121
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1122

    
1123
                    foreach (var markupitem in markupitems)
1124
                    {
1125
                        await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
1126
                    }
1127
                }
1128
            }
1129

    
1130
            SetCommentPages();
1131
        }
1132

    
1133
        public void SetCommentPages()
1134
        {
1135
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1136
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1137
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1138
            {
1139
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1140
                if(item.MarkupList != null)
1141
                {
1142
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1143
                    instance.UserName = item.UserName;
1144
                    instance.Depart = item.Depatment;
1145
                    instance.MarkupInfoID = item.MarkupInfoID;
1146
                    instance.IsSelected = true;
1147
                    instance.isConSolidation = item.Consolidate;
1148
                    instance.SetColor = item.DisplayColor;
1149
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1150
                    {
1151
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1152
                    }
1153
                    else
1154
                    {
1155
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1156
                    }
1157
                    _pages.Add(instance);
1158
                }                   
1159
            }
1160
            
1161
           this.pageNavigator.SetCommentList(_pages.ToList());
1162
        }
1163

    
1164
        public void MarkupitemViewUpdate(string markupinfo_id)
1165
        {
1166
            //db에 업데이트 한 list 를 view 에 업데이트
1167
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1168
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1169
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1170
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1171
            if (dbinfo.MarkupList.Count > 0)
1172
            {
1173
                if (viewinfo.MarkupList != null)
1174
                {
1175
                    viewinfo.MarkupList.Clear();
1176
                    viewinfo.MarkupList = null;
1177
                }
1178
                viewinfo.MarkupList = new List<MarkupItem>();
1179
                foreach (var item in dbinfo.MarkupList)
1180
                {
1181
                    viewinfo.MarkupList.Add(item);
1182
                }
1183
            }
1184
        }
1185

    
1186
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1187
        {
1188
            var instance = ViewerDataModel.Instance;
1189

    
1190
            if(instance.IsWheelPageChanage)
1191
            {
1192
                return;
1193
            }
1194

    
1195
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1196
            {
1197
       
1198
                int changePage = 0;
1199
                
1200
                if (e.Delta > 0)
1201
                {
1202
                    if (0 < instance.ContentOffsetY)
1203
                    {
1204
                        Vector dragOffset = new Vector(0, e.Delta);
1205
                        MoveZoomAndPanControl(dragOffset);
1206
                    }
1207
                    //else
1208
                    //{
1209
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1210
                    //    {
1211
                    //        instance.IsWheelPageChanage = true;
1212
                    //        changePage -= 1;
1213
                    //    }
1214
                    //}
1215
                }
1216
                else if(e.Delta < 0)
1217
                {
1218
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1219
                    {
1220
                        Vector dragOffset = new Vector(0,e.Delta);
1221
                        MoveZoomAndPanControl(dragOffset);
1222
                    }
1223
                    //else
1224
                    //{
1225
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1226
                    //    {
1227
                    //        instance.IsWheelPageChanage = true;
1228
                    //        changePage += 1;
1229
                    //    }
1230
                    //}
1231
                }
1232

    
1233
                //if (changePage != 0)
1234
                //{
1235
                //    await Task.Factory.StartNew(() =>
1236
                //    {
1237
                //        double beforeScale = instance.ContentScale;
1238

    
1239
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1240

    
1241
                //        handler = (snd, evt) =>
1242
                //        {
1243
                //            /// 최상단으로 이전 zoomScale로 위치한다
1244
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1245
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1246
                //            instance.IsWheelPageChanage = false;
1247
                //            pageNavigator.PageChanged -= handler;
1248
                //        };
1249

    
1250
                //        pageNavigator.PageChanged += handler;
1251

    
1252
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1253
                //    });
1254
                    
1255

    
1256
                //}
1257
            }
1258
            else
1259
            {
1260
                e.Handled = true;
1261
                if (e.Delta > 0)
1262
                {
1263
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1264
                    ZoomIn(currentContentMousePoint);
1265
                }
1266
                else
1267
                {
1268
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1269
                    ZoomOut(currentContentMousePoint);
1270
                }
1271
            }
1272
        }
1273

    
1274
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1275
        {
1276
            e.Handled = true;
1277
            if (e.Delta > 0)
1278
            {
1279
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1280
                ZoomIn_Sync(currentContentMousePoint);
1281
            }
1282
            else
1283
            {
1284
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1285
                ZoomOut_Sync(currentContentMousePoint);
1286
            }
1287
        }
1288

    
1289
        #region ZoomIn & ZoomOut
1290

    
1291
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1292
        {
1293
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1294
                zoomAndPanControl.ContentZoomFocusY));
1295
        }
1296

    
1297
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1298
        {
1299
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1300
                zoomAndPanControl.ContentZoomFocusY));
1301
        }
1302

    
1303

    
1304
        //강인구 추가 (줌 인아웃 수치 변경)
1305
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1306
        private void ZoomOut(Point contentZoomCenter)
1307
        {
1308
            if (zoomAndPanControl.ContentScale > 0.39)
1309
            {
1310
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1311
            }
1312
            else
1313
            {
1314
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1315
            }
1316

    
1317
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1318
            {
1319
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1320
            }
1321
        }
1322

    
1323
        private void ZoomIn(Point contentZoomCenter)
1324
        {
1325
            if (zoomAndPanControl.ContentScale > 0.19)
1326
            {
1327
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1328
            }
1329
            else
1330
            {
1331
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1332
            }
1333

    
1334
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1335
            {
1336
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1337
            }
1338

    
1339
        }
1340

    
1341
        private void ZoomOut_Sync(Point contentZoomCenter)
1342
        {
1343
            if (zoomAndPanControl2.ContentScale > 0.39)
1344
            {
1345
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1346
            }
1347
            else
1348
            {
1349
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1350
            }
1351

    
1352
            if (Sync.IsChecked)
1353
            {
1354
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1355
            }
1356
        }
1357

    
1358
        private void ZoomIn_Sync(Point contentZoomCenter)
1359
        {
1360
            if (zoomAndPanControl2.ContentScale > 0.19)
1361
            {
1362
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1363
            }
1364
            else
1365
            {
1366
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1367
            }
1368

    
1369
            if (Sync.IsChecked)
1370
            {
1371
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1372
            }
1373
        }
1374

    
1375
        private void ZoomOut()
1376
        {
1377
            zoomAndPanControl.ContentScale -= 0.1;
1378
            //if (zoomAndPanControl2 != null)
1379
            //{
1380
            //    zoomAndPanControl2.ContentScale -= 0.1;
1381
            //}
1382
        }
1383

    
1384
        private void ZoomIn()
1385
        {
1386
            zoomAndPanControl.ContentScale += 0.1;
1387
            //if (zoomAndPanControl2 != null)
1388
            //{
1389
            //    zoomAndPanControl2.ContentScale += 0.1;
1390
            //}
1391
        }
1392

    
1393
        #endregion
1394

    
1395
        private void init()
1396
        {
1397
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1398
            {
1399

    
1400
                ControlList.Clear();
1401
                listBox.Items.Clear();
1402
                selected_item.Clear();
1403

    
1404
                (item as IMarkupCommonData).IsSelected = false;
1405
            }
1406

    
1407
        }
1408

    
1409
        private HitTestResultBehavior MyCallback(HitTestResult result)
1410
        {
1411
            //this.cursor = Cursors.UpArrow;
1412
            var element = result.VisualHit;
1413
            while (element != null && !(element is CommentUserInfo))
1414
                element = VisualTreeHelper.GetParent(element);
1415

    
1416
            if (element == null)
1417
            {
1418
                return HitTestResultBehavior.Stop;
1419
            }
1420
            else
1421
            {
1422
                if (element is CommentUserInfo)
1423
                {
1424
                    if (!hitList.Contains(element))
1425
                    {
1426
                        hitList.Add((CommentUserInfo)element);
1427
                    }
1428
                    else
1429
                    {
1430
                        return HitTestResultBehavior.Stop;
1431
                    }
1432
                }
1433
            }
1434
            return HitTestResultBehavior.Continue;
1435
        }
1436

    
1437
        public void ReleaseSelectPath()
1438
        {
1439
            if (SelectionPath == null)
1440
            {
1441
                SelectionPath = new Path();
1442
                SelectionPath.Name = "";
1443
            }
1444
            if (SelectionPath.Name != "")
1445
            {
1446
                SelectionPath.Name = "None";
1447
            }
1448
            SelectionPath.Opacity = 0.01;
1449
            SelectionPath.RenderTransform = null;
1450
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1451
        }
1452

    
1453
        #region 컨트롤 초기화 
1454
        public void Control_Init(object control)
1455
        {
1456
            if (L_Size != 0 && (control as IPath) != null)
1457
            {
1458
                (control as IPath).LineSize = L_Size;
1459
                L_Size = 0;
1460
            }
1461

    
1462
            switch (control.GetType().Name)
1463
            {
1464
                case "RectangleControl":
1465
                    {
1466
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1467
                    }
1468
                    break;
1469
                case "CircleControl":
1470
                    {
1471
                        (control as CircleControl).StrokeColor = Brushes.Red;
1472
                    }
1473
                    break;
1474
                case "TriControl":
1475
                    {
1476
                        (control as TriControl).StrokeColor = Brushes.Red;
1477
                    }
1478
                    break;
1479
                case "RectCloudControl":
1480
                    {
1481
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1482
                    }
1483
                    break;
1484
                case "CloudControl":
1485
                    {
1486
                        (control as CloudControl).StrokeColor = Brushes.Red;
1487
                    }
1488
                    break;
1489
                case "PolygonControl":
1490
                    {
1491
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1492
                    }
1493
                    break;
1494
                case "ArcControl":
1495
                    {
1496
                        (control as ArcControl).StrokeColor = Brushes.Red;
1497
                    }
1498
                    break;
1499
                case "ArrowArcControl":
1500
                    {
1501
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1502
                    }
1503
                    break;
1504
                case "LineControl":
1505
                    {
1506
                        (control as LineControl).StrokeColor = Brushes.Red;
1507
                    }
1508
                    break;
1509
                case "ArrowControl_Multi":
1510
                    {
1511
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1512
                    }
1513
                    break;
1514
                case "TextControl":
1515
                    {
1516
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1517
                    }
1518
                    break;
1519
                case "ArrowTextControl":
1520
                    {
1521
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1522
                    }
1523
                    break;
1524
                case "InsideWhiteControl":
1525
                    {
1526
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1527
                    }
1528
                    break;
1529
                case "OverlapWhiteControl":
1530
                    {
1531
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1532
                    }
1533
                    break;
1534
                case "ClipWhiteControl":
1535
                    {
1536
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1537
                    }
1538
                    break;
1539
                case "CoordinateControl":
1540
                    {
1541
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1542
                    }
1543
                    break;
1544
            }
1545
        }
1546
        #endregion
1547

    
1548
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1549
        {
1550
            //Control_Init(e.Source);
1551
        }
1552
        //private Window _dragdropWindow = null;
1553

    
1554
        [DllImport("user32.dll")]
1555
        [return: MarshalAs(UnmanagedType.Bool)]
1556
        internal static extern bool GetCursorPos(ref Win32Point pt);
1557

    
1558
        [StructLayout(LayoutKind.Sequential)]
1559
        internal struct Win32Point
1560
        {
1561
            public Int32 X;
1562
            public Int32 Y;
1563
        };
1564
        /*
1565
       public string symbol_id = null;
1566
       public long symbol_group_id;
1567
       public int symbol_SelectedIndex;
1568
       public ImageSource symbol_img;
1569
       public string symbol_Data = null;
1570
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1571
       {
1572
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1573
               zoomAndPanCanvas.ActualHeight / 2));
1574

    
1575

    
1576
               if (this._dragdropWindow != null)
1577
               {
1578
                   this._dragdropWindow.Close();
1579
                   this._dragdropWindow = null;
1580
               }
1581

    
1582
               symbol_id = id;
1583
               symbol_group_id = group_id;
1584
               symbol_SelectedIndex = SelectedIndex;
1585
               symbol_Data = Data_;
1586
               symbol_img = img;
1587

    
1588

    
1589
               CreateDragDropWindow2(img);
1590
              
1591
    }
1592

    
1593
    private void CreateDragDropWindow2(ImageSource image)
1594
        {
1595
            this._dragdropWindow = new Window();
1596
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1597
            _dragdropWindow.WindowStyle = WindowStyle.None;
1598
            _dragdropWindow.AllowsTransparency = true;           
1599
            _dragdropWindow.AllowDrop = false;
1600
            _dragdropWindow.Background = null;
1601
            _dragdropWindow.IsHitTestVisible = false;
1602
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1603
            _dragdropWindow.Topmost = true;
1604
            _dragdropWindow.ShowInTaskbar = false;
1605
            
1606
            Rectangle r = new Rectangle();
1607
            r.Width = image.Width;
1608
            r.Height = image.Height;
1609
            r.Opacity = 0.5;            
1610
            r.Fill = new ImageBrush(image);
1611
            this._dragdropWindow.Content = r;
1612

    
1613
            Win32Point w32Mouse = new Win32Point();
1614
            GetCursorPos(ref w32Mouse);
1615

    
1616
            //w32Mouse.X = getCurrentPoint.X;
1617
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1618
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1619
            this._dragdropWindow.Show();
1620
        }
1621

    
1622
        
1623

    
1624
         */
1625

    
1626
        public void MoveZoomAndPanControl(Vector dragOffset)
1627
        {
1628
   
1629
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1630
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1631

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

    
1639
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1640
        {
1641
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1642
            {
1643
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1644

    
1645
                Point currentPos = e.GetPosition(rect);
1646

    
1647
                floatingTip.HorizontalOffset = currentPos.X + 20;
1648
                floatingTip.VerticalOffset = currentPos.Y;
1649
            }
1650

    
1651
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1652
            
1653
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1654
            {
1655
                SetCursor();
1656
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1657
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1658

    
1659
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1660

    
1661
                MoveZoomAndPanControl(dragOffset);
1662
            }
1663

    
1664
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1665
            {
1666
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1667
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1668
                SetCursor();
1669

    
1670
                if (currentControl != null)
1671
                {
1672
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1673
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1674
                    //강인구 추가
1675
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1676

    
1677
                    if ((currentControl as IPath) != null)
1678
                    {
1679
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1680
                    }
1681
                    if ((currentControl as LineControl) != null)
1682
                    {
1683
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1684
                    }
1685

    
1686
                    if ((currentControl as IShapeControl) != null)
1687
                    {
1688
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1689
                    }
1690
                    if ((currentControl as TextControl) != null)
1691
                    {
1692
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1693
                        {
1694
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1695
                        }
1696
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1697
                        {
1698
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1699
                        }
1700
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1701
                        {
1702
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1703
                        }
1704
                    }
1705
                    else if ((currentControl as ArrowTextControl) != null)
1706
                    {
1707
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1708
                        {
1709
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1710
                        }
1711
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1712
                        {
1713
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1714
                        }
1715
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1716
                        {
1717
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1718
                        }
1719
                    }
1720
                    else if ((currentControl as RectCloudControl) != null)
1721
                    {
1722
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1723
                    }
1724
                    else if ((currentControl as CloudControl) != null)
1725
                    {
1726
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1727
                    }
1728

    
1729

    
1730
                    #region // 모든 컨트롤의 공통기능 제어
1731
                    if (controlType != ControlType.PenControl)
1732
                    {
1733
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1734
                    }
1735

    
1736

    
1737
                    #endregion
1738

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

    
1741
                    switch (controlType)
1742
                    {
1743
                        case (ControlType.Coordinate):
1744
                            {
1745
                                var control = currentControl as CoordinateControl;
1746
                                if (control != null)
1747
                                {
1748
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1749
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1750
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1751
                                }
1752
                            }
1753
                            break;
1754
                        case (ControlType.InsideWhite):
1755
                            {
1756
                                var control = currentControl as InsideWhiteControl;
1757
                                if (control != null)
1758
                                {
1759
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1760
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1761
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1762
                                    control.Paint = PaintSet.Fill;
1763
                                }
1764
                            }
1765
                            break;
1766
                        case ControlType.OverlapWhite:
1767
                            {
1768
                                var control = currentControl as OverlapWhiteControl;
1769
                                if (control != null)
1770
                                {
1771
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1772
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1773
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1774
                                    control.Paint = PaintSet.Fill;
1775
                                }
1776
                            }
1777
                            break;
1778
                        case ControlType.ClipWhite:
1779
                            {
1780
                                var control = currentControl as ClipWhiteControl;
1781
                                if (control != null)
1782
                                {
1783
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1784
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1785
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1786
                                    control.Paint = PaintSet.Fill;
1787
                                }
1788
                            }
1789
                            break;
1790
                        case ControlType.RectCloud:
1791
                            {
1792
                                var control = currentControl as RectCloudControl;
1793
                                if (control != null)
1794
                                {
1795
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1796
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1797
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1798
                                }
1799
                            }
1800
                            break;
1801
                        case ControlType.SingleLine:
1802
                        case ControlType.CancelLine:
1803
                        case ControlType.ArrowLine:
1804
                        case ControlType.TwinLine:
1805
                        case ControlType.DimLine:
1806
                            {
1807
                                var control = currentControl as LineControl;
1808
                                if (control != null)
1809
                                {
1810
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1811
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1812
                                }
1813

    
1814
                            }
1815
                            break;
1816

    
1817
                        case ControlType.ArcLine:
1818
                            {
1819
                                var control = currentControl as ArcControl;
1820
                                if (control != null)
1821
                                {
1822
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1823
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1824
                                }
1825
                            }
1826
                            break;
1827

    
1828
                        case ControlType.ArcArrow:
1829
                            {
1830
                                var control = currentControl as ArrowArcControl;
1831
                                if (control != null)
1832
                                {
1833
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1834
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1835
                                }
1836
                            }
1837
                            break;
1838

    
1839
                        case ControlType.ArrowMultiLine:
1840
                            {
1841
                                var control = currentControl as ArrowControl_Multi;
1842
                                if (control != null)
1843
                                {
1844
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1845
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1846
                                }
1847
                            }
1848
                            break;
1849

    
1850
                        case ControlType.Circle:
1851
                            {
1852
                                var control = currentControl as CircleControl;
1853

    
1854
                                if (control != null)
1855
                                {
1856
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1857
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1858
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1859
                                }
1860
                            }
1861
                            break;
1862

    
1863
                        case ControlType.PolygonCloud:
1864
                            {
1865
                                var control = currentControl as CloudControl;
1866
                                if (control != null)
1867
                                {
1868
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1869
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1870
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1871
                                }
1872
                            }
1873
                            break;
1874

    
1875
                        case ControlType.Triangle:
1876
                            {
1877
                                var control = currentControl as TriControl;
1878
                                if (control != null)
1879
                                {
1880
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1881
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1882
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1883
                                }
1884
                            }
1885
                            break;
1886

    
1887
                        case ControlType.ImgControl:
1888
                            {
1889
                                var control = currentControl as ImgControl;
1890
                                if (control != null)
1891
                                {
1892
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1893
                                }
1894
                            }
1895
                            break;
1896

    
1897
                        case ControlType.Date:
1898
                            {
1899
                                var control = currentControl as DateControl;
1900
                                if (control != null)
1901
                                {
1902
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1903
                                }
1904
                            }
1905
                            break;
1906

    
1907
                        case ControlType.ArrowTextControl:
1908
                        case ControlType.ArrowTransTextControl:
1909
                        case ControlType.ArrowTextBorderControl:
1910
                        case ControlType.ArrowTransTextBorderControl:
1911
                        case ControlType.ArrowTextCloudControl:
1912
                        case ControlType.ArrowTransTextCloudControl:
1913
                            {
1914
                                var control = currentControl as ArrowTextControl;
1915
                                if (control != null)
1916
                                {
1917
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1918
                                }
1919
                            }
1920
                            break;
1921
                        case ControlType.PolygonControl:
1922
                        case ControlType.ChainLine:
1923
                            {
1924
                                var control = currentControl as PolygonControl;
1925
                                if (control != null)
1926
                                {
1927
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1928
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1929
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1930
                                }
1931
                            }
1932
                            break;
1933
                        case ControlType.Sign:
1934
                            {
1935
                                var control = currentControl as SignControl;
1936
                                if (control != null)
1937
                                {
1938
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1939
                                }
1940
                            }
1941
                            break;
1942
                        case ControlType.Symbol:
1943
                            {
1944
                                var control = currentControl as SymControl;
1945
                                if (control != null)
1946
                                {
1947
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1948
                                }
1949
                            }
1950
                            break;
1951
                        case ControlType.Stamp:
1952
                            {
1953
                                var control = currentControl as SymControlN;
1954
                                if (control != null)
1955
                                {
1956
                                    if (control.STAMP != null)
1957
                                    {
1958
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1959
                                    }
1960
                                    else
1961
                                    {
1962
                                        currentControl = null;
1963
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1964
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1965
                                    }
1966
                                }
1967
                            }
1968
                            break;
1969
                        case ControlType.Rectangle:
1970
                        case ControlType.Mark:
1971
                            {
1972
                                var control = currentControl as RectangleControl;
1973
                                if (control != null)
1974
                                {
1975
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1976
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1977
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1978
                                }
1979
                            }
1980
                            break;
1981
                        case ControlType.PenControl:
1982
                            {
1983
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1984
                                //inkBoard.Strokes.Add(stroke);
1985
                            }
1986
                            break;
1987
                        default:
1988
                            break;
1989
                    }
1990

    
1991
                    #endregion
1992
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
1993
                    {
1994
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
1995
                    }
1996

    
1997
                }
1998
            }
1999
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2000
            {
2001
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2002
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2003
                SetCursor();
2004
                if (currentControl == null)
2005
                {
2006
                    switch (controlType)
2007
                    {
2008
                        case ControlType.PenControl:
2009
                            {
2010
                                if (inkBoard.Tag.ToString() == "Ink")
2011
                                {
2012
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2013
                                }
2014
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2015
                                {
2016
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2017
                                }
2018
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2019
                                {
2020
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2021
                                }
2022

    
2023
                                //inkBoard.Strokes.Add(stroke);
2024
                            }
2025
                            break;
2026
                    }
2027
                    return;
2028
                }
2029
            }
2030
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
2031
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
2032
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2033
            {
2034
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2035

    
2036
                if (isDraggingSelectionRect)
2037
                {
2038
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2039
                    e.Handled = true;
2040
                }
2041
                else if (isLeftMouseButtonDownOnWindow)
2042
                {
2043
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2044
                    double dragDistance = Math.Abs(dragDelta.Length);
2045

    
2046
                    if (dragDistance > DragThreshold)
2047
                    {
2048
                        isDraggingSelectionRect = true;
2049
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2050
                    }
2051

    
2052
                    e.Handled = true;
2053
                }
2054

    
2055
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2056
                {
2057
                }
2058
                else
2059
                {
2060
                    e.Handled = true;
2061
                }
2062
            }
2063
            /*
2064
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2065
            { //symbol      
2066
                if(_dragdropWindow != null)
2067
                {
2068
                    Win32Point w32Mouse = new Win32Point();
2069
                    GetCursorPos(ref w32Mouse);
2070

    
2071
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2072
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2073
                }                
2074
            }
2075
            */
2076
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
2077
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2078
            {
2079
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2080
                if(control != null)
2081
                {
2082
                    this.cursor = Cursors.Hand;
2083
                    SetCursor();
2084
                }
2085
                else
2086
                {
2087
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2088
                    SetCursor();
2089
                }
2090
            }
2091
            else
2092
            {
2093
            }
2094
        }
2095

    
2096
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2097
        {
2098
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2099
            {
2100
                SetCursor();
2101
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2102
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2103

    
2104
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2105

    
2106
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2107
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2108

    
2109
                if (Sync.IsChecked)
2110
                {
2111
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2112
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2113
                }
2114
            }
2115
        }
2116

    
2117
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2118

    
2119
        private EllipseGeometry hitArea = new EllipseGeometry();
2120

    
2121
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2122
        {
2123
            IsDrawing = false;
2124
    
2125
            if (mouseHandlingMode != MouseHandlingMode.None)
2126
            {
2127
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2128
                {
2129
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2130

    
2131
                    SetCursor();
2132

    
2133
                    switch (controlType)
2134
                    {
2135
                        case ControlType.None:
2136
                            break;
2137
                        case ControlType.Rectangle:
2138
                            {
2139

    
2140
                            }
2141
                            break;
2142
                        case ControlType.PenControl:
2143
                            {
2144

    
2145
                            }
2146
                            break;
2147
                        default:
2148
                            break;
2149
                    }                    
2150
                }
2151
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2152
                {
2153
                  
2154
                    if (isLeftMouseButtonDownOnWindow)
2155
                    {
2156
                        bool wasDragSelectionApplied = false;
2157

    
2158
                        if (isDraggingSelectionRect)
2159
                        {
2160
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2161
                            {
2162
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2163
                                mouseHandlingMode = MouseHandlingMode.None;
2164
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2165
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2166
                                Set_Symbol_Capture(endPoint);
2167
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2168
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
2169
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2170
                            }
2171
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2172
                            {
2173
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2174
                                mouseHandlingMode = MouseHandlingMode.None;
2175
                                Set_Capture();
2176

    
2177
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2178
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2179
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2180
                            }
2181
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2182
                            {
2183
                                ApplyDragSelectionRect();
2184
                            }
2185
                            else
2186
                            {
2187
                                double x = Canvas.GetLeft(dragZoomBorder);
2188
                                double y = Canvas.GetTop(dragZoomBorder);
2189
                                double width = dragZoomBorder.Width;
2190
                                double height = dragZoomBorder.Height;
2191
                                Rect dragRect = new Rect(x, y, width, height);
2192

    
2193
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2194

    
2195
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2196
                            }
2197

    
2198
                            isDraggingSelectionRect = false;
2199
                            e.Handled = true;
2200
                            wasDragSelectionApplied = true;
2201
                        }
2202

    
2203
                        if (isLeftMouseButtonDownOnWindow)
2204
                        {
2205
                            isLeftMouseButtonDownOnWindow = false;
2206
                            this.ReleaseMouseCapture();
2207
                            e.Handled = true;
2208
                        }
2209

    
2210
                        if (!wasDragSelectionApplied)
2211
                        {
2212
                            init();
2213
                        }
2214
                    }
2215
                }
2216
                else if (e.RightButton == MouseButtonState.Pressed)
2217
                {
2218
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2219
                    SetCursor();
2220
                }
2221

    
2222
                zoomAndPanControl.ReleaseMouseCapture();
2223

    
2224

    
2225
                e.Handled = true;
2226
            }
2227
            else
2228
            {
2229
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2230
                SetCursor();
2231
            }
2232

    
2233
            ///mouseButtonDown = MouseButton.Left;
2234
            //controlType = ControlType.SingleLine;
2235
        }
2236

    
2237
        public void Set_Symbol_Capture(Point endPoint)
2238
        {       
2239
            double x = CanvasDrawingMouseDownPoint.X;
2240
            double y = CanvasDrawingMouseDownPoint.Y;
2241
            if(x > endPoint.X)
2242
            {
2243
                x = endPoint.X;
2244
                y = endPoint.Y;
2245
            }
2246

    
2247
            double width = dragCaptureBorder.Width;
2248
            double height = dragCaptureBorder.Height;
2249

    
2250
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2251

    
2252
            if (x < 0)
2253
            {
2254
                width += x;
2255
                x = 0;
2256
            }
2257
            if (y < 0)
2258
            {
2259
                height += y;
2260
                y = 0;
2261

    
2262
                width = (int)canvasImage.PixelWidth - x;
2263
            }
2264
            if (x + width > canvasImage.PixelWidth)
2265
            {
2266
                width = (int)canvasImage.PixelWidth - x;
2267
            }
2268
            if (y + height > canvasImage.PixelHeight)
2269
            {
2270
                height = (int)canvasImage.PixelHeight - y;
2271
            }
2272
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2273

    
2274
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2275
            var defaultBitmapImage = new BitmapImage();
2276
            defaultBitmapImage.BeginInit();
2277
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2278
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2279
            defaultBitmapImage.UriSource = new Uri(uri);
2280
            defaultBitmapImage.EndInit();
2281

    
2282
            //GC.Collect();
2283

    
2284
            if (defaultBitmapImage.IsDownloading)
2285
            {
2286
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2287
                {
2288
                    defaultBitmapImage.Freeze();
2289
                    //GC.Collect();
2290
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2291
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2292
                };
2293
            }
2294
        }
2295

    
2296
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2297
        {
2298
            ///mouseButtonDown = MouseButton.Left;
2299
        }
2300

    
2301
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2302
        {
2303
            ///mouseButtonDown = MouseButton.Left;
2304
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2305
        }
2306

    
2307
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2308
        {
2309

    
2310
        }
2311

    
2312
        /// <summary>
2313
        /// select items by dragging
2314
        /// </summary>
2315
        private void ApplyDragSelectionRect()
2316
        {
2317
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2318

    
2319
            double x = Canvas.GetLeft(dragSelectionBorder);
2320
            double y = Canvas.GetTop(dragSelectionBorder);
2321
            double width = dragSelectionBorder.Width;
2322
            double height = dragSelectionBorder.Height;
2323
            Boolean Flag = false;
2324
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2325
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2326

    
2327
            Rect dragRect = new Rect(x, y, width, height);
2328
            ///dragRect.Inflate(width / 10, height / 10);
2329

    
2330
            foreach (var item in Items)
2331
            {
2332
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2333

    
2334
                if (Flag)
2335
                {
2336
                    adornerSet.Add(item);
2337
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2338
                    Control_Style(item);
2339
                }
2340
            }
2341
            if (adornerSet.Count > 0)
2342
            {
2343
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2344
                SelectLayer.Children.Add(final);
2345
            }
2346
        }
2347

    
2348
        private void InitDragSelectionRect(Point pt1, Point pt2)
2349
        {
2350
            //캡쳐 중
2351
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2352
            {
2353
                dragCaptureBorder.Visibility = Visibility.Visible;
2354
            }
2355
            //선택 중
2356
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2357
            {
2358

    
2359
                dragSelectionBorder.Visibility = Visibility.Visible;
2360
            }
2361
            else
2362
            {
2363
                dragZoomBorder.Visibility = Visibility.Visible;
2364
            }
2365
            UpdateDragSelectionRect(pt1, pt2);
2366
        }
2367

    
2368
        /// <summary>
2369
        /// Update the position and size of the rectangle used for drag selection.
2370
        /// </summary>
2371
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2372
        {
2373
            double x, y, width, height;
2374

    
2375
            //
2376
            // Determine x,y,width and height of the rect inverting the points if necessary.
2377
            // 
2378

    
2379
            if (pt2.X < pt1.X)
2380
            {
2381
                x = pt2.X;
2382
                width = pt1.X - pt2.X;
2383
            }
2384
            else
2385
            {
2386
                x = pt1.X;
2387
                width = pt2.X - pt1.X;
2388
            }
2389

    
2390
            if (pt2.Y < pt1.Y)
2391
            {
2392
                y = pt2.Y;
2393
                height = pt1.Y - pt2.Y;
2394
            }
2395
            else
2396
            {
2397
                y = pt1.Y;
2398
                height = pt2.Y - pt1.Y;
2399
            }
2400

    
2401
            //
2402
            // Update the coordinates of the rectangle used for drag selection.
2403
            //
2404
            //캡쳐 중
2405
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2406
            {
2407
                Canvas.SetLeft(dragCaptureBorder, x);
2408
                Canvas.SetTop(dragCaptureBorder, y);
2409
                dragCaptureBorder.Width = width;
2410
                dragCaptureBorder.Height = height;
2411
            }
2412
            //선택 중
2413
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2414
            {
2415
                Canvas.SetLeft(dragSelectionBorder, x);
2416
                Canvas.SetTop(dragSelectionBorder, y);
2417
                dragSelectionBorder.Width = width;
2418
                dragSelectionBorder.Height = height;
2419
            }
2420
            else
2421
            {
2422
                Canvas.SetLeft(dragZoomBorder, x);
2423
                Canvas.SetTop(dragZoomBorder, y);
2424
                dragZoomBorder.Width = width;
2425
                dragZoomBorder.Height = height;
2426
            }
2427
        }
2428

    
2429
        private void drawingPannelRotate(double angle)
2430
        {
2431
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2432
            rotate.Angle = angle;
2433
            var rotationNum = Math.Abs((rotate.Angle / 90));
2434

    
2435
            if (angle == 90 || angle == 270)
2436
            {
2437
                double emptySize = zoomAndPanCanvas.Width;
2438
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2439
                zoomAndPanCanvas.Height = emptySize;
2440
            }
2441
            if (angle == 0)
2442
            {
2443
                translate.X = 0;
2444
                translate.Y = 0;
2445
            }
2446
            else if (angle == 90)
2447
            {
2448
                translate.X = zoomAndPanCanvas.Width;
2449
                translate.Y = 0;
2450
            }
2451
            else if (angle == 180)
2452
            {
2453
                translate.X = zoomAndPanCanvas.Width;
2454
                translate.Y = zoomAndPanCanvas.Height;
2455
            }
2456
            else
2457
            {
2458
                translate.X = 0;
2459
                translate.Y = zoomAndPanCanvas.Height;
2460
            }
2461

    
2462
            zoomAndPanControl.RotationAngle = rotate.Angle;
2463

    
2464

    
2465
            if (!testPanel2.IsHidden)
2466
            {
2467
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2468
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2469
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2470
            }
2471

    
2472
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2473
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2474
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2475
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2476
            ViewerDataModel.Instance.Angle = rotate.Angle;
2477
        }
2478

    
2479
        private void syncPannelRotate(double angle)
2480
        {
2481
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2482
            rotate.Angle = angle;
2483
            var rotationNum = Math.Abs((rotate.Angle / 90));
2484

    
2485
            if (angle == 90 || angle == 270)
2486
            {
2487
                double emptySize = zoomAndPanCanvas2.Width;
2488
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2489
                zoomAndPanCanvas2.Height = emptySize;
2490
            }
2491
            if (angle == 0)
2492
            {
2493
                translate2.X = 0;
2494
                translate2.Y = 0;
2495
            }
2496
            else if (angle == 90)
2497
            {
2498
                translate2.X = zoomAndPanCanvas2.Width;
2499
                translate2.Y = 0;
2500
            }
2501
            else if (angle == 180)
2502
            {
2503
                translate2.X = zoomAndPanCanvas2.Width;
2504
                translate2.Y = zoomAndPanCanvas2.Height;
2505
            }
2506
            else
2507
            {
2508
                translate2.X = 0;
2509
                translate2.Y = zoomAndPanCanvas2.Height;
2510
            }
2511

    
2512
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2513
        }
2514

    
2515
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2516
        {
2517
            string Data_ = "";
2518

    
2519
            try
2520
            {
2521
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2522
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2523
                if (Data_ != null || Data_ != "")
2524
                {
2525
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2526
                }
2527
                else
2528
                {
2529
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2530
                }
2531

    
2532
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2533
                //{
2534
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2535
                //    STATE = 0,
2536
                //};
2537
                if (Data_ != null)
2538
                {
2539
                    Image img = new Image();
2540
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2541
                    if (Data_.Contains(".svg"))
2542
                    {
2543
                        byte[] imageData = null;
2544
                        DrawingImage image = null;
2545
                        using (System.Net.WebClient web = new System.Net.WebClient())
2546
                        {
2547
                            imageData = web.DownloadData(new Uri(Data_));
2548
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2549
                            image = SvgReader.Load(stream);
2550
                        }
2551
                        img.Source = image;
2552
                    }
2553
                    else
2554
                    {
2555
                        img.Source = new BitmapImage(new Uri(Data_));
2556
                    }
2557

    
2558
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2559
                    {
2560
                        PointSet = new List<Point>(),
2561
                        FilePath = Data_,
2562
                        ImageData = img.Source,
2563
                        StartPoint = canvasZoomPanningMouseDownPoint,
2564
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2565
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2566
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2567
                        canvasZoomPanningMouseDownPoint.Y),
2568
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2569
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2570
                    };
2571

    
2572
                    currentControl.PointSet = new List<Point>
2573
                                        {
2574
                                            currentControl.StartPoint,
2575
                                            currentControl.LeftBottomPoint,
2576
                                            currentControl.EndPoint,
2577
                                            currentControl.TopRightPoint,
2578
                                        };
2579
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2580
                    UndoData = new Undo_data()
2581
                    {
2582
                        IsUndo = false,
2583
                        Event = Event_Type.Create,
2584
                        EventTime = DateTime.Now,
2585
                        Markup_List = new List<Multi_Undo_data>()
2586
                    };
2587
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2588
                    {
2589
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2590
                    });
2591

    
2592
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2593
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2594
                    UndoData.Markup_List.Add(multi_Undo_Data);
2595
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2596

    
2597
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2598
                    currentControl.CommentID = Commons.shortGuid();
2599
                    currentControl.SymbolID = id;
2600
                    currentControl.GroupID = group_id;
2601
                    currentControl.ApplyTemplate();
2602
                    currentControl.SetImage();
2603

    
2604
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2605
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2606
                    SelectLayer.Children.Add(final);
2607
                }
2608
            }
2609
            catch (Exception ex)
2610
            {
2611
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2612
            }
2613
        }
2614

    
2615
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2616
        {
2617
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2618
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2619
            {
2620
                set_option.Value = double.Parse(set_option.ContentText);
2621
                //set_option.Focusable = false;
2622
                zoomAndPanControl.Focus();
2623
            }
2624

    
2625
            ConvertInkControlToPolygon();
2626

    
2627
            ///TODO:
2628
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2629
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2630

    
2631
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2632
            {
2633
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2634
            }
2635
            /// up to here
2636

    
2637
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2638
            {
2639
                if (item as ArrowTextControl != null)
2640
                {
2641
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2642
                }
2643
                else if (item as TextControl != null)
2644
                {
2645
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2646
                }
2647
            }
2648

    
2649
            //if (currentControl != null)
2650
            {
2651
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2652
                if (text_item_ != null)
2653
                {
2654
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2655
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2656
                    (text_item_ as TextControl).IsEditingMode = false;                    
2657
                    currentControl = null;
2658
                }
2659

    
2660
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2661
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2662
                {
2663
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2664
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2665
                    currentControl = null;
2666
                }
2667
            }
2668

    
2669
            double Ang = 0;                                          
2670
            if (rotate.Angle != 0)
2671
            {
2672
                Ang = 360 - rotate.Angle;
2673
            }
2674

    
2675
            if (e.OriginalSource is System.Windows.Controls.Image)
2676
            {
2677
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2678
            }
2679
            /*
2680
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2681
            {                
2682
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2683
                if(symbol_id != null)
2684
                {
2685
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2686
                }                
2687
            }
2688

    
2689
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2690
            {
2691
                if (this._dragdropWindow != null)
2692
                {
2693
                    this._dragdropWindow.Close();
2694
                    this._dragdropWindow = null;
2695
                    symbol_id = null;
2696
                }
2697
            }
2698
            */
2699

    
2700
            if (e.LeftButton == MouseButtonState.Pressed)
2701
            {
2702
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2703
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2704

    
2705
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2706
                SetCursor();
2707

    
2708
                if (!ViewerDataModel.Instance.IsPressCtrl)
2709
                {
2710
                    SelectionSet.Instance.UnSelect(this);
2711
                }
2712
            }
2713

    
2714
            if (e.MiddleButton == MouseButtonState.Pressed)
2715
            {
2716
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2717
                cursor = Cursors.SizeAll;
2718
                SetCursor();
2719
            }
2720
            if (e.RightButton == MouseButtonState.Pressed)
2721
            {
2722
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2723
                cursor = Cursors.SizeAll;
2724
                SetCursor();
2725
            }
2726
            else if (e.XButton1 == MouseButtonState.Pressed)
2727
            {
2728
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2729
                {
2730
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2731
                }
2732

    
2733
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2734

    
2735
            }
2736
            else if (e.XButton2 == MouseButtonState.Pressed)
2737
            {
2738
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2739
                {
2740
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2741
                }
2742
            }
2743

    
2744
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2745
            {
2746
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2747
                {
2748
                    if (SelectLayer.Children.Count == 0)
2749
                    {
2750
                        isLeftMouseButtonDownOnWindow = true;
2751
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2752
                    }
2753

    
2754
                    if (controlType == ControlType.None)
2755
                    {
2756
                        isLeftMouseButtonDownOnWindow = true;
2757
                    }
2758
                }
2759

    
2760
                /// 캡쳐 모드 설정
2761
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2762
                {
2763
                    dragCaptureBorder.Visibility = Visibility.Visible;
2764
                    isLeftMouseButtonDownOnWindow = true;
2765
                }
2766

    
2767
                /// 줌 모드 설정
2768
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2769
                {
2770
                    isLeftMouseButtonDownOnWindow = true;
2771
                }
2772

    
2773
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2774

    
2775
                if(control == null)
2776
                {
2777

    
2778
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2779
                }
2780
                else
2781
                {
2782
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2783

    
2784
                    AdornerFinal final = null;
2785

    
2786
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2787
                    {
2788
                        /// 기존 selection 해제
2789
                        SelectionSet.Instance.UnSelect(this);
2790

    
2791
                        final = new AdornerFinal(control);
2792

    
2793
                        this.Control_Style(control);
2794

    
2795
                        if ((control as IPath) != null)
2796
                        {
2797
                            if ((control as IPath).LineSize != 0)
2798
                            {
2799
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2800
                            }
2801
                        }
2802
                        if ((control as IShapeControl) != null)
2803
                        {
2804
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2805
                            {
2806
                                ViewerDataModel.Instance.checkHatchShape = true;
2807
                            }
2808
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2809
                            {
2810
                                ViewerDataModel.Instance.checkFillShape = true;
2811
                            }
2812
                            else
2813
                            {
2814
                                ViewerDataModel.Instance.checkHatchShape = false;
2815
                                ViewerDataModel.Instance.checkFillShape = false;
2816
                            }
2817
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2818
                        }
2819

    
2820
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2821

    
2822
                        if ((control as TextControl) != null)
2823
                        {
2824
                            if(!((control as TextControl).EnableEditing)) {
2825
                                (control as TextControl).EnableEditing = true;
2826
                            }
2827
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2828
                            {
2829
                                ViewerDataModel.Instance.checkTextStyle = true;
2830
                            }
2831
                            else
2832
                            {
2833
                                ViewerDataModel.Instance.checkTextStyle = false;
2834
                            }
2835
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2836
                            {
2837
                                ViewerDataModel.Instance.checkTextWeight = true;
2838
                            }
2839
                            else
2840
                            {
2841
                                ViewerDataModel.Instance.checkTextWeight = false;
2842
                            }
2843
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2844
                            {
2845
                                ViewerDataModel.Instance.checkUnderLine = true;
2846
                            }
2847
                            else
2848
                            {
2849
                                ViewerDataModel.Instance.checkUnderLine = false;
2850
                            }
2851
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2852
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2853

    
2854
                        }
2855
                        else if ((control as ArrowTextControl) != null)
2856
                        {
2857
                            if (!((control as ArrowTextControl).EnableEditing))
2858
                            {
2859
                                (control as ArrowTextControl).EnableEditing = true;
2860
                            }
2861
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2862
                            {
2863
                                ViewerDataModel.Instance.checkTextStyle = true;
2864
                            }
2865
                            else
2866
                            {
2867
                                ViewerDataModel.Instance.checkTextStyle = false;
2868
                            }
2869
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2870
                            {
2871
                                ViewerDataModel.Instance.checkTextWeight = true;
2872
                            }
2873
                            else
2874
                            {
2875
                                ViewerDataModel.Instance.checkTextWeight = false;
2876
                            }
2877
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2878
                            {
2879
                                ViewerDataModel.Instance.checkUnderLine = true;
2880
                            }
2881
                            else
2882
                            {
2883
                                ViewerDataModel.Instance.checkUnderLine = false;
2884
                            }
2885
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2886
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2887
                        }
2888
                        else if ((control as RectCloudControl) != null)
2889
                        {
2890
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2891
                        }
2892
                        else if ((control as CloudControl) != null)
2893
                        {
2894
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2895
                        }
2896
                    }
2897
                    else
2898
                    {
2899
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2900
                        SelectionSet.Instance.UnSelect(this);
2901
                        comment.Add(control);
2902

    
2903
                        Control_Style(control);
2904

    
2905
                        final = new AdornerFinal(comment);
2906
                    }
2907

    
2908
                    if (final != null)
2909
                    {
2910
                        this.SelectLayer.Children.Add(final);
2911
                    }
2912
                }
2913
            }
2914
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2915
            {               
2916
                init();
2917
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2918
                if (cursor != Cursors.SizeAll)
2919
                {
2920
                    cursor = Cursors.Cross;
2921
                    SetCursor();
2922
                }
2923
                bool init_user = false;
2924
                foreach (var user in gridViewMarkup.Items)
2925
                {
2926
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2927
                    {
2928
                        init_user = true;
2929
                    }
2930
                }
2931
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2932
                {
2933
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
2934
                    RadWindow.Alert(new DialogParameters
2935
                    {
2936
                        Owner = Application.Current.MainWindow,
2937
                        Theme = new VisualStudio2013Theme(),
2938
                        Header = "Info",
2939
                        Content = "Existing comments already existed. Select from the user list first",
2940
                    });
2941
                    return;
2942
                }
2943
                else
2944
                {
2945
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2946
                    if (item != null)
2947
                    {
2948
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2949
                    }
2950
                }
2951

    
2952
                switch (controlType)
2953
                {
2954
                    case ControlType.Coordinate:
2955
                        {
2956
                            if (e.LeftButton == MouseButtonState.Pressed)
2957
                            {
2958
                                if (currentControl is CoordinateControl)
2959
                                {
2960
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2961
                                    {
2962
                                        return;
2963
                                    }
2964

    
2965
                                    CreateCommand.Instance.Execute(currentControl);
2966

    
2967
                                    currentControl = null;
2968
                                    this.cursor = Cursors.Arrow;
2969
                                }
2970
                                else
2971
                                {
2972
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2973
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2974
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2975
                                    {
2976
                                        currentControl = null;
2977
                                        this.cursor = Cursors.Arrow;
2978
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2979
                                        return;
2980
                                    }
2981
                                    else
2982
                                    {
2983
                                        currentControl = new CoordinateControl
2984
                                        {
2985
                                            Background = new SolidColorBrush(Colors.Black),
2986
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
2987
                                            ControlType = ControlType.Coordinate
2988
                                        };
2989

    
2990
                                        currentControl.CommentID = Commons.shortGuid();
2991
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2992
                                        currentControl.IsNew = true;
2993

    
2994
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2995

    
2996
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2997
                                    }
2998
                                }
2999
                            }
3000
                        }
3001
                        break;
3002
                    case ControlType.InsideWhite:
3003
                        {
3004
                            if (e.LeftButton == MouseButtonState.Pressed)
3005
                            {
3006
                                if (currentControl is InsideWhiteControl)
3007
                                {
3008
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3009
                                    {
3010
                                        return;
3011
                                    }
3012

    
3013
                                    CreateCommand.Instance.Execute(currentControl);
3014

    
3015
                                    currentControl = null;
3016
                                    this.cursor = Cursors.Arrow;
3017
                                }
3018
                                else
3019
                                {
3020
                                    currentControl = new InsideWhiteControl
3021
                                    {
3022
                                        Background = new SolidColorBrush(Colors.Black),
3023
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3024
                                        ControlType = ControlType.InsideWhite
3025
                                    };
3026

    
3027
                                    currentControl.CommentID = Commons.shortGuid();
3028
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3029
                                    currentControl.IsNew = true;
3030
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3031

    
3032
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3033
                                }
3034
                            }
3035
                        }
3036
                        break;
3037
                    case ControlType.OverlapWhite:
3038
                        {
3039
                            if (e.LeftButton == MouseButtonState.Pressed)
3040
                            {
3041
                                if (currentControl is OverlapWhiteControl)
3042
                                {
3043
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3044
                                    {
3045
                                        return;
3046
                                    }
3047

    
3048
                                    CreateCommand.Instance.Execute(currentControl);
3049

    
3050
                                    currentControl = null;
3051
                                    this.cursor = Cursors.Arrow;
3052
                                }
3053
                                else
3054
                                {
3055
                                    currentControl = new OverlapWhiteControl
3056
                                    {
3057
                                        Background = new SolidColorBrush(Colors.Black),
3058
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3059
                                        ControlType = ControlType.OverlapWhite
3060
                                    };
3061

    
3062
                                    currentControl.CommentID = Commons.shortGuid();
3063
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3064
                                    currentControl.IsNew = true;
3065
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3066

    
3067
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3068
                                }
3069
                            }
3070
                        }
3071
                        break;
3072
                    case ControlType.ClipWhite:
3073
                        {
3074
                            if (e.LeftButton == MouseButtonState.Pressed)
3075
                            {
3076
                                if (currentControl is ClipWhiteControl)
3077
                                {
3078
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3079
                                    {
3080
                                        return;
3081
                                    }
3082

    
3083
                                    CreateCommand.Instance.Execute(currentControl);
3084

    
3085
                                    currentControl = null;
3086
                                    this.cursor = Cursors.Arrow;
3087
                                }
3088
                                else
3089
                                {
3090
                                    currentControl = new ClipWhiteControl
3091
                                    {
3092
                                        Background = new SolidColorBrush(Colors.Black),
3093
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3094
                                        ControlType = ControlType.ClipWhite
3095
                                    };
3096

    
3097
                                    currentControl.CommentID = Commons.shortGuid();
3098
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3099
                                    currentControl.IsNew = true;
3100
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3101

    
3102
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3103
                                }
3104
                            }
3105
                        }
3106
                        break;
3107
                    case ControlType.Rectangle:
3108
                        {
3109
                            if (e.LeftButton == MouseButtonState.Pressed)
3110
                            {
3111
                                if (currentControl is RectangleControl)
3112
                                {
3113
                                    //20180906 LJY TEST IsRotationDrawingEnable
3114
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3115
                                    {
3116
                                        return;
3117
                                    }
3118

    
3119
                                    CreateCommand.Instance.Execute(currentControl);
3120
                                    currentControl = null;
3121
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3122
                                }
3123
                                else
3124
                                {
3125
                                    currentControl = new RectangleControl
3126
                                    {
3127
                                        Background = new SolidColorBrush(Colors.Black),
3128
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3129
                                        ControlType = ControlType.Rectangle
3130
                                    };
3131

    
3132
                                    currentControl.CommentID = Commons.shortGuid();
3133
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3134
                                    currentControl.IsNew = true;
3135
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3136

    
3137
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3138
                                }
3139
                            }
3140
                        }
3141
                        break;
3142
                    case ControlType.RectCloud:
3143
                        {
3144
                            if (e.LeftButton == MouseButtonState.Pressed)
3145
                            {
3146
                                if (currentControl is RectCloudControl)
3147
                                {
3148
                                    //20180906 LJY TEST IsRotationDrawingEnable
3149
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3150
                                    {
3151
                                        return;
3152
                                    }
3153

    
3154
                                    CreateCommand.Instance.Execute(currentControl);
3155

    
3156
                                    currentControl = null;
3157
                                
3158
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3159
                                }
3160
                                else
3161
                                {
3162
                                    currentControl = new RectCloudControl
3163
                                    {
3164
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3165
                                        ControlType = ControlType.RectCloud,
3166
                                        Background = new SolidColorBrush(Colors.Black)
3167
                                    };
3168

    
3169
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3170
                                    currentControl.CommentID = Commons.shortGuid();
3171
                                    currentControl.IsNew = true;
3172
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3173
                                }
3174
                            }
3175
                        }
3176
                        break;
3177
                    case ControlType.Circle:
3178
                        {
3179
                            if (e.LeftButton == MouseButtonState.Pressed)
3180
                            {
3181
                                if (currentControl is CircleControl)
3182
                                {
3183
                                    //20180906 LJY TEST IsRotationDrawingEnable
3184
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3185
                                    {
3186
                                        return;
3187
                                    }
3188

    
3189
                                    CreateCommand.Instance.Execute(currentControl);
3190

    
3191
                                    currentControl = null;
3192
                                }
3193
                                else
3194
                                {
3195
                                    currentControl = new CircleControl
3196
                                    {
3197
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3198
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3199
                                        Background = new SolidColorBrush(Colors.Black)
3200
                                    };
3201

    
3202
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3203
                                    currentControl.CommentID = Commons.shortGuid();
3204
                                    currentControl.IsNew = true;
3205
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3206
                                }
3207
                            }
3208
                        }
3209
                        break;
3210
                    case ControlType.Triangle:
3211
                        {
3212
                            if (e.LeftButton == MouseButtonState.Pressed)
3213
                            {
3214
                                if (currentControl is TriControl)
3215
                                {
3216
                                    var content = currentControl as TriControl;
3217
                                    if (content.MidPoint == new Point(0, 0))
3218
                                    {
3219
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3220
                                    }
3221
                                    else
3222
                                    {
3223
                                        //20180906 LJY TEST IsRotationDrawingEnable
3224
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3225
                                        {
3226
                                            return;
3227
                                        }
3228

    
3229
                                        CreateCommand.Instance.Execute(currentControl);
3230

    
3231
                                        currentControl = null;
3232
                                    }
3233
                                }
3234
                                else
3235
                                {
3236
                                    currentControl = new TriControl
3237
                                    {
3238
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3239
                                        Background = new SolidColorBrush(Colors.Black),
3240
                                    };
3241

    
3242
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3243
                                    currentControl.CommentID = Commons.shortGuid();
3244
                                    currentControl.IsNew = true;
3245
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3246
                                }
3247
                            }
3248
                        }
3249
                        break;
3250
                    case ControlType.CancelLine:
3251
                    case ControlType.SingleLine:
3252
                    case ControlType.ArrowLine:
3253
                    case ControlType.TwinLine:
3254
                    case ControlType.DimLine:
3255
                        {
3256
                            if (e.LeftButton == MouseButtonState.Pressed)
3257
                            {
3258
                                if (currentControl is LineControl)
3259
                                {
3260
                                    //20180906 LJY TEST IsRotationDrawingEnable
3261
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3262
                                    {
3263
                                        return;
3264
                                    }
3265

    
3266
                                    CreateCommand.Instance.Execute(currentControl);
3267
                                    currentControl = null;
3268
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3269
                                }
3270
                                else
3271
                                {
3272
                                    currentControl = new LineControl
3273
                                    {
3274
                                        ControlType = this.controlType,
3275
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3276
                                        Background = new SolidColorBrush(Colors.Black)
3277
                                    };
3278

    
3279
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3280
                                    currentControl.CommentID = Commons.shortGuid();
3281
                                    currentControl.IsNew = true;
3282
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3283
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3284
                                }
3285
                            }
3286
                        }
3287
                        break;
3288
                    case ControlType.PolygonControl:
3289
                        {
3290
                            if (currentControl is PolygonControl)
3291
                            {
3292
                                var control = currentControl as PolygonControl;
3293

    
3294
                                if (e.RightButton == MouseButtonState.Pressed)
3295
                                {
3296
                                    control.IsCompleted = true;
3297
                                }
3298

    
3299
                                if (!control.IsCompleted)
3300
                                {
3301
                                    control.PointSet.Add(control.EndPoint);
3302
                                }
3303
                                else
3304
                                {
3305
                                    //20180906 LJY TEST IsRotationDrawingEnable
3306
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3307
                                    {
3308
                                        return;
3309
                                    }
3310

    
3311
                                    var firstPoint = control.PointSet.First();
3312
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3313
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3314
                                    control.PointSet.Add(firstPoint);
3315

    
3316
                                    control.ApplyOverViewData();
3317

    
3318
                                    CreateCommand.Instance.Execute(currentControl);
3319
                                    control.UpdateControl();
3320
                                    currentControl = null;
3321
                                }
3322
                            }
3323
                            else
3324
                            {
3325
                                if (e.LeftButton == MouseButtonState.Pressed)
3326
                                {
3327
                                    currentControl = new PolygonControl
3328
                                    {
3329
                                        PointSet = new List<Point>(),
3330
                                    };
3331

    
3332
                                    var polygonControl = (currentControl as PolygonControl);
3333
                                    currentControl.CommentID = Commons.shortGuid();
3334
                                    currentControl.IsNew = true;
3335
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3336
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3337
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3338
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3339
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3340
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3341
                                    polygonControl.ApplyTemplate();
3342
                                    polygonControl.Visibility = Visibility.Visible;
3343
                                }
3344
                            }
3345
                        }
3346
                        break;
3347
                    case ControlType.ChainLine:
3348
                        {
3349
                            if (currentControl is PolygonControl)
3350
                            {
3351
                                var control = currentControl as PolygonControl;
3352

    
3353
                                if (e.RightButton == MouseButtonState.Pressed)
3354
                                {
3355
                                    //20180906 LJY TEST IsRotationDrawingEnable
3356
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3357
                                    {
3358
                                        return;
3359
                                    }
3360

    
3361
                                    CreateCommand.Instance.Execute(currentControl);
3362

    
3363
                                    currentControl = null;
3364
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3365
                                    return;
3366
                                }
3367

    
3368
                                if (!control.IsCompleted)
3369
                                {
3370
                                    control.PointSet.Add(control.EndPoint);
3371
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3372
                                }
3373
                            }
3374
                            else
3375
                            {
3376
                                if (e.LeftButton == MouseButtonState.Pressed)
3377
                                {
3378
                                    MainAngle.Visibility = Visibility.Visible;
3379
                                    currentControl = new PolygonControl
3380
                                    {
3381
                                        PointSet = new List<Point>(),
3382
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3383
                                        ControlType = ControlType.ChainLine,
3384
                                        DashSize = ViewerDataModel.Instance.DashSize,
3385
                                        LineSize = ViewerDataModel.Instance.LineSize,
3386
                                        //PointC = new StylusPointSet()
3387
                                    };
3388

    
3389
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3390
                                    //{
3391
                                        var polygonControl = (currentControl as PolygonControl);
3392
                                        currentControl.CommentID = Commons.shortGuid();
3393
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3394
                                        currentControl.IsNew = true;
3395
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3396
                                        //currentControl.OnApplyTemplate();
3397
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3398
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3399
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3400
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3401
                                    //}
3402
                                }
3403
                            }
3404
                        }
3405
                        break;
3406
                    case ControlType.ArcLine:
3407
                        {
3408
                            if (e.LeftButton == MouseButtonState.Pressed)
3409
                            {
3410
                                if (currentControl is ArcControl)
3411
                                {
3412
                                    //20180906 LJY TEST IsRotationDrawingEnable
3413
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3414
                                    {
3415
                                        return;
3416
                                    }
3417

    
3418
                                    CreateCommand.Instance.Execute(currentControl);
3419

    
3420
                                    currentControl = null;
3421
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3422
                                }
3423
                                else
3424
                                {
3425
                                    currentControl = new ArcControl
3426
                                    {
3427
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3428
                                        Background = new SolidColorBrush(Colors.Black)
3429
                                    };
3430
                                    currentControl.CommentID = Commons.shortGuid();
3431
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3432
                                    currentControl.IsNew = true;
3433
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3434
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3435
                                }
3436
                            }
3437
                            else if (e.RightButton == MouseButtonState.Pressed)
3438
                            {
3439
                                if (currentControl != null)
3440
                                {
3441
                                    (currentControl as ArcControl).setClock();
3442
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3443
                                }
3444
                            }
3445
                        }
3446
                        break;
3447
                    case ControlType.ArcArrow:
3448
                        {
3449
                            if (e.LeftButton == MouseButtonState.Pressed)
3450
                            {
3451
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3452
                                //{
3453
                                if (currentControl is ArrowArcControl)
3454
                                {
3455
                                    //20180906 LJY TEST IsRotationDrawingEnable
3456
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3457
                                    {
3458
                                        return;
3459
                                    }
3460

    
3461
                                    CreateCommand.Instance.Execute(currentControl);
3462

    
3463
                                    currentControl = null;
3464
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3465
                                }
3466
                                else
3467
                                {
3468
                                    currentControl = new ArrowArcControl
3469
                                    {
3470
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3471
                                        Background = new SolidColorBrush(Colors.Black)
3472
                                    };
3473
                                    currentControl.CommentID = Commons.shortGuid();
3474
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3475
                                    currentControl.IsNew = true;
3476
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3477
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3478
                                }
3479
                                //}
3480
                            }
3481
                            else if (e.RightButton == MouseButtonState.Pressed)
3482
                            {
3483
                                if (currentControl != null)
3484
                                {
3485
                                    (currentControl as ArrowArcControl).setClock();
3486
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3487
                                    //(currentControl as ArcControl).ApplyTemplate();
3488
                                }
3489
                            }
3490
                        }
3491
                        break;
3492
                    case ControlType.ArrowMultiLine:
3493
                        {
3494
                            if (e.LeftButton == MouseButtonState.Pressed)
3495
                            {
3496
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3497
                                //{
3498

    
3499
                                    if (currentControl is ArrowControl_Multi)
3500
                                    {
3501
                                        var content = currentControl as ArrowControl_Multi;
3502
                                        if (content.MiddlePoint == new Point(0, 0))
3503
                                        {
3504
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3505
                                            {
3506
                                                content.MiddlePoint = content.EndPoint;
3507
                                            }
3508
                                            else
3509
                                            {
3510
                                                content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3511
                                            }
3512
                                        }
3513
                                        else
3514
                                        {
3515
                                            //20180906 LJY TEST IsRotationDrawingEnable
3516
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3517
                                            {
3518
                                                return;
3519
                                            }
3520

    
3521
                                            CreateCommand.Instance.Execute(currentControl);
3522

    
3523
                                            currentControl = null;
3524
                                            ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3525
                                        }
3526
                                    }
3527
                                    else
3528
                                    {
3529
                                        currentControl = new ArrowControl_Multi
3530
                                        {
3531
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3532
                                            Background = new SolidColorBrush(Colors.Black)
3533
                                        };
3534
                                        currentControl.CommentID = Commons.shortGuid();
3535
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3536
                                        currentControl.IsNew = true;
3537
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3538
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3539
                                    }
3540
                                //}
3541
                            }
3542
                        }
3543
                        break;
3544
                    case ControlType.PolygonCloud:
3545
                        {
3546
                            if (currentControl is CloudControl)
3547
                            {
3548
                                var control = currentControl as CloudControl;
3549
                                if (e.RightButton == MouseButtonState.Pressed)
3550
                                {
3551
                                    control.IsCompleted = true;
3552
                                }
3553

    
3554
                                if (!control.IsCompleted)
3555
                                {
3556
                                    control.PointSet.Add(control.EndPoint);
3557
                                }
3558
                                else
3559
                                {
3560
                                    //20180906 LJY TEST IsRotationDrawingEnable
3561
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3562
                                    {
3563
                                        return;
3564
                                    }
3565

    
3566
                                    CreateCommand.Instance.Execute(currentControl);
3567

    
3568
                                    control.isTransOn = true;
3569
                                    var firstPoint = control.PointSet.First();
3570

    
3571
                                    control.PointSet.Add(firstPoint);
3572
                                    control.DrawingCloud();
3573
                                    control.ApplyOverViewData();
3574

    
3575
                                    currentControl = null;
3576
                                }
3577
                            }
3578
                            else
3579
                            {
3580
                                if (e.LeftButton == MouseButtonState.Pressed)
3581
                                {
3582
                                    currentControl = new CloudControl
3583
                                    {
3584
                                        PointSet = new List<Point>(),
3585
                                        PointC = new StylusPointSet()
3586
                                    };
3587

    
3588
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3589
                                    //{
3590
                                        var polygonControl = (currentControl as CloudControl);
3591
                                        currentControl.CommentID = Commons.shortGuid();
3592
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3593
                                        currentControl.IsNew = true;
3594
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3595

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

    
3618
                                        CreateCommand.Instance.Execute(currentControl);
3619
                                        controlType = ControlType.ImgControl;
3620
                                        currentControl = null;
3621
                                    }
3622
                                    else
3623
                                    {
3624
                                        
3625
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3626
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3627
                                        {
3628
                                            Image img = new Image();
3629
                                            if (filename.Contains(".svg"))
3630
                                            {
3631
                                                byte[] imageData = null;
3632
                                                DrawingImage image = null;
3633
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3634
                                                {
3635
                                                    imageData = web.DownloadData(new Uri(filename));
3636
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3637
                                                    image = SvgReader.Load(stream);
3638
                                                }
3639
                                                img.Source = image;
3640
                                            }
3641
                                            else
3642
                                            {
3643
                                                img.Source = new BitmapImage(new Uri(filename));
3644
                                            }
3645

    
3646
                                            currentControl = new ImgControl
3647
                                            {
3648
                                                    Background = new SolidColorBrush(Colors.Black),
3649
                                                    PointSet = new List<Point>(),
3650
                                                    FilePath = filename,
3651
                                                    ImageData = img.Source,
3652
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3653
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3654
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3655
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3656
                                                    ControlType = ControlType.ImgControl
3657
                                                };
3658

    
3659
                                        
3660
                                                currentControl.CommentID = Commons.shortGuid();                                            
3661
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3662
                                                currentControl.IsNew = true;
3663
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3664

    
3665
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3666
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3667
                                    }
3668
                                    }
3669
                                //}
3670
                            }
3671
                        }
3672
                        break;
3673
                    case ControlType.Date:
3674
                        {
3675
                            if (e.LeftButton == MouseButtonState.Pressed)
3676
                            {
3677
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3678
                                //{
3679
                                if (currentControl is DateControl)
3680
                                {
3681
                                    //20180906 LJY TEST IsRotationDrawingEnable
3682
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3683
                                    {
3684
                                        return;
3685
                                    }
3686

    
3687
                                    CreateCommand.Instance.Execute(currentControl);
3688
                                    currentControl = null;
3689

    
3690
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3691
                                    {
3692
                                        controlType = ControlType.None;
3693
                                        IsSwingMode = false;
3694
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3695
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3696
                                        mouseHandlingMode = MouseHandlingMode.None;
3697
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3698
                                        txtBatch.Visibility = Visibility.Collapsed;
3699

    
3700
                                    }
3701
                                }
3702
                                else
3703
                                {
3704
                                    currentControl = new DateControl
3705
                                    {
3706
                                        StartPoint = CanvasDrawingMouseDownPoint,
3707
                                        Background = new SolidColorBrush(Colors.Black)
3708
                                    };
3709
                                    currentControl.CommentID = Commons.shortGuid();
3710
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3711
                                    currentControl.IsNew = true;
3712
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3713

    
3714
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3715
                                    if (currentControl is ImgControl)
3716
                                    {
3717
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3718
                                    }
3719
                                }
3720
                                //}
3721
                            }
3722
                        }
3723
                        break;
3724
                    case ControlType.TextControl:
3725
                        {
3726
                            if (e.LeftButton == MouseButtonState.Pressed)
3727
                            {
3728
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3729
                                {
3730
                                    currentControl = new TextControl
3731
                                    {
3732
                                        ControlType = controlType
3733
                                    };
3734
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3735
                                    currentControl.CommentID = Commons.shortGuid();
3736
                                    currentControl.IsNew = true;
3737
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3738
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3739
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3740

    
3741
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3742
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3743
                                    
3744
                                    (currentControl as TextControl).ControlType_No = 0;
3745
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3746
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3747
                                    (currentControl as TextControl).ApplyTemplate();
3748
                                    (currentControl as TextControl).Base_TextBox.Focus();
3749
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3750
                                    CreateCommand.Instance.Execute(currentControl);
3751
                                }
3752
                            }
3753
                        }
3754
                        break;
3755
                    case ControlType.TextBorder:
3756
                        {
3757
                            if (e.LeftButton == MouseButtonState.Pressed)
3758
                            {
3759
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3760
                                {
3761
                                    currentControl = new TextControl
3762
                                    {
3763
                                        ControlType = controlType
3764
                                    };
3765

    
3766
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3767
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3768
                                    currentControl.CommentID = Commons.shortGuid();
3769
                                    currentControl.IsNew = true;
3770
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3771
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3772
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3773
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3774
                                    
3775
                                    (currentControl as TextControl).ControlType_No = 1;
3776
                                    (currentControl as TextControl).CommentAngle = Ang;
3777
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3778
                                    (currentControl as TextControl).ApplyTemplate();
3779
                                    (currentControl as TextControl).Base_TextBox.Focus();
3780
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3781
                                    CreateCommand.Instance.Execute(currentControl);
3782
                                }
3783
                            }
3784
                        }
3785
                        break;
3786
                    case ControlType.TextCloud:
3787
                        {
3788
                            if (e.LeftButton == MouseButtonState.Pressed)
3789
                            {
3790
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3791
                                {
3792
                                    currentControl = new TextControl
3793
                                    {
3794
                                        ControlType = controlType
3795
                                    };
3796

    
3797
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3798
                                    currentControl.CommentID = Commons.shortGuid();
3799
                                    currentControl.IsNew = true;
3800
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3801
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3802

    
3803
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3804
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3805
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3806

    
3807
                                    (currentControl as TextControl).CommentAngle = Ang;
3808
                                    (currentControl as TextControl).ControlType_No = 2;
3809
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3810
                                    (currentControl as TextControl).ApplyTemplate();
3811
                                    (currentControl as TextControl).Base_TextBox.Focus();
3812
                                    CreateCommand.Instance.Execute(currentControl);
3813
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3814
                                    //currentControl = null;
3815
                                }
3816
                            }
3817
                        }
3818
                        break;
3819
                    case ControlType.ArrowTextControl:
3820
                         {
3821
                            if (e.LeftButton == MouseButtonState.Pressed)
3822
                            {
3823
                                if (currentControl is ArrowTextControl)
3824
                                {
3825
                                    //20180906 LJY TEST IsRotationDrawingEnable
3826
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3827
                                    {
3828
                                        return;
3829
                                    }
3830

    
3831
                                    CreateCommand.Instance.Execute(currentControl);
3832

    
3833
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3834
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3835
                                    (currentControl as ArrowTextControl).IsNew = false;
3836
                                    currentControl = null;
3837
                                }
3838
                                else
3839
                                {
3840
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3841
                                    //{
3842
                                        currentControl = new ArrowTextControl();
3843
                                        currentControl.CommentID = Commons.shortGuid();
3844
                                        currentControl.IsNew = true;
3845
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3846
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3847

    
3848
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3849
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3850
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3851
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3852
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3853

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

    
3857
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3858
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3859
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3860
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3861

    
3862
                                    
3863
                                    //}
3864
                                }
3865
                            }
3866
                        }
3867
                        break;
3868
                    case ControlType.ArrowTransTextControl:
3869
                        {
3870
                            if (e.LeftButton == MouseButtonState.Pressed)
3871
                            {
3872
                                if (currentControl is ArrowTextControl)
3873
                                {
3874
                                    //20180906 LJY TEST IsRotationDrawingEnable
3875
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3876
                                    {
3877
                                        return;
3878
                                    }
3879

    
3880
                                    CreateCommand.Instance.Execute(currentControl);
3881

    
3882
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3883
                                    
3884
                                    currentControl.IsNew = false;
3885
                                    currentControl = null;
3886
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3887
                                }
3888
                                else
3889
                                {
3890
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3891
                                    //{
3892
                                    currentControl = new ArrowTextControl()
3893
                                    {
3894
                                        ControlType = ControlType.ArrowTransTextControl
3895
                                    };
3896
                                    currentControl.CommentID = Commons.shortGuid();
3897
                                    currentControl.IsNew = true;
3898
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3899
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3900
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3901
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3902
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                  
3903
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3904
                                    (currentControl as ArrowTextControl).isFixed = true;
3905
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3906

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

    
3910
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3911
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3912
                                    (currentControl as ArrowTextControl).isTrans = true;
3913
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3914
                                }
3915
                            }
3916
                        }
3917
                        break;
3918
                    case ControlType.ArrowTextBorderControl:
3919
                         {
3920
                            if (e.LeftButton == MouseButtonState.Pressed)
3921
                            {
3922
                                if (currentControl is ArrowTextControl)
3923
                                {
3924
                                    //20180906 LJY TEST IsRotationDrawingEnable
3925
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3926
                                    {
3927
                                        return;
3928
                                    }
3929

    
3930
                                    CreateCommand.Instance.Execute(currentControl);
3931
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3932
                                    currentControl.IsNew = false;
3933
                                    currentControl = null;
3934
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3935
                                }
3936
                                else
3937
                                {
3938
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3939
                                    //{
3940
                                        currentControl = new ArrowTextControl()
3941
                                        {
3942
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3943
                                        };
3944
                                        currentControl.CommentID = Commons.shortGuid();
3945
                                        currentControl.IsNew = true;
3946
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3947
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3948

    
3949
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3950

    
3951
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3952

    
3953
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3954
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3955
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3956
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3957
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3958
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3959
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3960
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3961
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);                                    
3962
                                    //}
3963
                                }
3964
                            }
3965
                        }
3966
                        break;
3967
                    case ControlType.ArrowTransTextBorderControl:
3968
                        {
3969
                            if (e.LeftButton == MouseButtonState.Pressed)
3970
                            {
3971
                                if (currentControl is ArrowTextControl)
3972
                                {
3973
                                    //20180906 LJY TEST IsRotationDrawingEnable
3974
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3975
                                    {
3976
                                        return;
3977
                                    }
3978
                                    CreateCommand.Instance.Execute(currentControl);
3979
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3980
                                    currentControl.IsNew = false;
3981
                                    currentControl = null;
3982

    
3983
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3984
                                }
3985
                                else
3986
                                {
3987
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3988
                                    //{
3989
                                    
3990

    
3991
                                    currentControl = new ArrowTextControl()
3992
                                    {
3993
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3994
                                        ControlType = ControlType.ArrowTransTextBorderControl
3995

    
3996
                                    };
3997
                                        currentControl.CommentID = Commons.shortGuid();
3998
                                        currentControl.IsNew = true;
3999
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4000
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4001

    
4002
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4003

    
4004
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4005
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                    
4006
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4007
                                        (currentControl as ArrowTextControl).isFixed = true;
4008
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4009
                                     
4010
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4011
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4012
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4013
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4014
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4015
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4016
                                    
4017
                                    //20180911 LJY
4018
                                        (currentControl as ArrowTextControl).isTrans = true;
4019
                                    
4020

    
4021
                                    //}
4022
                                }
4023
                            }
4024
                        }
4025
                        break;
4026
                    case ControlType.ArrowTextCloudControl:
4027
                        {
4028
                            if (e.LeftButton == MouseButtonState.Pressed)
4029
                            {
4030
                                if (currentControl is ArrowTextControl)
4031
                                {
4032
                                    //20180906 LJY TEST IsRotationDrawingEnable
4033
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4034
                                    {
4035
                                        return;
4036
                                    }
4037
                                    CreateCommand.Instance.Execute(currentControl);
4038
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4039
                                    currentControl.IsNew = false;
4040
                                    currentControl = null;
4041
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4042
                                }
4043
                                else
4044
                                {
4045
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4046
                                    //{
4047
                                        currentControl = new ArrowTextControl()
4048
                                        {
4049
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4050
                                        };
4051
                                        currentControl.CommentID = Commons.shortGuid();
4052
                                        currentControl.IsNew = true;
4053
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4054
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4055

    
4056
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4057
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4058
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                 
4059
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4060
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4061
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4062
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4063
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4064
                                    
4065
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4066
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4067
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);                                        
4068
                                    //}
4069
                                }
4070
                            }
4071
                        }
4072
                        break;
4073
                    case ControlType.ArrowTransTextCloudControl:
4074
                        {
4075
                            if (e.LeftButton == MouseButtonState.Pressed)
4076
                            {
4077
                                if (currentControl is ArrowTextControl)
4078
                                {
4079
                                    //20180906 LJY TEST IsRotationDrawingEnable
4080
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4081
                                    {
4082
                                        return;
4083
                                    }
4084
                                    CreateCommand.Instance.Execute(currentControl);
4085
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4086
                                    currentControl.IsNew = false;
4087
                                    currentControl = null;
4088
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4089
                                }
4090
                                else
4091
                                {
4092
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4093
                                    //{
4094
                                        currentControl = new ArrowTextControl()
4095
                                        {
4096
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4097
                                            ControlType = ControlType.ArrowTransTextCloudControl
4098

    
4099
                                        };
4100
                                        currentControl.CommentID = Commons.shortGuid();
4101
                                        currentControl.IsNew = true; 
4102
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4103
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4104
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4105

    
4106
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4107
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
4108
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4109
                                        (currentControl as ArrowTextControl).isFixed = true;
4110
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4111

    
4112
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4113
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4114
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4115
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4116
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4117
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);  
4118
                                    
4119
                                    //20180911 LJY
4120
                                        (currentControl as ArrowTextControl).isTrans = true;
4121
                                    //}
4122
                                }
4123
                            }
4124
                        }
4125
                        break;
4126
                    //강인구 추가
4127
                    case ControlType.Sign:
4128
                        {
4129
                            if (e.LeftButton == MouseButtonState.Pressed)
4130
                            {
4131
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4132
                                //{
4133
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4134

    
4135
                                if (_sign == null)
4136
                                    {
4137
                                        txtBatch.Visibility = Visibility.Collapsed;
4138
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4139
                                        controlType = ControlType.None;
4140

    
4141
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4142
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4143
                                        return;
4144
                                    }
4145

    
4146
                                    if (currentControl is SignControl)
4147
                                    {
4148
                                        //20180906 LJY TEST IsRotationDrawingEnable
4149
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4150
                                        {
4151
                                            return;
4152
                                        }
4153

    
4154
                                        CreateCommand.Instance.Execute(currentControl);
4155
                                        currentControl = null;
4156
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4157
                                        {
4158
                                            txtBatch.Text = "Place Date";
4159
                                            controlType = ControlType.Date;
4160
                                        }
4161
                                    }
4162
                                    else
4163
                                    {
4164
                                        currentControl = new SignControl
4165
                                        {
4166
                                            Background = new SolidColorBrush(Colors.Black),
4167
                                            UserNumber = App.ViewInfo.UserID,
4168
                                            ProjectNO = App.ViewInfo.ProjectNO,
4169
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4170
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4171
                                            ControlType = ControlType.Sign
4172
                                        };
4173

    
4174
                                        currentControl.CommentID = Commons.shortGuid();
4175
                                        currentControl.IsNew = true;
4176
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4177
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4178

    
4179
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4180
                                        (currentControl as SignControl).CommentAngle -= rotate.Angle;                                    
4181
                                }
4182
                                //}
4183
                            }
4184
                        }
4185
                        break;
4186
                    case ControlType.Mark:
4187
                        {
4188
                            if (e.LeftButton == MouseButtonState.Pressed)
4189
                            {
4190
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4191
                                //{
4192
                                    if (currentControl is RectangleControl)
4193
                                    {
4194
                                        //20180906 LJY TEST IsRotationDrawingEnable
4195
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4196
                                        {
4197
                                            return;
4198
                                        }
4199

    
4200
                                        CreateCommand.Instance.Execute(currentControl);
4201
                                        (currentControl as RectangleControl).ApplyOverViewData();
4202
                                        currentControl = null;
4203
                                    
4204
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4205

    
4206
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4207
                                        {
4208
                                            txtBatch.Text = "Place Signature";
4209
                                            controlType = ControlType.Sign;
4210
                                        }
4211
                                    }
4212
                                    else
4213
                                    {
4214
                                        currentControl = new RectangleControl
4215
                                        {
4216
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4217
                                            Background = new SolidColorBrush(Colors.Black),
4218
                                            ControlType = ControlType.Mark ,
4219
                                            Paint = PaintSet.Fill
4220
                                        };
4221

    
4222
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4223
                                        currentControl.CommentID = Commons.shortGuid();
4224
                                        currentControl.IsNew = true;
4225
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4226
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4227
                                    }
4228
                                //}
4229
                            }
4230
                        }
4231
                        break;
4232
                    case ControlType.Symbol:
4233
                        {
4234
                            if (e.LeftButton == MouseButtonState.Pressed)
4235
                            {
4236
                                if (currentControl is SymControl)
4237
                                {
4238
                                    //20180906 LJY TEST IsRotationDrawingEnable
4239
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4240
                                    {
4241
                                        return;
4242
                                    }
4243
                                    CreateCommand.Instance.Execute(currentControl);
4244
                                    currentControl = null;
4245
                                
4246
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4247
                                }
4248
                                else
4249
                                {
4250
                                    currentControl = new SymControl
4251
                                    {
4252
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4253
                                        Background = new SolidColorBrush(Colors.Black),
4254
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4255
                                        ControlType = ControlType.Symbol
4256
                                    };
4257

    
4258
                                    currentControl.IsNew = true;
4259
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4260
                                    currentControl.CommentID = Commons.shortGuid();
4261
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4262

    
4263
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4264
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4265
                                }
4266
                                //}
4267
                            }
4268
                        }
4269
                        break;
4270
                    case ControlType.Stamp:
4271
                        {
4272
                            if (e.LeftButton == MouseButtonState.Pressed)
4273
                            {
4274
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4275
                                //{
4276
                                    if (currentControl is SymControlN)
4277
                                    {
4278
                                        //20180906 LJY TEST IsRotationDrawingEnable
4279
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4280
                                        {
4281
                                            return;
4282
                                        }
4283

    
4284
                                        CreateCommand.Instance.Execute(currentControl);
4285
                                        currentControl = null;
4286
                                   
4287

    
4288
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4289
                                    }
4290
                                    else
4291
                                    {
4292
                                        currentControl = new SymControlN
4293
                                        {
4294
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4295
                                            Background = new SolidColorBrush(Colors.Black),
4296
                                            STAMP = App.SystemInfo.STAMP,                                            
4297
                                            ControlType = ControlType.Stamp
4298
                                        };
4299

    
4300
                                        currentControl.IsNew = true;
4301
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4302
                                        currentControl.CommentID = Commons.shortGuid();
4303
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4304
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4305
                                        (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4306
                                }                                    
4307
                                //}
4308
                            }
4309
                        }
4310
                        break;
4311
                    case ControlType.PenControl:
4312
                        {
4313
                            if (inkBoard.Tag.ToString() == "Ink")
4314
                            {
4315
                                inkBoard.IsEnabled = true;
4316
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4317
                            }
4318
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4319
                            {
4320
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4321
                            }
4322
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4323
                            {
4324
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4325
                            }
4326
                            IsDrawing = true;
4327
                            return;
4328
                        }
4329
                    default:
4330
                        if (currentControl != null)
4331
                        {
4332
                            currentControl.CommentID = null;
4333
                            currentControl.IsNew = false;
4334
                        }
4335
                        break;
4336
                }
4337

    
4338
                if (currentControl != null)
4339
                {
4340
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4341
                }
4342
            }
4343
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4344
            {
4345
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4346
                {
4347
                    bool mouseOff = false;
4348
                    foreach (var item in SelectLayer.Children)
4349
                    {
4350
                        if (item is AdornerFinal)
4351
                        {
4352

    
4353
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4354
                            if (over != null)
4355
                            {
4356
                                mouseOff = true;
4357
                            }
4358
                        }
4359
                    }
4360

    
4361
                    if (!mouseOff)
4362
                    {
4363
                        SelectionSet.Instance.UnSelect(this);
4364
                    }
4365
                }
4366
                zoomAndPanControl.CaptureMouse();
4367
                e.Handled = true;
4368
            }
4369
          
4370
        }
4371

    
4372
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4373
        {
4374
            ///mouseButtonDown = e.ChangedButton;
4375
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4376
        }
4377

    
4378
        private void RemoveLineStroke(Point P)
4379
        {
4380
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4381
            if (control != null)
4382
            {
4383
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4384
            }
4385
        }
4386

    
4387
        private void RemovePointStroke(Point P)
4388
        {
4389
            foreach (Stroke hits in inkBoard.Strokes)
4390
            {
4391
                foreach (StylusPoint sty in hits.StylusPoints)
4392
                {
4393

    
4394
                }
4395
                if (hits.HitTest(P))
4396
                {
4397
                    inkBoard.Strokes.Remove(hits);
4398
                    return;
4399
                }
4400
            }
4401
        }
4402

    
4403
        private void StartNewStroke(Point P)
4404
        {
4405
            strokePoints = new StylusPointCollection();
4406
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4407
            strokePoints.Add(segment1Start);
4408
            stroke = new Stroke(strokePoints);
4409

    
4410
            stroke.DrawingAttributes.Color = Colors.Red;
4411
            stroke.DrawingAttributes.Width = 4;
4412
            stroke.DrawingAttributes.Height = 4;
4413

    
4414
            inkBoard.Strokes.Add(stroke);
4415
        }
4416

    
4417
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4418
        {
4419
            ConsolidationMethod();
4420
        }
4421

    
4422
        /// <summary>
4423
        /// execute TeamConsolidationCommand
4424
        /// </summary>
4425
        public void TeamConsolidationMethod()
4426
        {
4427
            this.UpdateMyMarkupList();
4428
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4429
            {
4430
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4431
            }
4432
            else
4433
            {
4434

    
4435
                ViewerDataModel.Instance.IsConsolidate = true;
4436
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4437

    
4438
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4439
                {
4440
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4441
                    {
4442
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4443
                        return;
4444
                    }                    
4445
                }
4446
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4447
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4448
                {
4449
                    MarkupInfoList.Add(item);
4450
                }
4451
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4452
            }
4453
        }
4454

    
4455
        public void ConsolidationMethod()
4456
        {
4457
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4458
            {
4459
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4460
            }
4461
            else
4462
            {
4463
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4464
                foreach (var item in this.gridViewMarkup.SelectedItems)
4465
                {
4466
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4467
                }
4468
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4469
                
4470
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4471
            }
4472
        }
4473

    
4474
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4475
        {
4476
            if (App.ViewInfo != null)
4477
            {
4478
                btnConsolidate = (sender as RadRibbonButton);
4479
                if (!App.ViewInfo.NewCommentPermission)
4480
                {
4481
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4482
                }
4483
            }
4484
        }
4485

    
4486
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4487
        {
4488
            TeamConsolidationMethod();
4489
        }
4490

    
4491
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4492
        {
4493
            btnTeamConsolidate = sender as RadRibbonButton;
4494
            if (App.ViewInfo != null)
4495
            {
4496
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4497
                {
4498
                    if (btnConsolidate != null)
4499
                    {
4500
                        btnConsolidate.Visibility = Visibility.Collapsed;
4501
                    }
4502

    
4503
                    if (!App.ViewInfo.NewCommentPermission)
4504
                    {
4505
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4506
                    }
4507
                }
4508
                else
4509
                {
4510
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4511
                }
4512
            }
4513
        }
4514

    
4515
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4516
        {
4517
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4518
            if(item != null)
4519
            {
4520
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4521
                {
4522
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4523
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4524
                }
4525
                else
4526
                {
4527
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4528
                }
4529
            }else{
4530
                //Consolidate 가 없는 경우
4531
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4532
            }
4533
            
4534
        }
4535

    
4536
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4537
        {
4538
            btnFinalPDF = sender as RadRibbonButton;
4539
            if (App.ViewInfo != null)
4540
            {
4541
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4542
                {
4543
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4544
                    if (btnConsolidate != null)
4545
                    {
4546
                        btnConsolidate.Visibility = Visibility.Collapsed;
4547
                    }
4548
                }
4549
            }
4550
        }
4551

    
4552
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4553
        {
4554
            UpdateMyMarkupList();
4555

    
4556
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4557
            {
4558
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4559
            }
4560
            else
4561
            {
4562
                ViewerDataModel.Instance.IsConsolidate = true;
4563
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4564
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4565

    
4566
                string project_no = App.ViewInfo.ProjectNO;
4567
                string doc_id = _DocInfo.ID;
4568
                string user_id = App.ViewInfo.UserID;
4569
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4570
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4571
                {
4572
                    markupInfoItems.Add(item);
4573
                }
4574
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4575
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4576
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4577
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4578

    
4579
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4580
                if (item2 != null)
4581
                {
4582
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4583

    
4584
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4585
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4586
                }
4587
                else
4588
                {
4589
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4590
                }
4591
            }
4592
        }
4593

    
4594
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4595
        {
4596
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4597
#if Hyosung
4598
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4599
#else
4600
            if (App.ViewInfo != null)
4601
            {
4602
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4603
                {
4604
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4605
                }
4606
            }
4607
#endif
4608
        }
4609

    
4610
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4611
        {
4612
            SetCompareRect();
4613
        }
4614

    
4615
        private void Sync_Click(object sender, RoutedEventArgs e)
4616
        {
4617
            if (Sync.IsChecked)
4618
            {
4619
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4620
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4621
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4622
            }
4623
        }
4624

    
4625
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4626
        {
4627
            if (UserList.IsChecked)
4628
            {
4629
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4630
            }
4631
            else
4632
            {
4633
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4634
            }
4635
        }
4636

    
4637
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4638
        {
4639

    
4640
            if (BalanceMode.IsChecked)
4641
            {
4642
                ViewerDataModel.Instance.PageBalanceMode = true;
4643
            }
4644
            else
4645
            {
4646
                ViewerDataModel.Instance.PageBalanceMode = false;
4647
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4648
            }
4649
        }
4650

    
4651
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4652
        {
4653
            //초기화
4654
            testPanel2.IsHidden = true;
4655
            ViewerDataModel.Instance.PageBalanceMode = false;
4656
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4657
            ViewerDataModel.Instance.PageNumber = 0;
4658
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4659
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4660
            UserList.IsChecked = false;
4661
            BalanceMode.IsChecked = false;
4662
        }
4663

    
4664
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4665
        {
4666
            if ((sender as System.Windows.Controls.Control).Tag != null)
4667
            {
4668
                //Compare 초기화
4669
                CompareMode.IsChecked = false;
4670
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4671

    
4672
                if (ViewerDataModel.Instance.PageNumber == 0)
4673
                {
4674
                    ViewerDataModel.Instance.PageNumber = 1;
4675
                }
4676

    
4677
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4678
                {
4679
                }
4680
                else
4681
                {
4682
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4683
                }
4684

    
4685

    
4686

    
4687
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4688
                {
4689

    
4690
                }
4691
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4692
                {
4693
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4694
                }
4695

    
4696
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4697

    
4698
                if (!testPanel2.IsHidden)
4699
                {
4700
                    if (IsSyncPDFMode)
4701
                    {
4702
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4703
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4704

    
4705
                        if (pdfpath.IsDownloading)
4706
                        {
4707
                            pdfpath.DownloadCompleted += (ex, arg) =>
4708
                            {
4709
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4710
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4711
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4712
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4713
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4714
                            };
4715
                        }
4716
                        else
4717
                        {
4718
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4719
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4720
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4721

    
4722
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4723
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4724
                        }
4725

    
4726
                    }
4727
                    else
4728
                    {
4729
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4730

    
4731
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4732

    
4733
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4734
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4735
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4736

    
4737
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4738
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4739

    
4740
                        if (defaultBitmapImage_Compare.IsDownloading)
4741
                        {
4742
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4743
                            {
4744
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4745
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4746
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4747

    
4748
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4749
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4750
                            };
4751
                        }
4752
                    }
4753

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

    
4758
                    foreach (var item in gridSelectionRevItem)
4759
                    {
4760
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4761
                        foreach (var markupitem in markupitems)
4762
                        {
4763
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4764
                        }
4765
                    }
4766

    
4767
                    //강인구 추가
4768
                    zoomAndPanControl2.ZoomTo(new Rect
4769
                    {
4770
                        X = 0,
4771
                        Y = 0,
4772
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4773
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4774
                    });
4775

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

    
4778
                }
4779
            }
4780
        }
4781

    
4782
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4783
        {
4784
            if (MarkupMode.IsChecked)
4785
            {
4786
                IsSyncPDFMode = true;
4787

    
4788
                var uri = CurrentRev.TO_VENDOR;
4789

    
4790
                if (ViewerDataModel.Instance.PageNumber == 0)
4791
                {
4792
                    ViewerDataModel.Instance.PageNumber = 1;
4793
                }
4794

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

    
4799
                if (pdfpath.IsDownloading)
4800
                {
4801
                    pdfpath.DownloadCompleted += (ex, arg) =>
4802
                    {
4803
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4804
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4805
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4806
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4807
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4808
                    };
4809
                }
4810
                else
4811
                {
4812
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4813
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4814
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4815

    
4816
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4817
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4818
                }
4819
            }
4820
            else
4821
            {
4822
                IsSyncPDFMode = false;
4823
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4824

    
4825
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4826

    
4827
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4828
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4829
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4830

    
4831
                if (defaultBitmapImage_Compare.IsDownloading)
4832
                {
4833
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4834
                    {
4835
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4836
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4837
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4838
                    };
4839
                }
4840
                zoomAndPanControl2.ApplyTemplate();
4841
                zoomAndPanControl2.UpdateLayout();
4842
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4843
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4844
            }
4845
        }
4846

    
4847
        /// <summary>
4848
        /// Compare된 영역을 초기화
4849
        /// </summary>
4850
        private void ClearCompareRect()
4851
        {
4852
            da.From = 1;
4853
            da.To = 1;
4854
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4855
            da.AutoReverse = false;
4856
            canvas_compareBorder.Children.Clear();
4857
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4858
        }
4859

    
4860
        /// <summary>
4861
        /// 문서 Comprare 
4862
        /// </summary>
4863
        private void SetCompareRect()
4864
        {
4865
            if (CompareMode.IsChecked)
4866
            {
4867
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4868
                {
4869
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4870
                }
4871
                if (ViewerDataModel.Instance.PageNumber == 0)
4872
                {
4873
                    ViewerDataModel.Instance.PageNumber = 1;
4874
                }
4875

    
4876
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4877
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4878
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4879

    
4880
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4881
            }
4882
            else
4883
            {
4884
                ClearCompareRect();
4885
            }
4886
        }
4887

    
4888
        private void RadButton_Click(object sender, RoutedEventArgs e)
4889
        {
4890
            gridViewHistory_Busy.IsBusy = true;
4891

    
4892
            RadButton instance = sender as RadButton;
4893
            if (instance.CommandParameter != null)
4894
            {
4895
                CurrentRev = instance.CommandParameter as VPRevision;
4896
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4897

    
4898
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4899
                {
4900
                    if (ea.Error == null && ea.Result != null)
4901
                    {
4902
                        testPanel2.IsHidden = false;
4903

    
4904
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4905
                        foreach(var info in ea.Result)
4906
                        {
4907
                            if(info.UserID == App.ViewInfo.UserID)
4908
                            {
4909
                                info.userDelete = true;
4910
                                info.DisplayColor = "FFFF0000";
4911
                            }
4912
                            else
4913
                            {
4914
                                info.userDelete = false;
4915
                            }
4916
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4917
                        }
4918
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4919

    
4920
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4921

    
4922
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4923

    
4924
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4925
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4926
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4927
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4928
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4929
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4930

    
4931
                        zoomAndPanControl2.ApplyTemplate();
4932
                        zoomAndPanControl2.UpdateLayout();
4933
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4934
                        {
4935
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4936
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4937
                        }
4938

    
4939
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4940
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4941
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4942

    
4943
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4944
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4945
                        gridViewHistory_Busy.IsBusy = false;
4946
                    }
4947

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

    
4950
                    if (GetSyncMarkupInfoItemshandler != null)
4951
                    {
4952
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4953
                    }
4954

    
4955
                    ClearCompareRect();
4956
                    SetCompareRect();
4957
                };
4958

    
4959
                /// 중복 실행이 발생하여 수정함.
4960
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4961
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4962

    
4963
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4964
            }
4965
        }
4966

    
4967
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4968
        {
4969
            try
4970
            {
4971
                if (sender is RadButton)
4972
                {
4973
                    if ((sender as RadButton).Tag != null)
4974
                    {
4975
                        var url = (sender as RadButton).Tag.ToString();
4976
                        System.Diagnostics.Process.Start(url);
4977
                    }
4978
                    else
4979
                    {
4980
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4981
                    }
4982
                }
4983
            }
4984
            catch (Exception ex)
4985
            {
4986
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4987
            }
4988
        }
4989

    
4990
        public void Sync_Event(VPRevision Currnet_Rev)
4991
        {
4992
            CurrentRev = Currnet_Rev;
4993

    
4994
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4995
            {
4996
                if (ea.Error == null && ea.Result != null)
4997
                {
4998
                    testPanel2.IsHidden = false;
4999

    
5000
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5001
                    foreach(var info in ea.Result)
5002
                    {
5003
                        if(info.UserID == App.ViewInfo.UserID)
5004
                        {
5005
                            info.userDelete = true;
5006
                            info.DisplayColor = "FFFF0000";
5007
                        }
5008
                        else
5009
                        {
5010
                            info.userDelete = false;
5011
                        }
5012
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5013
                    }
5014
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5015

    
5016
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5017

    
5018
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5019

    
5020
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5021

    
5022
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5023
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5024
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5025

    
5026
                    if (defaultBitmapImage_Compare.IsDownloading)
5027
                    {
5028
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5029
                        {
5030
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5031
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5032
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5033
                        };
5034
                    }
5035

    
5036

    
5037
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5038
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5039
                    zoomAndPanControl2.ApplyTemplate();
5040
                    zoomAndPanControl2.UpdateLayout();
5041

    
5042
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5043
                    {
5044
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5045
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5046
                    }
5047
                    //}
5048

    
5049
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5050
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5051
                    gridViewHistory_Busy.IsBusy = false;
5052
                }
5053
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5054

    
5055
            };
5056
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5057
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5058
        }
5059

    
5060
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5061
        {
5062
            if (sender is Image)
5063
            {
5064
                if ((sender as Image).Tag != null)
5065
                {
5066
                    var pdfUrl = (sender as Image).Tag.ToString();
5067
                    System.Diagnostics.Process.Start(pdfUrl);
5068
                }
5069
                else
5070
                {
5071
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5072
                }
5073
            }
5074
        }
5075

    
5076
        private void Create_Symbol(object sender, RoutedEventArgs e)
5077
        {
5078
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5079

    
5080
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5081
            {
5082
                DialogMessage_Alert("Please Select Controls", "Alert");
5083
            }
5084
            else //선택된 것이 있으면
5085
            {
5086
                string MarkupData = "";
5087
                adorner_ = new AdornerFinal();
5088

    
5089
                foreach (var item in SelectLayer.Children)
5090
                {
5091
                    if (item.GetType().Name == "AdornerFinal")
5092
                    {
5093
                        adorner_ = (item as Controls.AdornerFinal);
5094
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5095
                        {
5096
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5097
                            {
5098
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5099
                                MarkupData += markupReturn.ConvertData;
5100
                            }
5101
                        }
5102
                    }
5103
                }
5104
                DialogParameters parameters = new DialogParameters()
5105
                {
5106
                    Owner = Application.Current.MainWindow,
5107
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5108
                    DefaultPromptResultValue = "Custom State",
5109
                    Content = "Name :",
5110
                    Header = "Insert Custom Symbol Name",
5111
                    Theme = new VisualStudio2013Theme(),
5112
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5113
                };
5114
                RadWindow.Prompt(parameters);
5115
            }
5116

    
5117
        }
5118
        public int symbolselectindex = 0;
5119
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5120
        {
5121
            //Save save = new Save();
5122
            try
5123
            {
5124
                string svgfilename = null;
5125
                if (symbolname != null)
5126
                {
5127
                    if (symbolpng == true || symbolsvg == true)
5128
                    {
5129
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5130
                        string guid = Commons.shortGuid();
5131

    
5132
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5133
                        //Check_Uri.UriCheck();
5134
                        fileUploader.RunCompleted += (ex, arg) =>
5135
                        {
5136
                            filename = arg.Result;
5137
                            if (symbolpng == true)
5138
                            {
5139
                                if (filename != null)
5140
                                { 
5141
                                    if (symbolselectindex == 0)
5142
                                    {
5143
                                        SymbolSave(symbolname, filename, data);
5144
                                    }
5145
                                    else
5146
                                    {
5147
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5148
                                    }
5149
                                    DataBind();
5150
                                }                                
5151
                            }
5152

    
5153
                            if (symbolsvg == true)
5154
                            {
5155
                                try
5156
                                {
5157
                                    var defaultBitmapImage = new BitmapImage();
5158
                                    defaultBitmapImage.BeginInit();
5159
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5160
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5161
                                    Check_Uri.UriCheck(filename);
5162
                                    defaultBitmapImage.UriSource = new Uri(filename);
5163
                                    defaultBitmapImage.EndInit();
5164

    
5165
                                    System.Drawing.Bitmap image;
5166

    
5167
                                    if (defaultBitmapImage.IsDownloading)
5168
                                    {
5169
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5170
                                        {
5171
                                            defaultBitmapImage.Freeze();
5172
                                            image = GetBitmap(defaultBitmapImage);
5173
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5174
                                            Process potrace = new Process
5175
                                            {
5176
                                                StartInfo = new ProcessStartInfo
5177
                                                {
5178
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5179
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5180
                                                    RedirectStandardInput = true,
5181
                                                    RedirectStandardOutput = true,
5182
                                                    RedirectStandardError = true,
5183
                                                    UseShellExecute = false,
5184
                                                    CreateNoWindow = true,
5185
                                                    WindowStyle = ProcessWindowStyle.Hidden
5186
                                                },
5187
                                            };
5188

    
5189
                                            StringBuilder svgBuilder = new StringBuilder();
5190
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5191
                                            {
5192
                                                svgBuilder.AppendLine(e2.Data);
5193
                                            };
5194

    
5195
                                            potrace.EnableRaisingEvents = true;
5196
                                            potrace.Start();
5197
                                            potrace.Exited += (sender, e) =>
5198
                                            {
5199
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5200
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5201
                                                Check_Uri.UriCheck(svgfilename);
5202
                                                if (symbolselectindex == 0)
5203
                                                {
5204
                                                    SymbolSave(symbolname, svgfilename, data);
5205
                                                }
5206
                                                else
5207
                                                {
5208
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5209
                                                }
5210

    
5211
                                                DataBind();
5212
                                            };
5213
                                            potrace.WaitForExit();
5214
                                        };
5215
                                    }
5216
                                    else
5217
                                    {
5218
                                        //GC.Collect();
5219
                                    }
5220
                                }
5221
                                catch(Exception ee)
5222
                                {
5223
                                    DialogMessage_Alert("" + ee, "Alert");
5224
                                }
5225
                            }
5226
                        };                                             
5227
                    }
5228
                }
5229
            }
5230
            catch (Exception e)
5231
            {
5232
                //DialogMessage_Alert(e + "", "Alert");
5233
            }            
5234
        }
5235

    
5236
        public void SymbolSave(string Name, string Url, string Data)
5237
        {
5238
            try
5239
            {
5240
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5241
                {
5242
                    ID = Commons.shortGuid(),
5243
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5244
                    NAME = Name,
5245
                    IMAGE_URL = Url,
5246
                    DATA = Data
5247
                };
5248

    
5249
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5250
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5251
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5252
            }
5253
            catch (Exception)
5254
            {
5255
                throw;
5256
            }
5257
        }
5258

    
5259
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5260
        {
5261
            try
5262
            {
5263
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5264
                {
5265
                    ID = Commons.shortGuid(),
5266
                    DEPARTMENT = Department,
5267
                    NAME = Name,
5268
                    IMAGE_URL = Url,
5269
                    DATA = Data
5270
                };
5271
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5272
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5273
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5274
            }
5275
            catch (Exception)
5276
            {
5277
                throw;
5278
            }
5279
        }
5280

    
5281
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5282
        {           
5283
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5284
            DataBind();
5285
        }
5286

    
5287
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5288
        {
5289
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5290
            DataBind();
5291
        }
5292
        private void DataBind()
5293
        {
5294
            try
5295
            {
5296
                Symbol_Custom Custom = new Symbol_Custom();
5297
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5298
                
5299
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5300
                foreach (var item in symbol_Private)
5301
                {
5302
                    Custom.Name = item.NAME;
5303
                    Custom.ImageUri = item.IMAGE_URL;
5304
                    Custom.ID = item.ID;
5305
                    Custom_List.Add(Custom);
5306
                    Custom = new Symbol_Custom();
5307
                }
5308
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5309
                
5310
                Custom = new Symbol_Custom();
5311
                Custom_List = new List<Symbol_Custom>();
5312

    
5313
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5314

    
5315
                List<SYMBOL_PUBLIC> symbol_Public;
5316

    
5317
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5318
                {
5319
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5320
                }
5321
                else
5322
                {
5323
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5324
                }
5325
                foreach (var item in symbol_Public)
5326
                {
5327
                    Custom.Name = item.NAME;
5328
                    Custom.ImageUri = item.IMAGE_URL;
5329
                    Custom.ID = item.ID;
5330
                    Custom_List.Add(Custom);
5331
                    Custom = new Symbol_Custom();
5332
                }
5333
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5334
                BaseClient.Close();                
5335
            }
5336
            catch(Exception e)
5337
            {
5338
                //DialogMessage_Alert("DataBind", "Alert");
5339
            }
5340
            
5341
        }
5342
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5343
        {
5344
            try
5345
            {
5346
                if (args.PromptResult != null)
5347
                {
5348
                    if (args.DialogResult.Value)
5349
                    {
5350
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5351

    
5352
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5353
                        _Encoder.Save(fs);
5354
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5355

    
5356
                        byte[] Img_byte = fs.ToArray();
5357

    
5358
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5359
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5360
                        Check_Uri.UriCheck(filename);
5361
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5362
                        {
5363
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5364
                        }
5365
                        else
5366
                        {
5367
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5368
                        }
5369
                        DataBind();
5370
                    }
5371
                }
5372
            }
5373
            catch(Exception ex)
5374
            {
5375
                DialogMessage_Alert("" + ex, "Alert");
5376
            }
5377
        }
5378

    
5379
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5380
        {
5381

    
5382
            Canvas _canvas = new Canvas();
5383
            _canvas.Background = Brushes.White;
5384
            _canvas.Width = adorner_.BorderSize.Width;
5385
            _canvas.Height = adorner_.BorderSize.Height;
5386
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5387

    
5388
            BitmapEncoder encoder = new PngBitmapEncoder();
5389

    
5390

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

    
5393
            DrawingVisual dv = new DrawingVisual();
5394

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

    
5398
            using (DrawingContext ctx = dv.RenderOpen())
5399
            {
5400
                VisualBrush vb = new VisualBrush(_canvas);
5401
                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)));
5402
            }
5403

    
5404
            try
5405
            {
5406
                renderBitmap.Render(dv);
5407

    
5408
                //GC.Collect();
5409
                GC.WaitForPendingFinalizers();
5410
                //GC.Collect();
5411
                // encode png data
5412
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5413
                // puch rendered bitmap into it
5414
                pngEncoder.Interlace = PngInterlaceOption.Off;
5415
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5416
                return pngEncoder;
5417

    
5418
            }
5419
            catch //(Exception ex)
5420
            {
5421
                return null;
5422
            }
5423

    
5424
        }
5425

    
5426
        public void DialogMessage_Alert(string content, string header)
5427
        {
5428
            DialogParameters parameters = new DialogParameters()
5429
            {
5430
                Owner = this.ParentOfType<MainWindow>(),
5431
                Content = new TextBlock()
5432
                { 
5433
                    MinWidth = 400,
5434
                    FontSize = 11,
5435
                    Text = content,
5436
                    TextWrapping = System.Windows.TextWrapping.Wrap
5437
                },
5438
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5439
                Header = header,
5440
                Theme = new VisualStudio2013Theme(),
5441
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5442
            };            
5443
            RadWindow.Alert(parameters);
5444
        }
5445

    
5446
#region 캡쳐 기능
5447

    
5448
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5449
        {
5450
            if (x < 0)
5451
            {
5452
                width += x;
5453
                x = 0;
5454
            }
5455
            if (y < 0)
5456
            {
5457
                height += y;
5458
                y = 0;
5459

    
5460
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5461
            }
5462
            if (x + width > zoomAndPanCanvas.ActualWidth)
5463
            {
5464
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5465
            }
5466
            if (y + height > zoomAndPanCanvas.ActualHeight)
5467
            {
5468
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5469
            }
5470

    
5471
            byte[] pixels = CopyPixels(x, y, width, height);
5472

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

    
5475
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5476
        }
5477

    
5478
        public byte[] CopyPixels(int x, int y, int width, int height)
5479
        {
5480
            byte[] pixels = new byte[width * height * 4];
5481
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5482

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

    
5486
            return pixels;
5487
        }
5488

    
5489
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5490
        {
5491
            DrawingVisual drawingVisual = new DrawingVisual();
5492
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5493

    
5494
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5495
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5496
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5497
            drawingContext.Close();
5498

    
5499
            // 비트맵으로 변환합니다.
5500
            RenderTargetBitmap target =
5501
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5502
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5503

    
5504
            target.Render(drawingVisual);
5505
            return target;
5506
        }
5507

    
5508
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5509
        {
5510
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5511
            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);
5512
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5513
            bmp.UnlockBits(data);
5514
            return bmp;
5515
        }
5516
        public string symbolname = null;
5517
        public bool symbolsvg = true;
5518
        public bool symbolpng = true;
5519

    
5520
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5521
        {
5522
            System.Drawing.Bitmap image = GetBitmap(source);
5523
            //흰색 제거
5524
            //image.MakeTransparent(System.Drawing.Color.White);
5525

    
5526
            var imageStream = new System.IO.MemoryStream();
5527
            byte[] imageBytes = null;
5528
            using (imageStream)
5529
            {
5530
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5531
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5532
                imageStream.Position = 0;
5533
                imageBytes = imageStream.ToArray();
5534
            }
5535

    
5536
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5537

    
5538
            RadWindow CheckPop = new RadWindow();
5539
            //Alert check = new Alert(Msg);
5540

    
5541
            CheckPop = new RadWindow
5542
            {
5543
                MinWidth = 400,
5544
                MinHeight = 100,
5545
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5546
                Header = "Alert",
5547
                Content = symbolPrompt,
5548
                //DialogResult = 
5549
                ResizeMode = System.Windows.ResizeMode.NoResize,
5550
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5551
                IsTopmost = true,
5552
            };
5553
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5554
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5555
            CheckPop.ShowDialog();
5556

    
5557
            /*
5558
            DialogParameters parameters = new DialogParameters()
5559
            {
5560
                Owner = Application.Current.MainWindow,
5561
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5562
                DefaultPromptResultValue = "Custom State",
5563
                Content = "Name :",
5564
                Header = "Insert Custom Symbol Name",
5565
                Theme = new VisualStudio2013Theme(),
5566
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5567
            };            
5568
            RadWindow.Prompt(parameters);
5569
            */
5570
        }
5571

    
5572
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5573
        {
5574
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5575
            KCOMDataModel.DataModel.CHECK_LIST check_;
5576
            string Result = streamToBase64.ImageToBase64(source);
5577
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5578
            string projectno = App.ViewInfo.ProjectNO;
5579
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5580

    
5581
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5582
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5583
            if (Item != null)
5584
            {
5585
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5586
            }
5587
            else
5588
            {
5589
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5590
            }
5591

    
5592
            if (Item == null)
5593
            {
5594
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5595
                {
5596
                    ID = Commons.shortGuid(),
5597
                    USER_ID = App.ViewInfo.UserID,
5598
                    IMAGE_URL = Result,
5599
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5600
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5601
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5602
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5603
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5604
                    STATUS = "False",
5605
                    CREATE_TIME = DateTime.Now,
5606
                    UPDATE_TIME = DateTime.Now,
5607
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5608
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5609
                };
5610
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5611
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5612
                //this.BaseClient.AddCheckList(projectno, check_);
5613
            }
5614
            else
5615
            {
5616
                Item.IMAGE_URL = Result;
5617
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5618
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5619
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5620
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5621
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5622
            }
5623

    
5624
        }
5625

    
5626
        public void Set_Capture()
5627
        {
5628
            double x = CanvasDrawingMouseDownPoint.X;
5629
            double y = CanvasDrawingMouseDownPoint.Y;
5630
            double width = dragCaptureBorder.Width;
5631
            double height = dragCaptureBorder.Height;
5632

    
5633
            if (width > 5 || height > 5)
5634
            {
5635
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5636
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5637
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5638
            }
5639
        }
5640
#endregion
5641

    
5642
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5643
        {
5644
            multi_Undo_Data = new Multi_Undo_data();
5645

    
5646
            multi_Undo_Data.Markup = control;
5647

    
5648
            if ((control as IShapeControl) != null)
5649
            {
5650
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5651
            }
5652
            if ((control as IDashControl) != null)
5653
            {
5654
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5655
            }
5656
            if ((control as IPath) != null)
5657
            {
5658
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5659
            }
5660
            if ((control as UIElement) != null)
5661
            {
5662
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5663
            }
5664

    
5665
            return multi_Undo_Data;
5666
        }
5667

    
5668
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5669
        {
5670
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5671
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5672
            {
5673
                if (items.UserID == Select_ID)
5674
                {
5675
                    foreach (var item in items.MarkupList)
5676
                    {
5677
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5678
                        {
5679
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5680
                                items.MarkupInfoID, Commons.shortGuid());
5681
                        }
5682
                    }
5683
                }
5684
            }
5685
        }
5686

    
5687
        /// <summary>
5688
        /// convert inkcontrol to polygoncontrol
5689
        /// </summary>
5690
        public void ConvertInkControlToPolygon()
5691
        {
5692
            if (inkBoard.Strokes.Count > 0)
5693
            {
5694
                inkBoard.Strokes.ToList().ForEach(stroke =>
5695
                {
5696
                    InkToPath ip = new InkToPath();
5697

    
5698
                    List<Point> inkPointSet = new List<Point>();
5699
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5700

    
5701
                    PolygonControl pc = new PolygonControl()
5702
                    {
5703
                        CommentAngle = 0,
5704
                        PointSet = inkPointSet,
5705
                        ControlType = ControlType.Ink
5706
                    };
5707
                    pc.StartPoint = inkPointSet[0];
5708
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5709
                    pc.LineSize = 3;
5710
                    pc.CommentID = Commons.shortGuid();
5711
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5712

    
5713
                    if (pc.PointSet.Count > 0)
5714
                    {
5715
                        CreateCommand.Instance.Execute(pc);
5716
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5717
                    }
5718
                });
5719
                inkBoard.Strokes.Clear();
5720
            }
5721
        }
5722

    
5723
        /// <summary>
5724
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5725
        /// </summary>
5726
        /// <author>ingu</author>
5727
        /// <date>2018.06.05</date>
5728
        /// <param name="getPoint"></param>
5729
        /// <returns></returns>
5730
        private bool IsGetoutpoint(Point getPoint)
5731
        {
5732
            if (getPoint == new Point())
5733
            {
5734
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5735
                currentControl = null;
5736
                return true;
5737
            }
5738

    
5739
            return false;
5740
        }
5741

    
5742
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5743
        {
5744
            e.Effects = DragDropEffects.Copy;
5745
        }
5746

    
5747
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5748
        {
5749
            e.Effects = DragDropEffects.Copy;
5750
        }
5751

    
5752
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5753
        {
5754
            e.Effects = DragDropEffects.None;
5755
        }
5756

    
5757
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5758
        {
5759
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5760
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5761

    
5762
            ScaleImage(pageWidth, pageHeight);
5763
        }
5764

    
5765
        /// <summary>
5766
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5767
        /// </summary>
5768
        /// <param name="pageWidth">원본 사이즈</param>
5769
        /// <param name="pageHeight">원본 사이즈</param>
5770
        /// <returns></returns>
5771
        private void ScaleImage(double pageWidth,double pageHeight)
5772
        {
5773
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5774
        }
5775

    
5776
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5777
        {
5778
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5779
        }
5780

    
5781
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
5782
        {
5783
            var checkbox = (sender as CheckBox);
5784

    
5785
            if (checkbox != null)
5786
            {
5787
                if (checkbox.IsChecked.GetValueOrDefault())
5788
                {
5789
                    gridViewMarkup.SelectAll();
5790
                }
5791
                else
5792
                {
5793
                    gridViewMarkup.UnselectAll();
5794
                }
5795
            }
5796
        }
5797

    
5798
        /*
5799
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5800
        {
5801
            try
5802
            {
5803
                if (e.Data.GetDataPresent(typeof(string)))
5804
                {
5805
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5806
                    string dragData = e.Data.GetData(typeof(string)) as string;
5807
                    Move_Symbol(sender, dragData);
5808
                }
5809
            }
5810
            catch (Exception ex)
5811
            {
5812
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5813
            }            
5814
        }
5815
        */
5816
    }
5817

    
5818
    public class testItem
5819
    {
5820
        public string Title { get; set; }
5821
    }
5822
}
클립보드 이미지 추가 (최대 크기: 500 MB)