프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 7f8a2ff4

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

1

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

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

    
57
            T instance = Activator.CreateInstance<T>();
58

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

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

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

    
95
        public TextBox Gui { get; private set; }
96

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

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

    
118
            Gui.Text += line + Environment.NewLine;
119
        }
120
    }
121

    
122
    /// <summary>
123
    /// MainMenu.xaml에 대한 상호 작용 논리
124
    /// </summary>
125
    public partial class MainMenu : UserControl
126
    {
127
        #region 프로퍼티
128
        public CommentUserInfo currentControl { get; set; }
129
        public ControlType controlType { get; set; }
130
        private Move move = new Move();
131
        private double[] rotateValue = { 0, 90, 180, 270 };
132
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
133
        private static readonly double DragThreshold = 5;
134
        private System.Windows.Input.Cursor cursor { get; set; }
135

    
136
        /// <summary>
137
        ///  문서의 마우스 위치
138
        /// </summary>
139
        public Point CanvasDrawingMouseDownPoint;
140

    
141
        public string filename { get; set; }
142
        private Point canvasZoomPanningMouseDownPoint;
143
        public Point getCurrentPoint;
144
        private Point canvasZoommovingMouseDownPoint;
145
        List<object> ControlList = new List<object>();
146
        private ListBox listBox = new ListBox();
147
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
148
        private bool isDraggingSelectionRect = false;
149
        DrawingAttributes inkDA = new DrawingAttributes();
150
        private VPRevision CurrentRev { get; set; }
151
        public RadRibbonButton btnConsolidate { get; set; }
152
        public RadRibbonButton btnFinalPDF { get; set; }
153
        public RadRibbonButton btnTeamConsolidate { get; set; }
154
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
155

    
156
        public string Filename_ { get; set; }
157
        public double L_Size = 0;
158
        public AdornerFinal adorner_;
159
        public Multi_Undo_data multi_Undo_Data;
160
        public string Symbol_ID = "";
161
        /// <summary>
162
        /// Set to 'true' when the left mouse-button is down.
163
        /// </summary>
164
        public bool isLeftMouseButtonDownOnWindow = false;
165

    
166
        public InkPresenter _InkBoard = null;
167
        Stroke stroke;
168
        Boolean IsDrawing = false;
169
        StylusPointCollection strokePoints;
170
        //StylusPointCollection erasePoints;
171
        RenderTargetBitmap canvasImage;
172
        Point Sync_Offset_Point;
173

    
174
        //강인구 테스트
175
        private Path _SelectionPath { get; set; }
176
        public Path SelectionPath
177
        {
178
            get
179
            {
180
                return _SelectionPath;
181
            }
182
            set
183
            {
184
                if (_SelectionPath != value)
185
                {
186
                    _SelectionPath = value;
187
                    RaisePropertyChanged("SelectionPath");
188

    
189
                }
190
            }
191
        }
192

    
193
        private System.Windows.Controls.Image _imageViewer { get; set; }
194
        public System.Windows.Controls.Image imageViewer
195
        {
196
            get
197
            {
198
                if (_imageViewer == null)
199
                {
200
                    _imageViewer = new System.Windows.Controls.Image();
201
                    return _imageViewer;
202
                }
203
                else
204
                {
205
                    return _imageViewer;
206
                }
207
            }
208
            set
209
            {
210
                if (_imageViewer != value)
211
                {
212
                    _imageViewer = value;
213
                }
214
            }
215
        }
216

    
217
        public bool IsSyncPDFMode { get; set; }
218

    
219
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
220
        public System.Windows.Controls.Image imageViewer_Compare
221
        {
222
            get
223
            {
224
                if (_imageViewer_Compare == null)
225
                {
226
                    _imageViewer_Compare = new System.Windows.Controls.Image();
227
                    return _imageViewer_Compare;
228
                }
229
                else
230
                {
231
                    return _imageViewer_Compare;
232
                }
233
            }
234
            set
235
            {
236
                if (_imageViewer_Compare != value)
237
                {
238
                    _imageViewer_Compare = value;
239
                }
240
            }
241
        }
242

    
243
        #endregion
244

    
245
        public MainMenu()
246
        {
247
            //App.splashString(ISplashMessage.MAINMENU_0);            
248
           InitializeComponent();
249

    
250
            List<testItem> testItems = new List<testItem>
251
            {
252
                new testItem{Title = "test1"},
253
                new testItem{Title = "test2"},
254
                new testItem{Title = "test3"},
255
                new testItem{Title = "test4"},
256
            };
257

    
258
            lstSymbolPrivate.ItemsSource = testItems;
259

    
260
            this.Loaded += MainMenu_Loaded;
261
        }
262

    
263
        public class TempDt
264
        {
265
            public int PageNumber { get; set; }
266
            public string CommentID { get; set; }
267
            public string ConvertData { get; set; }
268
            public int DATA_TYPE { get; set; }
269
            public string MarkupInfoID { get; set; }
270
            public int IsUpdate { get; set; }
271
        }
272

    
273
        List<TempDt> tempDtList = new List<TempDt>();
274

    
275
        private void SetCursor()
276
        {
277
            this.Cursor = cursor;
278
        }
279

    
280
        /// <summary>
281
        /// get image url
282
        /// </summary>
283
        /// <author>humkyung</author>
284
        /// <param name="sDocumentID"></param>
285
        /// <returns></returns>
286
        public string GetImageURL(string sDocumentID, int iPageNo)
287
        {
288
            string uri = string.Empty;
289

    
290
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
291
            if (userData.COMPANY != "EXT")
292
            {
293
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
294
            }
295
            else
296
            {
297
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
298
            }
299

    
300
            return uri;
301
        }
302

    
303
        /// <summary>
304
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
305
        /// </summary>
306
        /// <returns></returns>
307
        public string GetOriginalPDFURL()
308
        {
309
            string uri = string.Empty;
310
            string sDocumentID = this._DocItem.DOCUMENT_ID;
311
            string filename = string.Empty;
312
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
313
            {
314
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
315
            }
316
            else
317
            {
318
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
319
            }
320

    
321
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
322
            if (userData.COMPANY != "EXT")
323
            {
324
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
325
            }
326
            else
327
            {
328
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
329
            }
330
            uri = uri.Replace(".png", "");
331
            return uri;
332
        }
333

    
334
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
335
        {
336
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
337
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
338
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
339
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
340
            {
341
                return true;
342
            }
343

    
344
            return false;
345
        }
346

    
347
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
348
        {
349
            if (rotate.Angle == 90 || rotate.Angle == 270)
350
            {
351
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
352
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
353
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
354
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
355
                {
356
                    return true;
357
                }
358
            }
359
            else
360
            {
361
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
362
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
363
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
364
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
365
                {
366
                    return true;
367
                }
368
            }
369

    
370
            return false;
371
        }
372

    
373
        public void DeleteItem(MarkupInfoItem item)
374
        {
375
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
376
            {
377
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
378

    
379
            
380
            ViewerDataModel.Instance._markupInfoList.Remove(item);
381

    
382
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
383
            {
384
                ViewerDataModel.Instance.MarkupControls.Remove(a);
385
            });
386

    
387
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
388
            {
389
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
390
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
391
                null, Event_Type.Delete, a.CommentID, null);
392
            });
393

    
394
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
395
            {
396
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
397
                //임시파일에서도 삭제
398
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
399
            });
400

    
401
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
402

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

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

    
463
                        Button content = (sender as Button);
464
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
465

    
466
                        DeleteItem(item);
467
                    }
468
                }
469
            };
470
            RadWindow.Confirm(parameters);
471
        }
472

    
473
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
474

    
475
        private static Timer timer;
476
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
477
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
478
        {
479
            //InitializeComponent();            
480
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
481

    
482
            if (App.ParameterMode)
483
            {
484
                App.splashString(ISplashMessage.MAINMENU_1);
485
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
486
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
487
                imageViewer_Compare = new Image();
488
                ViewerDataModel.Instance.Capture_Opacity = 0;
489
                da.From = 0.8;
490
                da.To = 0;
491
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
492
                da.AutoReverse = true;
493
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
494

    
495
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
496
                {
497
                    this.SymbolPane.Visibility = Visibility.Collapsed;
498
                    this.FavoritePane.Visibility = Visibility.Collapsed;
499
                    this.drawingRotateCanvas.IsHitTestVisible = false;
500
                }
501
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
502
            }
503

    
504
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
505

    
506
        }
507

    
508
        private async Task DownloadOriginalFileAsync()
509
        {
510
            try
511
            {
512
                using (System.Net.WebClient client = new System.Net.WebClient())
513
                {
514
                    string instnaceFile = System.IO.Path.GetTempFileName().Replace(".pdf", ".tmp");
515
                    string downloadurl = GetOriginalPDFURL();
516
                    
517
                    // canceltoken을 위해서 상위에 선언
518
                    var task = client.DownloadFileTaskAsync(new Uri(downloadurl), instnaceFile);
519

    
520
                    client.DownloadProgressChanged += (snd, evt) =>
521
                    {
522
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
523

    
524
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
525
                    };
526

    
527
                    await task;
528

    
529
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
530
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
531
                    ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
532
                }
533
            }
534
            catch (Exception ex)
535
            {
536
                Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0);
537
            }
538
        }
539

    
540
        private void timercallback(Object o)
541
        {
542
            Stopwatch sw = new Stopwatch();
543
            sw.Start();
544
            TempFile.TempFileAdd();
545
            sw.Stop();
546

    
547
            Dispatcher.InvokeAsync(new Action(delegate
548
            {
549
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
550
                {
551
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
552
                }
553
            }));
554

    
555
            ////GC.Collect();
556
        }
557
        
558
        /// <summary>
559
        /// update my markuplist
560
        ///  - update existing markup data if already exist
561
        ///  - add new markup data if control is new
562
        /// </summary>
563
        public void UpdateMyMarkupList()
