프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
180
                }
181
            }
182
        }
183

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

    
208
        public bool IsSyncPDFMode { get; set; }
209

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

    
234
        #endregion
235

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

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

    
249
            //lstSymbolPrivate.ItemsSource = testItems;
250

    
251
            this.Loaded += MainMenu_Loaded;
252
        }
253

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

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

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

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

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

    
291
            return uri;
292
        }
293

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

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

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

    
335
            return false;
336
        }
337

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

    
361
            return false;
362
        }
363

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
498
        }
499

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

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

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

    
519
                    await task;
520

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

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

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

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

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

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

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

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

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

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

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

    
622
        DispatcherTimer renderTesttimer;
623

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

    
636

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

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

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

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

    
660
            #endregion
661

    
662
            ViewerDataModel.Instance.PageNumber = BalancePoint;
663

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

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

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

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

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

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

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

    
686
            #endregion
687

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

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

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

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

    
736
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
737

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

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

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

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

    
777
            SearchFocusBorder.Visibility = Visibility.Collapsed;
778

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

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

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

    
797

    
798
            var instanceMain = ViewerDataModel.Instance.SystemMain;
799

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

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

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

    
812
        private void MarkupLoad(int pageNumber)
813
        { 
814
            /// 컨트롤을 새로 생성한다.
815
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
816
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
817

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

    
840
            /// fire selection event
841
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
842
            this.gridViewMarkup.UnselectAll();
843
            this.gridViewMarkup.Select(gridSelectionItem);
844

    
845
            if (!testPanel2.IsHidden)
846
            {
847
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
848
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
849
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
850

    
851
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
852
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
853

    
854

    
855
                foreach (var item in gridSelectionRevItem)
856
                {
857
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
858
                    {
859
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
860
                    });
861
                }
862
            }
863
            
864
            SetCommentPages();
865

    
866
        }
867

    
868
        public void SetCommentPages()
869
        {
870
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
871
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
872
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
873
            {
874
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
875
                if(item.MarkupList != null)
876
                {
877
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
878
                    instance.UserName = item.UserName;
879
                    instance.Depart = item.Depatment;
880
                    instance.MarkupInfoID = item.MarkupInfoID;
881
                    instance.IsSelected = true;
882
                    instance.isConSolidation = item.Consolidate;
883
                    instance.SetColor = item.DisplayColor;
884
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
885
                    {
886
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
887
                    }
888
                    else
889
                    {
890
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
891
                    }
892
                    _pages.Add(instance);
893
                }                   
894
            }
895
            
896
            this.pageNavigator.SetCommentList(_pages.ToList());
897
        }
898

    
899
        public void MarkupitemViewUpdate(string markupinfo_id)
900
        {
901
            //db에 업데이트 한 list 를 view 에 업데이트
902
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
903
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
904
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
905
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
906
            if (dbinfo.MarkupList.Count > 0)
907
            {
908
                if (viewinfo.MarkupList != null)
909
                {
910
                    viewinfo.MarkupList.Clear();
911
                    viewinfo.MarkupList = null;
912
                }
913
                viewinfo.MarkupList = new List<MarkupItem>();
914
                foreach (var item in dbinfo.MarkupList)
915
                {
916
                    viewinfo.MarkupList.Add(item);
917
                }
918
            }
919
        }
920

    
921
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
922
        {
923
            var instance = ViewerDataModel.Instance;
924

    
925
            if(instance.IsWheelPageChanage)
926
            {
927
                return;
928
            }
929

    
930
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
931
            {
932
       
933
                int changePage = 0;
934
                
935
                if (e.Delta > 0)
936
                {
937
                    if (0 < instance.ContentOffsetY)
938
                    {
939
                        Vector dragOffset = new Vector(0, e.Delta);
940
                        MoveZoomAndPanControl(dragOffset);
941
                    }
942
                    //else
943
                    //{
944
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
945
                    //    {
946
                    //        instance.IsWheelPageChanage = true;
947
                    //        changePage -= 1;
948
                    //    }
949
                    //}
950
                }
951
                else if(e.Delta < 0)
952
                {
953
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
954
                    {
955
                        Vector dragOffset = new Vector(0,e.Delta);
956
                        MoveZoomAndPanControl(dragOffset);
957
                    }
958
                    //else
959
                    //{
960
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
961
                    //    {
962
                    //        instance.IsWheelPageChanage = true;
963
                    //        changePage += 1;
964
                    //    }
965
                    //}
966
                }
967

    
968
                //if (changePage != 0)
969
                //{
970
                //    await Task.Factory.StartNew(() =>
971
                //    {
972
                //        double beforeScale = instance.ContentScale;
973

    
974
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
975

    
976
                //        handler = (snd, evt) =>
977
                //        {
978
                //            /// 최상단으로 이전 zoomScale로 위치한다
979
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
980
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
981
                //            instance.IsWheelPageChanage = false;
982
                //            pageNavigator.PageChanged -= handler;
983
                //        };
984

    
985
                //        pageNavigator.PageChanged += handler;
986

    
987
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
988
                //    });
989
                    
990

    
991
                //}
992
            }
993
            else
994
            {
995
                e.Handled = true;
996
                if (e.Delta > 0)
997
                {
998
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
999
                    ZoomIn(currentContentMousePoint);
1000
                }
1001
                else
1002
                {
1003
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1004
                    ZoomOut(currentContentMousePoint);
1005
                }
1006
            }
1007
        }
1008

    
1009
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1010
        {
1011
            e.Handled = true;
1012
            if (e.Delta > 0)
1013
            {
1014
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1015
                ZoomIn_Sync(currentContentMousePoint);
1016
            }
1017
            else
1018
            {
1019
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1020
                ZoomOut_Sync(currentContentMousePoint);
1021
            }
1022
        }
1023

    
1024
        #region ZoomIn & ZoomOut
1025

    
1026
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1027
        {
1028
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1029
                zoomAndPanControl.ContentZoomFocusY));
1030
        }
1031

    
1032
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1033
        {
1034
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1035
                zoomAndPanControl.ContentZoomFocusY));
1036
        }
1037

    
1038

    
1039
        //강인구 추가 (줌 인아웃 수치 변경)
1040
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1041
        private void ZoomOut(Point contentZoomCenter)
1042
        {
1043
            if (zoomAndPanControl.ContentScale > 0.39)
1044
            {
1045
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1046
            }
1047
            else
1048
            {
1049
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1050
            }
1051

    
1052
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1053
            {
1054
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1055
            }
1056
        }
1057

    
1058
        private void ZoomIn(Point contentZoomCenter)
1059
        {
1060
            if (zoomAndPanControl.ContentScale > 0.19)
1061
            {
1062
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1063
            }
1064
            else
1065
            {
1066
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1067
            }
1068

    
1069
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1070
            {
1071
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1072
            }
1073

    
1074
        }
1075

    
1076
        private void ZoomOut_Sync(Point contentZoomCenter)
1077
        {
1078
            if (zoomAndPanControl2.ContentScale > 0.39)
1079
            {
1080
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1081
            }
1082
            else
1083
            {
1084
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1085
            }
1086

    
1087
            if (Sync.IsChecked)
1088
            {
1089
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1090
            }
1091
        }
1092

    
1093
        private void ZoomIn_Sync(Point contentZoomCenter)
1094
        {
1095
            if (zoomAndPanControl2.ContentScale > 0.19)
1096
            {
1097
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1098
            }
1099
            else
1100
            {
1101
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1102
            }
1103

    
1104
            if (Sync.IsChecked)
1105
            {
1106
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1107
            }
1108
        }
1109

    
1110
        private void ZoomOut()
1111
        {
1112
            zoomAndPanControl.ContentScale -= 0.1;
1113
            //if (zoomAndPanControl2 != null)
1114
            //{
1115
            //    zoomAndPanControl2.ContentScale -= 0.1;
1116
            //}
1117
        }
1118

    
1119
        private void ZoomIn()
1120
        {
1121
            zoomAndPanControl.ContentScale += 0.1;
1122
            //if (zoomAndPanControl2 != null)
1123
            //{
1124
            //    zoomAndPanControl2.ContentScale += 0.1;
1125
            //}
1126
        }
1127

    
1128
        #endregion
1129

    
1130
        private void init()
1131
        {
1132
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1133
            {
1134

    
1135
                ControlList.Clear();
1136
                listBox.Items.Clear();
1137
                selected_item.Clear();
1138

    
1139
                (item as IMarkupCommonData).IsSelected = false;
1140
            }
1141

    
1142
        }
1143

    
1144
        private HitTestResultBehavior MyCallback(HitTestResult result)
1145
        {
1146
            //this.cursor = Cursors.UpArrow;
1147
            var element = result.VisualHit;
1148
            while (element != null && !(element is CommentUserInfo))
1149
                element = VisualTreeHelper.GetParent(element);
1150

    
1151
            if (element == null)
1152
            {
1153
                return HitTestResultBehavior.Stop;
1154
            }
1155
            else
1156
            {
1157
                if (element is CommentUserInfo)
1158
                {
1159
                    if (!hitList.Contains(element))
1160
                    {
1161
                        hitList.Add((CommentUserInfo)element);
1162
                    }
1163
                    else
1164
                    {
1165
                        return HitTestResultBehavior.Stop;
1166
                    }
1167
                }
1168
            }
1169
            return HitTestResultBehavior.Continue;
1170
        }
1171

    
1172
        public void ReleaseSelectPath()
1173
        {
1174
            if (SelectionPath == null)
1175
            {
1176
                SelectionPath = new Path();
1177
                SelectionPath.Name = "";
1178
            }
1179
            if (SelectionPath.Name != "")
1180
            {
1181
                SelectionPath.Name = "None";
1182
            }
1183
            SelectionPath.Opacity = 0.01;
1184
            SelectionPath.RenderTransform = null;
1185
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1186
        }
1187

    
1188
        #region 컨트롤 초기화 
1189
        public void Control_Init(object control)
