프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
180
                }
181
            }
182
        }
183

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

    
208
        public bool IsSyncPDFMode { get; set; }
209

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

    
234
        #endregion
235

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

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

    
249
            //lstSymbolPrivate.ItemsSource = testItems;
250

    
251
            this.Loaded += MainMenu_Loaded;
252
        }
253

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

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

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

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

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

    
291
            return uri;
292
        }
293

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

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

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

    
335
            return false;
336
        }
337

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

    
361
            return false;
362
        }
363

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
499
        }
500

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

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

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

    
520
                    await task;
521

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

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

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

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

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

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

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

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

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

    
609
            /// up to here
610

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

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

    
631
        DispatcherTimer renderTesttimer;
632

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

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

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

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

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

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

    
671
            #endregion
672

    
673
            ViewerDataModel.Instance.PageNumber = BalancePoint;
674

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

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

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

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

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

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

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

    
697
            #endregion
698

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

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

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

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

    
747
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
748

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

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

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

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

    
788
            SearchFocusBorder.Visibility = Visibility.Collapsed;
789

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

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

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

    
808

    
809
            var instanceMain = ViewerDataModel.Instance.SystemMain;
810

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

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

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

    
823
        private async Task MarkupLoadAsync(int pageNumber)
824
        {
825
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
826
            stopwatch.Start();
827

    
828
            /// 컨트롤을 새로 생성한다.
829
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
830
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
831

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

    
834
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
835
            { 
836
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
837
                if (info != null)
838
                {
839
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
840
                    if (info.UserID == App.ViewInfo.UserID)
841
                    {
842
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
843
                                        markup.MarkupInfoID, markup.ID);
844
                        control.Visibility = Visibility.Hidden;
845
                    }
846
                    else
847
                    {
848
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
849
                                                                markup.MarkupInfoID, markup.ID);
850
                        control.Visibility = Visibility.Hidden;
851
                    }
852
                }
853
            };
854
            /// up to here
855

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

    
858
            /// fire selection event
859
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
860
            this.gridViewMarkup.UnselectAll();
861
            this.gridViewMarkup.Select(gridSelectionItem);
862

    
863
            if (!testPanel2.IsHidden)
864
            {
865
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
866
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
867
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
868

    
869
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
870
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
871

    
872

    
873
                foreach (var item in gridSelectionRevItem)
874
                {
875
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
876

    
877
                    foreach (var markupitem in markupitems)
878
                    {
879
                        await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
880
                    }
881
                }
882
            }
883

    
884
            SetCommentPages();
885
        }
886

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

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

    
940
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
941
        {
942
            var instance = ViewerDataModel.Instance;
943

    
944
            if(instance.IsWheelPageChanage)
945
            {
946
                return;
947
            }
948

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

    
987
                //if (changePage != 0)
988
                //{
989
                //    await Task.Factory.StartNew(() =>
990
                //    {
991
                //        double beforeScale = instance.ContentScale;
992

    
993
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
994

    
995
                //        handler = (snd, evt) =>
996
                //        {
997
                //            /// 최상단으로 이전 zoomScale로 위치한다
998
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
999
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1000
                //            instance.IsWheelPageChanage = false;
1001
                //            pageNavigator.PageChanged -= handler;
1002
                //        };
1003

    
1004
                //        pageNavigator.PageChanged += handler;
1005

    
1006
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1007
                //    });
1008
                    
1009

    
1010
                //}
1011
            }
1012
            else
1013
            {
1014
                e.Handled = true;
1015
                if (e.Delta > 0)
1016
                {
1017
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1018
                    ZoomIn(currentContentMousePoint);
1019
                }
1020
                else
1021
                {
1022
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1023
                    ZoomOut(currentContentMousePoint);
1024
                }
1025
            }
1026
        }
1027

    
1028
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1029
        {
1030
            e.Handled = true;
1031
            if (e.Delta > 0)
1032
            {
1033
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1034
                ZoomIn_Sync(currentContentMousePoint);
1035
            }
1036
            else
1037
            {
1038
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1039
                ZoomOut_Sync(currentContentMousePoint);
1040
            }
1041
        }
1042

    
1043
        #region ZoomIn & ZoomOut
1044

    
1045
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1046
        {
1047
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1048
                zoomAndPanControl.ContentZoomFocusY));
1049
        }
1050

    
1051
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1052
        {
1053
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1054
                zoomAndPanControl.ContentZoomFocusY));
1055
        }
1056

    
1057

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

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

    
1077
        private void ZoomIn(Point contentZoomCenter)
1078
        {
1079
            if (zoomAndPanControl.ContentScale > 0.19)
1080
            {
1081
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1082
            }
1083
            else
1084
            {
1085
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1086
            }
1087

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

    
1093
        }
1094

    
1095
        private void ZoomOut_Sync(Point contentZoomCenter)
1096
        {
1097
            if (zoomAndPanControl2.ContentScale > 0.39)
1098
            {
1099
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1100
            }
1101
            else
1102
            {
1103
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1104
            }
1105

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

    
1112
        private void ZoomIn_Sync(Point contentZoomCenter)
1113
        {
1114
            if (zoomAndPanControl2.ContentScale > 0.19)
1115
            {
1116
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1117
            }
1118
            else
1119
            {
1120
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1121
            }
1122

    
1123
            if (Sync.IsChecked)
1124
            {
1125
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1126
            }
1127
        }
1128

    
1129
        private void ZoomOut()
1130
        {
1131
            zoomAndPanControl.ContentScale -= 0.1;
1132
            //if (zoomAndPanControl2 != null)
1133
            //{
1134
            //    zoomAndPanControl2.ContentScale -= 0.1;
1135
            //}
1136
        }
1137

    
1138
        private void ZoomIn()
1139
        {
1140
            zoomAndPanControl.ContentScale += 0.1;
1141
            //if (zoomAndPanControl2 != null)
1142
            //{
1143
            //    zoomAndPanControl2.ContentScale += 0.1;
1144
            //}
1145
        }
1146

    
1147
        #endregion
1148

    
1149
        private void init()
1150
        {
1151
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1152
            {
1153

    
1154
                ControlList.Clear();
1155
                listBox.Items.Clear();
1156
                selected_item.Clear();
1157

    
1158
                (item as IMarkupCommonData).IsSelected = false;
1159
            }
1160

    
1161
        }
1162

    
1163
        private HitTestResultBehavior MyCallback(HitTestResult result)
1164
        {
1165
            //this.cursor = Cursors.UpArrow;
1166
            var element = result.VisualHit;
1167
            while (element != null && !(element is CommentUserInfo))
1168
                element = VisualTreeHelper.GetParent(element);
1169

    
1170
            if (element == null)
1171
            {
1172
                return HitTestResultBehavior.Stop;
1173
            }
1174
            else
1175
            {
1176
                if (element is CommentUserInfo)
1177
                {
1178
                    if (!hitList.Contains(element))
1179
                    {
1180
                        hitList.Add((CommentUserInfo)element);
1181
                    }
1182
                    else
1183
                    {
1184
                        return HitTestResultBehavior.Stop;
1185
                    }
1186
                }
1187
            }
1188
            return HitTestResultBehavior.Continue;
1189
        }
1190

    
1191
        public void ReleaseSelectPath()
1192
        {
1193
            if (SelectionPath == null)
1194
            {
1195
                SelectionPath = new Path();
1196
                SelectionPath.Name = "";
1197
            }
1198
            if (SelectionPath.Name != "")
1199
            {
1200
                SelectionPath.Name = "None";
1201
            }
1202
            SelectionPath.Opacity = 0.01;
1203
            SelectionPath.RenderTransform = null;
1204
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1205
        }
1206

    
1207
        #region 컨트롤 초기화 
1208
        public void Control_Init(object control)
1209
        {
1210
            if (L_Size != 0 && (control as IPath) != null)
1211
            {
1212
                (control as IPath).LineSize = L_Size;
1213
                L_Size = 0;
1214
            }
1215

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

    
1302
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1303
        {
1304
            //Control_Init(e.Source);
1305
        }
1306
        //private Window _dragdropWindow = null;
1307

    
1308
        [DllImport("user32.dll")]
1309
        [return: MarshalAs(UnmanagedType.Bool)]
1310
        internal static extern bool GetCursorPos(ref Win32Point pt);
1311

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

    
1329

    
1330
               if (this._dragdropWindow != null)
1331
               {
1332
                   this._dragdropWindow.Close();
1333
                   this._dragdropWindow = null;
1334
               }
1335

    
1336
               symbol_id = id;
1337
               symbol_group_id = group_id;
1338
               symbol_SelectedIndex = SelectedIndex;
1339
               symbol_Data = Data_;
1340
               symbol_img = img;
1341

    
1342

    
1343
               CreateDragDropWindow2(img);
1344
              
1345
    }
1346

    
1347
    private void CreateDragDropWindow2(ImageSource image)
1348
        {
1349
            this._dragdropWindow = new Window();
1350
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1351
            _dragdropWindow.WindowStyle = WindowStyle.None;
1352
            _dragdropWindow.AllowsTransparency = true;           
1353
            _dragdropWindow.AllowDrop = false;
1354
            _dragdropWindow.Background = null;
1355
            _dragdropWindow.IsHitTestVisible = false;
1356
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1357
            _dragdropWindow.Topmost = true;
1358
            _dragdropWindow.ShowInTaskbar = false;
1359
            
1360
            Rectangle r = new Rectangle();
1361
            r.Width = image.Width;
1362
            r.Height = image.Height;
1363
            r.Opacity = 0.5;            
1364
            r.Fill = new ImageBrush(image);
1365
            this._dragdropWindow.Content = r;
1366

    
1367
            Win32Point w32Mouse = new Win32Point();
1368
            GetCursorPos(ref w32Mouse);
1369

    
1370
            //w32Mouse.X = getCurrentPoint.X;
1371
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1372
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1373
            this._dragdropWindow.Show();
1374
        }
1375

    
1376
        
1377

    
1378
         */
1379

    
1380
        public void MoveZoomAndPanControl(Vector dragOffset)
1381
        {
1382
   
1383
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1384
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1385

    
1386
            if (Sync.IsChecked)
1387
            {
1388
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1389
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1390
            }
1391
        }
1392

    
1393
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1394
        {
1395
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1396
            {
1397
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1398

    
1399
                Point currentPos = e.GetPosition(rect);
1400

    
1401
                floatingTip.HorizontalOffset = currentPos.X + 20;
1402
                floatingTip.VerticalOffset = currentPos.Y;
1403
            }
1404

    
1405
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1406
            
1407
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1408
            {
1409
                SetCursor();
1410
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1411
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1412

    
1413
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1414

    
1415
                MoveZoomAndPanControl(dragOffset);
1416
            }
1417

    
1418
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1419
            {
1420
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1421
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1422
                SetCursor();
1423

    
1424
                if (currentControl != null)
1425
                {
1426
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1427
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1428
                    //강인구 추가
1429
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1430

    
1431
                    if ((currentControl as IPath) != null)
1432
                    {
1433
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1434
                    }
1435
                    if ((currentControl as LineControl) != null)
1436
                    {
1437
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1438
                    }
1439

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

    
1483

    
1484
                    #region // 모든 컨트롤의 공통기능 제어
1485
                    if (controlType != ControlType.PenControl)
1486
                    {
1487
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1488
                    }
1489

    
1490

    
1491
                    #endregion
1492

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

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

    
1568
                            }
1569
                            break;
1570

    
1571
                        case ControlType.ArcLine:
1572
                            {
1573
                                var control = currentControl as ArcControl;
1574
                                if (control != null)
1575
                                {
1576
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1577
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1578
                                }
1579
                            }
1580
                            break;
1581

    
1582
                        case ControlType.ArcArrow:
1583
                            {
1584
                                var control = currentControl as ArrowArcControl;
1585
                                if (control != null)
1586
                                {
1587
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1588
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1589
                                }
1590
                            }
1591
                            break;
1592

    
1593
                        case ControlType.ArrowMultiLine:
1594
                            {
1595
                                var control = currentControl as ArrowControl_Multi;
1596
                                if (control != null)
1597
                                {
1598
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1599
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1600
                                }
1601
                            }
1602
                            break;
1603

    
1604
                        case ControlType.Circle:
1605
                            {
1606
                                var control = currentControl as CircleControl;
1607

    
1608
                                if (control != null)
1609
                                {
1610
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1611
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1612
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1613
                                }
1614
                            }
1615
                            break;
1616

    
1617
                        case ControlType.PolygonCloud:
1618
                            {
1619
                                var control = currentControl as CloudControl;
1620
                                if (control != null)
1621
                                {
1622
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1623
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1624
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1625
                                }
1626
                            }
1627
                            break;
1628

    
1629
                        case ControlType.Triangle:
1630
                            {
1631
                                var control = currentControl as TriControl;
1632
                                if (control != null)
1633
                                {
1634
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1635
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1636
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1637
                                }
1638
                            }
1639
                            break;
1640

    
1641
                        case ControlType.ImgControl:
1642
                            {
1643
                                var control = currentControl as ImgControl;
1644
                                if (control != null)
1645
                                {
1646
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1647
                                }
1648
                            }
1649
                            break;
1650

    
1651
                        case ControlType.Date:
1652
                            {
1653
                                var control = currentControl as DateControl;
1654
                                if (control != null)
1655
                                {
1656
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1657
                                }
1658
                            }
1659
                            break;
1660

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

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

    
1776
                                //inkBoard.Strokes.Add(stroke);
1777
                            }
1778
                            break;
1779
                    }
1780
                    return;
1781
                }