564
        {
565
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
566

    
567
            /// add or update markup list
568
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
569
            {
570
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
571

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

    
596
            /// delete markup list
597
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
598

    
599
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
600
                          where (markup.PageNumber == iPageNo) 
601
                          && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
602
                          select markup).ToList();
603

    
604
            foreach (var markup in deleted)
605
            {
606
                ViewerDataModel.Instance.MyMarkupList.Remove(markup);
607
            }
608
            /// up to here
609

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

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

    
630
        DispatcherTimer renderTesttimer;
631

    
632
        /// <summary>
633
        /// start page changing
634
        ///  - save controls if page is modified
635
        ///  - starting download page image
636
        /// </summary>
637
        /// <param name="sender"></param>
638
        /// <param name="e"></param>
639
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
640
        {
641
            CompareMode.IsChecked = false;
642
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
643
           
644
            #region 페이지가 벗어난 경우
645

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

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

    
658
            #endregion
659

    
660
            ViewerDataModel.Instance.PageNumber = BalancePoint;
661

    
662
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
663
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
664
            var pageUri = pageNavigator.CurrentPage.PageUri;
665
            var contentScale = zoomAndPanControl.ContentScale;
666

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

    
669
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
670
            try
671
            {
672
                System.Diagnostics.Debug.WriteLine(pageUri);
673
                ViewerDataModel.Instance.ImageViewPath = null;
674

    
675
                new System.Net.Http.HttpClient().CancelPendingRequests();
676
                 //await Task.Delay(300);
677

    
678
                ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
679
            }
680
            catch (Exception ex)
681
            {
682
                ViewerDataModel.Instance.ImageViewPath = null;
683
                string imgfailedmsg = string.Format(CommonLib.Common.GetAlertMessageString("GetImageResourceFailed", "MSG", "해당 문서의 {0} Page Convert가 정상적이지 않습니다. 관리자에게 문의해 주세요."), pageNavigator.CurrentPage.PageNumber);                
684
                DialogMessage_Alert(imgfailedmsg, "Warning");
685
                App.FileLogger.Fatal(ex);
686
            }
687
            ScaleImage(pageWidth, pageHeight);
688

    
689
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
690
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
691

    
692
            zoomAndPanCanvas.Width = pageWidth;
693
            zoomAndPanCanvas.Height = pageHeight;
694

    
695
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
696
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
697

    
698
            inkBoard.Width = pageWidth;
699
            inkBoard.Height = pageHeight;
700

    
701
            #endregion
702

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

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

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

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

    
751
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
752

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

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

    
775
                            zoomAndPanControl.ZoomTo(new Rect
776
                            {
777
                                X = 0,
778
                                Y = 0,
779
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
780
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
781
                            });
782

    
783
                            //defaultBitmapImage_Compare dispose
784
                            defaultBitmapImage_Compare = null;
785
                            GC.Collect();
786
                        };
787
                    }
788
                }
789
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
790
            }
791

    
792
            SearchFocusBorder.Visibility = Visibility.Collapsed;
793

    
794
            this.pageNavigator.ChangePage(e.PageNumber);
795
        }
796

    
797
        /// <summary>
798
        /// called after page is changed
799
        /// </summary>
800
        /// <param name="sender"></param>
801
        /// <param name="e"></param>
802
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
803
        {
804
            //if (zoomAndPanCanvas.Width.IsNaN())
805
            //{
806
            
807
            await zoomAndPanControl.Dispatcher.InvokeAsync(()=>
808
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
809
                );
810
            //}
811

    
812
            /// 컨트롤을 새로 생성한다.
813
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
814
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
815
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == ViewerDataModel.Instance.PageNumber))
816
            { 
817
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
818
                if (info != null)
819
                {
820
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
821
                    if (info.UserID == App.ViewInfo.UserID)
822
                    {
823
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
824
                                        markup.MarkupInfoID, markup.ID);
825
                        control.Visibility = Visibility.Hidden;
826
                    }
827
                    else
828
                    {
829
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
830
                                                                markup.MarkupInfoID, markup.ID);
831
                        control.Visibility = Visibility.Hidden;
832
                    }
833
                }
834
            };
835
            /// up to here
836

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

    
842
            if (!testPanel2.IsHidden)
843
            {
844
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
845
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
846
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
847

    
848
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
849
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
850

    
851

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

    
861
            var instanceMain = this.ParentOfType<MainWindow>();
862
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
863
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
864

    
865
            instanceMain.dzTopMenu.rotateOffSet = 0;
866
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
867
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
868
            
869
            SetCommentPages();
870

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

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

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

    
929
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
930
        {
931
            var instance = ViewerDataModel.Instance;
932

    
933
            if(instance.IsWheelPageChanage)
934
            {
935
                return;
936
            }
937

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

    
976
                //if (changePage != 0)
977
                //{
978
                //    await Task.Factory.StartNew(() =>
979
                //    {
980
                //        double beforeScale = instance.ContentScale;
981

    
982
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
983

    
984
                //        handler = (snd, evt) =>
985
                //        {
986
                //            /// 최상단으로 이전 zoomScale로 위치한다
987
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
988
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
989
                //            instance.IsWheelPageChanage = false;
990
                //            pageNavigator.PageChanged -= handler;
991
                //        };
992

    
993
                //        pageNavigator.PageChanged += handler;
994

    
995
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
996
                //    });
997
                    
998

    
999
                //}
1000
            }
1001
            else
1002
            {
1003
                e.Handled = true;
1004
                if (e.Delta > 0)
1005
                {
1006
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1007
                    ZoomIn(currentContentMousePoint);
1008
                }
1009
                else
1010
                {
1011
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1012
                    ZoomOut(currentContentMousePoint);
1013
                }
1014
            }
1015
        }
1016

    
1017
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1018
        {
1019
            e.Handled = true;
1020
            if (e.Delta > 0)
1021
            {
1022
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1023
                ZoomIn_Sync(currentContentMousePoint);
1024
            }
1025
            else
1026
            {
1027
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1028
                ZoomOut_Sync(currentContentMousePoint);
1029
            }
1030
        }
1031

    
1032
        #region ZoomIn & ZoomOut
1033

    
1034
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1035
        {
1036
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1037
                zoomAndPanControl.ContentZoomFocusY));
1038
        }
1039

    
1040
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1041
        {
1042
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1043
                zoomAndPanControl.ContentZoomFocusY));
1044
        }
1045

    
1046

    
1047
        //강인구 추가 (줌 인아웃 수치 변경)
1048
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1049
        private void ZoomOut(Point contentZoomCenter)
1050
        {
1051
            if (zoomAndPanControl.ContentScale > 0.39)
1052
            {
1053
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1054
            }
1055
            else
1056
            {
1057
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1058
            }
1059

    
1060
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1061
            {
1062
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1063
            }
1064
        }
1065

    
1066
        private void ZoomIn(Point contentZoomCenter)
1067
        {
1068
            if (zoomAndPanControl.ContentScale > 0.19)
1069
            {
1070
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1071
            }
1072
            else
1073
            {
1074
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1075
            }
1076

    
1077
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1078
            {
1079
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1080
            }
1081

    
1082
        }
1083

    
1084
        private void ZoomOut_Sync(Point contentZoomCenter)
1085
        {
1086
            if (zoomAndPanControl2.ContentScale > 0.39)
1087
            {
1088
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1089
            }
1090
            else
1091
            {
1092
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1093
            }
1094

    
1095
            if (Sync.IsChecked)
1096
            {
1097
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1098
            }
1099
        }
1100

    
1101
        private void ZoomIn_Sync(Point contentZoomCenter)
1102
        {
1103
            if (zoomAndPanControl2.ContentScale > 0.19)
1104
            {
1105
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1106
            }
1107
            else
1108
            {
1109
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1110
            }
1111

    
1112
            if (Sync.IsChecked)
1113
            {
1114
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1115
            }
1116
        }
1117

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

    
1127
        private void ZoomIn()
1128
        {
1129
            zoomAndPanControl.ContentScale += 0.1;
1130
            //if (zoomAndPanControl2 != null)
1131
            //{
1132
            //    zoomAndPanControl2.ContentScale += 0.1;
1133
            //}
1134
        }
1135

    
1136
        #endregion
1137

    
1138
        private void init()
1139
        {
1140
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1141
            {
1142

    
1143
                ControlList.Clear();
1144
                listBox.Items.Clear();
1145
                selected_item.Clear();
1146

    
1147
                (item as IMarkupCommonData).IsSelected = false;
1148
            }
1149

    
1150
        }
1151

    
1152
        private HitTestResultBehavior MyCallback(HitTestResult result)
1153
        {
1154
            //this.cursor = Cursors.UpArrow;
1155
            var element = result.VisualHit;
1156
            while (element != null && !(element is CommentUserInfo))
1157
                element = VisualTreeHelper.GetParent(element);
1158

    
1159
            if (element == null)
1160
            {
1161
                return HitTestResultBehavior.Stop;
1162
            }
1163
            else
1164
            {
1165
                if (element is CommentUserInfo)
1166
                {
1167
                    if (!hitList.Contains(element))
1168
                    {
1169
                        hitList.Add((CommentUserInfo)element);
1170
                    }
1171
                    else
1172
                    {
1173
                        return HitTestResultBehavior.Stop;
1174
                    }
1175
                }
1176
            }
1177
            return HitTestResultBehavior.Continue;
1178
        }
1179

    
1180
        public void ReleaseSelectPath()
1181
        {
1182
            if (SelectionPath == null)
1183
            {
1184
                SelectionPath = new Path();
1185
                SelectionPath.Name = "";
1186
            }
1187
            if (SelectionPath.Name != "")
1188
            {
1189
                SelectionPath.Name = "None";
1190
            }
1191
            SelectionPath.Opacity = 0.01;
1192
            SelectionPath.RenderTransform = null;
1193
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1194
        }
1195

    
1196
        #region 컨트롤 초기화 
1197
        public void Control_Init(object control)