1190
        {
1191
            if (L_Size != 0 && (control as IPath) != null)
1192
            {
1193
                (control as IPath).LineSize = L_Size;
1194
                L_Size = 0;
1195
            }
1196

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

    
1283
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1284
        {
1285
            //Control_Init(e.Source);
1286
        }
1287
        //private Window _dragdropWindow = null;
1288

    
1289
        [DllImport("user32.dll")]
1290
        [return: MarshalAs(UnmanagedType.Bool)]
1291
        internal static extern bool GetCursorPos(ref Win32Point pt);
1292

    
1293
        [StructLayout(LayoutKind.Sequential)]
1294
        internal struct Win32Point
1295
        {
1296
            public Int32 X;
1297
            public Int32 Y;
1298
        };
1299
        /*
1300
       public string symbol_id = null;
1301
       public long symbol_group_id;
1302
       public int symbol_SelectedIndex;
1303
       public ImageSource symbol_img;
1304
       public string symbol_Data = null;
1305
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1306
       {
1307
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1308
               zoomAndPanCanvas.ActualHeight / 2));
1309

    
1310

    
1311
               if (this._dragdropWindow != null)
1312
               {
1313
                   this._dragdropWindow.Close();
1314
                   this._dragdropWindow = null;
1315
               }
1316

    
1317
               symbol_id = id;
1318
               symbol_group_id = group_id;
1319
               symbol_SelectedIndex = SelectedIndex;
1320
               symbol_Data = Data_;
1321
               symbol_img = img;
1322

    
1323

    
1324
               CreateDragDropWindow2(img);
1325
              
1326
    }
1327

    
1328
    private void CreateDragDropWindow2(ImageSource image)
1329
        {
1330
            this._dragdropWindow = new Window();
1331
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1332
            _dragdropWindow.WindowStyle = WindowStyle.None;
1333
            _dragdropWindow.AllowsTransparency = true;           
1334
            _dragdropWindow.AllowDrop = false;
1335
            _dragdropWindow.Background = null;
1336
            _dragdropWindow.IsHitTestVisible = false;
1337
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1338
            _dragdropWindow.Topmost = true;
1339
            _dragdropWindow.ShowInTaskbar = false;
1340
            
1341
            Rectangle r = new Rectangle();
1342
            r.Width = image.Width;
1343
            r.Height = image.Height;
1344
            r.Opacity = 0.5;            
1345
            r.Fill = new ImageBrush(image);
1346
            this._dragdropWindow.Content = r;
1347

    
1348
            Win32Point w32Mouse = new Win32Point();
1349
            GetCursorPos(ref w32Mouse);
1350

    
1351
            //w32Mouse.X = getCurrentPoint.X;
1352
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1353
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1354
            this._dragdropWindow.Show();
1355
        }
1356

    
1357
        
1358

    
1359
         */
1360

    
1361
        public void MoveZoomAndPanControl(Vector dragOffset)
1362
        {
1363
   
1364
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1365
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1366

    
1367
            if (Sync.IsChecked)
1368
            {
1369
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1370
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1371
            }
1372
        }
1373

    
1374
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1375
        {
1376
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1377
            {
1378
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1379

    
1380
                Point currentPos = e.GetPosition(rect);
1381

    
1382
                floatingTip.HorizontalOffset = currentPos.X + 20;
1383
                floatingTip.VerticalOffset = currentPos.Y;
1384
            }
1385

    
1386
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1387
            
1388
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1389
            {
1390
                SetCursor();
1391
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1392
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1393

    
1394
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1395

    
1396
                MoveZoomAndPanControl(dragOffset);
1397
            }
1398

    
1399
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1400
            {
1401
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1402
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1403
                SetCursor();
1404

    
1405
                if (currentControl != null)
1406
                {
1407
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1408
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1409
                    //강인구 추가
1410
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1411

    
1412
                    if ((currentControl as IPath) != null)
1413
                    {
1414
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1415
                    }
1416
                    if ((currentControl as LineControl) != null)
1417
                    {
1418
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1419
                    }
1420

    
1421
                    if ((currentControl as IShapeControl) != null)
1422
                    {
1423
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1424
                    }
1425
                    if ((currentControl as TextControl) != null)
1426
                    {
1427
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1428
                        {
1429
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1430
                        }
1431
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1432
                        {
1433
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1434
                        }
1435
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1436
                        {
1437
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1438
                        }
1439
                    }
1440
                    else if ((currentControl as ArrowTextControl) != null)
1441
                    {
1442
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1443
                        {
1444
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1445
                        }
1446
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1447
                        {
1448
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1449
                        }
1450
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1451
                        {
1452
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1453
                        }
1454
                    }
1455
                    else if ((currentControl as RectCloudControl) != null)
1456
                    {
1457
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1458
                    }
1459
                    else if ((currentControl as CloudControl) != null)
1460
                    {
1461
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1462
                    }
1463

    
1464

    
1465
                    #region // 모든 컨트롤의 공통기능 제어
1466
                    if (controlType != ControlType.PenControl)
1467
                    {
1468
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1469
                    }
1470

    
1471

    
1472
                    #endregion
1473

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

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

    
1549
                            }
1550
                            break;
1551

    
1552
                        case ControlType.ArcLine:
1553
                            {
1554
                                var control = currentControl as ArcControl;
1555
                                if (control != null)
1556
                                {
1557
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1558
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1559
                                }
1560
                            }
1561
                            break;
1562

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

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

    
1585
                        case ControlType.Circle:
1586
                            {
1587
                                var control = currentControl as CircleControl;
1588

    
1589
                                if (control != null)
1590
                                {
1591
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1592
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1593
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1594
                                }
1595
                            }
1596
                            break;
1597

    
1598
                        case ControlType.PolygonCloud:
1599
                            {
1600
                                var control = currentControl as CloudControl;
1601
                                if (control != null)
1602
                                {
1603
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1604
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1605
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1606
                                }
1607
                            }
1608
                            break;
1609

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

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

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

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

    
1726
                    #endregion
1727
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
1728
                    {
1729
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
1730
                    }
1731
                }
1732
            }
1733
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1734
            {
1735
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1736
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1737
                SetCursor();
1738
                if (currentControl == null)
1739
                {
1740
                    switch (controlType)
1741
                    {
1742
                        case ControlType.PenControl:
1743
                            {
1744
                                if (inkBoard.Tag.ToString() == "Ink")
1745
                                {
1746
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1747
                                }
1748
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1749
                                {
1750
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1751
                                }
1752
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1753
                                {
1754
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1755
                                }
1756

    
1757
                                //inkBoard.Strokes.Add(stroke);
1758
                            }
1759
                            break;
1760
                    }
1761
                    return;
1762
                }
1763
            }
1764
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1765
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1766
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1767
            {
1768
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1769

    
1770
                if (isDraggingSelectionRect)
1771
                {
1772
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1773
                    e.Handled = true;
1774
                }
1775
                else if (isLeftMouseButtonDownOnWindow)
1776
                {
1777
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1778
                    double dragDistance = Math.Abs(dragDelta.Length);
1779

    
1780
                    if (dragDistance > DragThreshold)
1781
                    {
1782
                        isDraggingSelectionRect = true;
1783
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1784
                    }
1785

    
1786
                    e.Handled = true;
1787
                }
1788

    
1789
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1790
                {
1791
                }
1792
                else
1793
                {
1794
                    e.Handled = true;
1795
                }
1796
            }
1797
            /*
1798
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1799
            { //symbol      
1800
                if(_dragdropWindow != null)
1801
                {
1802
                    Win32Point w32Mouse = new Win32Point();
1803
                    GetCursorPos(ref w32Mouse);
1804

    
1805
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1806
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1807
                }                
1808
            }
1809
            */
1810
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1811
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1812
            {
1813
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1814
                if(control != null)
1815
                {
1816
                    this.cursor = Cursors.Hand;
1817
                    SetCursor();
1818
                }
1819
                else
1820
                {
1821
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1822
                    SetCursor();
1823
                }
1824
            }
1825
            else
1826
            {
1827
            }
1828
        }
1829

    
1830
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1831
        {
1832
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1833
            {
1834
                SetCursor();
1835
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1836
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1837

    
1838
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1839

    
1840
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1841
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1842

    
1843
                if (Sync.IsChecked)
1844
                {
1845
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1846
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1847
                }
1848
            }
1849
        }
1850

    
1851
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1852

    
1853
        private EllipseGeometry hitArea = new EllipseGeometry();
1854

    
1855
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1856
        {
1857
            IsDrawing = false;
1858
    
1859
            if (mouseHandlingMode != MouseHandlingMode.None)
1860
            {
1861
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1862
                {
1863
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1864

    
1865
                    SetCursor();
1866

    
1867
                    switch (controlType)
1868
                    {
1869
                        case ControlType.None:
1870
                            break;
1871
                        case ControlType.Rectangle:
1872
                            {
1873

    
1874
                            }
1875
                            break;
1876
                        case ControlType.PenControl:
1877
                            {
1878

    
1879
                            }
1880
                            break;
1881
                        default:
1882
                            break;
1883
                    }                    
1884
                }
1885
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1886
                {
1887
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1888

    
1889
                    if (isLeftMouseButtonDownOnWindow)
1890
                    {
1891
                        bool wasDragSelectionApplied = false;
1892

    
1893
                        if (isDraggingSelectionRect)
1894
                        {
1895
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1896
                            {
1897
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1898
                                mouseHandlingMode = MouseHandlingMode.None;
1899
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1900
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1901
                                Set_Symbol_Capture(endPoint);
1902
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1903
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1904
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1905
                            }
1906
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1907
                            {
1908
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1909
                                mouseHandlingMode = MouseHandlingMode.None;
1910
                                Set_Capture();
1911

    
1912
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1913
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1914
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1915
                            }
1916
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1917
                            {
1918
                                ApplyDragSelectionRect();
1919
                            }
1920
                            else
1921
                            {
1922
                                double x = Canvas.GetLeft(dragZoomBorder);
1923
                                double y = Canvas.GetTop(dragZoomBorder);
1924
                                double width = dragZoomBorder.Width;
1925
                                double height = dragZoomBorder.Height;
1926
                                Rect dragRect = new Rect(x, y, width, height);
1927

    
1928
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1929

    
1930
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1931
                            }
1932

    
1933
                            isDraggingSelectionRect = false;
1934
                            e.Handled = true;
1935
                            wasDragSelectionApplied = true;
1936
                        }
1937

    
1938
                        if (isLeftMouseButtonDownOnWindow)
1939
                        {
1940
                            isLeftMouseButtonDownOnWindow = false;
1941
                            this.ReleaseMouseCapture();
1942
                            e.Handled = true;
1943
                        }
1944

    
1945
                        if (!wasDragSelectionApplied)
1946
                        {
1947
                            init();
1948
                        }
1949
                    }
1950
                }
1951
                else if (e.RightButton == MouseButtonState.Pressed)
1952
                {
1953
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1954
                    SetCursor();
1955
                }
1956

    
1957
                zoomAndPanControl.ReleaseMouseCapture();
1958

    
1959

    
1960
                e.Handled = true;
1961
            }
1962
            else
1963
            {
1964
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1965
                SetCursor();
1966
            }
1967

    
1968
            ///mouseButtonDown = MouseButton.Left;
1969
            //controlType = ControlType.SingleLine;
1970
        }
1971

    
1972
        public void Set_Symbol_Capture(Point endPoint)
1973
        {       
1974
            double x = CanvasDrawingMouseDownPoint.X;
1975
            double y = CanvasDrawingMouseDownPoint.Y;
1976
            if(x > endPoint.X)
1977
            {
1978
                x = endPoint.X;
1979
                y = endPoint.Y;
1980
            }
1981

    
1982
            double width = dragCaptureBorder.Width;
1983
            double height = dragCaptureBorder.Height;
1984

    
1985
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1986

    
1987
            if (x < 0)
1988
            {
1989
                width += x;
1990
                x = 0;
1991
            }
1992
            if (y < 0)
1993
            {
1994
                height += y;
1995
                y = 0;
1996

    
1997
                width = (int)canvasImage.PixelWidth - x;
1998
            }
1999
            if (x + width > canvasImage.PixelWidth)
2000
            {
2001
                width = (int)canvasImage.PixelWidth - x;
2002
            }
2003
            if (y + height > canvasImage.PixelHeight)
2004
            {
2005
                height = (int)canvasImage.PixelHeight - y;
2006
            }
2007
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2008

    
2009
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2010
            var defaultBitmapImage = new BitmapImage();
2011
            defaultBitmapImage.BeginInit();
2012
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2013
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2014
            defaultBitmapImage.UriSource = new Uri(uri);
2015
            defaultBitmapImage.EndInit();
2016

    
2017
            //GC.Collect();
2018

    
2019
            if (defaultBitmapImage.IsDownloading)
2020
            {
2021
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2022
                {
2023
                    defaultBitmapImage.Freeze();
2024
                    //GC.Collect();
2025
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2026
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2027
                };
2028
            }
2029
        }
2030

    
2031
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2032
        {
2033
            ///mouseButtonDown = MouseButton.Left;
2034
        }
2035

    
2036
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2037
        {
2038
            ///mouseButtonDown = MouseButton.Left;
2039
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2040
        }
2041

    
2042
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2043
        {
2044

    
2045
        }
2046

    
2047
        /// <summary>
2048
        /// select items by dragging
2049
        /// </summary>
2050
        private void ApplyDragSelectionRect()
2051
        {
2052
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2053

    
2054
            double x = Canvas.GetLeft(dragSelectionBorder);
2055
            double y = Canvas.GetTop(dragSelectionBorder);
2056
            double width = dragSelectionBorder.Width;
2057
            double height = dragSelectionBorder.Height;
2058
            Boolean Flag = false;
2059
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2060
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2061

    
2062
            Rect dragRect = new Rect(x, y, width, height);
2063
            ///dragRect.Inflate(width / 10, height / 10);
2064

    
2065
            foreach (var item in Items)
2066
            {
2067
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2068

    
2069
                if (Flag)
2070
                {
2071
                    adornerSet.Add(item);
2072
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2073
                    Control_Style(item);
2074
                }
2075
            }
2076
            if (adornerSet.Count > 0)
2077
            {
2078
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2079
                SelectLayer.Children.Add(final);
2080
            }
2081
        }
2082

    
2083
        private void InitDragSelectionRect(Point pt1, Point pt2)
2084
        {
2085
            //캡쳐 중
2086
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2087
            {
2088
                dragCaptureBorder.Visibility = Visibility.Visible;
2089
            }
2090
            //선택 중
2091
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2092
            {
2093

    
2094
                dragSelectionBorder.Visibility = Visibility.Visible;
2095
            }
2096
            else
2097
            {
2098
                dragZoomBorder.Visibility = Visibility.Visible;
2099
            }
2100
            UpdateDragSelectionRect(pt1, pt2);
2101
        }
2102

    
2103
        /// <summary>
2104
        /// Update the position and size of the rectangle used for drag selection.
2105
        /// </summary>
2106
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2107
        {
2108
            double x, y, width, height;
2109

    
2110
            //
2111
            // Determine x,y,width and height of the rect inverting the points if necessary.
2112
            // 
2113

    
2114
            if (pt2.X < pt1.X)
2115
            {
2116
                x = pt2.X;
2117
                width = pt1.X - pt2.X;
2118
            }
2119
            else
2120
            {
2121
                x = pt1.X;
2122
                width = pt2.X - pt1.X;
2123
            }
2124

    
2125
            if (pt2.Y < pt1.Y)
2126
            {
2127
                y = pt2.Y;
2128
                height = pt1.Y - pt2.Y;
2129
            }
2130
            else
2131
            {
2132
                y = pt1.Y;
2133
                height = pt2.Y - pt1.Y;
2134
            }
2135

    
2136
            //
2137
            // Update the coordinates of the rectangle used for drag selection.
2138
            //
2139
            //캡쳐 중
2140
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2141
            {
2142
                Canvas.SetLeft(dragCaptureBorder, x);
2143
                Canvas.SetTop(dragCaptureBorder, y);
2144
                dragCaptureBorder.Width = width;
2145
                dragCaptureBorder.Height = height;
2146
            }
2147
            //선택 중
2148
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2149
            {
2150
                Canvas.SetLeft(dragSelectionBorder, x);
2151
                Canvas.SetTop(dragSelectionBorder, y);
2152
                dragSelectionBorder.Width = width;
2153
                dragSelectionBorder.Height = height;
2154
            }
2155
            else
2156
            {
2157
                Canvas.SetLeft(dragZoomBorder, x);
2158
                Canvas.SetTop(dragZoomBorder, y);
2159
                dragZoomBorder.Width = width;
2160
                dragZoomBorder.Height = height;
2161
            }
2162
        }
2163

    
2164
        private void drawingPannelRotate(double angle)