1782
            }
1783
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1784
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1785
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1786
            {
1787
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1788

    
1789
                if (isDraggingSelectionRect)
1790
                {
1791
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1792
                    e.Handled = true;
1793
                }
1794
                else if (isLeftMouseButtonDownOnWindow)
1795
                {
1796
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1797
                    double dragDistance = Math.Abs(dragDelta.Length);
1798

    
1799
                    if (dragDistance > DragThreshold)
1800
                    {
1801
                        isDraggingSelectionRect = true;
1802
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1803
                    }
1804

    
1805
                    e.Handled = true;
1806
                }
1807

    
1808
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1809
                {
1810
                }
1811
                else
1812
                {
1813
                    e.Handled = true;
1814
                }
1815
            }
1816
            /*
1817
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1818
            { //symbol      
1819
                if(_dragdropWindow != null)
1820
                {
1821
                    Win32Point w32Mouse = new Win32Point();
1822
                    GetCursorPos(ref w32Mouse);
1823

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

    
1849
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1850
        {
1851
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1852
            {
1853
                SetCursor();
1854
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1855
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1856

    
1857
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1858

    
1859
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1860
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1861

    
1862
                if (Sync.IsChecked)
1863
                {
1864
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1865
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1866
                }
1867
            }
1868
        }
1869

    
1870
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1871

    
1872
        private EllipseGeometry hitArea = new EllipseGeometry();
1873

    
1874
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1875
        {
1876
            IsDrawing = false;
1877
    
1878
            if (mouseHandlingMode != MouseHandlingMode.None)
1879
            {
1880
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1881
                {
1882
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1883

    
1884
                    SetCursor();
1885

    
1886
                    switch (controlType)
1887
                    {
1888
                        case ControlType.None:
1889
                            break;
1890
                        case ControlType.Rectangle:
1891
                            {
1892

    
1893
                            }
1894
                            break;
1895
                        case ControlType.PenControl:
1896
                            {
1897

    
1898
                            }
1899
                            break;
1900
                        default:
1901
                            break;
1902
                    }                    
1903
                }
1904
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1905
                {
1906
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1907

    
1908
                    if (isLeftMouseButtonDownOnWindow)
1909
                    {
1910
                        bool wasDragSelectionApplied = false;
1911

    
1912
                        if (isDraggingSelectionRect)
1913
                        {
1914
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1915
                            {
1916
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1917
                                mouseHandlingMode = MouseHandlingMode.None;
1918
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1919
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1920
                                Set_Symbol_Capture(endPoint);
1921
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1922
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1923
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1924
                            }
1925
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1926
                            {
1927
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1928
                                mouseHandlingMode = MouseHandlingMode.None;
1929
                                Set_Capture();
1930

    
1931
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1932
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1933
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1934
                            }
1935
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1936
                            {
1937
                                ApplyDragSelectionRect();
1938
                            }
1939
                            else
1940
                            {
1941
                                double x = Canvas.GetLeft(dragZoomBorder);
1942
                                double y = Canvas.GetTop(dragZoomBorder);
1943
                                double width = dragZoomBorder.Width;
1944
                                double height = dragZoomBorder.Height;
1945
                                Rect dragRect = new Rect(x, y, width, height);
1946

    
1947
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1948

    
1949
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1950
                            }
1951

    
1952
                            isDraggingSelectionRect = false;
1953
                            e.Handled = true;
1954
                            wasDragSelectionApplied = true;
1955
                        }
1956

    
1957
                        if (isLeftMouseButtonDownOnWindow)
1958
                        {
1959
                            isLeftMouseButtonDownOnWindow = false;
1960
                            this.ReleaseMouseCapture();
1961
                            e.Handled = true;
1962
                        }
1963

    
1964
                        if (!wasDragSelectionApplied)
1965
                        {
1966
                            init();
1967
                        }
1968
                    }
1969
                }
1970
                else if (e.RightButton == MouseButtonState.Pressed)
1971
                {
1972
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1973
                    SetCursor();
1974
                }
1975

    
1976
                zoomAndPanControl.ReleaseMouseCapture();
1977

    
1978

    
1979
                e.Handled = true;
1980
            }
1981
            else
1982
            {
1983
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1984
                SetCursor();
1985
            }
1986

    
1987
            ///mouseButtonDown = MouseButton.Left;
1988
            //controlType = ControlType.SingleLine;
1989
        }
1990

    
1991
        public void Set_Symbol_Capture(Point endPoint)
1992
        {       
1993
            double x = CanvasDrawingMouseDownPoint.X;
1994
            double y = CanvasDrawingMouseDownPoint.Y;
1995
            if(x > endPoint.X)
1996
            {
1997
                x = endPoint.X;
1998
                y = endPoint.Y;
1999
            }
2000

    
2001
            double width = dragCaptureBorder.Width;
2002
            double height = dragCaptureBorder.Height;
2003

    
2004
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2005

    
2006
            if (x < 0)
2007
            {
2008
                width += x;
2009
                x = 0;
2010
            }
2011
            if (y < 0)
2012
            {
2013
                height += y;
2014
                y = 0;
2015

    
2016
                width = (int)canvasImage.PixelWidth - x;
2017
            }
2018
            if (x + width > canvasImage.PixelWidth)
2019
            {
2020
                width = (int)canvasImage.PixelWidth - x;
2021
            }
2022
            if (y + height > canvasImage.PixelHeight)
2023
            {
2024
                height = (int)canvasImage.PixelHeight - y;
2025
            }
2026
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2027

    
2028
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2029
            var defaultBitmapImage = new BitmapImage();
2030
            defaultBitmapImage.BeginInit();
2031
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2032
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2033
            defaultBitmapImage.UriSource = new Uri(uri);
2034
            defaultBitmapImage.EndInit();
2035

    
2036
            //GC.Collect();
2037

    
2038
            if (defaultBitmapImage.IsDownloading)
2039
            {
2040
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2041
                {
2042
                    defaultBitmapImage.Freeze();
2043
                    //GC.Collect();
2044
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2045
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2046
                };
2047
            }
2048
        }
2049

    
2050
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2051
        {
2052
            ///mouseButtonDown = MouseButton.Left;
2053
        }
2054

    
2055
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2056
        {
2057
            ///mouseButtonDown = MouseButton.Left;
2058
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2059
        }
2060

    
2061
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2062
        {
2063

    
2064
        }
2065

    
2066
        /// <summary>
2067
        /// select items by dragging
2068
        /// </summary>
2069
        private void ApplyDragSelectionRect()
2070
        {
2071
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2072

    
2073
            double x = Canvas.GetLeft(dragSelectionBorder);
2074
            double y = Canvas.GetTop(dragSelectionBorder);
2075
            double width = dragSelectionBorder.Width;
2076
            double height = dragSelectionBorder.Height;
2077
            Boolean Flag = false;
2078
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2079
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2080

    
2081
            Rect dragRect = new Rect(x, y, width, height);
2082
            ///dragRect.Inflate(width / 10, height / 10);
2083

    
2084
            foreach (var item in Items)
2085
            {
2086
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2087

    
2088
                if (Flag)
2089
                {
2090
                    adornerSet.Add(item);
2091
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2092
                    Control_Style(item);
2093
                }
2094
            }
2095
            if (adornerSet.Count > 0)
2096
            {
2097
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2098
                SelectLayer.Children.Add(final);
2099
            }
2100
        }
2101

    
2102
        private void InitDragSelectionRect(Point pt1, Point pt2)
2103
        {
2104
            //캡쳐 중
2105
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2106
            {
2107
                dragCaptureBorder.Visibility = Visibility.Visible;
2108
            }
2109
            //선택 중
2110
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2111
            {
2112

    
2113
                dragSelectionBorder.Visibility = Visibility.Visible;
2114
            }
2115
            else
2116
            {
2117
                dragZoomBorder.Visibility = Visibility.Visible;
2118
            }
2119
            UpdateDragSelectionRect(pt1, pt2);
2120
        }
2121

    
2122
        /// <summary>
2123
        /// Update the position and size of the rectangle used for drag selection.
2124
        /// </summary>
2125
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2126
        {
2127
            double x, y, width, height;
2128

    
2129
            //
2130
            // Determine x,y,width and height of the rect inverting the points if necessary.
2131
            // 
2132

    
2133
            if (pt2.X < pt1.X)
2134
            {
2135
                x = pt2.X;
2136
                width = pt1.X - pt2.X;
2137
            }
2138
            else
2139
            {
2140
                x = pt1.X;
2141
                width = pt2.X - pt1.X;
2142
            }
2143

    
2144
            if (pt2.Y < pt1.Y)
2145
            {
2146
                y = pt2.Y;
2147
                height = pt1.Y - pt2.Y;
2148
            }
2149
            else
2150
            {
2151
                y = pt1.Y;
2152
                height = pt2.Y - pt1.Y;
2153
            }
2154

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

    
2183
        private void drawingPannelRotate(double angle)
2184
        {
2185
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2186
            rotate.Angle = angle;
2187
            var rotationNum = Math.Abs((rotate.Angle / 90));
2188

    
2189
            if (angle == 90 || angle == 270)
2190
            {
2191
                double emptySize = zoomAndPanCanvas.Width;
2192
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2193
                zoomAndPanCanvas.Height = emptySize;
2194
            }
2195
            if (angle == 0)
2196
            {
2197
                translate.X = 0;
2198
                translate.Y = 0;
2199
            }
2200
            else if (angle == 90)
2201
            {
2202
                translate.X = zoomAndPanCanvas.Width;
2203
                translate.Y = 0;
2204
            }
2205
            else if (angle == 180)
2206
            {
2207
                translate.X = zoomAndPanCanvas.Width;
2208
                translate.Y = zoomAndPanCanvas.Height;
2209
            }
2210
            else
2211
            {
2212
                translate.X = 0;
2213
                translate.Y = zoomAndPanCanvas.Height;
2214
            }
2215

    
2216
            zoomAndPanControl.RotationAngle = rotate.Angle;
2217

    
2218

    
2219
            if (!testPanel2.IsHidden)
2220
            {
2221
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2222
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2223
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2224
            }
2225

    
2226
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2227
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2228
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2229
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2230
            ViewerDataModel.Instance.Angle = rotate.Angle;
2231
        }
2232

    
2233
        private void syncPannelRotate(double angle)
2234
        {
2235
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2236
            rotate.Angle = angle;
2237
            var rotationNum = Math.Abs((rotate.Angle / 90));
2238

    
2239
            if (angle == 90 || angle == 270)
2240
            {
2241
                double emptySize = zoomAndPanCanvas2.Width;
2242
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2243
                zoomAndPanCanvas2.Height = emptySize;
2244
            }
2245
            if (angle == 0)
2246
            {
2247
                translate2.X = 0;
2248
                translate2.Y = 0;
2249
            }
2250
            else if (angle == 90)
2251
            {
2252
                translate2.X = zoomAndPanCanvas2.Width;
2253
                translate2.Y = 0;
2254
            }
2255
            else if (angle == 180)
2256
            {
2257
                translate2.X = zoomAndPanCanvas2.Width;
2258
                translate2.Y = zoomAndPanCanvas2.Height;
2259
            }
2260
            else
2261
            {
2262
                translate2.X = 0;
2263
                translate2.Y = zoomAndPanCanvas2.Height;
2264
            }
2265

    
2266
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2267
        }
2268

    
2269
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2270
        {
2271
            string Data_ = "";
2272

    
2273
            try
2274
            {
2275
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2276
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2277
                if (Data_ != null || Data_ != "")
2278
                {
2279
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2280
                }
2281
                else
2282
                {
2283
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2284
                }
2285

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

    
2312
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2313
                    {
2314
                        PointSet = new List<Point>(),
2315
                        FilePath = Data_,
2316
                        ImageData = img.Source,
2317
                        StartPoint = canvasZoomPanningMouseDownPoint,
2318
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2319
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2320
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2321
                        canvasZoomPanningMouseDownPoint.Y),
2322
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2323
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2324
                    };
2325

    
2326
                    currentControl.PointSet = new List<Point>
2327
                                        {
2328
                                            currentControl.StartPoint,
2329
                                            currentControl.LeftBottomPoint,
2330
                                            currentControl.EndPoint,
2331
                                            currentControl.TopRightPoint,
2332
                                        };
2333
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2334
                    UndoData = new Undo_data()
2335
                    {
2336
                        IsUndo = false,
2337
                        Event = Event_Type.Create,
2338
                        EventTime = DateTime.Now,
2339
                        Markup_List = new List<Multi_Undo_data>()
2340
                    };
2341
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2342
                    {
2343
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2344
                    });
2345

    
2346
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2347
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2348
                    UndoData.Markup_List.Add(multi_Undo_Data);
2349
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2350

    
2351
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2352
                    currentControl.CommentID = Commons.shortGuid();
2353
                    currentControl.SymbolID = id;
2354
                    currentControl.GroupID = group_id;
2355
                    currentControl.ApplyTemplate();
2356
                    currentControl.SetImage();
2357

    
2358
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2359
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2360
                    SelectLayer.Children.Add(final);
2361
                }
2362
            }
2363
            catch (Exception ex)
2364
            {
2365
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2366
            }
2367
        }
2368

    
2369
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2370
        {
2371
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2372
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2373
            {
2374
                set_option.Value = double.Parse(set_option.ContentText);
2375
                //set_option.Focusable = false;
2376
                zoomAndPanControl.Focus();
2377
            }
2378

    
2379
            ConvertInkControlToPolygon();
2380

    
2381
            ///TODO:
2382
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2383
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2384

    
2385
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2386
            {
2387
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2388
            }
2389
            /// up to here
2390

    
2391
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2392
            {
2393
                if (item as ArrowTextControl != null)
2394
                {
2395
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2396
                }
2397
                else if (item as TextControl != null)
2398
                {
2399
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2400
                }
2401
            }
2402

    
2403
            //if (currentControl != null)
2404
            {
2405
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2406
                if (text_item_ != null)
2407
                {
2408
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2409
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2410
                    (text_item_ as TextControl).IsEditingMode = false;                    
2411
                    currentControl = null;
2412
                }
2413

    
2414
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2415
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2416
                {
2417
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2418
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2419
                    currentControl = null;
2420
                }
2421
            }
2422

    
2423
            double Ang = 0;                                          
2424
            if (rotate.Angle != 0)
2425
            {
2426
                Ang = 360 - rotate.Angle;
2427
            }
2428

    
2429
            if (e.OriginalSource is System.Windows.Controls.Image)
2430
            {
2431
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2432
            }
2433
            /*
2434
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2435
            {                
2436
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2437
                if(symbol_id != null)
2438
                {
2439
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2440
                }                
2441
            }
2442

    
2443
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2444
            {
2445
                if (this._dragdropWindow != null)
2446
                {
2447
                    this._dragdropWindow.Close();
2448
                    this._dragdropWindow = null;
2449
                    symbol_id = null;
2450
                }
2451
            }
2452
            */