1198
        {
1199
            if (L_Size != 0 && (control as IPath) != null)
1200
            {
1201
                (control as IPath).LineSize = L_Size;
1202
                L_Size = 0;
1203
            }
1204

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

    
1291
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1292
        {
1293
            //Control_Init(e.Source);
1294
        }
1295
        //private Window _dragdropWindow = null;
1296

    
1297
        [DllImport("user32.dll")]
1298
        [return: MarshalAs(UnmanagedType.Bool)]
1299
        internal static extern bool GetCursorPos(ref Win32Point pt);
1300

    
1301
        [StructLayout(LayoutKind.Sequential)]
1302
        internal struct Win32Point
1303
        {
1304
            public Int32 X;
1305
            public Int32 Y;
1306
        };
1307
        /*
1308
       public string symbol_id = null;
1309
       public long symbol_group_id;
1310
       public int symbol_SelectedIndex;
1311
       public ImageSource symbol_img;
1312
       public string symbol_Data = null;
1313
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1314
       {
1315
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1316
               zoomAndPanCanvas.ActualHeight / 2));
1317

    
1318

    
1319
               if (this._dragdropWindow != null)
1320
               {
1321
                   this._dragdropWindow.Close();
1322
                   this._dragdropWindow = null;
1323
               }
1324

    
1325
               symbol_id = id;
1326
               symbol_group_id = group_id;
1327
               symbol_SelectedIndex = SelectedIndex;
1328
               symbol_Data = Data_;
1329
               symbol_img = img;
1330

    
1331

    
1332
               CreateDragDropWindow2(img);
1333
              
1334
    }
1335

    
1336
    private void CreateDragDropWindow2(ImageSource image)
1337
        {
1338
            this._dragdropWindow = new Window();
1339
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1340
            _dragdropWindow.WindowStyle = WindowStyle.None;
1341
            _dragdropWindow.AllowsTransparency = true;           
1342
            _dragdropWindow.AllowDrop = false;
1343
            _dragdropWindow.Background = null;
1344
            _dragdropWindow.IsHitTestVisible = false;
1345
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1346
            _dragdropWindow.Topmost = true;
1347
            _dragdropWindow.ShowInTaskbar = false;
1348
            
1349
            Rectangle r = new Rectangle();
1350
            r.Width = image.Width;
1351
            r.Height = image.Height;
1352
            r.Opacity = 0.5;            
1353
            r.Fill = new ImageBrush(image);
1354
            this._dragdropWindow.Content = r;
1355

    
1356
            Win32Point w32Mouse = new Win32Point();
1357
            GetCursorPos(ref w32Mouse);
1358

    
1359
            //w32Mouse.X = getCurrentPoint.X;
1360
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1361
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1362
            this._dragdropWindow.Show();
1363
        }
1364

    
1365
        
1366

    
1367
         */
1368

    
1369
        public void MoveZoomAndPanControl(Vector dragOffset)
1370
        {
1371
   
1372
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1373
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1374

    
1375
            if (Sync.IsChecked)
1376
            {
1377
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1378
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1379
            }
1380
        }
1381

    
1382
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1383
        {
1384
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1385
            {
1386
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1387

    
1388
                Point currentPos = e.GetPosition(rect);
1389

    
1390
                floatingTip.HorizontalOffset = currentPos.X + 20;
1391
                floatingTip.VerticalOffset = currentPos.Y;
1392
            }
1393

    
1394
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1395
            
1396
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1397
            {
1398
                SetCursor();
1399
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1400
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1401

    
1402
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1403

    
1404
                MoveZoomAndPanControl(dragOffset);
1405
            }
1406

    
1407
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1408
            {
1409
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1410
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1411
                SetCursor();
1412

    
1413
                if (currentControl != null)
1414
                {
1415
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1416
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1417
                    //강인구 추가
1418
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1419

    
1420
                    if ((currentControl as IPath) != null)
1421
                    {
1422
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1423
                    }
1424
                    if ((currentControl as LineControl) != null)
1425
                    {
1426
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1427
                    }
1428

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

    
1472

    
1473
                    #region // 모든 컨트롤의 공통기능 제어
1474
                    if (controlType != ControlType.PenControl)
1475
                    {
1476
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1477
                    }
1478

    
1479

    
1480
                    #endregion
1481

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

    
1484
                    switch (controlType)
1485
                    {
1486
                        case (ControlType.Coordinate):
1487
                            {
1488
                                var control = currentControl as CoordinateControl;
1489
                                if (control != null)
1490
                                {
1491
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1492
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1493
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1494
                                }
1495
                            }
1496
                            break;
1497
                        case (ControlType.InsideWhite):
1498
                            {
1499
                                var control = currentControl as InsideWhiteControl;
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
                                    control.Paint = PaintSet.Fill;
1506
                                }
1507
                            }
1508
                            break;
1509
                        case ControlType.OverlapWhite:
1510
                            {
1511
                                var control = currentControl as OverlapWhiteControl;
1512
                                if (control != null)
1513
                                {
1514
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1515
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1516
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1517
                                    control.Paint = PaintSet.Fill;
1518
                                }
1519
                            }
1520
                            break;
1521
                        case ControlType.ClipWhite:
1522
                            {
1523
                                var control = currentControl as ClipWhiteControl;
1524
                                if (control != null)
1525
                                {
1526
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1527
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1528
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1529
                                    control.Paint = PaintSet.Fill;
1530
                                }
1531
                            }
1532
                            break;
1533
                        case ControlType.RectCloud:
1534
                            {
1535
                                var control = currentControl as RectCloudControl;
1536
                                if (control != null)
1537
                                {
1538
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1539
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1540
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1541
                                }
1542
                            }
1543
                            break;
1544
                        case ControlType.SingleLine:
1545
                        case ControlType.CancelLine:
1546
                        case ControlType.ArrowLine:
1547
                        case ControlType.TwinLine:
1548
                        case ControlType.DimLine:
1549
                            {
1550
                                var control = currentControl as LineControl;
1551
                                if (control != null)
1552
                                {
1553
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1554
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1555
                                }
1556

    
1557
                            }
1558
                            break;
1559

    
1560
                        case ControlType.ArcLine:
1561
                            {
1562
                                var control = currentControl as ArcControl;
1563
                                if (control != null)
1564
                                {
1565
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1566
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1567
                                }
1568
                            }
1569
                            break;
1570

    
1571
                        case ControlType.ArcArrow:
1572
                            {
1573
                                var control = currentControl as ArrowArcControl;
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.ArrowMultiLine:
1583
                            {
1584
                                var control = currentControl as ArrowControl_Multi;
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.Circle:
1594
                            {
1595
                                var control = currentControl as CircleControl;
1596

    
1597
                                if (control != null)
1598
                                {
1599
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1600
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1601
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1602
                                }
1603
                            }
1604
                            break;
1605

    
1606
                        case ControlType.PolygonCloud:
1607
                            {
1608
                                var control = currentControl as CloudControl;
1609
                                if (control != null)
1610
                                {
1611
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1612
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1613
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1614
                                }
1615
                            }
1616
                            break;
1617

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

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

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

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

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

    
1765
                                //inkBoard.Strokes.Add(stroke);
1766
                            }
1767
                            break;
1768
                    }
1769
                    return;
1770
                }
1771
            }
1772
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1773
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1774
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1775
            {
1776
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1777

    
1778
                if (isDraggingSelectionRect)
1779
                {
1780
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1781
                    e.Handled = true;
1782
                }
1783
                else if (isLeftMouseButtonDownOnWindow)
1784
                {
1785
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
1786
                    double dragDistance = Math.Abs(dragDelta.Length);
1787

    
1788
                    if (dragDistance > DragThreshold)
1789
                    {
1790
                        isDraggingSelectionRect = true;
1791
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
1792
                    }
1793

    
1794
                    e.Handled = true;
1795
                }
1796

    
1797
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
1798
                {
1799
                }
1800
                else
1801
                {
1802
                    e.Handled = true;
1803
                }
1804
            }
1805
            /*
1806
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1807
            { //symbol      
1808
                if(_dragdropWindow != null)
1809
                {
1810
                    Win32Point w32Mouse = new Win32Point();
1811
                    GetCursorPos(ref w32Mouse);
1812

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

    
1838
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1839
        {
1840
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1841
            {
1842
                SetCursor();
1843
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1844
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1845

    
1846
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1847

    
1848
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1849
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1850

    
1851
                if (Sync.IsChecked)
1852
                {
1853
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1854
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1855
                }
1856
            }
1857
        }
1858

    
1859
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1860

    
1861
        private EllipseGeometry hitArea = new EllipseGeometry();
1862

    
1863
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1864
        {
1865
            IsDrawing = false;
1866
    
1867
            if (mouseHandlingMode != MouseHandlingMode.None)
1868
            {
1869
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1870
                {
1871
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1872

    
1873
                    SetCursor();
1874

    
1875
                    switch (controlType)
1876
                    {
1877
                        case ControlType.None:
1878
                            break;
1879
                        case ControlType.Rectangle:
1880
                            {
1881

    
1882
                            }
1883
                            break;
1884
                        case ControlType.PenControl:
1885
                            {
1886

    
1887
                            }
1888
                            break;
1889
                        default:
1890
                            break;
1891
                    }                    
1892
                }
1893
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1894
                {
1895
                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
1896

    
1897
                    if (isLeftMouseButtonDownOnWindow)
1898
                    {
1899
                        bool wasDragSelectionApplied = false;
1900

    
1901
                        if (isDraggingSelectionRect)
1902
                        {
1903
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1904
                            {
1905
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1906
                                mouseHandlingMode = MouseHandlingMode.None;
1907
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1908
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1909
                                Set_Symbol_Capture(endPoint);
1910
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1911
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1912
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1913
                            }
1914
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1915
                            {
1916
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1917
                                mouseHandlingMode = MouseHandlingMode.None;
1918
                                Set_Capture();
1919

    
1920
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1921
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1922
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1923
                            }
1924
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1925
                            {
1926
                                ApplyDragSelectionRect();
1927
                            }
1928
                            else
1929
                            {
1930
                                double x = Canvas.GetLeft(dragZoomBorder);
1931
                                double y = Canvas.GetTop(dragZoomBorder);
1932
                                double width = dragZoomBorder.Width;
1933
                                double height = dragZoomBorder.Height;
1934
                                Rect dragRect = new Rect(x, y, width, height);
1935

    
1936
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1937

    
1938
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1939
                            }
1940

    
1941
                            isDraggingSelectionRect = false;
1942
                            e.Handled = true;
1943
                            wasDragSelectionApplied = true;
1944
                        }
1945

    
1946
                        if (isLeftMouseButtonDownOnWindow)
1947
                        {
1948
                            isLeftMouseButtonDownOnWindow = false;
1949
                            this.ReleaseMouseCapture();
1950
                            e.Handled = true;
1951
                        }
1952

    
1953
                        if (!wasDragSelectionApplied)
1954
                        {
1955
                            init();
1956
                        }
1957
                    }
1958
                }
1959
                else if (e.RightButton == MouseButtonState.Pressed)
1960
                {
1961
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1962
                    SetCursor();
1963
                }
1964

    
1965
                zoomAndPanControl.ReleaseMouseCapture();
1966

    
1967

    
1968
                e.Handled = true;
1969
            }
1970
            else
1971
            {
1972
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1973
                SetCursor();
1974
            }
1975

    
1976
            ///mouseButtonDown = MouseButton.Left;
1977
            //controlType = ControlType.SingleLine;
1978
        }
1979

    
1980
        public void Set_Symbol_Capture(Point endPoint)
1981
        {       
1982
            double x = CanvasDrawingMouseDownPoint.X;
1983
            double y = CanvasDrawingMouseDownPoint.Y;
1984
            if(x > endPoint.X)
1985
            {
1986
                x = endPoint.X;
1987
                y = endPoint.Y;
1988
            }
1989

    
1990
            double width = dragCaptureBorder.Width;
1991
            double height = dragCaptureBorder.Height;
1992

    
1993
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1994

    
1995
            if (x < 0)
1996
            {
1997
                width += x;
1998
                x = 0;
1999
            }
2000
            if (y < 0)
2001
            {
2002
                height += y;
2003
                y = 0;
2004

    
2005
                width = (int)canvasImage.PixelWidth - x;
2006
            }
2007
            if (x + width > canvasImage.PixelWidth)
2008
            {
2009
                width = (int)canvasImage.PixelWidth - x;
2010
            }
2011
            if (y + height > canvasImage.PixelHeight)
2012
            {
2013
                height = (int)canvasImage.PixelHeight - y;
2014
            }
2015
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2016

    
2017
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2018
            var defaultBitmapImage = new BitmapImage();
2019
            defaultBitmapImage.BeginInit();
2020
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2021
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2022
            defaultBitmapImage.UriSource = new Uri(uri);
2023
            defaultBitmapImage.EndInit();
2024

    
2025
            //GC.Collect();
2026

    
2027
            if (defaultBitmapImage.IsDownloading)
2028
            {
2029
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2030
                {
2031
                    defaultBitmapImage.Freeze();
2032
                    //GC.Collect();
2033
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2034
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2035
                };
2036
            }
2037
        }
2038

    
2039
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2040
        {
2041
            ///mouseButtonDown = MouseButton.Left;
2042
        }
2043

    
2044
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2045
        {
2046
            ///mouseButtonDown = MouseButton.Left;
2047
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2048
        }
2049

    
2050
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2051
        {
2052

    
2053
        }
2054

    
2055
        /// <summary>
2056
        /// select items by dragging
2057
        /// </summary>
2058
        private void ApplyDragSelectionRect()
2059
        {
2060
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2061

    
2062
            double x = Canvas.GetLeft(dragSelectionBorder);
2063
            double y = Canvas.GetTop(dragSelectionBorder);
2064
            double width = dragSelectionBorder.Width;
2065
            double height = dragSelectionBorder.Height;
2066
            Boolean Flag = false;
2067
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2068
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2069

    
2070
            Rect dragRect = new Rect(x, y, width, height);
2071
            ///dragRect.Inflate(width / 10, height / 10);
2072

    
2073
            foreach (var item in Items)
2074
            {
2075
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2076

    
2077
                if (Flag)
2078
                {
2079
                    adornerSet.Add(item);
2080
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2081
                    Control_Style(item);
2082
                }
2083
            }
2084
            if (adornerSet.Count > 0)
2085
            {
2086
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2087
                SelectLayer.Children.Add(final);
2088
            }
2089
        }
2090

    
2091
        private void InitDragSelectionRect(Point pt1, Point pt2)
2092
        {
2093
            //캡쳐 중
2094
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2095
            {
2096
                dragCaptureBorder.Visibility = Visibility.Visible;
2097
            }
2098
            //선택 중
2099
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2100
            {
2101

    
2102
                dragSelectionBorder.Visibility = Visibility.Visible;
2103
            }
2104
            else
2105
            {
2106
                dragZoomBorder.Visibility = Visibility.Visible;
2107
            }
2108
            UpdateDragSelectionRect(pt1, pt2);
2109
        }
2110

    
2111
        /// <summary>
2112
        /// Update the position and size of the rectangle used for drag selection.
2113
        /// </summary>
2114
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2115
        {
2116
            double x, y, width, height;
2117

    
2118
            //
2119
            // Determine x,y,width and height of the rect inverting the points if necessary.
2120
            // 
2121

    
2122
            if (pt2.X < pt1.X)
2123
            {
2124
                x = pt2.X;
2125
                width = pt1.X - pt2.X;
2126
            }
2127
            else
2128
            {
2129
                x = pt1.X;
2130
                width = pt2.X - pt1.X;
2131
            }
2132

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

    
2144
            //
2145
            // Update the coordinates of the rectangle used for drag selection.
2146
            //
2147
            //캡쳐 중
2148
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2149
            {
2150
                Canvas.SetLeft(dragCaptureBorder, x);
2151
                Canvas.SetTop(dragCaptureBorder, y);
2152
                dragCaptureBorder.Width = width;
2153
                dragCaptureBorder.Height = height;
2154
            }
2155
            //선택 중
2156
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2157
            {
2158
                Canvas.SetLeft(dragSelectionBorder, x);
2159
                Canvas.SetTop(dragSelectionBorder, y);
2160
                dragSelectionBorder.Width = width;
2161
                dragSelectionBorder.Height = height;
2162
            }
2163
            else
2164
            {
2165
                Canvas.SetLeft(dragZoomBorder, x);
2166
                Canvas.SetTop(dragZoomBorder, y);
2167
                dragZoomBorder.Width = width;
2168
                dragZoomBorder.Height = height;
2169
            }
2170
        }
2171

    
2172
        private void drawingPannelRotate(double angle)
2173
        {
2174
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2175
            rotate.Angle = angle;
2176
            var rotationNum = Math.Abs((rotate.Angle / 90));
2177

    
2178
            if (angle == 90 || angle == 270)
2179
            {
2180
                double emptySize = zoomAndPanCanvas.Width;
2181
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2182
                zoomAndPanCanvas.Height = emptySize;
2183
            }
2184
            if (angle == 0)
2185
            {
2186
                translate.X = 0;
2187
                translate.Y = 0;
2188
            }
2189
            else if (angle == 90)
2190
            {
2191
                translate.X = zoomAndPanCanvas.Width;
2192
                translate.Y = 0;
2193
            }
2194
            else if (angle == 180)
2195
            {
2196
                translate.X = zoomAndPanCanvas.Width;
2197
                translate.Y = zoomAndPanCanvas.Height;
2198
            }
2199
            else
2200
            {
2201
                translate.X = 0;
2202
                translate.Y = zoomAndPanCanvas.Height;
2203
            }
2204

    
2205
            zoomAndPanControl.RotationAngle = rotate.Angle;
2206

    
2207

    
2208
            if (!testPanel2.IsHidden)
2209
            {
2210
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2211
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2212
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2213
            }
2214

    
2215
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2216
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2217
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2218
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2219
            ViewerDataModel.Instance.Angle = rotate.Angle;
2220
        }
2221

    
2222
        private void syncPannelRotate(double angle)
2223
        {
2224
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2225
            rotate.Angle = angle;
2226
            var rotationNum = Math.Abs((rotate.Angle / 90));
2227

    
2228
            if (angle == 90 || angle == 270)
2229
            {
2230
                double emptySize = zoomAndPanCanvas2.Width;
2231
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2232
                zoomAndPanCanvas2.Height = emptySize;
2233
            }
2234
            if (angle == 0)
2235
            {
2236
                translate2.X = 0;
2237
                translate2.Y = 0;
2238
            }
2239
            else if (angle == 90)
2240
            {
2241
                translate2.X = zoomAndPanCanvas2.Width;
2242
                translate2.Y = 0;
2243
            }
2244
            else if (angle == 180)
2245
            {
2246
                translate2.X = zoomAndPanCanvas2.Width;
2247
                translate2.Y = zoomAndPanCanvas2.Height;
2248
            }
2249
            else
2250
            {
2251
                translate2.X = 0;
2252
                translate2.Y = zoomAndPanCanvas2.Height;
2253
            }
2254

    
2255
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2256
        }
2257

    
2258
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2259
        {
2260
            string Data_ = "";
2261

    
2262
            try
2263
            {
2264
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2265
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2266
                if (Data_ != null || Data_ != "")
2267
                {
2268
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2269
                }
2270
                else
2271
                {
2272
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2273
                }
2274

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

    
2301
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2302
                    {
2303
                        PointSet = new List<Point>(),
2304
                        FilePath = Data_,
2305
                        ImageData = img.Source,
2306
                        StartPoint = canvasZoomPanningMouseDownPoint,
2307
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2308
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2309
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2310
                        canvasZoomPanningMouseDownPoint.Y),
2311
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2312
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2313
                    };
2314

    
2315
                    currentControl.PointSet = new List<Point>
2316
                                        {
2317
                                            currentControl.StartPoint,
2318
                                            currentControl.LeftBottomPoint,
2319
                                            currentControl.EndPoint,
2320
                                            currentControl.TopRightPoint,
2321
                                        };
2322
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2323
                    UndoData = new Undo_data()
2324
                    {
2325
                        IsUndo = false,
2326
                        Event = Event_Type.Create,
2327
                        EventTime = DateTime.Now,
2328
                        Markup_List = new List<Multi_Undo_data>()
2329
                    };
2330
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2331
                    {
2332
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2333
                    });
2334

    
2335
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2336
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2337
                    UndoData.Markup_List.Add(multi_Undo_Data);
2338
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2339

    
2340
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2341
                    currentControl.CommentID = Commons.shortGuid();
2342
                    currentControl.SymbolID = id;
2343
                    currentControl.GroupID = group_id;
2344
                    currentControl.ApplyTemplate();
2345
                    currentControl.SetImage();
2346

    
2347
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2348
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2349
                    SelectLayer.Children.Add(final);
2350
                }
2351
            }
2352
            catch (Exception ex)
2353
            {
2354
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2355
            }
2356
        }
2357

    
2358
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2359
        {
2360
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2361
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2362
            {
2363
                set_option.Value = double.Parse(set_option.ContentText);
2364
                //set_option.Focusable = false;
2365
                zoomAndPanControl.Focus();
2366
            }
2367

    
2368
            ConvertInkControlToPolygon();
2369

    
2370
            ///TODO:
2371
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2372
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2373

    
2374
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2375
            {
2376
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2377
            }
2378
            /// up to here
2379

    
2380
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2381
            {
2382
                if (item as ArrowTextControl != null)
2383
                {
2384
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2385
                }
2386
                else if (item as TextControl != null)
2387
                {
2388
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2389
                }
2390
            }
2391

    
2392
            //if (currentControl != null)
2393
            {
2394
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2395
                if (text_item_ != null)
2396
                {
2397
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2398
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2399
                    (text_item_ as TextControl).IsEditingMode = false;                    
2400
                    currentControl = null;
2401
                }
2402

    
2403
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2404
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2405
                {
2406
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2407
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2408
                    currentControl = null;
2409
                }
2410
            }
2411

    
2412
            double Ang = 0;                                          
2413
            if (rotate.Angle != 0)
2414
            {
2415
                Ang = 360 - rotate.Angle;
2416
            }
2417

    
2418
            if (e.OriginalSource is System.Windows.Controls.Image)
2419
            {
2420
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2421
            }
2422
            /*
2423
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2424
            {                
2425
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2426
                if(symbol_id != null)
2427
                {
2428
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2429
                }                
2430
            }
2431

    
2432
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2433
            {
2434
                if (this._dragdropWindow != null)
2435
                {
2436
                    this._dragdropWindow.Close();
2437
                    this._dragdropWindow = null;
2438
                    symbol_id = null;
2439
                }
2440
            }
2441
            */
2442

    
2443
            if (e.LeftButton == MouseButtonState.Pressed)
2444
            {
2445
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2446
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2447

    
2448
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2449
                SetCursor();
2450

    
2451
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2452
            }
2453

    
2454
            if (e.MiddleButton == MouseButtonState.Pressed)
2455
            {
2456
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2457
                cursor = Cursors.SizeAll;
2458
                SetCursor();
2459
            }
2460
            if (e.RightButton == MouseButtonState.Pressed)
2461
            {
2462
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2463
                cursor = Cursors.SizeAll;
2464
                SetCursor();
2465
            }
2466
            else if (e.XButton1 == MouseButtonState.Pressed)
2467
            {
2468
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2469
                {
2470
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2471
                }
2472

    
2473
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2474

    
2475
            }
2476
            else if (e.XButton2 == MouseButtonState.Pressed)
2477
            {
2478
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2479
                {
2480
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2481
                }
2482
            }
2483

    
2484
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2485
            {
2486
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2487
                {
2488
                    if (SelectLayer.Children.Count == 0)
2489
                    {
2490
                        isLeftMouseButtonDownOnWindow = true;
2491
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2492
                    }
2493

    
2494
                    if (controlType == ControlType.None)
2495
                    {
2496
                        isLeftMouseButtonDownOnWindow = true;
2497
                    }
2498
                }
2499

    
2500
                /// 캡쳐 모드 설정
2501
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2502
                {
2503
                    dragCaptureBorder.Visibility = Visibility.Visible;
2504
                    isLeftMouseButtonDownOnWindow = true;
2505
                }
2506

    
2507
                /// 줌 모드 설정
2508
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2509
                {
2510
                    isLeftMouseButtonDownOnWindow = true;
2511
                }
2512

    
2513
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2514
                if (control != null)
2515
                {
2516
                    AdornerFinal final = null;
2517

    
2518
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2519
                    {
2520
                        /// 기존 selection 해제
2521
                        SelectionSet.Instance.UnSelect(this);
2522

    
2523
                        final = new AdornerFinal(control);
2524

    
2525
                        this.Control_Style(control);
2526

    
2527
                        if ((control as IPath) != null)
2528
                        {
2529
                            if ((control as IPath).LineSize != 0)
2530
                            {
2531
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2532
                            }
2533
                        }
2534
                        if ((control as IShapeControl) != null)
2535
                        {
2536
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2537
                            {
2538
                                ViewerDataModel.Instance.checkHatchShape = true;
2539
                            }
2540
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2541
                            {
2542
                                ViewerDataModel.Instance.checkFillShape = true;
2543
                            }
2544
                            else
2545
                            {
2546
                                ViewerDataModel.Instance.checkHatchShape = false;
2547
                                ViewerDataModel.Instance.checkFillShape = false;
2548
                            }
2549
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2550
                        }
2551

    
2552
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2553

    
2554
                        if ((control as TextControl) != null)
2555
                        {
2556
                            if(!((control as TextControl).EnableEditing)) {
2557
                                (control as TextControl).EnableEditing = true;
2558
                            }
2559
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2560
                            {
2561
                                ViewerDataModel.Instance.checkTextStyle = true;
2562
                            }
2563
                            else
2564
                            {
2565
                                ViewerDataModel.Instance.checkTextStyle = false;
2566
                            }
2567
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2568
                            {
2569
                                ViewerDataModel.Instance.checkTextWeight = true;
2570
                            }
2571
                            else
2572
                            {
2573
                                ViewerDataModel.Instance.checkTextWeight = false;
2574
                            }
2575
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2576
                            {
2577
                                ViewerDataModel.Instance.checkUnderLine = true;
2578
                            }
2579
                            else
2580
                            {
2581
                                ViewerDataModel.Instance.checkUnderLine = false;
2582
                            }
2583
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2584
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2585

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

    
2635
                        Control_Style(control);
2636

    
2637
                        final = new AdornerFinal(comment);
2638
                    }
2639

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

    
2683
                switch (controlType)
2684
                {
2685
                    case ControlType.Coordinate:
2686
                        {
2687
                            if (e.LeftButton == MouseButtonState.Pressed)
2688
                            {
2689
                                if (currentControl is CoordinateControl)
2690
                                {
2691
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2692
                                    {
2693
                                        return;
2694
                                    }
2695

    
2696
                                    CreateCommand.Instance.Execute(currentControl);
2697

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

    
2721
                                        currentControl.CommentID = Commons.shortGuid();
2722
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2723
                                        currentControl.IsNew = true;
2724

    
2725
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2726

    
2727
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2728
                                    }
2729
                                }
2730
                            }
2731
                        }
2732
                        break;
2733
                    case ControlType.InsideWhite:
2734
                        {
2735
                            if (e.LeftButton == MouseButtonState.Pressed)
2736
                            {
2737
                                if (currentControl is InsideWhiteControl)
2738
                                {
2739
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2740
                                    {
2741
                                        return;
2742
                                    }
2743

    
2744
                                    CreateCommand.Instance.Execute(currentControl);
2745

    
2746
                                    currentControl = null;
2747
                                    this.cursor = Cursors.Arrow;
2748
                                }
2749
                                else
2750
                                {
2751
                                    currentControl = new InsideWhiteControl
2752
                                    {
2753
                                        Background = new SolidColorBrush(Colors.Black),
2754
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2755
                                        ControlType = ControlType.InsideWhite
2756
                                    };
2757

    
2758
                                    currentControl.CommentID = Commons.shortGuid();
2759
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2760
                                    currentControl.IsNew = true;
2761
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2762

    
2763
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2764
                                }
2765
                            }
2766
                        }
2767
                        break;
2768
                    case ControlType.OverlapWhite:
2769
                        {
2770
                            if (e.LeftButton == MouseButtonState.Pressed)
2771
                            {
2772
                                if (currentControl is OverlapWhiteControl)
2773
                                {
2774
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2775
                                    {
2776
                                        return;
2777
                                    }
2778

    
2779
                                    CreateCommand.Instance.Execute(currentControl);
2780

    
2781
                                    currentControl = null;
2782
                                    this.cursor = Cursors.Arrow;
2783
                                }
2784
                                else
2785
                                {
2786
                                    currentControl = new OverlapWhiteControl
2787
                                    {
2788
                                        Background = new SolidColorBrush(Colors.Black),
2789
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2790
                                        ControlType = ControlType.OverlapWhite
2791
                                    };
2792

    
2793
                                    currentControl.CommentID = Commons.shortGuid();
2794
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2795
                                    currentControl.IsNew = true;
2796
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2797

    
2798
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2799
                                }
2800
                            }
2801
                        }
2802
                        break;
2803
                    case ControlType.ClipWhite:
2804
                        {
2805
                            if (e.LeftButton == MouseButtonState.Pressed)
2806
                            {
2807
                                if (currentControl is ClipWhiteControl)
2808
                                {
2809
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2810
                                    {
2811
                                        return;
2812
                                    }
2813

    
2814
                                    CreateCommand.Instance.Execute(currentControl);
2815

    
2816
                                    currentControl = null;
2817
                                    this.cursor = Cursors.Arrow;
2818
                                }
2819
                                else
2820
                                {
2821
                                    currentControl = new ClipWhiteControl
2822
                                    {
2823
                                        Background = new SolidColorBrush(Colors.Black),
2824
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2825
                                        ControlType = ControlType.ClipWhite
2826
                                    };
2827

    
2828
                                    currentControl.CommentID = Commons.shortGuid();
2829
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2830
                                    currentControl.IsNew = true;
2831
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2832

    
2833
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2834
                                }
2835
                            }
2836
                        }
2837
                        break;
2838
                    case ControlType.Rectangle:
2839
                        {
2840
                            if (e.LeftButton == MouseButtonState.Pressed)
2841
                            {
2842
                                if (currentControl is RectangleControl)
2843
                                {
2844
                                    //20180906 LJY TEST IsRotationDrawingEnable
2845
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2846
                                    {
2847
                                        return;
2848
                                    }
2849

    
2850
                                    CreateCommand.Instance.Execute(currentControl);
2851
                                    currentControl = null;
2852
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2853
                                }
2854
                                else
2855
                                {
2856
                                    currentControl = new RectangleControl
2857
                                    {
2858
                                        Background = new SolidColorBrush(Colors.Black),
2859
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2860
                                        ControlType = ControlType.Rectangle
2861
                                    };
2862

    
2863
                                    currentControl.CommentID = Commons.shortGuid();
2864
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2865
                                    currentControl.IsNew = true;
2866
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2867

    
2868
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2869
                                }
2870
                            }
2871
                        }
2872
                        break;
2873
                    case ControlType.RectCloud:
2874
                        {
2875
                            if (e.LeftButton == MouseButtonState.Pressed)
2876
                            {
2877
                                if (currentControl is RectCloudControl)
2878
                                {
2879
                                    //20180906 LJY TEST IsRotationDrawingEnable
2880
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2881
                                    {
2882
                                        return;
2883
                                    }
2884

    
2885
                                    CreateCommand.Instance.Execute(currentControl);
2886

    
2887
                                    currentControl = null;
2888
                                
2889
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2890
                                }
2891
                                else
2892
                                {
2893
                                    currentControl = new RectCloudControl
2894
                                    {
2895
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2896
                                        ControlType = ControlType.RectCloud,
2897
                                        Background = new SolidColorBrush(Colors.Black)
2898
                                    };
2899

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

    
2920
                                    CreateCommand.Instance.Execute(currentControl);
2921

    
2922
                                    currentControl = null;
2923
                                }
2924
                                else
2925
                                {
2926
                                    currentControl = new CircleControl
2927
                                    {
2928
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
2929
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
2930
                                        Background = new SolidColorBrush(Colors.Black)
2931
                                    };
2932

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

    
2960
                                        CreateCommand.Instance.Execute(currentControl);
2961

    
2962
                                        currentControl = null;
2963
                                    }
2964
                                }
2965
                                else
2966
                                {
2967
                                    currentControl = new TriControl
2968
                                    {
2969
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
2970
                                        Background = new SolidColorBrush(Colors.Black),
2971
                                    };
2972

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

    
2997
                                    CreateCommand.Instance.Execute(currentControl);
2998
                                    currentControl = null;
2999
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3000
                                }
3001
                                else
3002
                                {
3003
                                    currentControl = new LineControl
3004
                                    {
3005
                                        ControlType = this.controlType,
3006
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3007
                                        Background = new SolidColorBrush(Colors.Black)
3008
                                    };
3009

    
3010
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3011
                                    currentControl.CommentID = Commons.shortGuid();
3012
                                    currentControl.IsNew = true;
3013
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3014
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3015
                                }
3016
                            }
3017
                        }
3018
                        break;
3019
                    case ControlType.PolygonControl:
3020
                        {
3021
                            if (currentControl is PolygonControl)
3022
                            {
3023
                                var control = currentControl as PolygonControl;
3024

    
3025
                                if (e.RightButton == MouseButtonState.Pressed)
3026
                                {
3027
                                    control.IsCompleted = true;
3028
                                }
3029

    
3030
                                if (!control.IsCompleted)
3031
                                {
3032
                                    control.PointSet.Add(control.EndPoint);
3033
                                }
3034
                                else
3035
                                {
3036
                                    //20180906 LJY TEST IsRotationDrawingEnable
3037
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3038
                                    {
3039
                                        return;
3040
                                    }
3041

    
3042
                                    var firstPoint = control.PointSet.First();
3043
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3044
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3045
                                    control.PointSet.Add(firstPoint);
3046

    
3047
                                    control.ApplyOverViewData();
3048

    
3049
                                    CreateCommand.Instance.Execute(currentControl);
3050
                                    control.UpdateControl();
3051
                                    currentControl = null;
3052
                                }
3053
                            }
3054
                            else
3055
                            {
3056
                                if (e.LeftButton == MouseButtonState.Pressed)
3057
                                {
3058
                                    currentControl = new PolygonControl
3059
                                    {
3060
                                        PointSet = new List<Point>(),
3061
                                    };
3062

    
3063
                                    var polygonControl = (currentControl as PolygonControl);
3064
                                    currentControl.CommentID = Commons.shortGuid();
3065
                                    currentControl.IsNew = true;
3066
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3067
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3068
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3069
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3070
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3071
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3072
                                    polygonControl.ApplyTemplate();
3073
                                    polygonControl.Visibility = Visibility.Visible;
3074
                                }
3075
                            }
3076
                        }
3077
                        break;
3078
                    case ControlType.ChainLine:
3079
                        {
3080
                            if (currentControl is PolygonControl)
3081
                            {
3082
                                var control = currentControl as PolygonControl;
3083

    
3084
                                if (e.RightButton == MouseButtonState.Pressed)
3085
                                {
3086
                                    //20180906 LJY TEST IsRotationDrawingEnable
3087
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3088
                                    {
3089
                                        return;
3090
                                    }
3091

    
3092
                                    CreateCommand.Instance.Execute(currentControl);
3093

    
3094
                                    currentControl = null;
3095
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3096
                                    return;
3097
                                }
3098

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

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

    
3149
                                    CreateCommand.Instance.Execute(currentControl);
3150

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

    
3192
                                    CreateCommand.Instance.Execute(currentControl);
3193

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

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

    
3252
                                            CreateCommand.Instance.Execute(currentControl);
3253

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

    
3285
                                if (!control.IsCompleted)
3286
                                {
3287
                                    control.PointSet.Add(control.EndPoint);
3288
                                }
3289
                                else
3290
                                {
3291
                                    //20180906 LJY TEST IsRotationDrawingEnable
3292
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3293
                                    {
3294
                                        return;
3295
                                    }
3296

    
3297
                                    CreateCommand.Instance.Execute(currentControl);
3298

    
3299
                                    control.isTransOn = true;
3300
                                    var firstPoint = control.PointSet.First();
3301

    
3302
                                    control.PointSet.Add(firstPoint);
3303
                                    control.DrawingCloud();
3304
                                    control.ApplyOverViewData();
3305

    
3306
                                    currentControl = null;
3307
                                }
3308
                            }
3309
                            else
3310
                            {
3311
                                if (e.LeftButton == MouseButtonState.Pressed)
3312
                                {
3313
                                    currentControl = new CloudControl
3314
                                    {
3315
                                        PointSet = new List<Point>(),
3316
                                        PointC = new StylusPointSet()
3317
                                    };
3318

    
3319
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3320
                                    //{
3321
                                        var polygonControl = (currentControl as CloudControl);
3322
                                        currentControl.CommentID = Commons.shortGuid();
3323
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3324
                                        currentControl.IsNew = true;
3325
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3326

    
3327
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3328
                                        polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3329
                                    
3330
                                    //}
3331
                                }
3332
                            }
3333
                        }
3334
                        break;
3335
                    case ControlType.ImgControl:
3336
                        {
3337
                            if (e.LeftButton == MouseButtonState.Pressed)
3338
                            {
3339
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3340
                                //{
3341
                                    if (currentControl is ImgControl)
3342
                                    {
3343
                                        //20180906 LJY TEST IsRotationDrawingEnable
3344
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3345
                                        {
3346
                                            return;
3347
                                        }
3348

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

    
3377
                                            currentControl = new ImgControl
3378
                                            {
3379
                                                    Background = new SolidColorBrush(Colors.Black),
3380
                                                    PointSet = new List<Point>(),
3381
                                                    FilePath = filename,
3382
                                                    ImageData = img.Source,
3383
                                                    StartPoint = CanvasDrawingMouseDownPoint,
3384
                                                    EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3385
                                                    TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3386
                                                    LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3387
                                                    ControlType = ControlType.ImgControl
3388
                                                };
3389

    
3390
                                        
3391
                                                currentControl.CommentID = Commons.shortGuid();                                            
3392
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3393
                                                currentControl.IsNew = true;
3394
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3395

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

    
3418
                                    CreateCommand.Instance.Execute(currentControl);
3419
                                    currentControl = null;
3420

    
3421
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3422
                                    {
3423
                                        controlType = ControlType.None;
3424
                                        IsSwingMode = false;
3425
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3426
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3427
                                        mouseHandlingMode = MouseHandlingMode.None;
3428
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3429
                                        txtBatch.Visibility = Visibility.Collapsed;
3430

    
3431
                                    }
3432
                                }
3433
                                else
3434
                                {
3435
                                    currentControl = new DateControl
3436
                                    {
3437
                                        StartPoint = CanvasDrawingMouseDownPoint,
3438
                                        Background = new SolidColorBrush(Colors.Black)
3439
                                    };
3440
                                    currentControl.CommentID = Commons.shortGuid();
3441
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3442
                                    currentControl.IsNew = true;
3443
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3444

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

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

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

    
3528
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3529
                                    currentControl.CommentID = Commons.shortGuid();
3530
                                    currentControl.IsNew = true;
3531
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3532
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3533

    
3534
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3535
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3536
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3537

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

    
3562
                                    CreateCommand.Instance.Execute(currentControl);
3563

    
3564
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3565
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3566
                                    (currentControl as ArrowTextControl).IsNew = false;
3567
                                    currentControl = null;
3568
                                }
3569
                                else
3570
                                {
3571
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3572
                                    //{
3573
                                        currentControl = new ArrowTextControl();
3574
                                        currentControl.CommentID = Commons.shortGuid();
3575
                                        currentControl.IsNew = true;
3576
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3577
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3578

    
3579
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3580
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3581
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3582
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3583
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3584

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

    
3588
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3589
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3590
                                        (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3591
                                        ViewerDataModel.Instance.AngleVisibility = Visibility.Visible;
3592

    
3593
                                    
3594
                                    //}
3595
                                }
3596
                            }
3597
                        }
3598
                        break;
3599
                    case ControlType.ArrowTransTextControl:
3600
                        {
3601
                            if (e.LeftButton == MouseButtonState.Pressed)
3602
                            {
3603
                                if (currentControl is ArrowTextControl)
3604
                                {
3605
                                    //20180906 LJY TEST IsRotationDrawingEnable
3606
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3607
                                    {
3608
                                        return;
3609
                                    }
3610

    
3611
                                    CreateCommand.Instance.Execute(currentControl);
3612

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

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

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

    
3661
                                    CreateCommand.Instance.Execute(currentControl);
3662
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3663
                                    currentControl.IsNew = false;
3664
                                    currentControl = null;
3665
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3666
                                }
3667
                                else
3668
                                {
3669
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3670
                                    //{
3671
                                        currentControl = new ArrowTextControl()
3672
                                        {
3673
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3674
                                        };
3675
                                        currentControl.CommentID = Commons.shortGuid();
3676
                                        currentControl.IsNew = true;
3677
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3678
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3679

    
3680
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3681

    
3682
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3683

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

    
3714
                                    ViewerDataModel.Instance.AngleVisibility = Visibility.Collapsed;
3715
                                }
3716
                                else
3717
                                {
3718
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3719
                                    //{
3720
                                    
3721

    
3722
                                    currentControl = new ArrowTextControl()
3723
                                    {
3724
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3725
                                        ControlType = ControlType.ArrowTransTextBorderControl
3726

    
3727
                                    };
3728
                                        currentControl.CommentID = Commons.shortGuid();
3729
                                        currentControl.IsNew = true;
3730
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3731
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3732

    
3733
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3734

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

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

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

    
3830
                                        };
3831
                                        currentControl.CommentID = Commons.shortGuid();
3832
                                        currentControl.IsNew = true; 
3833
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3834
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3835
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3836

    
3837
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3838
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);                                        
3839
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3840
                                        (currentControl as ArrowTextControl).isFixed = true;
3841
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3842

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

    
3866
                                    if (_sign == null)
3867
                                    {
3868
                                        txtBatch.Visibility = Visibility.Collapsed;
3869
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3870
                                        controlType = ControlType.None;
3871

    
3872
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3873
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3874
                                        return;
3875
                                    }
3876

    
3877
                                    if (currentControl is SignControl)
3878
                                    {
3879
                                        //20180906 LJY TEST IsRotationDrawingEnable
3880
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3881
                                        {
3882
                                            return;
3883
                                        }
3884

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

    
3905
                                        currentControl.CommentID = Commons.shortGuid();
3906
                                        currentControl.IsNew = true;
3907
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3908
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3909

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

    
3931
                                        CreateCommand.Instance.Execute(currentControl);
3932
                                        (currentControl as RectangleControl).ApplyOverViewData();
3933
                                        currentControl = null;
3934
                                    
3935
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3936

    
3937
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3938
                                        {
3939
                                            txtBatch.Text = "Place Signature";
3940
                                            controlType = ControlType.Sign;
3941
                                        }
3942
                                    }
3943
                                    else
3944
                                    {
3945
                                        currentControl = new RectangleControl
3946
                                        {
3947
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3948
                                            Background = new SolidColorBrush(Colors.Black),
3949
                                            ControlType = ControlType.Mark ,
3950
                                            Paint = PaintSet.Fill
3951
                                        };
3952

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

    
3989
                                    currentControl.IsNew = true;
3990
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3991
                                    currentControl.CommentID = Commons.shortGuid();
3992
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3993

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

    
4015
                                        CreateCommand.Instance.Execute(currentControl);
4016
                                        currentControl = null;
4017
                                   
4018

    
4019
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4020
                                    }
4021
                                    else
4022
                                    {
4023
                                        currentControl = new SymControlN
4024
                                        {
4025
                                            StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4026
                                            Background = new SolidColorBrush(Colors.Black),
4027
                                            STAMP = App.SystemInfo.STAMP,                                            
4028
                                            ControlType = ControlType.Stamp
4029
                                        };
4030

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

    
4069
                if (currentControl != null)
4070
                {
4071
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4072
                }
4073
            }
4074
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4075
            {
4076
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4077
                {
4078
                    bool mouseOff = false;
4079
                    foreach (var item in SelectLayer.Children)
4080
                    {
4081
                        if (item is AdornerFinal)
4082
                        {
4083

    
4084
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4085
                            if (over != null)
4086
                            {
4087
                                mouseOff = true;
4088
                            }
4089
                        }
4090
                    }
4091

    
4092
                    if (!mouseOff)
4093
                    {
4094
                        SelectionSet.Instance.UnSelect(this);
4095
                    }
4096
                }
4097
                zoomAndPanControl.CaptureMouse();
4098
                e.Handled = true;
4099
            }
4100
          
4101
        }
4102

    
4103
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4104
        {
4105
            ///mouseButtonDown = e.ChangedButton;
4106
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4107
        }
4108

    
4109
        private void RemoveLineStroke(Point P)
4110
        {
4111
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4112
            if (control != null)
4113
            {
4114
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4115
            }
4116
        }
4117

    
4118
        private void RemovePointStroke(Point P)
4119
        {
4120
            foreach (Stroke hits in inkBoard.Strokes)
4121
            {
4122
                foreach (StylusPoint sty in hits.StylusPoints)
4123
                {
4124

    
4125
                }
4126
                if (hits.HitTest(P))
4127
                {
4128
                    inkBoard.Strokes.Remove(hits);
4129
                    return;
4130
                }
4131
            }
4132
        }
4133

    
4134
        private void StartNewStroke(Point P)
4135
        {
4136
            strokePoints = new StylusPointCollection();
4137
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4138
            strokePoints.Add(segment1Start);
4139
            stroke = new Stroke(strokePoints);
4140

    
4141
            stroke.DrawingAttributes.Color = Colors.Red;
4142
            stroke.DrawingAttributes.Width = 4;
4143
            stroke.DrawingAttributes.Height = 4;
4144

    
4145
            inkBoard.Strokes.Add(stroke);
4146
        }
4147

    
4148
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4149
        {
4150
            ConsolidationMethod();
4151
        }
4152

    
4153
        /// <summary>
4154
        /// execute TeamConsolidationCommand
4155
        /// </summary>
4156
        public void TeamConsolidationMethod()
4157
        {
4158
            this.UpdateMyMarkupList();
4159
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4160
            {
4161
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4162
            }
4163
            else
4164
            {
4165

    
4166
                ViewerDataModel.Instance.IsConsolidate = true;
4167
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4168

    
4169
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4170
                {
4171
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4172
                    {
4173
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4174
                        return;
4175
                    }                    
4176
                }
4177
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4178
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4179
                {
4180
                    MarkupInfoList.Add(item);
4181
                }
4182
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4183
            }
4184
        }
4185

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

    
4205
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4206
        {
4207
            if (App.ViewInfo != null)
4208
            {
4209
                btnConsolidate = (sender as RadRibbonButton);
4210
                if (!App.ViewInfo.NewCommentPermission)
4211
                {
4212
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4213
                }
4214
            }
4215
        }
4216

    
4217
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4218
        {
4219
            TeamConsolidationMethod();
4220
        }
4221

    
4222
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4223
        {
4224
            btnTeamConsolidate = sender as RadRibbonButton;
4225
            if (App.ViewInfo != null)
4226
            {
4227
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4228
                {
4229
                    if (btnConsolidate != null)
4230
                    {
4231
                        btnConsolidate.Visibility = Visibility.Collapsed;
4232
                    }
4233

    
4234
                    if (!App.ViewInfo.NewCommentPermission)
4235
                    {
4236
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4237
                    }
4238
                }
4239
                else
4240
                {
4241
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4242
                }
4243
            }
4244
        }
4245

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

    
4267
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4268
        {
4269
            btnFinalPDF = sender as RadRibbonButton;
4270
            if (App.ViewInfo != null)
4271
            {
4272
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4273
                {
4274
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4275
                    if (btnConsolidate != null)
4276
                    {
4277
                        btnConsolidate.Visibility = Visibility.Collapsed;
4278
                    }
4279
                }
4280
            }
4281
        }
4282

    
4283
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4284
        {
4285
            UpdateMyMarkupList();
4286

    
4287
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4288
            {
4289
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4290
            }
4291
            else
4292
            {
4293
                ViewerDataModel.Instance.IsConsolidate = true;
4294
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4295
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4296

    
4297
                string project_no = App.ViewInfo.ProjectNO;
4298
                string doc_id = _DocInfo.ID;
4299
                string user_id = App.ViewInfo.UserID;
4300
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4301
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4302
                {
4303
                    markupInfoItems.Add(item);
4304
                }
4305
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4306
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4307
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4308
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4309

    
4310
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4311
                if (item2 != null)
4312
                {
4313
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4314

    
4315
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4316
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4317
                }
4318
                else
4319
                {
4320
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4321
                }
4322
            }
4323
        }
4324

    
4325
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4326
        {
4327
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4328

    
4329
            if (App.ViewInfo != null)
4330
            {
4331
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4332
                {
4333
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4334
                }
4335
            }
4336
        }
4337

    
4338
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4339
        {
4340
            SetCompareRect();
4341
        }
4342

    
4343
        private void Sync_Click(object sender, RoutedEventArgs e)
4344
        {
4345
            if (Sync.IsChecked)
4346
            {
4347
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4348
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4349
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4350
            }
4351
        }
4352

    
4353
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4354
        {
4355
            if (UserList.IsChecked)
4356
            {
4357
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4358
            }
4359
            else
4360
            {
4361
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4362
            }
4363
        }
4364

    
4365
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4366
        {
4367

    
4368
            if (BalanceMode.IsChecked)
4369
            {
4370
                ViewerDataModel.Instance.PageBalanceMode = true;
4371
            }
4372
            else
4373
            {
4374
                ViewerDataModel.Instance.PageBalanceMode = false;
4375
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4376
            }
4377
        }
4378

    
4379
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4380
        {
4381
            //초기화
4382
            testPanel2.IsHidden = true;
4383
            ViewerDataModel.Instance.PageBalanceMode = false;
4384
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4385
            ViewerDataModel.Instance.PageNumber = 0;
4386
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4387
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4388
            UserList.IsChecked = false;
4389
            BalanceMode.IsChecked = false;
4390
        }
4391

    
4392
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4393
        {
4394
            if ((sender as System.Windows.Controls.Control).Tag != null)
4395
            {
4396
                //Compare 초기화
4397
                CompareMode.IsChecked = false;
4398
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4399

    
4400
                if (ViewerDataModel.Instance.PageNumber == 0)
4401
                {
4402
                    ViewerDataModel.Instance.PageNumber = 1;
4403
                }
4404

    
4405
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4406
                {
4407
                }
4408
                else
4409
                {
4410
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4411
                }
4412

    
4413

    
4414

    
4415
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4416
                {
4417

    
4418
                }
4419
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4420
                {
4421
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4422
                }
4423

    
4424
                pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4425

    
4426
                if (!testPanel2.IsHidden)
4427
                {
4428
                    if (IsSyncPDFMode)
4429
                    {
4430
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4431
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4432

    
4433
                        if (pdfpath.IsDownloading)
4434
                        {
4435
                            pdfpath.DownloadCompleted += (ex, arg) =>
4436
                            {
4437
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4438
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4439
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4440
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4441
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4442
                            };
4443
                        }
4444
                        else
4445
                        {
4446
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4447
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4448
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4449

    
4450
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4451
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4452
                        }
4453

    
4454
                    }
4455
                    else
4456
                    {
4457
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4458

    
4459
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4460

    
4461
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4462
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4463
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4464

    
4465
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4466
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4467

    
4468
                        if (defaultBitmapImage_Compare.IsDownloading)
4469
                        {
4470
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4471
                            {
4472
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4473
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4474
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4475

    
4476
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4477
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4478
                            };
4479
                        }
4480
                    }
4481

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

    
4486
                    foreach (var item in gridSelectionRevItem)
4487
                    {
4488
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4489
                        {
4490
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4491
                        });
4492
                    }
4493

    
4494
                    //강인구 추가
4495
                    zoomAndPanControl2.ZoomTo(new Rect
4496
                    {
4497
                        X = 0,
4498
                        Y = 0,
4499
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4500
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4501
                    });
4502

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

    
4505
                }
4506
            }
4507
        }
4508

    
4509
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4510
        {
4511
            if (MarkupMode.IsChecked)
4512
            {
4513
                IsSyncPDFMode = true;
4514

    
4515
                var uri = CurrentRev.TO_VENDOR;
4516

    
4517
                if (ViewerDataModel.Instance.PageNumber == 0)
4518
                {
4519
                    ViewerDataModel.Instance.PageNumber = 1;
4520
                }
4521

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

    
4526
                if (pdfpath.IsDownloading)
4527
                {
4528
                    pdfpath.DownloadCompleted += (ex, arg) =>
4529
                    {
4530
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4531
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4532
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4533
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4534
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4535
                    };
4536
                }
4537
                else
4538
                {
4539
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4540
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4541
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4542

    
4543
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4544
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4545
                }
4546
            }
4547
            else
4548
            {
4549
                IsSyncPDFMode = false;
4550
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4551

    
4552
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4553

    
4554
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4555
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4556
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4557

    
4558
                if (defaultBitmapImage_Compare.IsDownloading)
4559
                {
4560
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4561
                    {
4562
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4563
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4564
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4565
                    };
4566
                }
4567
                zoomAndPanControl2.ApplyTemplate();
4568
                zoomAndPanControl2.UpdateLayout();
4569
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4570
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4571
            }
4572
        }
4573

    
4574
        /// <summary>
4575
        /// Compare된 영역을 초기화
4576
        /// </summary>
4577
        private void ClearCompareRect()
4578
        {
4579
            da.From = 1;
4580
            da.To = 1;
4581
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4582
            da.AutoReverse = false;
4583
            canvas_compareBorder.Children.Clear();
4584
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4585
        }
4586

    
4587
        /// <summary>
4588
        /// 문서 Comprare 
4589
        /// </summary>
4590
        private void SetCompareRect()
4591
        {
4592
            if (CompareMode.IsChecked)
4593
            {
4594
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4595
                {
4596
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4597
                }
4598
                if (ViewerDataModel.Instance.PageNumber == 0)
4599
                {
4600
                    ViewerDataModel.Instance.PageNumber = 1;
4601
                }
4602

    
4603
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4604
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4605
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4606

    
4607
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4608
            }
4609
            else
4610
            {
4611
                ClearCompareRect();
4612
            }
4613
        }
4614

    
4615
        private void RadButton_Click(object sender, RoutedEventArgs e)
4616
        {
4617
            gridViewHistory_Busy.IsBusy = true;
4618

    
4619
            RadButton instance = sender as RadButton;
4620
            if (instance.CommandParameter != null)
4621
            {
4622
                CurrentRev = instance.CommandParameter as VPRevision;
4623
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4624

    
4625
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4626
                {
4627
                    if (ea.Error == null && ea.Result != null)
4628
                    {
4629
                        testPanel2.IsHidden = false;
4630

    
4631
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4632
                        foreach(var info in ea.Result)
4633
                        {
4634
                            if(info.UserID == App.ViewInfo.UserID)
4635
                            {
4636
                                info.userDelete = true;
4637
                                info.DisplayColor = "FFFF0000";
4638
                            }
4639
                            else
4640
                            {
4641
                                info.userDelete = false;
4642
                            }
4643
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4644
                        }
4645
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4646

    
4647
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4648

    
4649
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4650

    
4651
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4652
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4653
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4654
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4655
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4656
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4657

    
4658
                        zoomAndPanControl2.ApplyTemplate();
4659
                        zoomAndPanControl2.UpdateLayout();
4660
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4661
                        {
4662
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4663
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4664
                        }
4665

    
4666
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4667
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4668
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4669

    
4670
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4671
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4672
                        gridViewHistory_Busy.IsBusy = false;
4673
                    }
4674

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

    
4677
                    if (GetSyncMarkupInfoItemshandler != null)
4678
                    {
4679
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4680
                    }
4681

    
4682
                    ClearCompareRect();
4683
                    SetCompareRect();
4684
                };
4685

    
4686
                /// 중복 실행이 발생하여 수정함.
4687
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4688
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4689

    
4690
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4691
            }
4692
        }
4693

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

    
4717
        public void Sync_Event(VPRevision Currnet_Rev)
4718
        {
4719
            CurrentRev = Currnet_Rev;
4720

    
4721
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4722
            {
4723
                if (ea.Error == null && ea.Result != null)
4724
                {
4725
                    testPanel2.IsHidden = false;
4726

    
4727
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4728
                    foreach(var info in ea.Result)
4729
                    {
4730
                        if(info.UserID == App.ViewInfo.UserID)
4731
                        {
4732
                            info.userDelete = true;
4733
                            info.DisplayColor = "FFFF0000";
4734
                        }
4735
                        else
4736
                        {
4737
                            info.userDelete = false;
4738
                        }
4739
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4740
                    }
4741
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4742

    
4743
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4744

    
4745
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4746

    
4747
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4748

    
4749
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4750
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4751
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4752

    
4753
                    if (defaultBitmapImage_Compare.IsDownloading)
4754
                    {
4755
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4756
                        {
4757
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4758
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4759
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4760
                        };
4761
                    }
4762

    
4763

    
4764
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4765
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4766
                    zoomAndPanControl2.ApplyTemplate();
4767
                    zoomAndPanControl2.UpdateLayout();
4768

    
4769
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4770
                    {
4771
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4772
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4773
                    }
4774
                    //}
4775

    
4776
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4777
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4778
                    gridViewHistory_Busy.IsBusy = false;
4779
                }
4780
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4781

    
4782
            };
4783
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4784
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4785
        }
4786

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

    
4803
        private void Create_Symbol(object sender, RoutedEventArgs e)
4804
        {
4805
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4806

    
4807
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4808
            {
4809
                DialogMessage_Alert("Please Select Controls", "Alert");
4810
            }
4811
            else //선택된 것이 있으면
4812
            {
4813
                string MarkupData = "";
4814
                adorner_ = new AdornerFinal();
4815

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

    
4844
        }
4845
        public int symbolselectindex = 0;
4846
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4847
        {
4848
            //Save save = new Save();
4849
            try
4850
            {
4851
                string svgfilename = null;
4852
                if (symbolname != null)
4853
                {
4854
                    if (symbolpng == true || symbolsvg == true)
4855
                    {
4856
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4857
                        string guid = Commons.shortGuid();
4858

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

    
4880
                            if (symbolsvg == true)
4881
                            {
4882
                                try
4883
                                {
4884
                                    var defaultBitmapImage = new BitmapImage();
4885
                                    defaultBitmapImage.BeginInit();
4886
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4887
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4888
                                    Check_Uri.UriCheck(filename);
4889
                                    defaultBitmapImage.UriSource = new Uri(filename);
4890
                                    defaultBitmapImage.EndInit();
4891

    
4892
                                    System.Drawing.Bitmap image;
4893

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

    
4916
                                            StringBuilder svgBuilder = new StringBuilder();
4917
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4918
                                            {
4919
                                                svgBuilder.AppendLine(e2.Data);
4920
                                            };
4921

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

    
4938
                                                DataBind();
4939
                                            };
4940
                                            potrace.WaitForExit();
4941
                                        };
4942
                                    }
4943
                                    else
4944
                                    {
4945
                                        //GC.Collect();
4946
                                    }
4947
                                }
4948
                                catch(Exception ee)
4949
                                {
4950
                                    DialogMessage_Alert("" + ee, "Alert");
4951
                                }
4952
                            }
4953
                        };                                             
4954
                    }
4955
                }
4956
            }
4957
            catch (Exception e)
4958
            {
4959
                //DialogMessage_Alert(e + "", "Alert");
4960
            }            
4961
        }
4962

    
4963
        public void SymbolSave(string Name, string Url, string Data)
4964
        {
4965
            try
4966
            {
4967
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4968
                {
4969
                    ID = Commons.shortGuid(),
4970
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4971
                    NAME = Name,
4972
                    IMAGE_URL = Url,
4973
                    DATA = Data
4974
                };
4975

    
4976
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4977
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4978
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4979
            }
4980
            catch (Exception)
4981
            {
4982
                throw;
4983
            }
4984
        }
4985

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

    
5008
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5009
        {           
5010
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5011
            DataBind();
5012
        }
5013

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

    
5040
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5041

    
5042
                List<SYMBOL_PUBLIC> symbol_Public;
5043

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

    
5079
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5080
                        _Encoder.Save(fs);
5081
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5082

    
5083
                        byte[] Img_byte = fs.ToArray();
5084

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

    
5106
        public PngBitmapEncoder symImage(string data)
5107
        {
5108

    
5109
            Canvas _canvas = new Canvas();
5110
            _canvas.Background = Brushes.White;
5111
            _canvas.Width = adorner_.BorderSize.Width;
5112
            _canvas.Height = adorner_.BorderSize.Height;
5113
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5114

    
5115
            BitmapEncoder encoder = new PngBitmapEncoder();
5116

    
5117

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

    
5120
            DrawingVisual dv = new DrawingVisual();
5121

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

    
5125
            using (DrawingContext ctx = dv.RenderOpen())
5126
            {
5127
                VisualBrush vb = new VisualBrush(_canvas);
5128
                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)));