2165
        {
2166
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2167
            rotate.Angle = angle;
2168
            var rotationNum = Math.Abs((rotate.Angle / 90));
2169

    
2170
            if (angle == 90 || angle == 270)
2171
            {
2172
                double emptySize = zoomAndPanCanvas.Width;
2173
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2174
                zoomAndPanCanvas.Height = emptySize;
2175
            }
2176
            if (angle == 0)
2177
            {
2178
                translate.X = 0;
2179
                translate.Y = 0;
2180
            }
2181
            else if (angle == 90)
2182
            {
2183
                translate.X = zoomAndPanCanvas.Width;
2184
                translate.Y = 0;
2185
            }
2186
            else if (angle == 180)
2187
            {
2188
                translate.X = zoomAndPanCanvas.Width;
2189
                translate.Y = zoomAndPanCanvas.Height;
2190
            }
2191
            else
2192
            {
2193
                translate.X = 0;
2194
                translate.Y = zoomAndPanCanvas.Height;
2195
            }
2196

    
2197
            zoomAndPanControl.RotationAngle = rotate.Angle;
2198

    
2199

    
2200
            if (!testPanel2.IsHidden)
2201
            {
2202
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2203
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2204
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2205
            }
2206

    
2207
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2208
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2209
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2210
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2211
            ViewerDataModel.Instance.Angle = rotate.Angle;
2212
        }
2213

    
2214
        private void syncPannelRotate(double angle)
2215
        {
2216
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2217
            rotate.Angle = angle;
2218
            var rotationNum = Math.Abs((rotate.Angle / 90));
2219

    
2220
            if (angle == 90 || angle == 270)
2221
            {
2222
                double emptySize = zoomAndPanCanvas2.Width;
2223
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2224
                zoomAndPanCanvas2.Height = emptySize;
2225
            }
2226
            if (angle == 0)
2227
            {
2228
                translate2.X = 0;
2229
                translate2.Y = 0;
2230
            }
2231
            else if (angle == 90)
2232
            {
2233
                translate2.X = zoomAndPanCanvas2.Width;
2234
                translate2.Y = 0;
2235
            }
2236
            else if (angle == 180)
2237
            {
2238
                translate2.X = zoomAndPanCanvas2.Width;
2239
                translate2.Y = zoomAndPanCanvas2.Height;
2240
            }
2241
            else
2242
            {
2243
                translate2.X = 0;
2244
                translate2.Y = zoomAndPanCanvas2.Height;
2245
            }
2246

    
2247
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2248
        }
2249

    
2250
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2251
        {
2252
            string Data_ = "";
2253

    
2254
            try
2255
            {
2256
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2257
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2258
                if (Data_ != null || Data_ != "")
2259
                {
2260
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2261
                }
2262
                else
2263
                {
2264
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2265
                }
2266

    
2267
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2268
                //{
2269
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2270
                //    STATE = 0,
2271
                //};
2272
                if (Data_ != null)
2273
                {
2274
                    Image img = new Image();
2275
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2276
                    if (Data_.Contains(".svg"))
2277
                    {
2278
                        byte[] imageData = null;
2279
                        DrawingImage image = null;
2280
                        using (System.Net.WebClient web = new System.Net.WebClient())
2281
                        {
2282
                            imageData = web.DownloadData(new Uri(Data_));
2283
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2284
                            image = SvgReader.Load(stream);
2285
                        }
2286
                        img.Source = image;
2287
                    }
2288
                    else
2289
                    {
2290
                        img.Source = new BitmapImage(new Uri(Data_));
2291
                    }
2292

    
2293
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2294
                    {
2295
                        PointSet = new List<Point>(),
2296
                        FilePath = Data_,
2297
                        ImageData = img.Source,
2298
                        StartPoint = canvasZoomPanningMouseDownPoint,
2299
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2300
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2301
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2302
                        canvasZoomPanningMouseDownPoint.Y),
2303
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2304
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2305
                    };
2306

    
2307
                    currentControl.PointSet = new List<Point>
2308
                                        {
2309
                                            currentControl.StartPoint,
2310
                                            currentControl.LeftBottomPoint,
2311
                                            currentControl.EndPoint,
2312
                                            currentControl.TopRightPoint,
2313
                                        };
2314
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2315
                    UndoData = new Undo_data()
2316
                    {
2317
                        IsUndo = false,
2318
                        Event = Event_Type.Create,
2319
                        EventTime = DateTime.Now,
2320
                        Markup_List = new List<Multi_Undo_data>()
2321
                    };
2322
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2323
                    {
2324
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2325
                    });
2326

    
2327
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2328
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2329
                    UndoData.Markup_List.Add(multi_Undo_Data);
2330
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2331

    
2332
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2333
                    currentControl.CommentID = Commons.shortGuid();
2334
                    currentControl.SymbolID = id;
2335
                    currentControl.GroupID = group_id;
2336
                    currentControl.ApplyTemplate();
2337
                    currentControl.SetImage();
2338

    
2339
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2340
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2341
                    SelectLayer.Children.Add(final);
2342
                }
2343
            }
2344
            catch (Exception ex)
2345
            {
2346
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2347
            }
2348
        }