2453

    
2454
            if (e.LeftButton == MouseButtonState.Pressed)
2455
            {
2456
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2457
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2458

    
2459
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2460
                SetCursor();
2461

    
2462
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2463
            }
2464

    
2465
            if (e.MiddleButton == MouseButtonState.Pressed)
2466
            {
2467
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2468
                cursor = Cursors.SizeAll;
2469
                SetCursor();
2470
            }
2471
            if (e.RightButton == MouseButtonState.Pressed)
2472
            {
2473
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2474
                cursor = Cursors.SizeAll;
2475
                SetCursor();
2476
            }
2477
            else if (e.XButton1 == MouseButtonState.Pressed)
2478
            {
2479
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2480
                {
2481
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2482
                }
2483

    
2484
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2485

    
2486
            }
2487
            else if (e.XButton2 == MouseButtonState.Pressed)
2488
            {
2489
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2490
                {
2491
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2492
                }
2493
            }
2494

    
2495
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2496
            {
2497
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2498
                {
2499
                    if (SelectLayer.Children.Count == 0)
2500
                    {
2501
                        isLeftMouseButtonDownOnWindow = true;
2502
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2503
                    }
2504

    
2505
                    if (controlType == ControlType.None)
2506
                    {
2507
                        isLeftMouseButtonDownOnWindow = true;
2508
                    }
2509
                }
2510

    
2511
                /// 캡쳐 모드 설정
2512
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2513
                {
2514
                    dragCaptureBorder.Visibility = Visibility.Visible;
2515
                    isLeftMouseButtonDownOnWindow = true;
2516
                }
2517

    
2518
                /// 줌 모드 설정
2519
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2520
                {
2521
                    isLeftMouseButtonDownOnWindow = true;
2522
                }
2523

    
2524
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2525
                if (control != null)
2526
                {
2527
                    AdornerFinal final = null;
2528

    
2529
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2530
                    {
2531
                        /// 기존 selection 해제
2532
                        SelectionSet.Instance.UnSelect(this);
2533

    
2534
                        final = new AdornerFinal(control);
2535

    
2536
                        this.Control_Style(control);
2537

    
2538
                        if ((control as IPath) != null)
2539
                        {
2540
                            if ((control as IPath).LineSize != 0)
2541
                            {
2542
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2543
                            }
2544
                        }
2545
                        if ((control as IShapeControl) != null)
2546
                        {
2547
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2548
                            {
2549
                                ViewerDataModel.Instance.checkHatchShape = true;
2550
                            }
2551
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2552
                            {
2553
                                ViewerDataModel.Instance.checkFillShape = true;
2554
                            }
2555
                            else
2556
                            {
2557
                                ViewerDataModel.Instance.checkHatchShape = false;
2558
                                ViewerDataModel.Instance.checkFillShape = false;
2559
                            }
2560
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2561
                        }
2562

    
2563
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2564

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

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

    
2646
                        Control_Style(control);
2647

    
2648
                        final = new AdornerFinal(comment);
2649
                    }
2650

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

    
2695
                switch (controlType)
2696
                {
2697
                    case ControlType.Coordinate:
2698
                        {
2699
                            if (e.LeftButton == MouseButtonState.Pressed)
2700
                            {
2701
                                if (currentControl is CoordinateControl)
2702
                                {
2703
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2704
                                    {
2705
                                        return;
2706
                                    }
2707

    
2708
                                    CreateCommand.Instance.Execute(currentControl);
2709

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

    
2733
                                        currentControl.CommentID = Commons.shortGuid();
2734
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2735
                                        currentControl.IsNew = true;
2736

    
2737
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2738

    
2739
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2740
                                    }
2741
                                }
2742
                            }
2743
                        }
2744
                        break;
2745
                    case ControlType.InsideWhite:
2746
                        {
2747
                            if (e.LeftButton == MouseButtonState.Pressed)
2748
                            {
2749
                                if (currentControl is InsideWhiteControl)
2750
                                {
2751
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2752
                                    {
2753
                                        return;
2754
                                    }
2755

    
2756
                                    CreateCommand.Instance.Execute(currentControl);
2757

    
2758
                                    currentControl = null;
2759
                                    this.cursor = Cursors.Arrow;
2760
                                }
2761
                                else
2762
                                {
2763
                                    currentControl = new InsideWhiteControl
2764
                                    {
2765
                                        Background = new SolidColorBrush(Colors.Black),
2766
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2767
                                        ControlType = ControlType.InsideWhite
2768
                                    };
2769

    
2770
                                    currentControl.CommentID = Commons.shortGuid();
2771
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2772
                                    currentControl.IsNew = true;
2773
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2774

    
2775
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2776
                                }
2777
                            }
2778
                        }
2779
                        break;
2780
                    case ControlType.OverlapWhite:
2781
                        {
2782
                            if (e.LeftButton == MouseButtonState.Pressed)
2783
                            {
2784
                                if (currentControl is OverlapWhiteControl)
2785
                                {
2786
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2787
                                    {
2788
                                        return;
2789
                                    }
2790

    
2791
                                    CreateCommand.Instance.Execute(currentControl);
2792

    
2793
                                    currentControl = null;
2794
                                    this.cursor = Cursors.Arrow;
2795
                                }
2796
                                else
2797
                                {
2798
                                    currentControl = new OverlapWhiteControl
2799
                                    {
2800
                                        Background = new SolidColorBrush(Colors.Black),
2801
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2802
                                        ControlType = ControlType.OverlapWhite
2803
                                    };
2804

    
2805
                                    currentControl.CommentID = Commons.shortGuid();
2806
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2807
                                    currentControl.IsNew = true;
2808
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2809

    
2810
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2811
                                }
2812
                            }
2813
                        }
2814
                        break;
2815
                    case ControlType.ClipWhite:
2816
                        {
2817
                            if (e.LeftButton == MouseButtonState.Pressed)
2818
                            {
2819
                                if (currentControl is ClipWhiteControl)
2820
                                {
2821
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2822
                                    {
2823
                                        return;
2824
                                    }
2825

    
2826
                                    CreateCommand.Instance.Execute(currentControl);
2827

    
2828
                                    currentControl = null;
2829
                                    this.cursor = Cursors.Arrow;
2830
                                }
2831
                                else
2832
                                {
2833
                                    currentControl = new ClipWhiteControl
2834
                                    {
2835
                                        Background = new SolidColorBrush(Colors.Black),
2836
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2837
                                        ControlType = ControlType.ClipWhite
2838
                                    };
2839

    
2840
                                    currentControl.CommentID = Commons.shortGuid();
2841
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2842
                                    currentControl.IsNew = true;
2843
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2844

    
2845
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2846
                                }
2847
                            }
2848
                        }
2849
                        break;
2850
                    case ControlType.Rectangle:
2851
                        {
2852
                            if (e.LeftButton == MouseButtonState.Pressed)
2853
                            {
2854
                                if (currentControl is RectangleControl)
2855
                                {
2856
                                    //20180906 LJY TEST IsRotationDrawingEnable
2857
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2858
                                    {
2859
                                        return;
2860
                                    }
2861

    
2862
                                    CreateCommand.Instance.Execute(currentControl);
2863
                                    currentControl = null;
2864
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2865
                                }
2866
                                else
2867
                                {
2868
                                    currentControl = new RectangleControl
2869
                                    {
2870
                                        Background = new SolidColorBrush(Colors.Black),
2871
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2872
                                        ControlType = ControlType.Rectangle
2873
                                    };
2874

    
2875
                                    currentControl.CommentID = Commons.shortGuid();
2876
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2877
                                    currentControl.IsNew = true;
2878
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2879

    
2880
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2881
                                }
2882
                            }
2883
                        }
2884
                        break;
2885
                    case ControlType.RectCloud:
2886
                        {
2887
                            if (e.LeftButton == MouseButtonState.Pressed)
2888
                            {
2889
                                if (currentControl is RectCloudControl)
2890
                                {
2891
                                    //20180906 LJY TEST IsRotationDrawingEnable
2892
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2893
                                    {
2894
                                        return;
2895
                                    }
2896

    
2897
                                    CreateCommand.Instance.Execute(currentControl);
2898

    
2899
                                    currentControl = null;
2900
                                
2901
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2902
                                }
2903
                                else
2904
                                {
2905
                                    currentControl = new RectCloudControl
2906
                                    {
2907
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2908
                                        ControlType = ControlType.RectCloud,
2909
                                        Background = new SolidColorBrush(Colors.Black)
2910
                                    };
2911

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

    
2932
                                    CreateCommand.Instance.Execute(currentControl);
2933

    
2934
                                    currentControl = null;
2935
                                }
2936
                                else
2937
                                {
2938
                                    currentControl = new CircleControl
2939
                                    {
2940
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2941
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2942
                                        Background = new SolidColorBrush(Colors.Black)
2943
                                    };
2944

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

    
2972
                                        CreateCommand.Instance.Execute(currentControl);
2973

    
2974
                                        currentControl = null;
2975
                                    }
2976
                                }
2977
                                else
2978
                                {
2979
                                    currentControl = new TriControl
2980
                                    {
2981
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2982
                                        Background = new SolidColorBrush(Colors.Black),
2983
                                    };
2984

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

    
3009
                                    CreateCommand.Instance.Execute(currentControl);
3010
                                    currentControl = null;
3011
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3012
                                }
3013
                                else
3014
                                {
3015
                                    currentControl = new LineControl
3016
                                    {
3017
                                        ControlType = this.controlType,
3018
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3019
                                        Background = new SolidColorBrush(Colors.Black)
3020
                                    };
3021

    
3022
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3023
                                    currentControl.CommentID = Commons.shortGuid();
3024
                                    currentControl.IsNew = true;
3025
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3026
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3027
                                }
3028
                            }
3029
                        }
3030
                        break;
3031
                    case ControlType.PolygonControl:
3032
                        {
3033
                            if (currentControl is PolygonControl)
3034
                            {
3035
                                var control = currentControl as PolygonControl;
3036

    
3037
                                if (e.RightButton == MouseButtonState.Pressed)
3038
                                {
3039
                                    control.IsCompleted = true;
3040
                                }
3041

    
3042
                                if (!control.IsCompleted)
3043
                                {
3044
                                    control.PointSet.Add(control.EndPoint);
3045
                                }
3046
                                else
3047
                                {
3048
                                    //20180906 LJY TEST IsRotationDrawingEnable
3049
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3050
                                    {
3051
                                        return;
3052
                                    }
3053

    
3054
                                    var firstPoint = control.PointSet.First();
3055
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3056
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3057
                                    control.PointSet.Add(firstPoint);
3058

    
3059
                                    control.ApplyOverViewData();
3060

    
3061
                                    CreateCommand.Instance.Execute(currentControl);
3062
                                    control.UpdateControl();
3063
                                    currentControl = null;
3064
                                }
3065
                            }
3066
                            else
3067
                            {
3068
                                if (e.LeftButton == MouseButtonState.Pressed)
3069
                                {
3070
                                    currentControl = new PolygonControl
3071
                                    {
3072
                                        PointSet = new List<Point>(),
3073
                                    };
3074

    
3075
                                    var polygonControl = (currentControl as PolygonControl);
3076
                                    currentControl.CommentID = Commons.shortGuid();
3077
                                    currentControl.IsNew = true;
3078
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3079
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3080
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3081
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3082
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3083
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3084
                                    polygonControl.ApplyTemplate();
3085
                                    polygonControl.Visibility = Visibility.Visible;
3086
                                }
3087
                            }
3088
                        }
3089
                        break;
3090
                    case ControlType.ChainLine:
3091
                        {
3092
                            if (currentControl is PolygonControl)
3093
                            {
3094
                                var control = currentControl as PolygonControl;
3095

    
3096
                                if (e.RightButton == MouseButtonState.Pressed)
3097
                                {
3098
                                    //20180906 LJY TEST IsRotationDrawingEnable
3099
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3100
                                    {
3101
                                        return;
3102
                                    }
3103

    
3104
                                    CreateCommand.Instance.Execute(currentControl);
3105

    
3106
                                    currentControl = null;
3107
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3108
                                    return;
3109
                                }
3110

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

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

    
3161
                                    CreateCommand.Instance.Execute(currentControl);
3162

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

    
3204
                                    CreateCommand.Instance.Execute(currentControl);
3205

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

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

    
3264
                                            CreateCommand.Instance.Execute(currentControl);
3265

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

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

    
3309
                                    CreateCommand.Instance.Execute(currentControl);
3310

    
3311
                                    control.isTransOn = true;
3312
                                    var firstPoint = control.PointSet.First();
3313

    
3314
                                    control.PointSet.Add(firstPoint);
3315
                                    control.DrawingCloud();
3316
                                    control.ApplyOverViewData();
3317

    
3318
                                    currentControl = null;
3319
                                }
3320
                            }
3321
                            else
3322
                            {
3323
                                if (e.LeftButton == MouseButtonState.Pressed)
3324
                                {
3325
                                    currentControl = new CloudControl
3326
                                    {
3327
                                        PointSet = new List<Point>(),
3328
                                        PointC = new StylusPointSet()
3329
                                    };
3330

    
3331
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3332
                                    //{
3333
                                        var polygonControl = (currentControl as CloudControl);
3334
                                        currentControl.CommentID = Commons.shortGuid();
3335
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3336
                                        currentControl.IsNew = true;
3337
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3338

    
3339
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3340
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3341
                                    
3342
                                    //}
3343
                                }
3344
                            }
3345
                        }