5129
            }
5130

    
5131
            try
5132
            {
5133
                renderBitmap.Render(dv);
5134

    
5135
                //GC.Collect();
5136
                GC.WaitForPendingFinalizers();
5137
                //GC.Collect();
5138
                // encode png data
5139
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5140
                // puch rendered bitmap into it
5141
                pngEncoder.Interlace = PngInterlaceOption.Off;
5142
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5143
                return pngEncoder;
5144

    
5145
            }
5146
            catch //(Exception ex)
5147
            {
5148
                return null;
5149
            }
5150

    
5151
        }
5152

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

    
5173
        #region 캡쳐 기능
5174

    
5175
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5176
        {
5177
            if (x < 0)
5178
            {
5179
                width += x;
5180
                x = 0;
5181
            }
5182
            if (y < 0)
5183
            {
5184
                height += y;
5185
                y = 0;
5186

    
5187
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5188
            }
5189
            if (x + width > zoomAndPanCanvas.ActualWidth)
5190
            {
5191
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5192
            }
5193
            if (y + height > zoomAndPanCanvas.ActualHeight)
5194
            {
5195
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5196
            }
5197

    
5198
            byte[] pixels = CopyPixels(x, y, width, height);
5199

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

    
5202
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5203
        }
5204

    
5205
        public byte[] CopyPixels(int x, int y, int width, int height)