2349

    
2350
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2351
        {
2352
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2353
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2354
            {
2355
                set_option.Value = double.Parse(set_option.ContentText);
2356
                //set_option.Focusable = false;
2357
                zoomAndPanControl.Focus();
2358
            }
2359

    
2360
            ConvertInkControlToPolygon();
2361

    
2362
            ///TODO:
2363
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2364
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2365

    
2366
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2367
            {
2368
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2369
            }
2370
            /// up to here
2371

    
2372
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2373
            {
2374
                if (item as ArrowTextControl != null)
2375
                {
2376
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2377
                }
2378
                else if (item as TextControl != null)
2379
                {
2380
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2381
                }
2382
            }
2383

    
2384
            //if (currentControl != null)
2385
            {
2386
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2387
                if (text_item_ != null)
2388
                {
2389
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2390
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2391
                    (text_item_ as TextControl).IsEditingMode = false;                    
2392
                    currentControl = null;
2393
                }
2394

    
2395
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2396
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2397
                {
2398
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2399
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2400
                    currentControl = null;
2401
                }
2402
            }
2403

    
2404
            double Ang = 0;                                          
2405
            if (rotate.Angle != 0)
2406
            {
2407
                Ang = 360 - rotate.Angle;
2408
            }
2409

    
2410
            if (e.OriginalSource is System.Windows.Controls.Image)
2411
            {
2412
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2413
            }
2414
            /*
2415
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2416
            {                
2417
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2418
                if(symbol_id != null)
2419
                {
2420
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2421
                }                
2422
            }
2423

    
2424
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2425
            {
2426
                if (this._dragdropWindow != null)
2427
                {
2428
                    this._dragdropWindow.Close();
2429
                    this._dragdropWindow = null;
2430
                    symbol_id = null;
2431
                }
2432
            }
2433
            */
2434

    
2435
            if (e.LeftButton == MouseButtonState.Pressed)
2436
            {
2437
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2438
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2439

    
2440
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2441
                SetCursor();
2442

    
2443
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2444
            }
2445

    
2446
            if (e.MiddleButton == MouseButtonState.Pressed)
2447
            {
2448
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2449
                cursor = Cursors.SizeAll;
2450
                SetCursor();
2451
            }
2452
            if (e.RightButton == MouseButtonState.Pressed)
2453
            {
2454
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2455
                cursor = Cursors.SizeAll;
2456
                SetCursor();
2457
            }
2458
            else if (e.XButton1 == MouseButtonState.Pressed)
2459
            {
2460
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2461
                {
2462
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2463
                }
2464

    
2465
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2466

    
2467
            }
2468
            else if (e.XButton2 == MouseButtonState.Pressed)
2469
            {
2470
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2471
                {
2472
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2473
                }
2474
            }
2475

    
2476
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2477
            {
2478
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2479
                {
2480
                    if (SelectLayer.Children.Count == 0)
2481
                    {
2482
                        isLeftMouseButtonDownOnWindow = true;
2483
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2484
                    }
2485

    
2486
                    if (controlType == ControlType.None)
2487
                    {
2488
                        isLeftMouseButtonDownOnWindow = true;
2489
                    }
2490
                }
2491

    
2492
                /// 캡쳐 모드 설정
2493
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2494
                {
2495
                    dragCaptureBorder.Visibility = Visibility.Visible;
2496
                    isLeftMouseButtonDownOnWindow = true;
2497
                }
2498

    
2499
                /// 줌 모드 설정
2500
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2501
                {
2502
                    isLeftMouseButtonDownOnWindow = true;
2503
                }
2504

    
2505
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2506
                if (control != null)
2507
                {
2508
                    AdornerFinal final = null;
2509

    
2510
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2511
                    {
2512
                        /// 기존 selection 해제
2513
                        SelectionSet.Instance.UnSelect(this);
2514

    
2515
                        final = new AdornerFinal(control);
2516

    
2517
                        this.Control_Style(control);
2518

    
2519
                        if ((control as IPath) != null)
2520
                        {
2521
                            if ((control as IPath).LineSize != 0)
2522
                            {
2523
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2524
                            }
2525
                        }
2526
                        if ((control as IShapeControl) != null)
2527
                        {
2528
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2529
                            {
2530
                                ViewerDataModel.Instance.checkHatchShape = true;
2531
                            }
2532
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2533
                            {
2534
                                ViewerDataModel.Instance.checkFillShape = true;
2535
                            }
2536
                            else
2537
                            {
2538
                                ViewerDataModel.Instance.checkHatchShape = false;
2539
                                ViewerDataModel.Instance.checkFillShape = false;
2540
                            }
2541
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2542
                        }
2543

    
2544
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2545

    
2546
                        if ((control as TextControl) != null)
2547
                        {
2548
                            if(!((control as TextControl).EnableEditing)) {
2549
                                (control as TextControl).EnableEditing = true;
2550
                            }
2551
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2552
                            {
2553
                                ViewerDataModel.Instance.checkTextStyle = true;
2554
                            }
2555
                            else
2556
                            {
2557
                                ViewerDataModel.Instance.checkTextStyle = false;
2558
                            }
2559
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2560
                            {
2561
                                ViewerDataModel.Instance.checkTextWeight = true;
2562
                            }
2563
                            else
2564
                            {
2565
                                ViewerDataModel.Instance.checkTextWeight = false;
2566
                            }
2567
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2568
                            {
2569
                                ViewerDataModel.Instance.checkUnderLine = true;
2570
                            }
2571
                            else
2572
                            {
2573
                                ViewerDataModel.Instance.checkUnderLine = false;
2574
                            }
2575
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2576
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2577

    
2578
                        }
2579
                        else if ((control as ArrowTextControl) != null)
2580
                        {
2581
                            if (!((control as ArrowTextControl).EnableEditing))
2582
                            {
2583
                                (control as ArrowTextControl).EnableEditing = true;
2584
                            }
2585
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2586
                            {
2587
                                ViewerDataModel.Instance.checkTextStyle = true;
2588
                            }
2589
                            else
2590
                            {
2591
                                ViewerDataModel.Instance.checkTextStyle = false;
2592
                            }
2593
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2594
                            {
2595
                                ViewerDataModel.Instance.checkTextWeight = true;
2596
                            }
2597
                            else
2598
                            {
2599
                                ViewerDataModel.Instance.checkTextWeight = false;
2600
                            }
2601
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2602
                            {
2603
                                ViewerDataModel.Instance.checkUnderLine = true;
2604
                            }
2605
                            else
2606
                            {
2607
                                ViewerDataModel.Instance.checkUnderLine = false;
2608
                            }
2609
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2610
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2611
                        }
2612
                        else if ((control as RectCloudControl) != null)
2613
                        {
2614
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2615
                        }
2616
                        else if ((control as CloudControl) != null)
2617
                        {
2618
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2619
                        }
2620
                    }
2621
                    else
2622
                    {
2623
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2624
                        SelectionSet.Instance.UnSelect(this);
2625
                        comment.Add(control);
2626

    
2627
                        Control_Style(control);
2628

    
2629
                        final = new AdornerFinal(comment);
2630
                    }
2631

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

    
2676
                switch (controlType)
2677
                {
2678
                    case ControlType.Coordinate:
2679
                        {
2680
                            if (e.LeftButton == MouseButtonState.Pressed)
2681
                            {
2682
                                if (currentControl is CoordinateControl)
2683
                                {
2684
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2685
                                    {
2686
                                        return;
2687
                                    }
2688

    
2689
                                    CreateCommand.Instance.Execute(currentControl);
2690

    
2691
                                    currentControl = null;
2692
                                    this.cursor = Cursors.Arrow;
2693
                                }
2694
                                else
2695
                                {
2696
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2697
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2698
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2699
                                    {
2700
                                        currentControl = null;
2701
                                        this.cursor = Cursors.Arrow;
2702
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2703
                                        return;
2704
                                    }
2705
                                    else
2706
                                    {
2707
                                        currentControl = new CoordinateControl
2708
                                        {
2709
                                            Background = new SolidColorBrush(Colors.Black),
2710
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
2711
                                            ControlType = ControlType.Coordinate
2712
                                        };
2713

    
2714
                                        currentControl.CommentID = Commons.shortGuid();
2715
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2716
                                        currentControl.IsNew = true;
2717

    
2718
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2719

    
2720
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2721
                                    }
2722
                                }
2723
                            }
2724
                        }
2725
                        break;
2726
                    case ControlType.InsideWhite:
2727
                        {
2728
                            if (e.LeftButton == MouseButtonState.Pressed)
2729
                            {
2730
                                if (currentControl is InsideWhiteControl)
2731
                                {
2732
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2733
                                    {
2734
                                        return;
2735
                                    }
2736

    
2737
                                    CreateCommand.Instance.Execute(currentControl);
2738

    
2739
                                    currentControl = null;
2740
                                    this.cursor = Cursors.Arrow;
2741
                                }
2742
                                else
2743
                                {
2744
                                    currentControl = new InsideWhiteControl
2745
                                    {
2746
                                        Background = new SolidColorBrush(Colors.Black),
2747
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2748
                                        ControlType = ControlType.InsideWhite
2749
                                    };
2750

    
2751
                                    currentControl.CommentID = Commons.shortGuid();
2752
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2753
                                    currentControl.IsNew = true;
2754
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2755

    
2756
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2757
                                }
2758
                            }
2759
                        }
2760
                        break;
2761
                    case ControlType.OverlapWhite:
2762
                        {
2763
                            if (e.LeftButton == MouseButtonState.Pressed)
2764
                            {
2765
                                if (currentControl is OverlapWhiteControl)
2766
                                {
2767
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2768
                                    {
2769
                                        return;
2770
                                    }
2771

    
2772
                                    CreateCommand.Instance.Execute(currentControl);
2773

    
2774
                                    currentControl = null;
2775
                                    this.cursor = Cursors.Arrow;
2776
                                }
2777
                                else
2778
                                {
2779
                                    currentControl = new OverlapWhiteControl
2780
                                    {
2781
                                        Background = new SolidColorBrush(Colors.Black),
2782
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2783
                                        ControlType = ControlType.OverlapWhite
2784
                                    };
2785

    
2786
                                    currentControl.CommentID = Commons.shortGuid();
2787
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2788
                                    currentControl.IsNew = true;
2789
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2790

    
2791
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2792
                                }
2793
                            }
2794
                        }
2795
                        break;
2796
                    case ControlType.ClipWhite:
2797
                        {
2798
                            if (e.LeftButton == MouseButtonState.Pressed)
2799
                            {
2800
                                if (currentControl is ClipWhiteControl)
2801
                                {
2802
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2803
                                    {
2804
                                        return;
2805
                                    }
2806

    
2807
                                    CreateCommand.Instance.Execute(currentControl);
2808

    
2809
                                    currentControl = null;
2810
                                    this.cursor = Cursors.Arrow;
2811
                                }
2812
                                else
2813
                                {
2814
                                    currentControl = new ClipWhiteControl
2815
                                    {
2816
                                        Background = new SolidColorBrush(Colors.Black),
2817
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2818
                                        ControlType = ControlType.ClipWhite
2819
                                    };
2820

    
2821
                                    currentControl.CommentID = Commons.shortGuid();
2822
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2823
                                    currentControl.IsNew = true;
2824
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2825

    
2826
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2827
                                }
2828
                            }
2829
                        }
2830
                        break;
2831
                    case ControlType.Rectangle:
2832
                        {
2833
                            if (e.LeftButton == MouseButtonState.Pressed)
2834
                            {
2835
                                if (currentControl is RectangleControl)
2836
                                {
2837
                                    //20180906 LJY TEST IsRotationDrawingEnable
2838
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2839
                                    {
2840
                                        return;
2841
                                    }
2842

    
2843
                                    CreateCommand.Instance.Execute(currentControl);
2844
                                    currentControl = null;
2845
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2846
                                }
2847
                                else
2848
                                {
2849
                                    currentControl = new RectangleControl
2850
                                    {
2851
                                        Background = new SolidColorBrush(Colors.Black),
2852
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2853
                                        ControlType = ControlType.Rectangle
2854
                                    };
2855

    
2856
                                    currentControl.CommentID = Commons.shortGuid();
2857
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2858
                                    currentControl.IsNew = true;
2859
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2860

    
2861
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2862
                                }
2863
                            }
2864
                        }
2865
                        break;
2866
                    case ControlType.RectCloud:
2867
                        {
2868
                            if (e.LeftButton == MouseButtonState.Pressed)
2869
                            {
2870
                                if (currentControl is RectCloudControl)
2871
                                {
2872
                                    //20180906 LJY TEST IsRotationDrawingEnable
2873
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2874
                                    {
2875
                                        return;
2876
                                    }
2877

    
2878
                                    CreateCommand.Instance.Execute(currentControl);
2879

    
2880
                                    currentControl = null;
2881
                                
2882
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2883
                                }
2884
                                else
2885
                                {
2886
                                    currentControl = new RectCloudControl
2887
                                    {
2888
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2889
                                        ControlType = ControlType.RectCloud,
2890
                                        Background = new SolidColorBrush(Colors.Black)
2891
                                    };
2892

    
2893
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2894
                                    currentControl.CommentID = Commons.shortGuid();
2895
                                    currentControl.IsNew = true;
2896
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2897
                                }
2898
                            }
2899
                        }
2900
                        break;
2901
                    case ControlType.Circle:
2902
                        {
2903
                            if (e.LeftButton == MouseButtonState.Pressed)
2904
                            {
2905
                                if (currentControl is CircleControl)
2906
                                {
2907
                                    //20180906 LJY TEST IsRotationDrawingEnable
2908
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2909
                                    {
2910
                                        return;
2911
                                    }
2912

    
2913
                                    CreateCommand.Instance.Execute(currentControl);
2914

    
2915
                                    currentControl = null;
2916
                                }
2917
                                else
2918
                                {
2919
                                    currentControl = new CircleControl
2920
                                    {
2921
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2922
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2923
                                        Background = new SolidColorBrush(Colors.Black)
2924
                                    };
2925

    
2926
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2927
                                    currentControl.CommentID = Commons.shortGuid();
2928
                                    currentControl.IsNew = true;
2929
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2930
                                }
2931
                            }
2932
                        }
2933
                        break;
2934
                    case ControlType.Triangle:
2935
                        {
2936
                            if (e.LeftButton == MouseButtonState.Pressed)
2937
                            {
2938
                                if (currentControl is TriControl)
2939
                                {
2940
                                    var content = currentControl as TriControl;
2941
                                    if (content.MidPoint == new Point(0, 0))
2942
                                    {
2943
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
2944
                                    }
2945
                                    else
2946
                                    {
2947
                                        //20180906 LJY TEST IsRotationDrawingEnable
2948
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2949
                                        {
2950
                                            return;
2951
                                        }
2952

    
2953
                                        CreateCommand.Instance.Execute(currentControl);
2954

    
2955
                                        currentControl = null;
2956
                                    }
2957
                                }
2958
                                else
2959
                                {
2960
                                    currentControl = new TriControl
2961
                                    {
2962
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2963
                                        Background = new SolidColorBrush(Colors.Black),
2964
                                    };
2965

    
2966
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2967
                                    currentControl.CommentID = Commons.shortGuid();
2968
                                    currentControl.IsNew = true;
2969
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2970
                                }
2971
                            }
2972
                        }
2973
                        break;
2974
                    case ControlType.CancelLine:
2975
                    case ControlType.SingleLine:
2976
                    case ControlType.ArrowLine:
2977
                    case ControlType.TwinLine:
2978
                    case ControlType.DimLine:
2979
                        {
2980
                            if (e.LeftButton == MouseButtonState.Pressed)
2981
                            {
2982
                                if (currentControl is LineControl)
2983
                                {
2984
                                    //20180906 LJY TEST IsRotationDrawingEnable
2985
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2986
                                    {
2987
                                        return;
2988
                                    }
2989

    
2990
                                    CreateCommand.Instance.Execute(currentControl);
2991
                                    currentControl = null;
2992
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
2993
                                }
2994
                                else
2995
                                {
2996
                                    currentControl = new LineControl
2997
                                    {
2998
                                        ControlType = this.controlType,
2999
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3000
                                        Background = new SolidColorBrush(Colors.Black)
3001
                                    };
3002

    
3003
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3004
                                    currentControl.CommentID = Commons.shortGuid();
3005
                                    currentControl.IsNew = true;
3006
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3007
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3008
                                }
3009
                            }
3010
                        }
3011
                        break;
3012
                    case ControlType.PolygonControl:
3013
                        {
3014
                            if (currentControl is PolygonControl)
3015
                            {
3016
                                var control = currentControl as PolygonControl;
3017

    
3018
                                if (e.RightButton == MouseButtonState.Pressed)
3019
                                {
3020
                                    control.IsCompleted = true;
3021
                                }
3022

    
3023
                                if (!control.IsCompleted)
3024
                                {
3025
                                    control.PointSet.Add(control.EndPoint);
3026
                                }
3027
                                else
3028
                                {
3029
                                    //20180906 LJY TEST IsRotationDrawingEnable
3030
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3031
                                    {
3032
                                        return;
3033
                                    }
3034

    
3035
                                    var firstPoint = control.PointSet.First();
3036
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3037
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3038
                                    control.PointSet.Add(firstPoint);
3039

    
3040
                                    control.ApplyOverViewData();
3041

    
3042
                                    CreateCommand.Instance.Execute(currentControl);
3043
                                    control.UpdateControl();
3044
                                    currentControl = null;
3045
                                }
3046
                            }
3047
                            else
3048
                            {
3049
                                if (e.LeftButton == MouseButtonState.Pressed)
3050
                                {
3051
                                    currentControl = new PolygonControl
3052
                                    {
3053
                                        PointSet = new List<Point>(),
3054
                                    };
3055

    
3056
                                    var polygonControl = (currentControl as PolygonControl);
3057
                                    currentControl.CommentID = Commons.shortGuid();
3058
                                    currentControl.IsNew = true;
3059
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3060
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3061
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3062
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3063
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3064
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3065
                                    polygonControl.ApplyTemplate();
3066
                                    polygonControl.Visibility = Visibility.Visible;
3067
                                }
3068
                            }
3069
                        }
3070
                        break;
3071
                    case ControlType.ChainLine:
3072
                        {
3073
                            if (currentControl is PolygonControl)
3074
                            {
3075
                                var control = currentControl as PolygonControl;
3076

    
3077
                                if (e.RightButton == MouseButtonState.Pressed)
3078
                                {
3079
                                    //20180906 LJY TEST IsRotationDrawingEnable
3080
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3081
                                    {
3082
                                        return;
3083
                                    }
3084

    
3085
                                    CreateCommand.Instance.Execute(currentControl);
3086

    
3087
                                    currentControl = null;
3088
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3089
                                    return;
3090
                                }
3091

    
3092
                                if (!control.IsCompleted)
3093
                                {
3094
                                    control.PointSet.Add(control.EndPoint);
3095
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3096
                                }
3097
                            }
3098
                            else
3099
                            {
3100
                                if (e.LeftButton == MouseButtonState.Pressed)
3101
                                {
3102
                                    MainAngle.Visibility = Visibility.Visible;
3103
                                    currentControl = new PolygonControl
3104
                                    {
3105
                                        PointSet = new List<Point>(),
3106
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3107
                                        ControlType = ControlType.ChainLine,
3108
                                        DashSize = ViewerDataModel.Instance.DashSize,
3109
                                        LineSize = ViewerDataModel.Instance.LineSize,
3110
                                        //PointC = new StylusPointSet()
3111
                                    };
3112

    
3113
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3114
                                    //{
3115
                                        var polygonControl = (currentControl as PolygonControl);
3116
                                        currentControl.CommentID = Commons.shortGuid();
3117
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3118
                                        currentControl.IsNew = true;
3119
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3120
                                        //currentControl.OnApplyTemplate();
3121
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3122
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3123
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3124
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3125
                                    //}
3126
                                }
3127
                            }
3128
                        }
3129
                        break;
3130
                    case ControlType.ArcLine:
3131
                        {
3132
                            if (e.LeftButton == MouseButtonState.Pressed)
3133
                            {
3134
                                if (currentControl is ArcControl)
3135
                                {
3136
                                    //20180906 LJY TEST IsRotationDrawingEnable
3137
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3138
                                    {
3139
                                        return;
3140
                                    }
3141

    
3142
                                    CreateCommand.Instance.Execute(currentControl);
3143

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

    
3185
                                    CreateCommand.Instance.Execute(currentControl);
3186

    
3187
                                    currentControl = null;
3188
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3189
                                }
3190
                                else
3191
                                {
3192
                                    currentControl = new ArrowArcControl
3193
                                    {
3194
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3195
                                        Background = new SolidColorBrush(Colors.Black)
3196
                                    };
3197
                                    currentControl.CommentID = Commons.shortGuid();
3198
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3199
                                    currentControl.IsNew = true;
3200
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3201
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3202
                                }
3203
                                //}
3204
                            }
3205
                            else if (e.RightButton == MouseButtonState.Pressed)
3206
                            {
3207
                                if (currentControl != null)
3208
                                {
3209
                                    (currentControl as ArrowArcControl).setClock();
3210
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3211
                                    //(currentControl as ArcControl).ApplyTemplate();
3212
                                }
3213
                            }
3214
                        }
3215
                        break;
3216
                    case ControlType.ArrowMultiLine:
3217
                        {
3218
                            if (e.LeftButton == MouseButtonState.Pressed)
3219
                            {
3220
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3221
                                //{
3222

    
3223
                                    if (currentControl is ArrowControl_Multi)
3224
                                    {
3225
                                        var content = currentControl as ArrowControl_Multi;
3226
                                        if (content.MiddlePoint == new Point(0, 0))
3227
                                        {
3228
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3229
                                            {
3230
                                                content.MiddlePoint = content.EndPoint;
3231
                                            }
3232
                                            else
3233
                                            {
3234
                                                content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3235
                                            }
3236
                                        }
3237
                                        else
3238
                                        {
3239
                                            //20180906 LJY TEST IsRotationDrawingEnable
3240
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3241
                                            {
3242
                                                return;
3243
                                            }
3244

    
3245
                                            CreateCommand.Instance.Execute(currentControl);
3246

    
3247
                                            currentControl = null;
3248
                                            ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3249
                                        }
3250
                                    }
3251
                                    else
3252
                                    {
3253
                                        currentControl = new ArrowControl_Multi
3254
                                        {
3255
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3256
                                            Background = new SolidColorBrush(Colors.Black)
3257
                                        };
3258
                                        currentControl.CommentID = Commons.shortGuid();
3259
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3260
                                        currentControl.IsNew = true;
3261
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3262
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3263
                                    }
3264
                                //}
3265
                            }
3266
                        }
3267
                        break;
3268
                    case ControlType.PolygonCloud:
3269
                        {
3270
                            if (currentControl is CloudControl)
3271
                            {
3272
                                var control = currentControl as CloudControl;
3273
                                if (e.RightButton == MouseButtonState.Pressed)
3274
                                {
3275
                                    control.IsCompleted = true;
3276
                                }
3277

    
3278
                                if (!control.IsCompleted)
3279
                                {
3280
                                    control.PointSet.Add(control.EndPoint);
3281
                                }
3282
                                else
3283
                                {
3284
                                    //20180906 LJY TEST IsRotationDrawingEnable
3285
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3286
                                    {
3287
                                        return;
3288
                                    }
3289

    
3290
                                    CreateCommand.Instance.Execute(currentControl);
3291

    
3292
                                    control.isTransOn = true;
3293
                                    var firstPoint = control.PointSet.First();
3294

    
3295
                                    control.PointSet.Add(firstPoint);
3296
                                    control.DrawingCloud();
3297
                                    control.ApplyOverViewData();
3298

    
3299
                                    currentControl = null;
3300
                                }
3301
                            }
3302
                            else
3303
                            {
3304
                                if (e.LeftButton == MouseButtonState.Pressed)
3305
                                {
3306
                                    currentControl = new CloudControl
3307
                                    {
3308
                                        PointSet = new List<Point>(),
3309
                                        PointC = new StylusPointSet()
3310
                                    };
3311

    
3312
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3313
                                    //{
3314
                                        var polygonControl = (currentControl as CloudControl);
3315
                                        currentControl.CommentID = Commons.shortGuid();
3316
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3317
                                        currentControl.IsNew = true;
3318
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3319

    
3320
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3321
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3322
                                    
3323
                                    //}
3324
                                }
3325
                            }
3326
                        }
3327
                        break;
3328
                    case ControlType.ImgControl:
3329
                        {
3330
                            if (e.LeftButton == MouseButtonState.Pressed)
3331
                            {
3332
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3333
                                //{
3334
                                    if (currentControl is ImgControl)
3335
                                    {
3336
                                        //20180906 LJY TEST IsRotationDrawingEnable
3337
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3338
                                        {
3339
                                            return;
3340
                                        }
3341

    
3342
                                        CreateCommand.Instance.Execute(currentControl);
3343
                                        controlType = ControlType.ImgControl;
3344
                                        currentControl = null;
3345
                                    }
3346
                                    else
3347
                                    {
3348
                                        
3349
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3350
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3351
                                        {
3352
                                            Image img = new Image();
3353
                                            if (filename.Contains(".svg"))
3354
                                            {
3355
                                                byte[] imageData = null;
3356
                                                DrawingImage image = null;
3357
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3358
                                                {
3359
                                                    imageData = web.DownloadData(new Uri(filename));
3360
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3361
                                                    image = SvgReader.Load(stream);
3362
                                                }
3363
                                                img.Source = image;
3364
                                            }
3365
                                            else
3366
                                            {
3367
                                                img.Source = new BitmapImage(new Uri(filename));
3368
                                            }
3369

    
3370
                                            currentControl = new ImgControl
3371
                                            {
3372
                                                    Background = new SolidColorBrush(Colors.Black),
3373
                                                    PointSet = new List<Point>(),
3374
                                                    FilePath = filename,
3375
                                                    ImageData = img.Source,
3376
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3377
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3378
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3379
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3380
                                                    ControlType = ControlType.ImgControl
3381
                                                };
3382

    
3383
                                        
3384
                                                currentControl.CommentID = Commons.shortGuid();                                            
3385
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3386
                                                currentControl.IsNew = true;
3387
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3388

    
3389
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3390
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3391
                                    }
3392
                                    }
3393
                                //}
3394
                            }
3395
                        }
3396
                        break;
3397
                    case ControlType.Date:
3398
                        {
3399
                            if (e.LeftButton == MouseButtonState.Pressed)
3400
                            {
3401
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3402
                                //{
3403
                                if (currentControl is DateControl)
3404
                                {
3405
                                    //20180906 LJY TEST IsRotationDrawingEnable
3406
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3407
                                    {
3408
                                        return;
3409
                                    }
3410

    
3411
                                    CreateCommand.Instance.Execute(currentControl);
3412
                                    currentControl = null;
3413

    
3414
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3415
                                    {
3416
                                        controlType = ControlType.None;
3417
                                        IsSwingMode = false;
3418
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3419
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3420
                                        mouseHandlingMode = MouseHandlingMode.None;
3421
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3422
                                        txtBatch.Visibility = Visibility.Collapsed;
3423

    
3424
                                    }
3425
                                }
3426
                                else
3427
                                {
3428
                                    currentControl = new DateControl
3429
                                    {
3430
                                        StartPoint = CanvasDrawingMouseDownPoint,
3431
                                        Background = new SolidColorBrush(Colors.Black)
3432
                                    };
3433
                                    currentControl.CommentID = Commons.shortGuid();
3434
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3435
                                    currentControl.IsNew = true;
3436
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3437

    
3438
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3439
                                    if (currentControl is ImgControl)
3440
                                    {
3441
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3442
                                    }
3443
                                }
3444
                                //}
3445
                            }
3446
                        }
3447
                        break;
3448
                    case ControlType.TextControl:
3449
                        {
3450
                            if (e.LeftButton == MouseButtonState.Pressed)
3451
                            {
3452
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3453
                                {
3454
                                    currentControl = new TextControl
3455
                                    {
3456
                                        ControlType = controlType
3457
                                    };
3458
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3459
                                    currentControl.CommentID = Commons.shortGuid();
3460
                                    currentControl.IsNew = true;
3461
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3462
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3463
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3464

    
3465
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3466
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3467
                                    
3468
                                    (currentControl as TextControl).ControlType_No = 0;
3469
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3470
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3471
                                    (currentControl as TextControl).ApplyTemplate();
3472
                                    (currentControl as TextControl).Base_TextBox.Focus();
3473
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3474
                                    CreateCommand.Instance.Execute(currentControl);
3475
                                }
3476
                            }
3477
                        }
3478
                        break;
3479
                    case ControlType.TextBorder:
3480
                        {
3481
                            if (e.LeftButton == MouseButtonState.Pressed)
3482
                            {
3483
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3484
                                {
3485
                                    currentControl = new TextControl
3486
                                    {
3487
                                        ControlType = controlType
3488
                                    };
3489

    
3490
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3491
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3492
                                    currentControl.CommentID = Commons.shortGuid();
3493
                                    currentControl.IsNew = true;
3494
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3495
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3496
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3497
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3498
                                    
3499
                                    (currentControl as TextControl).ControlType_No = 1;
3500
                                    (currentControl as TextControl).CommentAngle = Ang;
3501
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3502
                                    (currentControl as TextControl).ApplyTemplate();
3503
                                    (currentControl as TextControl).Base_TextBox.Focus();
3504
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3505
                                    CreateCommand.Instance.Execute(currentControl);
3506
                                }
3507
                            }
3508
                        }
3509
                        break;
3510
                    case ControlType.TextCloud:
3511
                        {
3512
                            if (e.LeftButton == MouseButtonState.Pressed)
3513
                            {
3514
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3515
                                {
3516
                                    currentControl = new TextControl
3517
                                    {
3518
                                        ControlType = controlType
3519
                                    };
3520

    
3521
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3522
                                    currentControl.CommentID = Commons.shortGuid();
3523
                                    currentControl.IsNew = true;
3524
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3525
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3526

    
3527
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3528
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3529
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3530

    
3531
                                    (currentControl as TextControl).CommentAngle = Ang;
3532
                                    (currentControl as TextControl).ControlType_No = 2;
3533
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3534
                                    (currentControl as TextControl).ApplyTemplate();
3535
                                    (currentControl as TextControl).Base_TextBox.Focus();
3536
                                    CreateCommand.Instance.Execute(currentControl);
3537
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3538
                                    //currentControl = null;
3539
                                }
3540
                            }
3541
                        }
3542
                        break;
3543
                    case ControlType.ArrowTextControl:
3544
                         {
3545
                            if (e.LeftButton == MouseButtonState.Pressed)
3546
                            {
3547
                                if (currentControl is ArrowTextControl)
3548
                                {
3549
                                    //20180906 LJY TEST IsRotationDrawingEnable
3550
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3551
                                    {
3552
                                        return;
3553
                                    }
3554

    
3555
                                    CreateCommand.Instance.Execute(currentControl);
3556

    
3557
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3558
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3559
                                    (currentControl as ArrowTextControl).IsNew = false;
3560
                                    currentControl = null;
3561
                                }
3562
                                else
3563
                                {
3564
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3565
                                    //{
3566
                                        currentControl = new ArrowTextControl();
3567
                                        currentControl.CommentID = Commons.shortGuid();
3568
                                        currentControl.IsNew = true;
3569
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3570
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3571

    
3572
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3573
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3574
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3575
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3576
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3577

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

    
3581
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3582
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3583
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3584
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3585

    
3586
                                    
3587
                                    //}
3588
                                }
3589
                            }
3590
                        }
3591
                        break;
3592
                    case ControlType.ArrowTransTextControl:
3593
                        {
3594
                            if (e.LeftButton == MouseButtonState.Pressed)
3595
                            {
3596
                                if (currentControl is ArrowTextControl)
3597
                                {
3598
                                    //20180906 LJY TEST IsRotationDrawingEnable
3599
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3600
                                    {
3601
                                        return;
3602
                                    }
3603

    
3604
                                    CreateCommand.Instance.Execute(currentControl);
3605

    
3606
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3607
                                    
3608
                                    currentControl.IsNew = false;
3609
                                    currentControl = null;
3610
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3611
                                }
3612
                                else
3613
                                {
3614
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3615
                                    //{
3616
                                    currentControl = new ArrowTextControl()
3617
                                    {
3618
                                        ControlType = ControlType.ArrowTransTextControl
3619
                                    };
3620
                                    currentControl.CommentID = Commons.shortGuid();
3621
                                    currentControl.IsNew = true;
3622
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3623
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3624
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3625
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3626
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                  
3627
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3628
                                    (currentControl as ArrowTextControl).isFixed = true;
3629
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3630

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

    
3634
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3635
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3636
                                    (currentControl as ArrowTextControl).isTrans = true;
3637
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3638
                                }
3639
                            }
3640
                        }
3641
                        break;
3642
                    case ControlType.ArrowTextBorderControl:
3643
                         {
3644
                            if (e.LeftButton == MouseButtonState.Pressed)
3645
                            {
3646
                                if (currentControl is ArrowTextControl)
3647
                                {
3648
                                    //20180906 LJY TEST IsRotationDrawingEnable
3649
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3650
                                    {
3651
                                        return;
3652
                                    }
3653

    
3654
                                    CreateCommand.Instance.Execute(currentControl);
3655
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3656
                                    currentControl.IsNew = false;
3657
                                    currentControl = null;
3658
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3659
                                }
3660
                                else
3661
                                {
3662
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3663
                                    //{
3664
                                        currentControl = new ArrowTextControl()
3665
                                        {
3666
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3667
                                        };
3668
                                        currentControl.CommentID = Commons.shortGuid();
3669
                                        currentControl.IsNew = true;
3670
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3671
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3672

    
3673
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3674

    
3675
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3676

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

    
3707
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3708
                                }
3709
                                else
3710
                                {
3711
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3712
                                    //{
3713
                                    
3714

    
3715
                                    currentControl = new ArrowTextControl()
3716
                                    {
3717
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3718
                                        ControlType = ControlType.ArrowTransTextBorderControl
3719

    
3720
                                    };
3721
                                        currentControl.CommentID = Commons.shortGuid();
3722
                                        currentControl.IsNew = true;
3723
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3724
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3725

    
3726
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3727

    
3728
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3729
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                    
3730
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3731
                                        (currentControl as ArrowTextControl).isFixed = true;
3732
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3733
                                     
3734
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3735
                                        (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3736
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3737
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3738
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3739
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3740
                                    
3741
                                    //20180911 LJY
3742
                                        (currentControl as ArrowTextControl).isTrans = true;
3743
                                    
3744

    
3745
                                    //}
3746
                                }
3747
                            }
3748
                        }
3749
                        break;
3750
                    case ControlType.ArrowTextCloudControl:
3751
                        {
3752
                            if (e.LeftButton == MouseButtonState.Pressed)
3753
                            {
3754
                                if (currentControl is ArrowTextControl)
3755
                                {
3756
                                    //20180906 LJY TEST IsRotationDrawingEnable
3757
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3758
                                    {
3759
                                        return;
3760
                                    }
3761
                                    CreateCommand.Instance.Execute(currentControl);
3762
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3763
                                    currentControl.IsNew = false;
3764
                                    currentControl = null;
3765
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3766
                                }
3767
                                else
3768
                                {
3769
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3770
                                    //{
3771
                                        currentControl = new ArrowTextControl()
3772
                                        {
3773
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3774
                                        };
3775
                                        currentControl.CommentID = Commons.shortGuid();
3776
                                        currentControl.IsNew = true;
3777
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3778
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3779

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

    
3823
                                        };
3824
                                        currentControl.CommentID = Commons.shortGuid();
3825
                                        currentControl.IsNew = true; 
3826
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3827
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3828
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3829

    
3830
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3831
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3832
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3833
                                        (currentControl as ArrowTextControl).isFixed = true;
3834
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3835

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

    
3859
                                if (_sign == null)
3860
                                    {
3861
                                        txtBatch.Visibility = Visibility.Collapsed;
3862
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3863
                                        controlType = ControlType.None;
3864

    
3865
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3866
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3867
                                        return;
3868
                                    }
3869

    
3870
                                    if (currentControl is SignControl)
3871
                                    {
3872
                                        //20180906 LJY TEST IsRotationDrawingEnable
3873
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3874
                                        {
3875
                                            return;
3876
                                        }
3877

    
3878
                                        CreateCommand.Instance.Execute(currentControl);
3879
                                        currentControl = null;
3880
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3881
                                        {
3882
                                            txtBatch.Text = "Place Date";
3883
                                            controlType = ControlType.Date;
3884
                                        }
3885
                                    }
3886
                                    else
3887
                                    {
3888
                                        currentControl = new SignControl
3889
                                        {
3890
                                            Background = new SolidColorBrush(Colors.Black),
3891
                                            UserNumber = App.ViewInfo.UserID,
3892
                                            ProjectNO = App.ViewInfo.ProjectNO,
3893
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3894
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3895
                                            ControlType = ControlType.Sign
3896
                                        };
3897

    
3898
                                        currentControl.CommentID = Commons.shortGuid();
3899
                                        currentControl.IsNew = true;
3900
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3901
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3902

    
3903
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3904
                                        (currentControl as SignControl).CommentAngle -= rotate.Angle;                                    
3905
                                }
3906
                                //}
3907
                            }
3908
                        }
3909
                        break;
3910
                    case ControlType.Mark:
3911
                        {
3912
                            if (e.LeftButton == MouseButtonState.Pressed)
3913
                            {
3914
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3915
                                //{
3916
                                    if (currentControl is RectangleControl)
3917
                                    {
3918
                                        //20180906 LJY TEST IsRotationDrawingEnable
3919
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3920
                                        {
3921
                                            return;
3922
                                        }
3923

    
3924
                                        CreateCommand.Instance.Execute(currentControl);
3925
                                        (currentControl as RectangleControl).ApplyOverViewData();
3926
                                        currentControl = null;
3927
                                    
3928
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3929

    
3930
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3931
                                        {
3932
                                            txtBatch.Text = "Place Signature";
3933
                                            controlType = ControlType.Sign;
3934
                                        }
3935
                                    }
3936
                                    else
3937
                                    {
3938
                                        currentControl = new RectangleControl
3939
                                        {
3940
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3941
                                            Background = new SolidColorBrush(Colors.Black),
3942
                                            ControlType = ControlType.Mark ,
3943
                                            Paint = PaintSet.Fill
3944
                                        };
3945

    
3946
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3947
                                        currentControl.CommentID = Commons.shortGuid();
3948
                                        currentControl.IsNew = true;
3949
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3950
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3951
                                    }
3952
                                //}
3953
                            }
3954
                        }
3955
                        break;
3956
                    case ControlType.Symbol:
3957
                        {
3958
                            if (e.LeftButton == MouseButtonState.Pressed)
3959
                            {
3960
                                if (currentControl is SymControl)
3961
                                {
3962
                                    //20180906 LJY TEST IsRotationDrawingEnable
3963
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3964
                                    {
3965
                                        return;
3966
                                    }
3967
                                    CreateCommand.Instance.Execute(currentControl);
3968
                                    currentControl = null;
3969
                                
3970
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3971
                                }
3972
                                else
3973
                                {
3974
                                    currentControl = new SymControl
3975
                                    {
3976
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3977
                                        Background = new SolidColorBrush(Colors.Black),
3978
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3979
                                        ControlType = ControlType.Symbol
3980
                                    };
3981

    
3982
                                    currentControl.IsNew = true;
3983
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3984
                                    currentControl.CommentID = Commons.shortGuid();
3985
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3986

    
3987
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3988
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
3989
                                }
3990
                                //}
3991
                            }
3992
                        }
3993
                        break;
3994
                    case ControlType.Stamp:
3995
                        {
3996
                            if (e.LeftButton == MouseButtonState.Pressed)
3997
                            {
3998
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3999
                                //{
4000
                                    if (currentControl is SymControlN)
4001
                                    {
4002
                                        //20180906 LJY TEST IsRotationDrawingEnable
4003
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4004
                                        {
4005
                                            return;
4006
                                        }
4007

    
4008
                                        CreateCommand.Instance.Execute(currentControl);
4009
                                        currentControl = null;
4010
                                   
4011

    
4012
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4013
                                    }
4014
                                    else
4015
                                    {
4016
                                        currentControl = new SymControlN
4017
                                        {
4018
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4019
                                            Background = new SolidColorBrush(Colors.Black),
4020
                                            STAMP = App.SystemInfo.STAMP,                                            
4021
                                            ControlType = ControlType.Stamp
4022
                                        };
4023

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

    
4062
                if (currentControl != null)
4063
                {
4064
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4065
                }
4066
            }
4067
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4068
            {
4069
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4070
                {
4071
                    bool mouseOff = false;
4072
                    foreach (var item in SelectLayer.Children)
4073
                    {
4074
                        if (item is AdornerFinal)
4075
                        {
4076

    
4077
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4078
                            if (over != null)
4079
                            {
4080
                                mouseOff = true;
4081
                            }
4082
                        }
4083
                    }
4084

    
4085
                    if (!mouseOff)
4086
                    {
4087
                        SelectionSet.Instance.UnSelect(this);
4088
                    }
4089
                }
4090
                zoomAndPanControl.CaptureMouse();
4091
                e.Handled = true;
4092
            }
4093
          
4094
        }
4095

    
4096
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4097
        {
4098
            ///mouseButtonDown = e.ChangedButton;
4099
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4100
        }
4101

    
4102
        private void RemoveLineStroke(Point P)
4103
        {
4104
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4105
            if (control != null)
4106
            {
4107
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4108
            }
4109
        }
4110

    
4111
        private void RemovePointStroke(Point P)
4112
        {
4113
            foreach (Stroke hits in inkBoard.Strokes)
4114
            {
4115
                foreach (StylusPoint sty in hits.StylusPoints)
4116
                {
4117

    
4118
                }
4119
                if (hits.HitTest(P))
4120
                {
4121
                    inkBoard.Strokes.Remove(hits);
4122
                    return;
4123
                }
4124
            }
4125
        }
4126

    
4127
        private void StartNewStroke(Point P)
4128
        {
4129
            strokePoints = new StylusPointCollection();
4130
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4131
            strokePoints.Add(segment1Start);
4132
            stroke = new Stroke(strokePoints);
4133

    
4134
            stroke.DrawingAttributes.Color = Colors.Red;
4135
            stroke.DrawingAttributes.Width = 4;
4136
            stroke.DrawingAttributes.Height = 4;
4137

    
4138
            inkBoard.Strokes.Add(stroke);
4139
        }
4140

    
4141
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4142
        {
4143
            ConsolidationMethod();
4144
        }
4145

    
4146
        /// <summary>
4147
        /// execute TeamConsolidationCommand
4148
        /// </summary>
4149
        public void TeamConsolidationMethod()
4150
        {
4151
            this.UpdateMyMarkupList();
4152
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4153
            {
4154
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4155
            }
4156
            else
4157
            {
4158

    
4159
                ViewerDataModel.Instance.IsConsolidate = true;
4160
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4161

    
4162
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4163
                {
4164
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4165
                    {
4166
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4167
                        return;
4168
                    }                    
4169
                }
4170
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4171
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4172
                {
4173
                    MarkupInfoList.Add(item);
4174
                }
4175
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4176
            }
4177
        }
4178

    
4179
        public void ConsolidationMethod()
4180
        {
4181
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4182
            {
4183
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4184
            }
4185
            else
4186
            {
4187
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4188
                foreach (var item in this.gridViewMarkup.SelectedItems)
4189
                {
4190
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4191
                }
4192
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4193
                
4194
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4195
            }
4196
        }
4197

    
4198
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4199
        {
4200
            if (App.ViewInfo != null)
4201
            {
4202
                btnConsolidate = (sender as RadRibbonButton);
4203
                if (!App.ViewInfo.NewCommentPermission)
4204
                {
4205
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4206
                }
4207
            }
4208
        }
4209

    
4210
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4211
        {
4212
            TeamConsolidationMethod();
4213
        }
4214

    
4215
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4216
        {
4217
            btnTeamConsolidate = sender as RadRibbonButton;
4218
            if (App.ViewInfo != null)
4219
            {
4220
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4221
                {
4222
                    if (btnConsolidate != null)
4223
                    {
4224
                        btnConsolidate.Visibility = Visibility.Collapsed;
4225
                    }
4226

    
4227
                    if (!App.ViewInfo.NewCommentPermission)
4228
                    {
4229
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4230
                    }
4231
                }
4232
                else
4233
                {
4234
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4235
                }
4236
            }
4237
        }
4238

    
4239
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4240
        {
4241
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4242
            if(item != null)
4243
            {
4244
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4245
                {
4246
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4247
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4248
                }
4249
                else
4250
                {
4251
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4252
                }
4253
            }else{
4254
                //Consolidate 가 없는 경우
4255
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4256
            }
4257
            
4258
        }
4259

    
4260
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4261
        {
4262
            btnFinalPDF = sender as RadRibbonButton;
4263
            if (App.ViewInfo != null)
4264
            {
4265
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4266
                {
4267
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4268
                    if (btnConsolidate != null)
4269
                    {
4270
                        btnConsolidate.Visibility = Visibility.Collapsed;
4271
                    }
4272
                }
4273
            }
4274
        }
4275

    
4276
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4277
        {
4278
            UpdateMyMarkupList();
4279

    
4280
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4281
            {
4282
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4283
            }
4284
            else
4285
            {
4286
                ViewerDataModel.Instance.IsConsolidate = true;
4287
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4288
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4289

    
4290
                string project_no = App.ViewInfo.ProjectNO;
4291
                string doc_id = _DocInfo.ID;
4292
                string user_id = App.ViewInfo.UserID;
4293
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4294
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4295
                {
4296
                    markupInfoItems.Add(item);
4297
                }
4298
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4299
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4300
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4301
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4302

    
4303
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4304
                if (item2 != null)
4305
                {
4306
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4307

    
4308
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4309
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4310
                }
4311
                else
4312
                {
4313
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4314
                }
4315
            }
4316
        }
4317

    
4318
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4319
        {
4320
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4321

    
4322
            if (App.ViewInfo != null)
4323
            {
4324
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4325
                {
4326
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4327
                }
4328
            }
4329
        }
4330

    
4331
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4332
        {
4333
            SetCompareRect();
4334
        }
4335

    
4336
        private void Sync_Click(object sender, RoutedEventArgs e)
4337
        {
4338
            if (Sync.IsChecked)
4339
            {
4340
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4341
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4342
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4343
            }
4344
        }
4345

    
4346
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4347
        {
4348
            if (UserList.IsChecked)
4349
            {
4350
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4351
            }
4352
            else
4353
            {
4354
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4355
            }
4356
        }
4357

    
4358
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4359
        {
4360

    
4361
            if (BalanceMode.IsChecked)
4362
            {
4363
                ViewerDataModel.Instance.PageBalanceMode = true;
4364
            }
4365
            else
4366
            {
4367
                ViewerDataModel.Instance.PageBalanceMode = false;
4368
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4369
            }
4370
        }
4371

    
4372
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4373
        {
4374
            //초기화
4375
            testPanel2.IsHidden = true;
4376
            ViewerDataModel.Instance.PageBalanceMode = false;
4377
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4378
            ViewerDataModel.Instance.PageNumber = 0;
4379
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4380
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4381
            UserList.IsChecked = false;
4382
            BalanceMode.IsChecked = false;
4383
        }
4384

    
4385
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4386
        {
4387
            if ((sender as System.Windows.Controls.Control).Tag != null)
4388
            {
4389
                //Compare 초기화
4390
                CompareMode.IsChecked = false;
4391
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4392

    
4393
                if (ViewerDataModel.Instance.PageNumber == 0)
4394
                {
4395
                    ViewerDataModel.Instance.PageNumber = 1;
4396
                }
4397

    
4398
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4399
                {
4400
                }
4401
                else
4402
                {
4403
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4404
                }
4405

    
4406

    
4407

    
4408
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4409
                {
4410

    
4411
                }
4412
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4413
                {
4414
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4415
                }
4416

    
4417
                pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4418

    
4419
                if (!testPanel2.IsHidden)
4420
                {
4421
                    if (IsSyncPDFMode)
4422
                    {
4423
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4424
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4425

    
4426
                        if (pdfpath.IsDownloading)
4427
                        {
4428
                            pdfpath.DownloadCompleted += (ex, arg) =>
4429
                            {
4430
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4431
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4432
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4433
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4434
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4435
                            };
4436
                        }
4437
                        else
4438
                        {
4439
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4440
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4441
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4442

    
4443
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4444
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4445
                        }
4446

    
4447
                    }
4448
                    else
4449
                    {
4450
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4451

    
4452
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4453

    
4454
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4455
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4456
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4457

    
4458
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4459
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4460

    
4461
                        if (defaultBitmapImage_Compare.IsDownloading)
4462
                        {
4463
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4464
                            {
4465
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4466
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4467
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4468

    
4469
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4470
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4471
                            };
4472
                        }
4473
                    }
4474

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

    
4479
                    foreach (var item in gridSelectionRevItem)
4480
                    {
4481
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4482
                        {
4483
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4484
                        });
4485
                    }
4486

    
4487
                    //강인구 추가
4488
                    zoomAndPanControl2.ZoomTo(new Rect
4489
                    {
4490
                        X = 0,
4491
                        Y = 0,
4492
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4493
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4494
                    });
4495

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

    
4498
                }
4499
            }
4500
        }
4501

    
4502
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4503
        {
4504
            if (MarkupMode.IsChecked)
4505
            {
4506
                IsSyncPDFMode = true;
4507

    
4508
                var uri = CurrentRev.TO_VENDOR;
4509

    
4510
                if (ViewerDataModel.Instance.PageNumber == 0)
4511
                {
4512
                    ViewerDataModel.Instance.PageNumber = 1;
4513
                }
4514

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

    
4519
                if (pdfpath.IsDownloading)
4520
                {
4521
                    pdfpath.DownloadCompleted += (ex, arg) =>
4522
                    {
4523
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4524
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4525
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4526
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4527
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4528
                    };
4529
                }
4530
                else
4531
                {
4532
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4533
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4534
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4535

    
4536
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4537
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4538
                }
4539
            }
4540
            else
4541
            {
4542
                IsSyncPDFMode = false;
4543
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4544

    
4545
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4546

    
4547
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4548
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4549
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4550

    
4551
                if (defaultBitmapImage_Compare.IsDownloading)
4552
                {
4553
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4554
                    {
4555
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4556
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4557
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4558
                    };
4559
                }
4560
                zoomAndPanControl2.ApplyTemplate();
4561
                zoomAndPanControl2.UpdateLayout();
4562
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4563
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4564
            }
4565
        }
4566

    
4567
        /// <summary>
4568
        /// Compare된 영역을 초기화
4569
        /// </summary>
4570
        private void ClearCompareRect()
4571
        {
4572
            da.From = 1;
4573
            da.To = 1;
4574
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4575
            da.AutoReverse = false;
4576
            canvas_compareBorder.Children.Clear();
4577
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4578
        }
4579

    
4580
        /// <summary>
4581
        /// 문서 Comprare 
4582
        /// </summary>
4583
        private void SetCompareRect()
4584
        {
4585
            if (CompareMode.IsChecked)
4586
            {
4587
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4588
                {
4589
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4590
                }
4591
                if (ViewerDataModel.Instance.PageNumber == 0)
4592
                {
4593
                    ViewerDataModel.Instance.PageNumber = 1;
4594
                }
4595

    
4596
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4597
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4598
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4599

    
4600
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4601
            }
4602
            else
4603
            {
4604
                ClearCompareRect();
4605
            }
4606
        }
4607

    
4608
        private void RadButton_Click(object sender, RoutedEventArgs e)
4609
        {
4610
            gridViewHistory_Busy.IsBusy = true;
4611

    
4612
            RadButton instance = sender as RadButton;
4613
            if (instance.CommandParameter != null)
4614
            {
4615
                CurrentRev = instance.CommandParameter as VPRevision;
4616
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4617

    
4618
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4619
                {
4620
                    if (ea.Error == null && ea.Result != null)
4621
                    {
4622
                        testPanel2.IsHidden = false;
4623

    
4624
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4625
                        foreach(var info in ea.Result)
4626
                        {
4627
                            if(info.UserID == App.ViewInfo.UserID)
4628
                            {
4629
                                info.userDelete = true;
4630
                                info.DisplayColor = "FFFF0000";
4631
                            }
4632
                            else
4633
                            {
4634
                                info.userDelete = false;
4635
                            }
4636
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4637
                        }
4638
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4639

    
4640
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4641

    
4642
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4643

    
4644
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4645
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4646
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4647
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4648
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4649
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4650

    
4651
                        zoomAndPanControl2.ApplyTemplate();
4652
                        zoomAndPanControl2.UpdateLayout();
4653
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4654
                        {
4655
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4656
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4657
                        }
4658

    
4659
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4660
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4661
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4662

    
4663
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4664
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4665
                        gridViewHistory_Busy.IsBusy = false;
4666
                    }
4667

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

    
4670
                    if (GetSyncMarkupInfoItemshandler != null)
4671
                    {
4672
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4673
                    }
4674

    
4675
                    ClearCompareRect();
4676
                    SetCompareRect();
4677
                };
4678

    
4679
                /// 중복 실행이 발생하여 수정함.
4680
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4681
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4682

    
4683
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4684
            }
4685
        }
4686

    
4687
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4688
        {
4689
            try
4690
            {
4691
                if (sender is RadButton)
4692
                {
4693
                    if ((sender as RadButton).Tag != null)
4694
                    {
4695
                        var url = (sender as RadButton).Tag.ToString();
4696
                        System.Diagnostics.Process.Start(url);
4697
                    }
4698
                    else
4699
                    {
4700
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4701
                    }
4702
                }
4703
            }
4704
            catch (Exception ex)
4705
            {
4706
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4707
            }
4708
        }
4709

    
4710
        public void Sync_Event(VPRevision Currnet_Rev)
4711
        {
4712
            CurrentRev = Currnet_Rev;
4713

    
4714
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4715
            {
4716
                if (ea.Error == null && ea.Result != null)
4717
                {
4718
                    testPanel2.IsHidden = false;
4719

    
4720
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4721
                    foreach(var info in ea.Result)
4722
                    {
4723
                        if(info.UserID == App.ViewInfo.UserID)
4724
                        {
4725
                            info.userDelete = true;
4726
                            info.DisplayColor = "FFFF0000";
4727
                        }
4728
                        else
4729
                        {
4730
                            info.userDelete = false;
4731
                        }
4732
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4733
                    }
4734
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4735

    
4736
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4737

    
4738
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4739

    
4740
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4741

    
4742
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4743
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4744
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4745

    
4746
                    if (defaultBitmapImage_Compare.IsDownloading)
4747
                    {
4748
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4749
                        {
4750
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4751
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4752
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4753
                        };
4754
                    }
4755

    
4756

    
4757
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4758
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4759
                    zoomAndPanControl2.ApplyTemplate();
4760
                    zoomAndPanControl2.UpdateLayout();
4761

    
4762
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4763
                    {
4764
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4765
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4766
                    }
4767
                    //}
4768

    
4769
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4770
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4771
                    gridViewHistory_Busy.IsBusy = false;
4772
                }
4773
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4774

    
4775
            };
4776
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4777
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4778
        }
4779

    
4780
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4781
        {
4782
            if (sender is Image)
4783
            {
4784
                if ((sender as Image).Tag != null)
4785
                {
4786
                    var pdfUrl = (sender as Image).Tag.ToString();
4787
                    System.Diagnostics.Process.Start(pdfUrl);
4788
                }
4789
                else
4790
                {
4791
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4792
                }
4793
            }
4794
        }
4795

    
4796
        private void Create_Symbol(object sender, RoutedEventArgs e)
4797
        {
4798
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4799

    
4800
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4801
            {
4802
                DialogMessage_Alert("Please Select Controls", "Alert");
4803
            }
4804
            else //선택된 것이 있으면
4805
            {
4806
                string MarkupData = "";
4807
                adorner_ = new AdornerFinal();
4808

    
4809
                foreach (var item in SelectLayer.Children)
4810
                {
4811
                    if (item.GetType().Name == "AdornerFinal")
4812
                    {
4813
                        adorner_ = (item as Controls.AdornerFinal);
4814
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4815
                        {
4816
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4817
                            {
4818
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4819
                                MarkupData += markupReturn.ConvertData;
4820
                            }
4821
                        }
4822
                    }
4823
                }
4824
                DialogParameters parameters = new DialogParameters()
4825
                {
4826
                    Owner = Application.Current.MainWindow,
4827
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4828
                    DefaultPromptResultValue = "Custom State",
4829
                    Content = "Name :",
4830
                    Header = "Insert Custom Symbol Name",
4831
                    Theme = new VisualStudio2013Theme(),
4832
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4833
                };
4834
                RadWindow.Prompt(parameters);
4835
            }
4836

    
4837
        }
4838
        public int symbolselectindex = 0;
4839
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4840
        {
4841
            //Save save = new Save();
4842
            try
4843
            {
4844
                string svgfilename = null;
4845
                if (symbolname != null)
4846
                {
4847
                    if (symbolpng == true || symbolsvg == true)
4848
                    {
4849
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4850
                        string guid = Commons.shortGuid();
4851

    
4852
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4853
                        //Check_Uri.UriCheck();
4854
                        fileUploader.RunCompleted += (ex, arg) =>
4855
                        {
4856
                            filename = arg.Result;
4857
                            if (symbolpng == true)
4858
                            {
4859
                                if (filename != null)
4860
                                { 
4861
                                    if (symbolselectindex == 0)
4862
                                    {
4863
                                        SymbolSave(symbolname, filename, data);
4864
                                    }
4865
                                    else
4866
                                    {
4867
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4868
                                    }
4869
                                    DataBind();
4870
                                }                                
4871
                            }
4872

    
4873
                            if (symbolsvg == true)
4874
                            {
4875
                                try
4876
                                {
4877
                                    var defaultBitmapImage = new BitmapImage();
4878
                                    defaultBitmapImage.BeginInit();
4879
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4880
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4881
                                    Check_Uri.UriCheck(filename);
4882
                                    defaultBitmapImage.UriSource = new Uri(filename);
4883
                                    defaultBitmapImage.EndInit();
4884

    
4885
                                    System.Drawing.Bitmap image;
4886

    
4887
                                    if (defaultBitmapImage.IsDownloading)
4888
                                    {
4889
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4890
                                        {
4891
                                            defaultBitmapImage.Freeze();
4892
                                            image = GetBitmap(defaultBitmapImage);
4893
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4894
                                            Process potrace = new Process
4895
                                            {
4896
                                                StartInfo = new ProcessStartInfo
4897
                                                {
4898
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4899
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4900
                                                    RedirectStandardInput = true,
4901
                                                    RedirectStandardOutput = true,
4902
                                                    RedirectStandardError = true,
4903
                                                    UseShellExecute = false,
4904
                                                    CreateNoWindow = true,
4905
                                                    WindowStyle = ProcessWindowStyle.Hidden
4906
                                                },
4907
                                            };
4908

    
4909
                                            StringBuilder svgBuilder = new StringBuilder();
4910
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4911
                                            {
4912
                                                svgBuilder.AppendLine(e2.Data);
4913
                                            };
4914

    
4915
                                            potrace.EnableRaisingEvents = true;
4916
                                            potrace.Start();
4917
                                            potrace.Exited += (sender, e) =>
4918
                                            {
4919
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4920
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4921
                                                Check_Uri.UriCheck(svgfilename);
4922
                                                if (symbolselectindex == 0)
4923
                                                {
4924
                                                    SymbolSave(symbolname, svgfilename, data);
4925
                                                }
4926
                                                else
4927
                                                {
4928
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4929
                                                }
4930

    
4931
                                                DataBind();
4932
                                            };
4933
                                            potrace.WaitForExit();
4934
                                        };
4935
                                    }
4936
                                    else
4937
                                    {
4938
                                        //GC.Collect();
4939
                                    }
4940
                                }
4941
                                catch(Exception ee)
4942
                                {
4943
                                    DialogMessage_Alert("" + ee, "Alert");
4944
                                }
4945
                            }
4946
                        };                                             
4947
                    }
4948
                }
4949
            }
4950
            catch (Exception e)
4951
            {
4952
                //DialogMessage_Alert(e + "", "Alert");
4953
            }            
4954
        }
4955

    
4956
        public void SymbolSave(string Name, string Url, string Data)
4957
        {
4958
            try
4959
            {
4960
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4961
                {
4962
                    ID = Commons.shortGuid(),
4963
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4964
                    NAME = Name,
4965
                    IMAGE_URL = Url,
4966
                    DATA = Data
4967
                };
4968

    
4969
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4970
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4971
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4972
            }
4973
            catch (Exception)
4974
            {
4975
                throw;
4976
            }
4977
        }
4978

    
4979
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4980
        {
4981
            try
4982
            {
4983
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4984
                {
4985
                    ID = Commons.shortGuid(),
4986
                    DEPARTMENT = Department,
4987
                    NAME = Name,
4988
                    IMAGE_URL = Url,
4989
                    DATA = Data
4990
                };
4991
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4992
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4993
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4994
            }
4995
            catch (Exception)
4996
            {
4997
                throw;
4998
            }
4999
        }
5000

    
5001
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5002
        {           
5003
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5004
            DataBind();
5005
        }
5006

    
5007
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5008
        {
5009
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5010
            DataBind();
5011
        }
5012
        private void DataBind()
5013
        {
5014
            try
5015
            {
5016
                Symbol_Custom Custom = new Symbol_Custom();
5017
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5018
                
5019
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5020
                foreach (var item in symbol_Private)
5021
                {
5022
                    Custom.Name = item.NAME;
5023
                    Custom.ImageUri = item.IMAGE_URL;
5024
                    Custom.ID = item.ID;
5025
                    Custom_List.Add(Custom);
5026
                    Custom = new Symbol_Custom();
5027
                }
5028
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5029
                
5030
                Custom = new Symbol_Custom();
5031
                Custom_List = new List<Symbol_Custom>();
5032

    
5033
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5034

    
5035
                List<SYMBOL_PUBLIC> symbol_Public;
5036

    
5037
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5038
                {
5039
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5040
                }
5041
                else
5042
                {
5043
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5044
                }
5045
                foreach (var item in symbol_Public)
5046
                {
5047
                    Custom.Name = item.NAME;
5048
                    Custom.ImageUri = item.IMAGE_URL;
5049
                    Custom.ID = item.ID;
5050
                    Custom_List.Add(Custom);
5051
                    Custom = new Symbol_Custom();
5052
                }
5053
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5054
                BaseClient.Close();                
5055
            }
5056
            catch(Exception e)
5057
            {
5058
                //DialogMessage_Alert("DataBind", "Alert");
5059
            }
5060
            
5061
        }
5062
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5063
        {
5064
            try
5065
            {
5066
                if (args.PromptResult != null)
5067
                {
5068
                    if (args.DialogResult.Value)
5069
                    {
5070
                        PngBitmapEncoder _Encoder = symImage(data);
5071

    
5072
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5073
                        _Encoder.Save(fs);
5074
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5075

    
5076
                        byte[] Img_byte = fs.ToArray();
5077

    
5078
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5079
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5080
                        Check_Uri.UriCheck(filename);
5081
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5082
                        {
5083
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5084
                        }
5085
                        else
5086
                        {
5087
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5088
                        }
5089
                        DataBind();
5090
                    }
5091
                }
5092
            }
5093
            catch(Exception ex)
5094
            {
5095
                DialogMessage_Alert("" + ex, "Alert");
5096
            }
5097
        }
5098

    
5099
        public PngBitmapEncoder symImage(string data)
5100
        {
5101

    
5102
            Canvas _canvas = new Canvas();
5103
            _canvas.Background = Brushes.White;
5104
            _canvas.Width = adorner_.BorderSize.Width;
5105
            _canvas.Height = adorner_.BorderSize.Height;
5106
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5107

    
5108
            BitmapEncoder encoder = new PngBitmapEncoder();
5109

    
5110

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

    
5113
            DrawingVisual dv = new DrawingVisual();
5114

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

    
5118
            using (DrawingContext ctx = dv.RenderOpen())
5119
            {
5120
                VisualBrush vb = new VisualBrush(_canvas);
5121
                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)));
5122
            }
5123

    
5124
            try
5125
            {
5126
                renderBitmap.Render(dv);
5127

    
5128
                //GC.Collect();
5129
                GC.WaitForPendingFinalizers();
5130
                //GC.Collect();
5131
                // encode png data
5132
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5133
                // puch rendered bitmap into it
5134
                pngEncoder.Interlace = PngInterlaceOption.Off;
5135
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5136
                return pngEncoder;
5137

    
5138
            }
5139
            catch //(Exception ex)
5140
            {
5141
                return null;
5142
            }
5143

    
5144
        }
5145

    
5146
        public void DialogMessage_Alert(string content, string header)
5147
        {
5148
            DialogParameters parameters = new DialogParameters()
5149
            {
5150
                Owner = this.ParentOfType<MainWindow>(),
5151
                Content = new TextBlock()
5152
                { 
5153
                    MinWidth = 400,
5154
                    FontSize = 11,
5155
                    Text = content,
5156
                    TextWrapping = System.Windows.TextWrapping.Wrap
5157
                },
5158
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5159
                Header = header,
5160
                Theme = new VisualStudio2013Theme(),
5161
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5162
            };            
5163
            RadWindow.Alert(parameters);
5164
        }
5165

    
5166
        #region 캡쳐 기능
5167

    
5168
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5169
        {
5170
            if (x < 0)
5171
            {
5172
                width += x;
5173
                x = 0;
5174
            }
5175
            if (y < 0)
5176
            {
5177
                height += y;
5178
                y = 0;
5179

    
5180
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5181
            }
5182
            if (x + width > zoomAndPanCanvas.ActualWidth)
5183
            {
5184
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5185
            }
5186
            if (y + height > zoomAndPanCanvas.ActualHeight)
5187
            {
5188
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5189
            }
5190

    
5191
            byte[] pixels = CopyPixels(x, y, width, height);
5192

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

    
5195
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5196
        }
5197

    
5198
        public byte[] CopyPixels(int x, int y, int width, int height)
5199
        {
5200
            byte[] pixels = new byte[width * height * 4];
5201
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5202

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

    
5206
            return pixels;
5207
        }
5208

    
5209
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5210
        {
5211
            DrawingVisual drawingVisual = new DrawingVisual();
5212
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5213

    
5214
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5215
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5216
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5217
            drawingContext.Close();
5218

    
5219
            // 비트맵으로 변환합니다.
5220
            RenderTargetBitmap target =
5221
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5222
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5223

    
5224
            target.Render(drawingVisual);
5225
            return target;
5226
        }
5227

    
5228
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5229
        {
5230
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5231
            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);
5232
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5233
            bmp.UnlockBits(data);
5234
            return bmp;
5235
        }
5236
        public string symbolname = null;
5237
        public bool symbolsvg = true;
5238
        public bool symbolpng = true;
5239

    
5240
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5241
        {
5242
            System.Drawing.Bitmap image = GetBitmap(source);
5243
            //흰색 제거
5244
            //image.MakeTransparent(System.Drawing.Color.White);
5245

    
5246
            var imageStream = new System.IO.MemoryStream();
5247
            byte[] imageBytes = null;
5248
            using (imageStream)
5249
            {
5250
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5251
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5252
                imageStream.Position = 0;
5253
                imageBytes = imageStream.ToArray();
5254
            }
5255

    
5256
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5257

    
5258
            RadWindow CheckPop = new RadWindow();
5259
            //Alert check = new Alert(Msg);
5260

    
5261
            CheckPop = new RadWindow
5262
            {
5263
                MinWidth = 400,
5264
                MinHeight = 100,
5265
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5266
                Header = "Alert",
5267
                Content = symbolPrompt,
5268
                //DialogResult = 
5269
                ResizeMode = System.Windows.ResizeMode.NoResize,
5270
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5271
                IsTopmost = true,
5272
            };
5273
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5274
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5275
            CheckPop.ShowDialog();
5276

    
5277
            /*
5278
            DialogParameters parameters = new DialogParameters()
5279
            {
5280
                Owner = Application.Current.MainWindow,
5281
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5282
                DefaultPromptResultValue = "Custom State",
5283
                Content = "Name :",
5284
                Header = "Insert Custom Symbol Name",
5285
                Theme = new VisualStudio2013Theme(),
5286
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5287
            };            
5288
            RadWindow.Prompt(parameters);
5289
            */
5290
        }
5291

    
5292
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5293
        {
5294
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5295
            KCOMDataModel.DataModel.CHECK_LIST check_;
5296
            string Result = streamToBase64.ImageToBase64(source);
5297
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5298
            string projectno = App.ViewInfo.ProjectNO;
5299
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5300

    
5301
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5302
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5303
            if (Item != null)
5304
            {
5305
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5306
            }
5307
            else
5308
            {
5309
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5310
            }
5311

    
5312
            if (Item == null)
5313
            {
5314
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5315
                {
5316
                    ID = Commons.shortGuid(),
5317
                    USER_ID = App.ViewInfo.UserID,
5318
                    IMAGE_URL = Result,
5319
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5320
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5321
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5322
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5323
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5324
                    STATUS = "False",
5325
                    CREATE_TIME = DateTime.Now,
5326
                    UPDATE_TIME = DateTime.Now,
5327
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5328
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5329
                };
5330
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5331
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5332
                //this.BaseClient.AddCheckList(projectno, check_);
5333
            }
5334
            else
5335
            {
5336
                Item.IMAGE_URL = Result;
5337
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5338
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5339
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5340
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5341
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5342
            }
5343

    
5344
        }
5345

    
5346
        public void Set_Capture()
5347
        {
5348
            double x = CanvasDrawingMouseDownPoint.X;
5349
            double y = CanvasDrawingMouseDownPoint.Y;
5350
            double width = dragCaptureBorder.Width;
5351
            double height = dragCaptureBorder.Height;
5352

    
5353
            if (width > 5 || height > 5)
5354
            {
5355
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5356
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5357
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5358
            }
5359
        }
5360
        #endregion
5361

    
5362
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5363
        {
5364
            multi_Undo_Data = new Multi_Undo_data();
5365

    
5366
            multi_Undo_Data.Markup = control;
5367

    
5368
            if ((control as IShapeControl) != null)
5369
            {
5370
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5371
            }
5372
            if ((control as IDashControl) != null)
5373
            {
5374
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5375
            }
5376
            if ((control as IPath) != null)
5377
            {
5378
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5379
            }
5380
            if ((control as UIElement) != null)
5381
            {
5382
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5383
            }
5384

    
5385
            return multi_Undo_Data;
5386
        }
5387

    
5388
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5389
        {
5390
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5391
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5392
            {
5393
                if (items.UserID == Select_ID)
5394
                {
5395
                    foreach (var item in items.MarkupList)
5396
                    {
5397
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5398
                        {
5399
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5400
                                items.MarkupInfoID, Commons.shortGuid());
5401
                        }
5402
                    }
5403
                }
5404
            }
5405
        }