3346
                        break;
3347
                    case ControlType.ImgControl:
3348
                        {
3349
                            if (e.LeftButton == MouseButtonState.Pressed)
3350
                            {
3351
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3352
                                //{
3353
                                    if (currentControl is ImgControl)
3354
                                    {
3355
                                        //20180906 LJY TEST IsRotationDrawingEnable
3356
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3357
                                        {
3358
                                            return;
3359
                                        }
3360

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

    
3389
                                            currentControl = new ImgControl
3390
                                            {
3391
                                                    Background = new SolidColorBrush(Colors.Black),
3392
                                                    PointSet = new List<Point>(),
3393
                                                    FilePath = filename,
3394
                                                    ImageData = img.Source,
3395
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3396
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3397
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3398
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3399
                                                    ControlType = ControlType.ImgControl
3400
                                                };
3401

    
3402
                                        
3403
                                                currentControl.CommentID = Commons.shortGuid();                                            
3404
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3405
                                                currentControl.IsNew = true;
3406
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3407

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

    
3430
                                    CreateCommand.Instance.Execute(currentControl);
3431
                                    currentControl = null;
3432

    
3433
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3434
                                    {
3435
                                        controlType = ControlType.None;
3436
                                        IsSwingMode = false;
3437
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3438
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3439
                                        mouseHandlingMode = MouseHandlingMode.None;
3440
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3441
                                        txtBatch.Visibility = Visibility.Collapsed;
3442

    
3443
                                    }
3444
                                }
3445
                                else
3446
                                {
3447
                                    currentControl = new DateControl
3448
                                    {
3449
                                        StartPoint = CanvasDrawingMouseDownPoint,
3450
                                        Background = new SolidColorBrush(Colors.Black)
3451
                                    };
3452
                                    currentControl.CommentID = Commons.shortGuid();
3453
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3454
                                    currentControl.IsNew = true;
3455
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3456

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

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

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

    
3540
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3541
                                    currentControl.CommentID = Commons.shortGuid();
3542
                                    currentControl.IsNew = true;
3543
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3544
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3545

    
3546
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3547
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3548
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3549

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

    
3574
                                    CreateCommand.Instance.Execute(currentControl);
3575

    
3576
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3577
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3578
                                    (currentControl as ArrowTextControl).IsNew = false;
3579
                                    currentControl = null;
3580
                                }
3581
                                else
3582
                                {
3583
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3584
                                    //{
3585
                                        currentControl = new ArrowTextControl();
3586
                                        currentControl.CommentID = Commons.shortGuid();
3587
                                        currentControl.IsNew = true;
3588
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3589
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3590

    
3591
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3592
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3593
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3594
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3595
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3596

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

    
3600
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3601
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3602
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3603
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3604

    
3605
                                    
3606
                                    //}
3607
                                }
3608
                            }
3609
                        }