5206
        {
5207
            byte[] pixels = new byte[width * height * 4];
5208
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5209

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

    
5213
            return pixels;
5214
        }
5215

    
5216
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5217
        {
5218
            DrawingVisual drawingVisual = new DrawingVisual();
5219
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5220

    
5221
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5222
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5223
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5224
            drawingContext.Close();
5225

    
5226
            // 비트맵으로 변환합니다.
5227
            RenderTargetBitmap target =
5228
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5229
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5230

    
5231
            target.Render(drawingVisual);
5232
            return target;
5233
        }
5234

    
5235
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5236
        {
5237
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5238
            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);
5239
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5240
            bmp.UnlockBits(data);
5241
            return bmp;
5242
        }
5243
        public string symbolname = null;
5244
        public bool symbolsvg = true;
5245
        public bool symbolpng = true;
5246

    
5247
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5248
        {
5249
            System.Drawing.Bitmap image = GetBitmap(source);
5250
            //흰색 제거
5251
            //image.MakeTransparent(System.Drawing.Color.White);
5252

    
5253
            var imageStream = new System.IO.MemoryStream();
5254
            byte[] imageBytes = null;
5255
            using (imageStream)
5256
            {
5257
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5258
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5259
                imageStream.Position = 0;
5260
                imageBytes = imageStream.ToArray();
5261
            }
5262

    
5263
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5264

    
5265
            RadWindow CheckPop = new RadWindow();
5266
            //Alert check = new Alert(Msg);
5267

    
5268
            CheckPop = new RadWindow
5269
            {
5270
                MinWidth = 400,
5271
                MinHeight = 100,
5272
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5273
                Header = "Alert",
5274
                Content = symbolPrompt,
5275
                //DialogResult = 
5276
                ResizeMode = System.Windows.ResizeMode.NoResize,
5277
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5278
                IsTopmost = true,
5279
            };
5280
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5281
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5282
            CheckPop.ShowDialog();
5283

    
5284
            /*
5285
            DialogParameters parameters = new DialogParameters()
5286
            {
5287
                Owner = Application.Current.MainWindow,
5288
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5289
                DefaultPromptResultValue = "Custom State",
5290
                Content = "Name :",
5291
                Header = "Insert Custom Symbol Name",
5292
                Theme = new VisualStudio2013Theme(),
5293
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5294
            };            
5295
            RadWindow.Prompt(parameters);
5296
            */
5297
        }