5406

    
5407
        /// <summary>
5408
        /// convert inkcontrol to polygoncontrol
5409
        /// </summary>
5410
        public void ConvertInkControlToPolygon()
5411
        {
5412
            if (inkBoard.Strokes.Count > 0)
5413
            {
5414
                inkBoard.Strokes.ToList().ForEach(stroke =>
5415
                {
5416
                    InkToPath ip = new InkToPath();
5417

    
5418
                    List<Point> inkPointSet = new List<Point>();
5419
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5420

    
5421
                    PolygonControl pc = new PolygonControl()
5422
                    {
5423
                        CommentAngle = 0,
5424
                        PointSet = inkPointSet,
5425
                        ControlType = ControlType.Ink
5426
                    };
5427
                    pc.StartPoint = inkPointSet[0];
5428
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5429
                    pc.LineSize = 3;
5430
                    pc.CommentID = Commons.shortGuid();
5431
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5432

    
5433
                    if (pc.PointSet.Count > 0)
5434
                    {
5435
                        CreateCommand.Instance.Execute(pc);
5436
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5437
                    }
5438
                });
5439
                inkBoard.Strokes.Clear();
5440
            }
5441
        }
5442

    
5443
        /// <summary>
5444
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5445
        /// </summary>
5446
        /// <author>ingu</author>