3610
                        break;
3611
                    case ControlType.ArrowTransTextControl:
3612
                        {
3613
                            if (e.LeftButton == MouseButtonState.Pressed)
3614
                            {
3615
                                if (currentControl is ArrowTextControl)
3616
                                {
3617
                                    //20180906 LJY TEST IsRotationDrawingEnable
3618
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3619
                                    {
3620
                                        return;
3621
                                    }
3622

    
3623
                                    CreateCommand.Instance.Execute(currentControl);
3624

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

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

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

    
3673
                                    CreateCommand.Instance.Execute(currentControl);
3674
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3675
                                    currentControl.IsNew = false;
3676
                                    currentControl = null;
3677
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3678
                                }
3679
                                else
3680
                                {
3681
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3682
                                    //{
3683
                                        currentControl = new ArrowTextControl()
3684
                                        {
3685
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3686
                                        };
3687
                                        currentControl.CommentID = Commons.shortGuid();
3688
                                        currentControl.IsNew = true;
3689
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3690
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3691

    
3692
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3693

    
3694
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3695

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

    
3726
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3727
                                }
3728
                                else
3729
                                {
3730
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3731
                                    //{
3732
                                    
3733

    
3734
                                    currentControl = new ArrowTextControl()
3735
                                    {
3736
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3737
                                        ControlType = ControlType.ArrowTransTextBorderControl
3738

    
3739
                                    };
3740
                                        currentControl.CommentID = Commons.shortGuid();
3741
                                        currentControl.IsNew = true;
3742
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3743
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3744

    
3745
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3746

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

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

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

    
3842
                                        };
3843
                                        currentControl.CommentID = Commons.shortGuid();
3844
                                        currentControl.IsNew = true; 
3845
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3846
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3847
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3848

    
3849
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3850
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3851
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3852
                                        (currentControl as ArrowTextControl).isFixed = true;
3853
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3854

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

    
3878
                                if (_sign == null)
3879
                                    {
3880
                                        txtBatch.Visibility = Visibility.Collapsed;
3881
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3882
                                        controlType = ControlType.None;
3883

    
3884
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3885
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3886
                                        return;
3887
                                    }
3888

    
3889
                                    if (currentControl is SignControl)
3890
                                    {
3891
                                        //20180906 LJY TEST IsRotationDrawingEnable
3892
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3893
                                        {
3894
                                            return;
3895
                                        }
3896

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

    
3917
                                        currentControl.CommentID = Commons.shortGuid();
3918
                                        currentControl.IsNew = true;
3919
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3920
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3921

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

    
3943
                                        CreateCommand.Instance.Execute(currentControl);
3944
                                        (currentControl as RectangleControl).ApplyOverViewData();
3945
                                        currentControl = null;
3946
                                    
3947
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3948

    
3949
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3950
                                        {
3951
                                            txtBatch.Text = "Place Signature";
3952
                                            controlType = ControlType.Sign;
3953
                                        }
3954
                                    }
3955
                                    else
3956
                                    {
3957
                                        currentControl = new RectangleControl
3958
                                        {
3959
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3960
                                            Background = new SolidColorBrush(Colors.Black),
3961
                                            ControlType = ControlType.Mark ,
3962
                                            Paint = PaintSet.Fill
3963
                                        };
3964

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

    
4001
                                    currentControl.IsNew = true;
4002
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4003
                                    currentControl.CommentID = Commons.shortGuid();
4004
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4005

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

    
4027
                                        CreateCommand.Instance.Execute(currentControl);
4028
                                        currentControl = null;
4029
                                   
4030

    
4031
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4032
                                    }
4033
                                    else
4034
                                    {
4035
                                        currentControl = new SymControlN
4036
                                        {
4037
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4038
                                            Background = new SolidColorBrush(Colors.Black),
4039
                                            STAMP = App.SystemInfo.STAMP,                                            
4040
                                            ControlType = ControlType.Stamp
4041
                                        };
4042

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

    
4081
                if (currentControl != null)
4082
                {
4083
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4084
                }
4085
            }
4086
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4087
            {
4088
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4089
                {
4090
                    bool mouseOff = false;
4091
                    foreach (var item in SelectLayer.Children)
4092
                    {
4093
                        if (item is AdornerFinal)
4094
                        {
4095

    
4096
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4097
                            if (over != null)
4098
                            {
4099
                                mouseOff = true;
4100
                            }
4101
                        }
4102
                    }
4103

    
4104
                    if (!mouseOff)
4105
                    {
4106
                        SelectionSet.Instance.UnSelect(this);
4107
                    }
4108
                }
4109
                zoomAndPanControl.CaptureMouse();
4110
                e.Handled = true;
4111
            }
4112
          
4113
        }
4114

    
4115
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4116
        {
4117
            ///mouseButtonDown = e.ChangedButton;
4118
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4119
        }
4120

    
4121
        private void RemoveLineStroke(Point P)
4122
        {
4123
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4124
            if (control != null)
4125
            {
4126
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4127
            }
4128
        }
4129

    
4130
        private void RemovePointStroke(Point P)
4131
        {
4132
            foreach (Stroke hits in inkBoard.Strokes)
4133
            {
4134
                foreach (StylusPoint sty in hits.StylusPoints)
4135
                {
4136

    
4137
                }
4138
                if (hits.HitTest(P))
4139
                {
4140
                    inkBoard.Strokes.Remove(hits);
4141
                    return;
4142
                }
4143
            }
4144
        }
4145

    
4146
        private void StartNewStroke(Point P)
4147
        {
4148
            strokePoints = new StylusPointCollection();
4149
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4150
            strokePoints.Add(segment1Start);
4151
            stroke = new Stroke(strokePoints);
4152

    
4153
            stroke.DrawingAttributes.Color = Colors.Red;
4154
            stroke.DrawingAttributes.Width = 4;
4155
            stroke.DrawingAttributes.Height = 4;
4156

    
4157
            inkBoard.Strokes.Add(stroke);
4158
        }
4159

    
4160
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4161
        {
4162
            ConsolidationMethod();
4163
        }
4164

    
4165
        /// <summary>
4166
        /// execute TeamConsolidationCommand
4167
        /// </summary>
4168
        public void TeamConsolidationMethod()
4169
        {
4170
            this.UpdateMyMarkupList();
4171
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4172
            {
4173
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4174
            }
4175
            else
4176
            {
4177

    
4178
                ViewerDataModel.Instance.IsConsolidate = true;
4179
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4180

    
4181
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4182
                {
4183
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4184
                    {
4185
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4186
                        return;
4187
                    }                    
4188
                }
4189
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4190
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4191
                {
4192
                    MarkupInfoList.Add(item);
4193
                }
4194
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4195
            }
4196
        }
4197

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

    
4217
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4218
        {
4219
            if (App.ViewInfo != null)
4220
            {
4221
                btnConsolidate = (sender as RadRibbonButton);
4222
                if (!App.ViewInfo.NewCommentPermission)
4223
                {
4224
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4225
                }
4226
            }
4227
        }
4228

    
4229
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4230
        {
4231
            TeamConsolidationMethod();
4232
        }
4233

    
4234
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4235
        {
4236
            btnTeamConsolidate = sender as RadRibbonButton;
4237
            if (App.ViewInfo != null)
4238
            {
4239
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4240
                {
4241
                    if (btnConsolidate != null)
4242
                    {
4243
                        btnConsolidate.Visibility = Visibility.Collapsed;
4244
                    }
4245

    
4246
                    if (!App.ViewInfo.NewCommentPermission)
4247
                    {
4248
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4249
                    }
4250
                }
4251
                else
4252
                {
4253
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4254
                }
4255
            }
4256
        }
4257

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

    
4279
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4280
        {
4281
            btnFinalPDF = sender as RadRibbonButton;
4282
            if (App.ViewInfo != null)
4283
            {
4284
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4285
                {
4286
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4287
                    if (btnConsolidate != null)
4288
                    {
4289
                        btnConsolidate.Visibility = Visibility.Collapsed;
4290
                    }
4291
                }
4292
            }
4293
        }
4294

    
4295
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4296
        {
4297
            UpdateMyMarkupList();
4298

    
4299
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4300
            {
4301
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4302
            }
4303
            else
4304
            {
4305
                ViewerDataModel.Instance.IsConsolidate = true;
4306
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4307
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4308

    
4309
                string project_no = App.ViewInfo.ProjectNO;
4310
                string doc_id = _DocInfo.ID;
4311
                string user_id = App.ViewInfo.UserID;
4312
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4313
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4314
                {
4315
                    markupInfoItems.Add(item);
4316
                }
4317
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4318
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4319
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4320
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4321

    
4322
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4323
                if (item2 != null)
4324
                {
4325
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4326

    
4327
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4328
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4329
                }
4330
                else
4331
                {
4332
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4333
                }
4334
            }
4335
        }
4336

    
4337
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4338
        {
4339
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4340
#if Hyosung
4341
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4342
#else
4343
            if (App.ViewInfo != null)
4344
            {
4345
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4346
                {
4347
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4348
                }
4349
            }
4350
#endif
4351
        }
4352

    
4353
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4354
        {
4355
            SetCompareRect();
4356
        }
4357

    
4358
        private void Sync_Click(object sender, RoutedEventArgs e)
4359
        {
4360
            if (Sync.IsChecked)
4361
            {
4362
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4363
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4364
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4365
            }
4366
        }
4367

    
4368
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4369
        {
4370
            if (UserList.IsChecked)
4371
            {
4372
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4373
            }
4374
            else
4375
            {
4376
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4377
            }
4378
        }
4379

    
4380
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4381
        {
4382

    
4383
            if (BalanceMode.IsChecked)
4384
            {
4385
                ViewerDataModel.Instance.PageBalanceMode = true;
4386
            }
4387
            else
4388
            {
4389
                ViewerDataModel.Instance.PageBalanceMode = false;
4390
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4391
            }
4392
        }
4393

    
4394
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4395
        {
4396
            //초기화
4397
            testPanel2.IsHidden = true;
4398
            ViewerDataModel.Instance.PageBalanceMode = false;
4399
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4400
            ViewerDataModel.Instance.PageNumber = 0;
4401
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4402
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4403
            UserList.IsChecked = false;
4404
            BalanceMode.IsChecked = false;
4405
        }
4406

    
4407
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4408
        {
4409
            if ((sender as System.Windows.Controls.Control).Tag != null)
4410
            {
4411
                //Compare 초기화
4412
                CompareMode.IsChecked = false;
4413
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4414

    
4415
                if (ViewerDataModel.Instance.PageNumber == 0)
4416
                {
4417
                    ViewerDataModel.Instance.PageNumber = 1;
4418
                }
4419

    
4420
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4421
                {
4422
                }
4423
                else
4424
                {
4425
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4426
                }
4427

    
4428

    
4429

    
4430
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4431
                {
4432

    
4433
                }
4434
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4435
                {
4436
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4437
                }
4438

    
4439
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4440

    
4441
                if (!testPanel2.IsHidden)
4442
                {
4443
                    if (IsSyncPDFMode)
4444
                    {
4445
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4446
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4447

    
4448
                        if (pdfpath.IsDownloading)
4449
                        {
4450
                            pdfpath.DownloadCompleted += (ex, arg) =>
4451
                            {
4452
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4453
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4454
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4455
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4456
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4457
                            };
4458
                        }
4459
                        else
4460
                        {
4461
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4462
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4463
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4464

    
4465
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4466
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4467
                        }
4468

    
4469
                    }
4470
                    else
4471
                    {
4472
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4473

    
4474
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4475

    
4476
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4477
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4478
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4479

    
4480
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4481
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4482

    
4483
                        if (defaultBitmapImage_Compare.IsDownloading)
4484
                        {
4485
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4486
                            {
4487
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4488
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4489
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4490

    
4491
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4492
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4493
                            };
4494
                        }
4495
                    }
4496

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

    
4501
                    foreach (var item in gridSelectionRevItem)
4502
                    {
4503
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4504
                        foreach (var markupitem in markupitems)
4505
                        {
4506
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4507
                        }
4508
                    }
4509

    
4510
                    //강인구 추가
4511
                    zoomAndPanControl2.ZoomTo(new Rect
4512
                    {
4513
                        X = 0,
4514
                        Y = 0,
4515
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4516
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4517
                    });
4518

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

    
4521
                }
4522
            }
4523
        }
4524

    
4525
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4526
        {
4527
            if (MarkupMode.IsChecked)
4528
            {
4529
                IsSyncPDFMode = true;
4530

    
4531
                var uri = CurrentRev.TO_VENDOR;
4532

    
4533
                if (ViewerDataModel.Instance.PageNumber == 0)
4534
                {
4535
                    ViewerDataModel.Instance.PageNumber = 1;
4536
                }
4537

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

    
4542
                if (pdfpath.IsDownloading)
4543
                {
4544
                    pdfpath.DownloadCompleted += (ex, arg) =>
4545
                    {
4546
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4547
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4548
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4549
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4550
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4551
                    };
4552
                }
4553
                else
4554
                {
4555
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4556
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4557
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4558

    
4559
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4560
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4561
                }
4562
            }
4563
            else
4564
            {
4565
                IsSyncPDFMode = false;
4566
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4567

    
4568
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4569

    
4570
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4571
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4572
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4573

    
4574
                if (defaultBitmapImage_Compare.IsDownloading)
4575
                {
4576
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4577
                    {
4578
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4579
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4580
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4581
                    };
4582
                }
4583
                zoomAndPanControl2.ApplyTemplate();
4584
                zoomAndPanControl2.UpdateLayout();
4585
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4586
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4587
            }
4588
        }
4589

    
4590
        /// <summary>
4591
        /// Compare된 영역을 초기화
4592
        /// </summary>
4593
        private void ClearCompareRect()
4594
        {
4595
            da.From = 1;
4596
            da.To = 1;
4597
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4598
            da.AutoReverse = false;
4599
            canvas_compareBorder.Children.Clear();
4600
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4601
        }
4602

    
4603
        /// <summary>
4604
        /// 문서 Comprare 
4605
        /// </summary>
4606
        private void SetCompareRect()
4607
        {
4608
            if (CompareMode.IsChecked)
4609
            {
4610
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4611
                {
4612
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4613
                }
4614
                if (ViewerDataModel.Instance.PageNumber == 0)
4615
                {
4616
                    ViewerDataModel.Instance.PageNumber = 1;
4617
                }
4618

    
4619
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4620
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4621
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4622

    
4623
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4624
            }
4625
            else
4626
            {
4627
                ClearCompareRect();
4628
            }
4629
        }
4630

    
4631
        private void RadButton_Click(object sender, RoutedEventArgs e)
4632
        {
4633
            gridViewHistory_Busy.IsBusy = true;
4634

    
4635
            RadButton instance = sender as RadButton;
4636
            if (instance.CommandParameter != null)
4637
            {
4638
                CurrentRev = instance.CommandParameter as VPRevision;
4639
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4640

    
4641
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4642
                {
4643
                    if (ea.Error == null && ea.Result != null)
4644
                    {
4645
                        testPanel2.IsHidden = false;
4646

    
4647
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4648
                        foreach(var info in ea.Result)
4649
                        {
4650
                            if(info.UserID == App.ViewInfo.UserID)
4651
                            {
4652
                                info.userDelete = true;
4653
                                info.DisplayColor = "FFFF0000";
4654
                            }
4655
                            else
4656
                            {
4657
                                info.userDelete = false;
4658
                            }
4659
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4660
                        }
4661
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4662

    
4663
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4664

    
4665
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4666

    
4667
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4668
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4669
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4670
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4671
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4672
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4673

    
4674
                        zoomAndPanControl2.ApplyTemplate();
4675
                        zoomAndPanControl2.UpdateLayout();
4676
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4677
                        {
4678
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4679
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4680
                        }
4681

    
4682
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4683
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4684
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4685

    
4686
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4687
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4688
                        gridViewHistory_Busy.IsBusy = false;
4689
                    }
4690

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

    
4693
                    if (GetSyncMarkupInfoItemshandler != null)
4694
                    {
4695
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4696
                    }
4697

    
4698
                    ClearCompareRect();
4699
                    SetCompareRect();
4700
                };
4701

    
4702
                /// 중복 실행이 발생하여 수정함.
4703
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4704
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4705

    
4706
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4707
            }
4708
        }
4709

    
4710
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4711
        {
4712
            try
4713
            {
4714
                if (sender is RadButton)
4715
                {
4716
                    if ((sender as RadButton).Tag != null)
4717
                    {
4718
                        var url = (sender as RadButton).Tag.ToString();
4719
                        System.Diagnostics.Process.Start(url);
4720
                    }
4721
                    else
4722
                    {
4723
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4724
                    }
4725
                }
4726
            }
4727
            catch (Exception ex)
4728
            {
4729
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4730
            }
4731
        }
4732

    
4733
        public void Sync_Event(VPRevision Currnet_Rev)
4734
        {
4735
            CurrentRev = Currnet_Rev;
4736

    
4737
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4738
            {
4739
                if (ea.Error == null && ea.Result != null)
4740
                {
4741
                    testPanel2.IsHidden = false;
4742

    
4743
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4744
                    foreach(var info in ea.Result)
4745
                    {
4746
                        if(info.UserID == App.ViewInfo.UserID)
4747
                        {
4748
                            info.userDelete = true;
4749
                            info.DisplayColor = "FFFF0000";
4750
                        }
4751
                        else
4752
                        {
4753
                            info.userDelete = false;
4754
                        }
4755
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4756
                    }
4757
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4758

    
4759
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4760

    
4761
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4762

    
4763
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4764

    
4765
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4766
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4767
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4768

    
4769
                    if (defaultBitmapImage_Compare.IsDownloading)
4770
                    {
4771
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4772
                        {
4773
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4774
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4775
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4776
                        };
4777
                    }
4778

    
4779

    
4780
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4781
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4782
                    zoomAndPanControl2.ApplyTemplate();
4783
                    zoomAndPanControl2.UpdateLayout();
4784

    
4785
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4786
                    {
4787
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4788
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4789
                    }
4790
                    //}
4791

    
4792
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4793
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4794
                    gridViewHistory_Busy.IsBusy = false;
4795
                }
4796
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4797

    
4798
            };
4799
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4800
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4801
        }
4802

    
4803
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4804
        {
4805
            if (sender is Image)
4806
            {
4807
                if ((sender as Image).Tag != null)
4808
                {
4809
                    var pdfUrl = (sender as Image).Tag.ToString();
4810
                    System.Diagnostics.Process.Start(pdfUrl);
4811
                }
4812
                else
4813
                {
4814
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4815
                }
4816
            }
4817
        }
4818

    
4819
        private void Create_Symbol(object sender, RoutedEventArgs e)
4820
        {
4821
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4822

    
4823
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4824
            {
4825
                DialogMessage_Alert("Please Select Controls", "Alert");
4826
            }
4827
            else //선택된 것이 있으면
4828
            {
4829
                string MarkupData = "";
4830
                adorner_ = new AdornerFinal();
4831

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

    
4860
        }
4861
        public int symbolselectindex = 0;
4862
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4863
        {
4864
            //Save save = new Save();
4865
            try
4866
            {
4867
                string svgfilename = null;
4868
                if (symbolname != null)
4869
                {
4870
                    if (symbolpng == true || symbolsvg == true)
4871
                    {
4872
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4873
                        string guid = Commons.shortGuid();
4874

    
4875
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4876
                        //Check_Uri.UriCheck();
4877
                        fileUploader.RunCompleted += (ex, arg) =>
4878
                        {
4879
                            filename = arg.Result;
4880
                            if (symbolpng == true)
4881
                            {
4882
                                if (filename != null)
4883
                                { 
4884
                                    if (symbolselectindex == 0)
4885
                                    {
4886
                                        SymbolSave(symbolname, filename, data);
4887
                                    }
4888
                                    else
4889
                                    {
4890
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4891
                                    }
4892
                                    DataBind();
4893
                                }                                
4894
                            }
4895

    
4896
                            if (symbolsvg == true)
4897
                            {
4898
                                try
4899
                                {
4900
                                    var defaultBitmapImage = new BitmapImage();
4901
                                    defaultBitmapImage.BeginInit();
4902
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4903
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4904
                                    Check_Uri.UriCheck(filename);
4905
                                    defaultBitmapImage.UriSource = new Uri(filename);
4906
                                    defaultBitmapImage.EndInit();
4907

    
4908
                                    System.Drawing.Bitmap image;
4909

    
4910
                                    if (defaultBitmapImage.IsDownloading)
4911
                                    {
4912
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4913
                                        {
4914
                                            defaultBitmapImage.Freeze();
4915
                                            image = GetBitmap(defaultBitmapImage);
4916
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4917
                                            Process potrace = new Process
4918
                                            {
4919
                                                StartInfo = new ProcessStartInfo
4920
                                                {
4921
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4922
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4923
                                                    RedirectStandardInput = true,
4924
                                                    RedirectStandardOutput = true,
4925
                                                    RedirectStandardError = true,
4926
                                                    UseShellExecute = false,
4927
                                                    CreateNoWindow = true,
4928
                                                    WindowStyle = ProcessWindowStyle.Hidden
4929
                                                },
4930
                                            };
4931

    
4932
                                            StringBuilder svgBuilder = new StringBuilder();
4933
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4934
                                            {
4935
                                                svgBuilder.AppendLine(e2.Data);
4936
                                            };
4937

    
4938
                                            potrace.EnableRaisingEvents = true;
4939
                                            potrace.Start();
4940
                                            potrace.Exited += (sender, e) =>
4941
                                            {
4942
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4943
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4944
                                                Check_Uri.UriCheck(svgfilename);
4945
                                                if (symbolselectindex == 0)
4946
                                                {
4947
                                                    SymbolSave(symbolname, svgfilename, data);
4948
                                                }
4949
                                                else
4950
                                                {
4951
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4952
                                                }
4953

    
4954
                                                DataBind();
4955
                                            };
4956
                                            potrace.WaitForExit();
4957
                                        };
4958
                                    }
4959
                                    else
4960
                                    {
4961
                                        //GC.Collect();
4962
                                    }
4963
                                }
4964
                                catch(Exception ee)
4965
                                {
4966
                                    DialogMessage_Alert("" + ee, "Alert");
4967
                                }
4968
                            }
4969
                        };                                             
4970
                    }
4971
                }
4972
            }
4973
            catch (Exception e)
4974
            {
4975
                //DialogMessage_Alert(e + "", "Alert");
4976
            }            
4977
        }
4978

    
4979
        public void SymbolSave(string Name, string Url, string Data)
4980
        {
4981
            try
4982
            {
4983
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4984
                {
4985
                    ID = Commons.shortGuid(),
4986
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4987
                    NAME = Name,
4988
                    IMAGE_URL = Url,
4989
                    DATA = Data
4990
                };
4991

    
4992
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4993
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4994
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4995
            }
4996
            catch (Exception)
4997
            {
4998
                throw;
4999
            }
5000
        }
5001

    
5002
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5003
        {
5004
            try
5005
            {
5006
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5007
                {
5008
                    ID = Commons.shortGuid(),
5009
                    DEPARTMENT = Department,
5010
                    NAME = Name,
5011
                    IMAGE_URL = Url,
5012
                    DATA = Data
5013
                };
5014
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5015
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5016
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5017
            }
5018
            catch (Exception)
5019
            {
5020
                throw;
5021
            }
5022
        }
5023

    
5024
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5025
        {           
5026
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5027
            DataBind();
5028
        }
5029

    
5030
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5031
        {
5032
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5033
            DataBind();
5034
        }
5035
        private void DataBind()
5036
        {
5037
            try
5038
            {
5039
                Symbol_Custom Custom = new Symbol_Custom();
5040
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5041
                
5042
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5043
                foreach (var item in symbol_Private)
5044
                {
5045
                    Custom.Name = item.NAME;
5046
                    Custom.ImageUri = item.IMAGE_URL;
5047
                    Custom.ID = item.ID;
5048
                    Custom_List.Add(Custom);
5049
                    Custom = new Symbol_Custom();
5050
                }
5051
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5052
                
5053
                Custom = new Symbol_Custom();
5054
                Custom_List = new List<Symbol_Custom>();
5055

    
5056
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5057

    
5058
                List<SYMBOL_PUBLIC> symbol_Public;
5059

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

    
5095
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5096
                        _Encoder.Save(fs);
5097
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5098

    
5099
                        byte[] Img_byte = fs.ToArray();
5100

    
5101
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5102
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5103
                        Check_Uri.UriCheck(filename);
5104
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5105
                        {
5106
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5107
                        }
5108
                        else
5109
                        {
5110
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5111
                        }
5112
                        DataBind();
5113
                    }
5114
                }
5115
            }
5116
            catch(Exception ex)
5117
            {
5118
                DialogMessage_Alert("" + ex, "Alert");
5119
            }
5120
        }