5298

    
5299
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5300
        {
5301
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5302
            KCOMDataModel.DataModel.CHECK_LIST check_;
5303
            string Result = streamToBase64.ImageToBase64(source);
5304
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5305
            string projectno = App.ViewInfo.ProjectNO;
5306
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5307

    
5308
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5309
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5310
            if (Item != null)
5311
            {
5312
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5313
            }
5314
            else
5315
            {
5316
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5317
            }
5318

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

    
5351
        }
5352

    
5353
        public void Set_Capture()
5354
        {
5355
            double x = CanvasDrawingMouseDownPoint.X;
5356
            double y = CanvasDrawingMouseDownPoint.Y;
5357
            double width = dragCaptureBorder.Width;
5358
            double height = dragCaptureBorder.Height;
5359

    
5360
            if (width > 5 || height > 5)
5361
            {
5362
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5363
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5364
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5365
            }
5366
        }
5367
        #endregion
5368

    
5369
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5370
        {
5371
            multi_Undo_Data = new Multi_Undo_data();
5372

    
5373
            multi_Undo_Data.Markup = control;
5374

    
5375
            if ((control as IShapeControl) != null)
5376
            {
5377
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5378
            }
5379
            if ((control as IDashControl) != null)
5380
            {
5381
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5382
            }
5383
            if ((control as IPath) != null)
5384
            {
5385
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5386
            }
5387
            if ((control as UIElement) != null)
5388
            {
5389
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5390
            }
5391

    
5392
            return multi_Undo_Data;
5393
        }