5447
        /// <date>2018.06.05</date>
5448
        /// <param name="getPoint"></param>
5449
        /// <returns></returns>
5450
        private bool IsGetoutpoint(Point getPoint)
5451
        {
5452
            if (getPoint == new Point())
5453
            {
5454
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5455
                currentControl = null;
5456
                return true;
5457
            }
5458

    
5459
            return false;
5460
        }
5461

    
5462
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5463
        {
5464
            e.Effects = DragDropEffects.Copy;
5465
        }
5466

    
5467
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5468
        {
5469
            e.Effects = DragDropEffects.Copy;
5470
        }
5471

    
5472
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5473
        {
5474
            e.Effects = DragDropEffects.None;
5475
        }
5476

    
5477
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5478
        {
5479
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5480
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5481

    
5482
            ScaleImage(pageWidth, pageHeight);
5483
        }
5484

    
5485
        /// <summary>
5486
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5487
        /// </summary>
5488
        /// <param name="pageWidth">원본 사이즈</param>
5489
        /// <param name="pageHeight">원본 사이즈</param>
5490
        /// <returns></returns>
5491
        private void ScaleImage(double pageWidth,double pageHeight)
5492
        {
5493
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5494
        }
5495

    
5496
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5497
        {
5498
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5499
        }
5500

    
5501

    
5502
        /*
5503
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5504
        {
5505
            try
5506
            {
5507
                if (e.Data.GetDataPresent(typeof(string)))
5508
                {
5509
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5510
                    string dragData = e.Data.GetData(typeof(string)) as string;
5511
                    Move_Symbol(sender, dragData);
5512
                }
5513
            }
5514
            catch (Exception ex)
5515
            {
5516
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5517
            }            
5518
        }
5519
        */
5520
    }
5521

    
5522
    public class testItem
5523
    {
5524
        public string Title { get; set; }
5525
    }
5526
}
클립보드 이미지 추가 (최대 크기: 500 MB)