5121

    
5122
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5123
        {
5124

    
5125
            Canvas _canvas = new Canvas();
5126
            _canvas.Background = Brushes.White;
5127
            _canvas.Width = adorner_.BorderSize.Width;
5128
            _canvas.Height = adorner_.BorderSize.Height;
5129
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5130

    
5131
            BitmapEncoder encoder = new PngBitmapEncoder();
5132

    
5133

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

    
5136
            DrawingVisual dv = new DrawingVisual();
5137

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

    
5141
            using (DrawingContext ctx = dv.RenderOpen())
5142
            {
5143
                VisualBrush vb = new VisualBrush(_canvas);
5144
                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)));
5145
            }
5146

    
5147
            try
5148
            {
5149
                renderBitmap.Render(dv);
5150

    
5151
                //GC.Collect();
5152
                GC.WaitForPendingFinalizers();
5153
                //GC.Collect();
5154
                // encode png data
5155
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5156
                // puch rendered bitmap into it
5157
                pngEncoder.Interlace = PngInterlaceOption.Off;
5158
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5159
                return pngEncoder;
5160

    
5161
            }
5162
            catch //(Exception ex)
5163
            {
5164
                return null;
5165
            }
5166

    
5167
        }
5168

    
5169
        public void DialogMessage_Alert(string content, string header)