5394

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

    
5414
        /// <summary>
5415
        /// convert inkcontrol to polygoncontrol
5416
        /// </summary>
5417
        public void ConvertInkControlToPolygon()
5418
        {
5419
            if (inkBoard.Strokes.Count > 0)
5420
            {
5421
                inkBoard.Strokes.ToList().ForEach(stroke =>
5422
                {
5423
                    InkToPath ip = new InkToPath();
5424

    
5425
                    List<Point> inkPointSet = new List<Point>();
5426
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5427

    
5428
                    PolygonControl pc = new PolygonControl()
5429
                    {
5430
                        CommentAngle = 0,
5431
                        PointSet = inkPointSet,
5432
                        ControlType = ControlType.Ink
5433
                    };
5434
                    pc.StartPoint = inkPointSet[0];
5435
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5436
                    pc.LineSize = 3;
5437
                    pc.CommentID = Commons.shortGuid();
5438
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5439

    
5440
                    if (pc.PointSet.Count > 0)
5441
                    {
5442
                        CreateCommand.Instance.Execute(pc);
5443
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5444
                    }
5445
                });
5446
                inkBoard.Strokes.Clear();
5447
            }
5448
        }
5449

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

    
5466
            return false;
5467
        }
5468

    
5469
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5470
        {
5471
            e.Effects = DragDropEffects.Copy;
5472
        }