5170
        {
5171
            DialogParameters parameters = new DialogParameters()
5172
            {
5173
                Owner = this.ParentOfType<MainWindow>(),
5174
                Content = new TextBlock()
5175
                { 
5176
                    MinWidth = 400,
5177
                    FontSize = 11,
5178
                    Text = content,
5179
                    TextWrapping = System.Windows.TextWrapping.Wrap
5180
                },
5181
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5182
                Header = header,
5183
                Theme = new VisualStudio2013Theme(),
5184
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5185
            };            
5186
            RadWindow.Alert(parameters);
5187
        }
5188

    
5189
#region 캡쳐 기능
5190

    
5191
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5192
        {
5193
            if (x < 0)
5194
            {
5195
                width += x;
5196
                x = 0;
5197
            }
5198
            if (y < 0)
5199
            {
5200
                height += y;
5201
                y = 0;
5202

    
5203
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5204
            }
5205
            if (x + width > zoomAndPanCanvas.ActualWidth)
5206
            {
5207
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5208
            }
5209
            if (y + height > zoomAndPanCanvas.ActualHeight)
5210
            {
5211
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5212
            }
5213

    
5214
            byte[] pixels = CopyPixels(x, y, width, height);
5215

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

    
5218
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5219
        }
5220

    
5221
        public byte[] CopyPixels(int x, int y, int width, int height)