5473

    
5474
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5475
        {
5476
            e.Effects = DragDropEffects.Copy;
5477
        }
5478

    
5479
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5480
        {
5481
            e.Effects = DragDropEffects.None;
5482
        }
5483

    
5484
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5485
        {
5486
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5487
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5488

    
5489
            ScaleImage(pageWidth, pageHeight);
5490
        }
5491

    
5492
        /// <summary>
5493
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5494
        /// </summary>
5495
        /// <param name="pageWidth">원본 사이즈</param>
5496
        /// <param name="pageHeight">원본 사이즈</param>
5497
        /// <returns></returns>
5498
        private void ScaleImage(double pageWidth,double pageHeight)
5499
        {
5500
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5501
        }
5502

    
5503
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5504
        {
5505
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5506
        }
5507

    
5508

    
5509
        /*
5510
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5511
        {
5512
            try
5513
            {
5514
                if (e.Data.GetDataPresent(typeof(string)))
5515
                {
5516
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5517
                    string dragData = e.Data.GetData(typeof(string)) as string;
5518
                    Move_Symbol(sender, dragData);
5519
                }
5520
            }
5521
            catch (Exception ex)
5522
            {
5523
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5524
            }            
5525
        }
5526
        */
5527
    }
5528

    
5529
    public class testItem
5530
    {
5531
        public string Title { get; set; }
5532
    }
5533
}
클립보드 이미지 추가 (최대 크기: 500 MB)