5222
        {
5223
            byte[] pixels = new byte[width * height * 4];
5224
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5225

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

    
5229
            return pixels;
5230
        }
5231

    
5232
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5233
        {
5234
            DrawingVisual drawingVisual = new DrawingVisual();
5235
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5236

    
5237
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5238
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5239
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5240
            drawingContext.Close();
5241

    
5242
            // 비트맵으로 변환합니다.
5243
            RenderTargetBitmap target =
5244
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5245
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5246

    
5247
            target.Render(drawingVisual);
5248
            return target;
5249
        }
5250

    
5251
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5252
        {
5253
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5254
            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);
5255
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5256
            bmp.UnlockBits(data);
5257
            return bmp;
5258
        }
5259
        public string symbolname = null;
5260
        public bool symbolsvg = true;
5261
        public bool symbolpng = true;
5262

    
5263
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5264
        {
5265
            System.Drawing.Bitmap image = GetBitmap(source);
5266
            //흰색 제거
5267
            //image.MakeTransparent(System.Drawing.Color.White);
5268

    
5269
            var imageStream = new System.IO.MemoryStream();
5270
            byte[] imageBytes = null;
5271
            using (imageStream)
5272
            {
5273
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5274
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5275
                imageStream.Position = 0;
5276
                imageBytes = imageStream.ToArray();
5277
            }
5278

    
5279
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5280

    
5281
            RadWindow CheckPop = new RadWindow();
5282
            //Alert check = new Alert(Msg);
5283

    
5284
            CheckPop = new RadWindow
5285
            {
5286
                MinWidth = 400,
5287
                MinHeight = 100,
5288
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5289
                Header = "Alert",
5290
                Content = symbolPrompt,
5291
                //DialogResult = 
5292
                ResizeMode = System.Windows.ResizeMode.NoResize,
5293
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5294
                IsTopmost = true,
5295
            };
5296
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5297
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5298
            CheckPop.ShowDialog();
5299

    
5300
            /*
5301
            DialogParameters parameters = new DialogParameters()
5302
            {
5303
                Owner = Application.Current.MainWindow,
5304
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5305
                DefaultPromptResultValue = "Custom State",
5306
                Content = "Name :",
5307
                Header = "Insert Custom Symbol Name",
5308
                Theme = new VisualStudio2013Theme(),
5309
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5310
            };            
5311
            RadWindow.Prompt(parameters);
5312
            */
5313
        }
5314

    
5315
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5316
        {
5317
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5318
            KCOMDataModel.DataModel.CHECK_LIST check_;
5319
            string Result = streamToBase64.ImageToBase64(source);
5320
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5321
            string projectno = App.ViewInfo.ProjectNO;
5322
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5323

    
5324
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5325
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5326
            if (Item != null)
5327
            {
5328
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5329
            }
5330
            else
5331
            {
5332
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5333
            }
5334

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

    
5367
        }
5368

    
5369
        public void Set_Capture()
5370
        {
5371
            double x = CanvasDrawingMouseDownPoint.X;
5372
            double y = CanvasDrawingMouseDownPoint.Y;
5373
            double width = dragCaptureBorder.Width;
5374
            double height = dragCaptureBorder.Height;
5375

    
5376
            if (width > 5 || height > 5)
5377
            {
5378
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5379
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5380
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5381
            }
5382
        }
5383
#endregion
5384

    
5385
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5386
        {
5387
            multi_Undo_Data = new Multi_Undo_data();
5388

    
5389
            multi_Undo_Data.Markup = control;
5390

    
5391
            if ((control as IShapeControl) != null)
5392
            {
5393
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5394
            }
5395
            if ((control as IDashControl) != null)
5396
            {
5397
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5398
            }
5399
            if ((control as IPath) != null)
5400
            {
5401
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5402
            }
5403
            if ((control as UIElement) != null)
5404
            {
5405
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5406
            }
5407

    
5408
            return multi_Undo_Data;
5409
        }
5410

    
5411
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5412
        {
5413
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5414
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5415
            {
5416
                if (items.UserID == Select_ID)
5417
                {
5418
                    foreach (var item in items.MarkupList)
5419
                    {
5420
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5421
                        {
5422
                           await  MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5423
                                items.MarkupInfoID, Commons.shortGuid());
5424
                        }
5425
                    }
5426
                }
5427
            }
5428
        }
5429

    
5430
        /// <summary>
5431
        /// convert inkcontrol to polygoncontrol
5432
        /// </summary>
5433
        public void ConvertInkControlToPolygon()
5434
        {
5435
            if (inkBoard.Strokes.Count > 0)
5436
            {
5437
                inkBoard.Strokes.ToList().ForEach(stroke =>
5438
                {
5439
                    InkToPath ip = new InkToPath();
5440

    
5441
                    List<Point> inkPointSet = new List<Point>();
5442
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5443

    
5444
                    PolygonControl pc = new PolygonControl()
5445
                    {
5446
                        CommentAngle = 0,
5447
                        PointSet = inkPointSet,
5448
                        ControlType = ControlType.Ink
5449
                    };
5450
                    pc.StartPoint = inkPointSet[0];
5451
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5452
                    pc.LineSize = 3;
5453
                    pc.CommentID = Commons.shortGuid();
5454
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5455

    
5456
                    if (pc.PointSet.Count > 0)
5457
                    {
5458
                        CreateCommand.Instance.Execute(pc);
5459
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5460
                    }
5461
                });
5462
                inkBoard.Strokes.Clear();
5463
            }
5464
        }
5465

    
5466
        /// <summary>
5467
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5468
        /// </summary>
5469
        /// <author>ingu</author>
5470
        /// <date>2018.06.05</date>
5471
        /// <param name="getPoint"></param>
5472
        /// <returns></returns>
5473
        private bool IsGetoutpoint(Point getPoint)
5474
        {
5475
            if (getPoint == new Point())
5476
            {
5477
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5478
                currentControl = null;
5479
                return true;
5480
            }
5481

    
5482
            return false;
5483
        }
5484

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

    
5490
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5491
        {
5492
            e.Effects = DragDropEffects.Copy;
5493
        }
5494

    
5495
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5496
        {
5497
            e.Effects = DragDropEffects.None;
5498
        }
5499

    
5500
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5501
        {
5502
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5503
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5504

    
5505
            ScaleImage(pageWidth, pageHeight);
5506
        }
5507

    
5508
        /// <summary>
5509
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5510
        /// </summary>
5511
        /// <param name="pageWidth">원본 사이즈</param>
5512
        /// <param name="pageHeight">원본 사이즈</param>
5513
        /// <returns></returns>
5514
        private void ScaleImage(double pageWidth,double pageHeight)
5515
        {
5516
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5517
        }
5518

    
5519
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5520
        {
5521
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5522
        }
5523

    
5524

    
5525
        /*
5526
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5527
        {
5528
            try
5529
            {
5530
                if (e.Data.GetDataPresent(typeof(string)))
5531
                {
5532
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5533
                    string dragData = e.Data.GetData(typeof(string)) as string;
5534
                    Move_Symbol(sender, dragData);
5535
                }
5536
            }
5537
            catch (Exception ex)
5538
            {
5539
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5540
            }            
5541
        }
5542
        */
5543
    }
5544

    
5545
    public class testItem
5546
    {
5547
        public string Title { get; set; }
5548
    }
5549
}
클립보드 이미지 추가 (최대 크기: 500 MB)