프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (246 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

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

    
54
            T instance = Activator.CreateInstance<T>();
55

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

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

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

    
92
        public TextBox Gui { get; private set; }
93

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

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

    
115
            Gui.Text += line + Environment.NewLine;
116
        }
117
    }
118

    
119
    /// <summary>
120
    /// MainMenu.xaml에 대한 상호 작용 논리
121
    /// </summary>
122
    public partial class MainMenu : UserControl
123
    {
124
        #region 프로퍼티
125
        public CommentUserInfo currentControl { get; set; }
126
        public ControlType controlType { get; set; }
127
        private Move move = new Move();
128
        private double[] rotateValue = { 0, 90, 180, 270 };
129
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
130
        private static readonly double DragThreshold = 5;
131
        private System.Windows.Input.Cursor cursor { get; set; }
132
        private Point canvasDrawingMouseDownPoint;
133
        public string filename { get; set; }
134
        private Point canvasZoomPanningMouseDownPoint;
135
        public Point getCurrentPoint;
136
        private Point canvasZoommovingMouseDownPoint;
137
        List<object> ControlList = new List<object>();
138
        private ListBox listBox = new ListBox();
139
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
140
        private bool isDraggingSelectionRect = false;
141
        DrawingAttributes inkDA = new DrawingAttributes();
142
        private VPRevision CurrentRev { get; set; }
143
        public RadRibbonButton btnConsolidate { get; set; }
144
        public RadRibbonButton btnFinalPDF { get; set; }
145
        public RadRibbonButton btnTeamConsolidate { get; set; }
146
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
147

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

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

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

    
181
                }
182
            }
183
        }
184

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

    
209
        public bool IsSyncPDFMode { get; set; }
210

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

    
235
        #endregion
236

    
237
        public MainMenu()
238
        {
239
            //InitializeComponent();    
240
            this.Loaded += MainMenu_Loaded;
241
        }
242

    
243
        public class TempDt
244
        {
245
            public int PageNumber { get; set; }
246
            public string CommentID { get; set; }
247
            public string ConvertData { get; set; }
248
            public int DATA_TYPE { get; set; }
249
            public string MarkupInfoID { get; set; }
250
            public int IsUpdate { get; set; }
251
        }
252

    
253
        List<TempDt> tempDtList = new List<TempDt>();
254

    
255
        private void SetCursor()
256
        {
257
            this.Cursor = cursor;
258
        }
259

    
260
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
261
        {
262
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
263
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
264
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
265
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
266
            {
267
                return true;
268
            }
269

    
270
            return false;
271
        }
272

    
273
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
274
        {
275
            if (rotate.Angle == 90 || rotate.Angle == 270)
276
            {
277
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
278
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
279
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
280
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
281
                {
282
                    return true;
283
                }
284
            }
285
            else
286
            {
287
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
288
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
289
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
290
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
291
                {
292
                    return true;
293
                }
294
            }
295

    
296
            return false;
297
        }
298

    
299

    
300
        public void DeleteItem(MarkupInfoItem item)
301
        {
302
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
303
            {
304
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
305
            }
306

    
307
            ViewerDataModel.Instance._markupInfoList.Remove(item);
308

    
309
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
310
            {
311
                ViewerDataModel.Instance.MarkupControls.Remove(a);
312
            });
313

    
314
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
315
            {
316
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
317
            });
318

    
319
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
320
            {
321
                ComingNewBieEnd = false;
322
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
323
                //임시파일에서도 삭제
324
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
325
            });
326

    
327
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
328

    
329
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
330
            {
331
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
332
                {
333
                    var infoId = Commons.shortGuid();
334
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
335
                    {
336
                        CreateTime = DateTime.Now,
337
                        Depatment = userData.DEPARTMENT,
338
                        UpdateTime = DateTime.Now,
339
                        DisplayColor = "#FFFF0000",
340
                        UserID = userData.ID,
341
                        UserName = userData.NAME,
342
                        PageCount = 1,
343
                        Description = "",
344
                        MarkupInfoID = infoId,
345
                        MarkupList = null,
346
                        MarkupVersionID = Commons.shortGuid(),
347
                        Consolidate = 0,
348
                        PartConsolidate = 0,
349
                        userDelete = true,
350
                        AvoidConsolidate = 0,
351
                        IsPreviewUser = true
352
                    };
353
                    App.Custom_ViewInfoId = infoId;
354
                }
355
            }
356
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
357
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
358
        }
359

    
360
        /// <summary>
361
        /// delete selected comments
362
        /// </summary>
363
        /// <param name="sender"></param>
364
        /// <param name="e"></param>
365
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
366
        {
367
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
368
            SelectionSet.Instance.UnSelect(this);
369

    
370
            Button content = (sender as Button);
371
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
372

    
373
            DeleteItem(item);
374
        }
375

    
376
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
377

    
378
        private static Timer timer;
379
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
380
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
381
        {
382
            InitializeComponent();
383
            
384
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
385

    
386
            if (App.ParameterMode)
387
            {
388
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
389
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
390
                imageViewer_Compare = new Image();
391
                ViewerDataModel.Instance.Capture_Opacity = 0;
392
                da.From = 0.8;
393
                da.To = 0;
394
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
395
                da.AutoReverse = true;
396
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
397

    
398
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
399
                {
400
                    this.SymbolPane.Visibility = Visibility.Collapsed;
401
                    this.FavoritePane.Visibility = Visibility.Collapsed;
402
                    this.drawingRotateCanvas.IsHitTestVisible = false;
403
                }
404
            }
405
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
406
        }
407

    
408
        
409

    
410
        private void timercallback(Object o)
411
        {
412
            Stopwatch sw = new Stopwatch();
413
            sw.Start();
414
            TempFile.TempFileAdd();
415
            sw.Stop();
416

    
417
            Dispatcher.InvokeAsync(new Action(delegate
418
            {
419
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
420
                {
421
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
422
                }
423
            }));
424

    
425
            ////GC.Collect();
426
        }
427
        
428
        /// <summary>
429
        /// update my markuplist
430
        ///  - update existing markup data if already exist
431
        ///  - add new markup data if control is new
432
        /// </summary>
433
        public void UpdateMyMarkupList()
434
        {
435
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
436
            bool isComingNewBie = false;
437

    
438
            /// add or update markup list
439
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
440
            {
441
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
442

    
443
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
444
                if (exist != null) //신규 추가 된 코멘트
445
                {
446
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
447
                    {
448
                        exist.Data = root.ConvertData;
449
                        exist.IsUpdate = true;
450
                        ComingNewBieEnd = false;
451
                    }
452
                }
453
                else if (root.CommentID != null)
454
                {
455
                    isComingNewBie = true;
456
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
457
                    {
458
                        ID = control.CommentID,
459
                        Data = root.ConvertData,
460
                        Data_Type = root.DATA_TYPE,
461
                        MarkupInfoID = App.Custom_ViewInfoId,
462
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
463
                        Symbol_ID = control.SymbolID,
464
                        //Group_ID = control.GroupID,
465
                    });
466
                    ComingNewBieEnd = false;
467
                }
468
            }
469

    
470
            /// delete markup list
471
            int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
472
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
473
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
474
                          select markup).ToList();
475
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
476
            /// up to here
477

    
478
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
479
            {
480
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
481
                {
482
                    ComingNewBieEnd = true;
483
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
484
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
485
                    gridViewMarkup.ItemsSource = null;
486
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
487
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
488

    
489
                    GroupDescriptor descriptor = new GroupDescriptor();
490
                    descriptor.Member = "Depatment";
491
                    descriptor.DisplayContent = "DEPT";
492
                    descriptor.SortDirection = ListSortDirection.Ascending;
493
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
494
                }
495
            }
496
        }
497

    
498
        bool ComingNewBieEnd = false;
499

    
500
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
501
        {
502
            if (zoomAndPanCanvas2.Width.IsNaN())
503
            {
504
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
505
            }
506

    
507
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
508
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
509

    
510
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
511
            foreach (var info in gridSelectionItem)
512
            {
513
                Logger.sendCheckLog(String.Format("==>{0}", info), 1);
514
            }
515
            /// fire selection event
516
            this.gridViewMarkup.UnselectAll();
517
            this.gridViewMarkup.Select(gridSelectionItem);
518

    
519
            if (!testPanel2.IsHidden)
520
            {
521
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
522
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
523
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
524

    
525
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
526
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
527

    
528

    
529
                foreach (var item in gridSelectionRevItem)
530
                {
531
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
532
                    {
533
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
534
                    });
535
                }
536
            }
537

    
538
            var instanceMain = this.ParentOfType<MainWindow>();
539
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
540
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
541

    
542
            instanceMain.dzTopMenu.rotateOffSet = 0;
543
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
544
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
545

    
546
            //}
547
            SetCommentPages(true);
548
        }
549
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
550
        {
551
            Logger.sendCheckLog("pageNavigator_PageChanging_Start", 1);
552
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
553
            {
554
                Logger.sendCheckLog("pageNavigator_PageChanging_이전페이지Save", 1);
555
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
556
            }
557
            Logger.sendCheckLog("pageNavigator_PageChanging_UndoDataListClear", 1);
558
            ViewerDataModel.Instance.UndoDataList.Clear();
559

    
560
            InkControl_Convert();
561

    
562
            SelectionSet.Instance.UnSelect(this);
563
            UpdateMyMarkupList();
564

    
565
            Logger.sendCheckLog("pageNavigator_PageChanging_변수생성 및 값 설정", 1);
566
            CompareMode.IsChecked = false;
567
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
568

    
569

    
570
            #region 페이지가 벗어난 경우
571

    
572
            if (BalancePoint < 1)
573
            {
574
                BalancePoint = 1;
575
                ViewerDataModel.Instance.PageBalanceNumber = 0;
576
            }
577

    
578
            if (pageNavigator.PageCount < BalancePoint)
579
            {
580
                BalancePoint = pageNavigator.PageCount;
581
                ViewerDataModel.Instance.PageBalanceNumber = 0;
582
            }
583

    
584
            #endregion
585

    
586
            ViewerDataModel.Instance.PageNumber = BalancePoint;
587

    
588
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
589
            string uri = "";
590
            if (userData.COMPANY != "EXT")
591
            {
592
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
593
            }
594
            else
595
            {
596
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
597
            }
598

    
599
            var defaultBitmapImage = new BitmapImage();
600
            defaultBitmapImage.BeginInit();
601
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
602
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
603
            defaultBitmapImage.UriSource = new Uri(uri);
604
            defaultBitmapImage.EndInit();
605

    
606
            ViewerDataModel.Instance.ImageViewPath = null;
607
            GC.Collect();
608

    
609
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
610
            if (defaultBitmapImage.IsDownloading)
611
            {
612
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
613
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
614
                {
615
                    defaultBitmapImage.Freeze();
616
                    mainPanel.UpdateLayout();
617
                    GC.Collect();
618
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
619
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
620
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
621
                    this.pageNavigator.SetNextPage();
622
                };
623
            }
624

    
625
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
626
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
627

    
628

    
629
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
630
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
631
            inkBoard.Width = zoomAndPanCanvas.Width;
632
            inkBoard.Height = zoomAndPanCanvas.Height;
633

    
634

    
635

    
636
            if (!testPanel2.IsHidden)
637
            {
638
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
639
                //PDF모드일때 잠시 대기(강인구)
640
                if (IsSyncPDFMode)
641
                {
642
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
643
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
644

    
645
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
646
                    if (pdfpath.IsDownloading)
647
                    {
648
                        pdfpath.DownloadCompleted += (ex, arg) =>
649
                        {
650
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
651
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
652
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
653
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
654
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
655
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
656
                        };
657
                    }
658
                    else
659
                    {
660
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
661
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
662
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
663
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
664

    
665
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
666
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
667
                    }
668
                }
669
                else
670
                {
671
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
672
                    string uri2 = "";
673
                    if (userData.COMPANY != "EXT")
674
                    {
675
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
676
                    }
677
                    else
678
                    {
679
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
680
                    }
681

    
682
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
683
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
684

    
685
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
686
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
687
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
688
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
689
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
690
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
691

    
692
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
693
                    zoomAndPanControl.ZoomTo(new Rect
694
                    {
695
                        X = 0,
696
                        Y = 0,
697
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
698
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
699
                    });
700

    
701
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
702
                    if (defaultBitmapImage_Compare.IsDownloading)
703
                    {
704
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
705
                        {
706
                            Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare DownloadCompleted", 1);
707
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
708
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
709
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
710

    
711
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
712
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
713

    
714
                            zoomAndPanControl.ZoomTo(new Rect
715
                            {
716
                                X = 0,
717
                                Y = 0,
718
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
719
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
720
                            });
721
                        };
722
                    }
723
                }
724
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
725
            }
726

    
727
        }
728

    
729

    
730
        
731

    
732
        private void SetCommentPages(bool onlyMe = false)
733
        {
734
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
735
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
736
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
737
            {
738
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
739
                instance.UserName = item.UserName;
740
                instance.Depart = item.Depatment;
741
                instance.MarkupInfoID = item.MarkupInfoID;
742
                instance.IsSelected = true;
743
                instance.isConSolidation = item.Consolidate;
744
                instance.SetColor = item.DisplayColor;
745
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
746
                {
747
                    instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
748
                }
749
                else
750
                {
751
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
752
                }
753
                _pages.Add(instance);
754
            }
755
            this.pageNavigator.SetCommentList(_pages.ToList());
756
        }
757

    
758
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
759
        {
760
            if (e.MiddleButton == MouseButtonState.Pressed)
761
            {
762

    
763
            }
764
            e.Handled = true;
765
            if (e.Delta > 0)
766
            {
767
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
768
                ZoomIn(currentContentMousePoint);
769
            }
770
            else
771
            {
772
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
773
                ZoomOut(currentContentMousePoint);
774
            }
775
        }
776

    
777
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
778
        {
779
            e.Handled = true;
780
            if (e.Delta > 0)
781
            {
782
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
783
                ZoomIn_Sync(currentContentMousePoint);
784
            }
785
            else
786
            {
787
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
788
                ZoomOut_Sync(currentContentMousePoint);
789
            }
790
        }
791

    
792
        #region ZoomIn & ZoomOut
793

    
794
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
795
        {
796
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
797
                zoomAndPanControl.ContentZoomFocusY));
798
        }
799

    
800
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
801
        {
802
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
803
                zoomAndPanControl.ContentZoomFocusY));
804
        }
805

    
806

    
807
        //강인구 추가 (줌 인아웃 수치 변경)
808
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
809
        private void ZoomOut(Point contentZoomCenter)
810
        {
811
            if (zoomAndPanControl.ContentScale > 0.39)
812
            {
813
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
814
            }
815
            else
816
            {
817
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
818
            }
819

    
820
            if (zoomAndPanControl2 != null && Sync.IsChecked)
821
            {
822
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
823
            }
824
        }
825

    
826
        private void ZoomIn(Point contentZoomCenter)
827
        {
828
            if (zoomAndPanControl.ContentScale > 0.19)
829
            {
830
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
831
            }
832
            else
833
            {
834
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
835
            }
836

    
837
            if (zoomAndPanControl2 != null && Sync.IsChecked)
838
            {
839
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
840
            }
841

    
842
        }
843

    
844
        private void ZoomOut_Sync(Point contentZoomCenter)
845
        {
846
            if (zoomAndPanControl2.ContentScale > 0.39)
847
            {
848
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
849
            }
850
            else
851
            {
852
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
853
            }
854

    
855
            if (Sync.IsChecked)
856
            {
857
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
858
            }
859
        }
860

    
861
        private void ZoomIn_Sync(Point contentZoomCenter)
862
        {
863
            if (zoomAndPanControl2.ContentScale > 0.19)
864
            {
865
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
866
            }
867
            else
868
            {
869
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
870
            }
871

    
872
            if (Sync.IsChecked)
873
            {
874
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
875
            }
876
        }
877

    
878
        private void ZoomOut()
879
        {
880
            zoomAndPanControl.ContentScale -= 0.1;
881
            //if (zoomAndPanControl2 != null)
882
            //{
883
            //    zoomAndPanControl2.ContentScale -= 0.1;
884
            //}
885
        }
886

    
887
        private void ZoomIn()
888
        {
889
            zoomAndPanControl.ContentScale += 0.1;
890
            //if (zoomAndPanControl2 != null)
891
            //{
892
            //    zoomAndPanControl2.ContentScale += 0.1;
893
            //}
894
        }
895

    
896
        #endregion
897

    
898
        private void init()
899
        {
900
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
901
            {
902

    
903
                ControlList.Clear();
904
                listBox.Items.Clear();
905
                selected_item.Clear();
906

    
907
                (item as IMarkupCommonData).IsSelected = false;
908
            }
909

    
910
        }
911

    
912
        private HitTestResultBehavior MyCallback(HitTestResult result)
913
        {
914
            //this.cursor = Cursors.UpArrow;
915
            var element = result.VisualHit;
916
            while (element != null && !(element is CommentUserInfo))
917
                element = VisualTreeHelper.GetParent(element);
918

    
919
            if (element == null)
920
            {
921
                return HitTestResultBehavior.Stop;
922
            }
923
            else
924
            {
925
                if (element is CommentUserInfo)
926
                {
927
                    if (!hitList.Contains(element))
928
                    {
929
                        hitList.Add((CommentUserInfo)element);
930
                    }
931
                    else
932
                    {
933
                        return HitTestResultBehavior.Stop;
934
                    }
935
                }
936
            }
937
            return HitTestResultBehavior.Continue;
938
        }
939

    
940
        public void ReleaseSelectPath()
941
        {
942
            if (SelectionPath == null)
943
            {
944
                SelectionPath = new Path();
945
                SelectionPath.Name = "";
946
            }
947
            if (SelectionPath.Name != "")
948
            {
949
                SelectionPath.Name = "None";
950
            }
951
            SelectionPath.Opacity = 0.01;
952
            SelectionPath.RenderTransform = null;
953
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
954
        }
955

    
956
        #region 컨트롤 초기화 
957
        public void Control_Init(object control)
958
        {
959
            if (L_Size != 0 && (control as IPath) != null)
960
            {
961
                (control as IPath).LineSize = L_Size;
962
                L_Size = 0;
963
            }
964

    
965
            switch (control.GetType().Name)
966
            {
967
                case "RectangleControl":
968
                    {
969
                        (control as RectangleControl).StrokeColor = Brushes.Red;
970
                    }
971
                    break;
972
                case "CircleControl":
973
                    {
974
                        (control as CircleControl).StrokeColor = Brushes.Red;
975
                    }
976
                    break;
977
                case "TriControl":
978
                    {
979
                        (control as TriControl).StrokeColor = Brushes.Red;
980
                    }
981
                    break;
982
                case "RectCloudControl":
983
                    {
984
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
985
                    }
986
                    break;
987
                case "CloudControl":
988
                    {
989
                        (control as CloudControl).StrokeColor = Brushes.Red;
990
                    }
991
                    break;
992
                case "PolygonControl":
993
                    {
994
                        (control as PolygonControl).StrokeColor = Brushes.Red;
995
                    }
996
                    break;
997
                case "ArcControl":
998
                    {
999
                        (control as ArcControl).StrokeColor = Brushes.Red;
1000
                    }
1001
                    break;
1002
                case "ArrowArcControl":
1003
                    {
1004
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1005
                    }
1006
                    break;
1007
                case "LineControl":
1008
                    {
1009
                        (control as LineControl).StrokeColor = Brushes.Red;
1010
                    }
1011
                    break;
1012
                case "ArrowControl_Multi":
1013
                    {
1014
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1015
                    }
1016
                    break;
1017
                case "TextControl":
1018
                    {
1019
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1020
                    }
1021
                    break;
1022
                case "ArrowTextControl":
1023
                    {
1024
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1025
                    }
1026
                    break;
1027
                case "InsideWhiteControl":
1028
                    {
1029
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1030
                    }
1031
                    break;
1032
                case "OverlapWhiteControl":
1033
                    {
1034
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1035
                    }
1036
                    break;
1037
                case "ClipWhiteControl":
1038
                    {
1039
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1040
                    }
1041
                    break;
1042
                case "CoordinateControl":
1043
                    {
1044
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1045
                    }
1046
                    break;
1047
            }
1048
        }
1049
        #endregion
1050

    
1051
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1052
        {
1053
            //Control_Init(e.Source);
1054
        }
1055
        private Window _dragdropWindow = null;
1056

    
1057
        [DllImport("user32.dll")]
1058
        [return: MarshalAs(UnmanagedType.Bool)]
1059
        internal static extern bool GetCursorPos(ref Win32Point pt);
1060

    
1061
        [StructLayout(LayoutKind.Sequential)]
1062
        internal struct Win32Point
1063
        {
1064
            public Int32 X;
1065
            public Int32 Y;
1066
        };
1067
        public string symbol_id = null;
1068
        public long symbol_group_id;
1069
        public int symbol_SelectedIndex;
1070
        public ImageSource symbol_img;
1071
        public string symbol_Data = null;
1072
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1073
        {
1074
            if (this._dragdropWindow != null)
1075
            {
1076
                this._dragdropWindow.Close();
1077
                this._dragdropWindow = null;
1078
            }
1079

    
1080
            symbol_id = id;
1081
            symbol_group_id = group_id;
1082
            symbol_SelectedIndex = SelectedIndex;
1083
            symbol_Data = Data_;
1084
            symbol_img = img;
1085

    
1086
      
1087
            CreateDragDropWindow2(img);
1088
        }
1089

    
1090
        private void CreateDragDropWindow2(ImageSource image)
1091
        {
1092
            this._dragdropWindow = new Window();
1093
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1094
            _dragdropWindow.WindowStyle = WindowStyle.None;
1095
            _dragdropWindow.AllowsTransparency = true;           
1096
            _dragdropWindow.AllowDrop = false;
1097
            _dragdropWindow.Background = null;
1098
            _dragdropWindow.IsHitTestVisible = false;
1099
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1100
            _dragdropWindow.Topmost = true;
1101
            _dragdropWindow.ShowInTaskbar = false;
1102
            
1103
            Rectangle r = new Rectangle();
1104
            r.Width = image.Width;
1105
            r.Height = image.Height;
1106
            r.Opacity = 0.5;            
1107
            r.Fill = new ImageBrush(image);
1108
            this._dragdropWindow.Content = r;
1109

    
1110
            Win32Point w32Mouse = new Win32Point();
1111
            GetCursorPos(ref w32Mouse);
1112

    
1113
            //w32Mouse.X = getCurrentPoint.X;
1114
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1115
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1116
            this._dragdropWindow.Show();
1117
        }
1118

    
1119
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1120
        {
1121
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1122
            {
1123
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1124

    
1125
                Point currentPos = e.GetPosition(rect);
1126

    
1127
                floatingTip.HorizontalOffset = currentPos.X + 20;
1128
                floatingTip.VerticalOffset = currentPos.Y;
1129
            }
1130

    
1131
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1132
            
1133
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1134
            {
1135
                SetCursor();
1136
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1137
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1138

    
1139
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1140
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1141
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1142

    
1143
                if (Sync.IsChecked)
1144
                {
1145
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1146
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1147
                }
1148
            }
1149

    
1150
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1151
            {
1152
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1153
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1154
                SetCursor();
1155

    
1156
                if (currentControl != null)
1157
                {
1158
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1159
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1160
                    //강인구 추가
1161
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1162

    
1163
                    if ((currentControl as IPath) != null)
1164
                    {
1165
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1166
                    }
1167
                    if ((currentControl as LineControl) != null)
1168
                    {
1169
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1170
                    }
1171

    
1172
                    if ((currentControl as IShapeControl) != null)
1173
                    {
1174
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1175
                    }
1176
                    if ((currentControl as TextControl) != null)
1177
                    {
1178
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1179
                        {
1180
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1181
                        }
1182
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1183
                        {
1184
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1185
                        }
1186
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1187
                        {
1188
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1189
                        }
1190
                    }
1191
                    else if ((currentControl as ArrowTextControl) != null)
1192
                    {
1193
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1194
                        {
1195
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1196
                        }
1197
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1198
                        {
1199
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1200
                        }
1201
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1202
                        {
1203
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1204
                        }
1205
                    }
1206
                    else if ((currentControl as RectCloudControl) != null)
1207
                    {
1208
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1209
                    }
1210
                    else if ((currentControl as CloudControl) != null)
1211
                    {
1212
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1213
                    }
1214

    
1215
                    switch (controlType)
1216
                    {
1217
                        case (ControlType.Coordinate):
1218
                            {
1219
                                var control = currentControl as CoordinateControl;
1220
                                if (control != null)
1221
                                {
1222
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1223
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1224
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1225
                                }
1226
                            }
1227
                            break;
1228
                        case (ControlType.InsideWhite):
1229
                            {
1230
                                var control = currentControl as InsideWhiteControl;
1231
                                if (control != null)
1232
                                {
1233
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1234
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1235
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1236
                                    control.Paint = PaintSet.Fill;
1237
                                }
1238
                            }
1239
                            break;
1240
                        case ControlType.OverlapWhite:
1241
                            {
1242
                                var control = currentControl as OverlapWhiteControl;
1243
                                if (control != null)
1244
                                {
1245
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1246
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1247
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1248
                                    control.Paint = PaintSet.Fill;
1249
                                }
1250
                            }
1251
                            break;
1252
                        case ControlType.ClipWhite:
1253
                            {
1254
                                var control = currentControl as ClipWhiteControl;
1255
                                if (control != null)
1256
                                {
1257
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1258
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1259
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1260
                                    control.Paint = PaintSet.Fill;
1261
                                }
1262
                            }
1263
                            break;
1264
                        case ControlType.RectCloud:
1265
                            {
1266
                                var control = currentControl as RectCloudControl;
1267
                                if (control != null)
1268
                                {
1269
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1270
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1271
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1272
                                }
1273
                            }
1274
                            break;
1275
                        case ControlType.SingleLine:
1276
                        case ControlType.CancelLine:
1277
                        case ControlType.ArrowLine:
1278
                        case ControlType.TwinLine:
1279
                        case ControlType.DimLine:
1280
                            {
1281
                                var control = currentControl as LineControl;
1282
                                if (control != null)
1283
                                {
1284
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1285
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1286
                                }
1287
                            }
1288
                            break;
1289

    
1290
                        case ControlType.ArcLine:
1291
                            {
1292
                                var control = currentControl as ArcControl;
1293
                                if (control != null)
1294
                                {
1295
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1296
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1297
                                }
1298
                            }
1299
                            break;
1300

    
1301
                        case ControlType.ArcArrow:
1302
                            {
1303
                                var control = currentControl as ArrowArcControl;
1304
                                if (control != null)
1305
                                {
1306
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1307
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1308
                                }
1309
                            }
1310
                            break;
1311

    
1312
                        case ControlType.ArrowMultiLine:
1313
                            {
1314
                                var control = currentControl as ArrowControl_Multi;
1315
                                if (control != null)
1316
                                {
1317
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1318
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1319
                                }
1320
                            }
1321
                            break;
1322

    
1323
                        case ControlType.Circle:
1324
                            {
1325
                                if (currentControl != null)
1326
                                {
1327
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1328
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1329
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1330
                                }
1331
                            }
1332
                            break;
1333

    
1334
                        case ControlType.PolygonCloud:
1335
                            {
1336
                                var control = currentControl as CloudControl;
1337
                                if (control != null)
1338
                                {
1339
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1340
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1341
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1342
                                }
1343
                            }
1344
                            break;
1345

    
1346
                        case ControlType.Triangle:
1347
                            {
1348
                                var control = currentControl as TriControl;
1349
                                if (control != null)
1350
                                {
1351
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1352
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1353
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1354
                                }
1355
                            }
1356
                            break;
1357

    
1358
                        case ControlType.ImgControl:
1359
                            {
1360
                                var control = currentControl as ImgControl;
1361
                                if (control != null)
1362
                                {
1363
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1364
                                }
1365
                            }
1366
                            break;
1367

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

    
1378
                        case ControlType.ArrowTextControl:
1379
                        case ControlType.ArrowTransTextControl:
1380
                        case ControlType.ArrowTextBorderControl:
1381
                        case ControlType.ArrowTransTextBorderControl:
1382
                        case ControlType.ArrowTextCloudControl:
1383
                        case ControlType.ArrowTransTextCloudControl:
1384
                            {
1385
                                var control = currentControl as ArrowTextControl;
1386
                                if (control != null)
1387
                                {
1388
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1389
                                }
1390
                            }
1391
                            break;
1392
                        case ControlType.PolygonControl:
1393
                        case ControlType.ChainLine:
1394
                            {
1395
                                var control = currentControl as PolygonControl;
1396
                                if (control != null)
1397
                                {
1398
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1399
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1400
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1401
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1402
                                }
1403
                            }
1404
                            break;
1405
                        case ControlType.Sign:
1406
                            {
1407
                                var control = currentControl as SignControl;
1408
                                if (control != null)
1409
                                {
1410
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1411
                                }
1412
                            }
1413
                            break;
1414
                        case ControlType.Symbol:
1415
                            {
1416
                                var control = currentControl as SymControl;
1417
                                if (control != null)
1418
                                {
1419
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1420
                                }
1421
                            }
1422
                            break;
1423
                        case ControlType.Stamp:
1424
                            {
1425
                                var control = currentControl as SymControlN;
1426
                                if (control != null)
1427
                                {
1428
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1429
                                }
1430
                            }
1431
                            break;
1432
                        case ControlType.Rectangle:
1433
                        case ControlType.Mark:
1434
                            {
1435
                                var control = currentControl as RectangleControl;
1436
                                if (control != null)
1437
                                {
1438
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1439
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1440
                                }
1441
                            }
1442
                            break;
1443
                        case ControlType.PenControl:
1444
                            {
1445
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1446
                                //inkBoard.Strokes.Add(stroke);
1447
                            }
1448
                            break;
1449
                        default:
1450
                            break;
1451
                    }
1452
                }
1453
            }
1454
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1455
            {
1456
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1457
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1458
                SetCursor();
1459
                if (currentControl == null)
1460
                {
1461
                    switch (controlType)
1462
                    {
1463
                        case ControlType.PenControl:
1464
                            {
1465
                                if (inkBoard.Tag.ToString() == "Ink")
1466
                                {
1467
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1468
                                }
1469
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1470
                                {
1471
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1472
                                }
1473
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1474
                                {
1475
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1476
                                }
1477

    
1478
                                //inkBoard.Strokes.Add(stroke);
1479
                            }
1480
                            break;
1481
                    }
1482
                    return;
1483
                }
1484
            }
1485
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1486
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1487
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1488
            {
1489
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1490

    
1491
                if (isDraggingSelectionRect)
1492
                {
1493
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1494
                    e.Handled = true;
1495
                }
1496
                else if (isLeftMouseButtonDownOnWindow)
1497
                {
1498
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1499
                    double dragDistance = Math.Abs(dragDelta.Length);
1500

    
1501
                    if (dragDistance > DragThreshold)
1502
                    {
1503
                        isDraggingSelectionRect = true;
1504
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1505
                    }
1506

    
1507
                    e.Handled = true;
1508
                }
1509

    
1510
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1511
                {
1512
                }
1513
                else
1514
                {
1515
                    e.Handled = true;
1516
                }
1517
            }
1518
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1519
            { //symbol      
1520
                if(_dragdropWindow != null)
1521
                {
1522
                    Win32Point w32Mouse = new Win32Point();
1523
                    GetCursorPos(ref w32Mouse);
1524

    
1525
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1526
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1527
                }                
1528
            }
1529
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1530
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1531
            {
1532
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1533
                if(control != null)
1534
                {
1535
                    this.cursor = Cursors.Hand;
1536
                    SetCursor();
1537
                }
1538
                else
1539
                {
1540
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1541
                    SetCursor();
1542
                }
1543
            }
1544
            else
1545
            {
1546
            }
1547
        }
1548

    
1549
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1550
        {
1551
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1552
            {
1553
                SetCursor();
1554
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1555
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1556

    
1557
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1558

    
1559
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1560
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1561

    
1562
                if (Sync.IsChecked)
1563
                {
1564
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1565
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1566
                }
1567
            }
1568
        }
1569

    
1570
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1571

    
1572
        private EllipseGeometry hitArea = new EllipseGeometry();
1573

    
1574
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1575
        {
1576
            IsDrawing = false;
1577

    
1578
            if (mouseHandlingMode != MouseHandlingMode.None)
1579
            {
1580
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1581
                {
1582
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1583

    
1584
                    SetCursor();
1585

    
1586
                    switch (controlType)
1587
                    {
1588
                        case ControlType.None:
1589
                            break;
1590
                        case ControlType.Rectangle:
1591
                            {
1592

    
1593
                            }
1594
                            break;
1595
                        case ControlType.PenControl:
1596
                            {
1597

    
1598
                            }
1599
                            break;
1600
                        default:
1601
                            break;
1602
                    }
1603
                }
1604
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1605
                {
1606
                    if (isLeftMouseButtonDownOnWindow)
1607
                    {
1608
                        bool wasDragSelectionApplied = false;
1609

    
1610
                        if (isDraggingSelectionRect)
1611
                        {
1612
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1613
                            {
1614
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1615
                                mouseHandlingMode = MouseHandlingMode.None;
1616
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1617
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1618
                                Set_Symbol_Capture(endPoint);
1619
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1620
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1621
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1622
                            }
1623
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1624
                            {
1625
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1626
                                mouseHandlingMode = MouseHandlingMode.None;
1627
                                Set_Capture();
1628

    
1629
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1630
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1631
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1632
                            }
1633
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1634
                            {
1635
                                ApplyDragSelectionRect();
1636
                            }
1637
                            else
1638
                            {
1639
                                double x = Canvas.GetLeft(dragZoomBorder);
1640
                                double y = Canvas.GetTop(dragZoomBorder);
1641
                                double width = dragZoomBorder.Width;
1642
                                double height = dragZoomBorder.Height;
1643
                                Rect dragRect = new Rect(x, y, width, height);
1644

    
1645
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1646

    
1647
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1648
                            }
1649

    
1650
                            isDraggingSelectionRect = false;
1651
                            e.Handled = true;
1652
                            wasDragSelectionApplied = true;
1653
                        }
1654

    
1655
                        if (isLeftMouseButtonDownOnWindow)
1656
                        {
1657
                            isLeftMouseButtonDownOnWindow = false;
1658
                            this.ReleaseMouseCapture();
1659
                            e.Handled = true;
1660
                        }
1661

    
1662
                        if (!wasDragSelectionApplied)
1663
                        {
1664
                            init();
1665
                        }
1666
                    }
1667
                }
1668
                else if (e.RightButton == MouseButtonState.Pressed)
1669
                {
1670
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1671
                    SetCursor();
1672
                }
1673

    
1674
                zoomAndPanControl.ReleaseMouseCapture();
1675

    
1676

    
1677
                e.Handled = true;
1678
            }
1679
            else
1680
            {
1681
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1682
                SetCursor();
1683
            }
1684

    
1685
            ///mouseButtonDown = MouseButton.Left;
1686
            //controlType = ControlType.SingleLine;
1687
        }
1688

    
1689
        public void Set_Symbol_Capture(Point endPoint)
1690
        {       
1691
            double x = canvasDrawingMouseDownPoint.X;
1692
            double y = canvasDrawingMouseDownPoint.Y;
1693
            if(x > endPoint.X)
1694
            {
1695
                x = endPoint.X;
1696
                y = endPoint.Y;
1697
            }
1698

    
1699
            double width = dragCaptureBorder.Width;
1700
            double height = dragCaptureBorder.Height;
1701

    
1702
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1703

    
1704
            if (x < 0)
1705
            {
1706
                width += x;
1707
                x = 0;
1708
            }
1709
            if (y < 0)
1710
            {
1711
                height += y;
1712
                y = 0;
1713

    
1714
                width = (int)canvasImage.PixelWidth - x;
1715
            }
1716
            if (x + width > canvasImage.PixelWidth)
1717
            {
1718
                width = (int)canvasImage.PixelWidth - x;
1719
            }
1720
            if (y + height > canvasImage.PixelHeight)
1721
            {
1722
                height = (int)canvasImage.PixelHeight - y;
1723
            }
1724
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1725

    
1726
            string uri = "";
1727
            if (userData.COMPANY != "EXT")
1728
            {
1729
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1730
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1731
            }
1732
            else
1733
            {
1734
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1735
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1736
            }
1737

    
1738
            var defaultBitmapImage = new BitmapImage();
1739
            defaultBitmapImage.BeginInit();
1740
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1741
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1742
            defaultBitmapImage.UriSource = new Uri(uri);
1743
            defaultBitmapImage.EndInit();
1744

    
1745
            //GC.Collect();
1746

    
1747
            if (defaultBitmapImage.IsDownloading)
1748
            {
1749
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1750
                {
1751
                    defaultBitmapImage.Freeze();
1752
                    //GC.Collect();
1753
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1754
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1755
                };
1756
            }
1757
        }
1758

    
1759
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1760
        {
1761
            ///mouseButtonDown = MouseButton.Left;
1762
        }
1763

    
1764
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1765
        {
1766
            ///mouseButtonDown = MouseButton.Left;
1767
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1768
        }
1769

    
1770
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1771
        {
1772

    
1773
        }
1774

    
1775
        /// <summary>
1776
        /// select items by dragging
1777
        /// </summary>
1778
        private void ApplyDragSelectionRect()
1779
        {
1780
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1781

    
1782
            double x = Canvas.GetLeft(dragSelectionBorder);
1783
            double y = Canvas.GetTop(dragSelectionBorder);
1784
            double width = dragSelectionBorder.Width;
1785
            double height = dragSelectionBorder.Height;
1786
            Boolean Flag = false;
1787
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1788
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1789

    
1790
            Rect dragRect = new Rect(x, y, width, height);
1791
            ///dragRect.Inflate(width / 10, height / 10);
1792

    
1793
            foreach (var item in Items)
1794
            {
1795
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1796

    
1797
                if (Flag)
1798
                {
1799
                    adornerSet.Add(item);
1800
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1801
                    Control_Style(item);
1802
                }
1803
            }
1804
            if (adornerSet.Count > 0)
1805
            {
1806
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1807
                SelectLayer.Children.Add(final);
1808
            }
1809
        }
1810

    
1811
        private void InitDragSelectionRect(Point pt1, Point pt2)
1812
        {
1813
            //캡쳐 중
1814
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1815
            {
1816
                dragCaptureBorder.Visibility = Visibility.Visible;
1817
            }
1818
            //선택 중
1819
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1820
            {
1821

    
1822
                dragSelectionBorder.Visibility = Visibility.Visible;
1823
            }
1824
            else
1825
            {
1826
                dragZoomBorder.Visibility = Visibility.Visible;
1827
            }
1828
            UpdateDragSelectionRect(pt1, pt2);
1829
        }
1830

    
1831
        /// <summary>
1832
        /// Update the position and size of the rectangle used for drag selection.
1833
        /// </summary>
1834
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1835
        {
1836
            double x, y, width, height;
1837

    
1838
            //
1839
            // Determine x,y,width and height of the rect inverting the points if necessary.
1840
            // 
1841

    
1842
            if (pt2.X < pt1.X)
1843
            {
1844
                x = pt2.X;
1845
                width = pt1.X - pt2.X;
1846
            }
1847
            else
1848
            {
1849
                x = pt1.X;
1850
                width = pt2.X - pt1.X;
1851
            }
1852

    
1853
            if (pt2.Y < pt1.Y)
1854
            {
1855
                y = pt2.Y;
1856
                height = pt1.Y - pt2.Y;
1857
            }
1858
            else
1859
            {
1860
                y = pt1.Y;
1861
                height = pt2.Y - pt1.Y;
1862
            }
1863

    
1864
            //
1865
            // Update the coordinates of the rectangle used for drag selection.
1866
            //
1867
            //캡쳐 중
1868
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1869
            {
1870
                Canvas.SetLeft(dragCaptureBorder, x);
1871
                Canvas.SetTop(dragCaptureBorder, y);
1872
                dragCaptureBorder.Width = width;
1873
                dragCaptureBorder.Height = height;
1874
            }
1875
            //선택 중
1876
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1877
            {
1878
                Canvas.SetLeft(dragSelectionBorder, x);
1879
                Canvas.SetTop(dragSelectionBorder, y);
1880
                dragSelectionBorder.Width = width;
1881
                dragSelectionBorder.Height = height;
1882
            }
1883
            else
1884
            {
1885
                Canvas.SetLeft(dragZoomBorder, x);
1886
                Canvas.SetTop(dragZoomBorder, y);
1887
                dragZoomBorder.Width = width;
1888
                dragZoomBorder.Height = height;
1889
            }
1890
        }
1891

    
1892
        private void drawingPannelRotate(double angle)
1893
        {
1894
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1895
            rotate.Angle = angle;
1896
            var rotationNum = Math.Abs((rotate.Angle / 90));
1897

    
1898
            if (angle == 90 || angle == 270)
1899
            {
1900
                double emptySize = zoomAndPanCanvas.Width;
1901
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1902
                zoomAndPanCanvas.Height = emptySize;
1903
            }
1904
            if (angle == 0)
1905
            {
1906
                translate.X = 0;
1907
                translate.Y = 0;
1908
            }
1909
            else if (angle == 90)
1910
            {
1911
                translate.X = zoomAndPanCanvas.Width;
1912
                translate.Y = 0;
1913
            }
1914
            else if (angle == 180)
1915
            {
1916
                translate.X = zoomAndPanCanvas.Width;
1917
                translate.Y = zoomAndPanCanvas.Height;
1918
            }
1919
            else
1920
            {
1921
                translate.X = 0;
1922
                translate.Y = zoomAndPanCanvas.Height;
1923
            }
1924

    
1925
            zoomAndPanControl.RotationAngle = rotate.Angle;
1926

    
1927

    
1928
            if (!testPanel2.IsHidden)
1929
            {
1930
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1931
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1932
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1933
            }
1934

    
1935
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1936
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1937
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1938
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1939
            ViewerDataModel.Instance.Angle = rotate.Angle;
1940
        }
1941

    
1942
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1943
        {
1944
            string Data_ = "";
1945

    
1946
            try
1947
            {
1948
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1949
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1950
                if (Data_ != null || Data_ != "")
1951
                {
1952
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1953
                }
1954
                else
1955
                {
1956
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1957
                }
1958

    
1959
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
1960
                //{
1961
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
1962
                //    STATE = 0,
1963
                //};
1964
                if (Data_ != null)
1965
                {
1966
                    Image img = new Image();
1967
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
1968
                    if (Data_.Contains(".svg"))
1969
                    {
1970
                        byte[] imageData = null;
1971
                        DrawingImage image = null;
1972
                        using (System.Net.WebClient web = new System.Net.WebClient())
1973
                        {
1974
                            imageData = web.DownloadData(new Uri(Data_));
1975
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
1976
                            image = SvgReader.Load(stream);
1977
                        }
1978
                        img.Source = image;
1979
                    }
1980
                    else
1981
                    {
1982
                        img.Source = new BitmapImage(new Uri(Data_));
1983
                    }
1984

    
1985
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
1986
                    {
1987
                        PointSet = new List<Point>(),
1988
                        FilePath = Data_,
1989
                        ImageData = img.Source,
1990
                        StartPoint = canvasZoomPanningMouseDownPoint,
1991
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
1992
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
1993
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
1994
                        canvasZoomPanningMouseDownPoint.Y),
1995
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
1996
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
1997
                    };
1998

    
1999
                    currentControl.PointSet = new List<Point>
2000
                                        {
2001
                                            currentControl.StartPoint,
2002
                                            currentControl.LeftBottomPoint,
2003
                                            currentControl.EndPoint,
2004
                                            currentControl.TopRightPoint,
2005
                                        };
2006
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2007
                    UndoData = new Undo_data()
2008
                    {
2009
                        IsUndo = false,
2010
                        Event = Event_Type.Create,
2011
                        EventTime = DateTime.Now,
2012
                        Markup_List = new List<Multi_Undo_data>()
2013
                    };
2014
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2015
                    {
2016
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2017
                    });
2018

    
2019
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2020
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2021
                    UndoData.Markup_List.Add(multi_Undo_Data);
2022
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2023

    
2024
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2025
                    currentControl.CommentID = Commons.shortGuid();
2026
                    currentControl.SymbolID = id;
2027
                    currentControl.GroupID = group_id;
2028
                    currentControl.ApplyTemplate();
2029
                    currentControl.SetImage();
2030

    
2031
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2032
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2033
                    SelectLayer.Children.Add(final);
2034
                }
2035
            }
2036
            catch (Exception ex)
2037
            {
2038
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2039
            }
2040
        }
2041

    
2042
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2043
        {            
2044
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2045
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2046
            {
2047
                set_option.Value = double.Parse(set_option.ContentText);
2048
            }
2049

    
2050
            InkControl_Convert();
2051

    
2052
            ///TODO:
2053
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2054
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2055

    
2056
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2057
            {
2058
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2059
            }
2060
            /// up to here
2061

    
2062
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2063
            {
2064
                if (arrow_text as ArrowTextControl != null)
2065
                {
2066
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2067
                }
2068
            }
2069

    
2070
            //if (currentControl != null)
2071
            {
2072
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2073
                if (text_item_ != null)
2074
                {
2075
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2076
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2077
                    (text_item_ as TextControl).IsEditing = false;
2078
                    (text_item_ as TextControl).EnableEditing = false;
2079
                    currentControl = null;
2080
                }
2081

    
2082
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2083
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2084
                {
2085
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2086
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2087
                    currentControl = null;
2088
                }
2089
            }
2090

    
2091
            double Ang = 0;                                          
2092
            if (rotate.Angle != 0)
2093
            {
2094
                Ang = 360 - rotate.Angle;
2095
            }
2096

    
2097
            if (e.OriginalSource is System.Windows.Controls.Image)
2098
            {
2099
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2100
            }
2101

    
2102
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2103
            {                
2104
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2105
                if(symbol_id != null)
2106
                {
2107
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2108
                }                
2109
            }
2110

    
2111
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2112
            {
2113
                if (this._dragdropWindow != null)
2114
                {
2115
                    this._dragdropWindow.Close();
2116
                    this._dragdropWindow = null;
2117
                    symbol_id = null;
2118
                }
2119
            }
2120

    
2121
            if (e.LeftButton == MouseButtonState.Pressed)
2122
            {
2123
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2124
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2125

    
2126
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2127
                SetCursor();
2128

    
2129
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2130
            }
2131

    
2132
            if (e.MiddleButton == MouseButtonState.Pressed)
2133
            {
2134
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2135
                cursor = Cursors.SizeAll;
2136
                SetCursor();
2137
            }
2138
            if (e.RightButton == MouseButtonState.Pressed)
2139
            {
2140
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2141
                cursor = Cursors.SizeAll;
2142
                SetCursor();
2143
            }
2144
            else if (e.XButton1 == MouseButtonState.Pressed)
2145
            {
2146
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2147
                {
2148
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2149
                }
2150

    
2151
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2152

    
2153
            }
2154
            else if (e.XButton2 == MouseButtonState.Pressed)
2155
            {
2156
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2157
                {
2158
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2159
                }
2160
            }
2161

    
2162
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2163
            {
2164
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2165
                {
2166
                    if (SelectLayer.Children.Count == 0)
2167
                    {
2168
                        isLeftMouseButtonDownOnWindow = true;
2169
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2170
                    }
2171

    
2172
                    if (controlType == ControlType.None)
2173
                    {
2174
                        isLeftMouseButtonDownOnWindow = true;
2175
                    }
2176
                }
2177

    
2178
                /// 캡쳐 모드 설정
2179
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2180
                {
2181
                    dragCaptureBorder.Visibility = Visibility.Visible;
2182
                    isLeftMouseButtonDownOnWindow = true;
2183
                }
2184

    
2185
                /// 줌 모드 설정
2186
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2187
                {
2188
                    isLeftMouseButtonDownOnWindow = true;
2189
                }
2190

    
2191
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2192
                if (control != null)
2193
                {
2194
                    AdornerFinal final = null;
2195

    
2196
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2197
                    {
2198
                        /// 기존 selection 해제
2199
                        SelectionSet.Instance.UnSelect(this);
2200

    
2201
                        final = new AdornerFinal(control);
2202

    
2203
                        this.Control_Style(control);
2204

    
2205
                        if ((control as IPath) != null)
2206
                        {
2207
                            if ((control as IPath).LineSize != 0)
2208
                            {
2209
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2210
                            }
2211
                        }
2212
                        if ((control as IShapeControl) != null)
2213
                        {
2214
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2215
                            {
2216
                                ViewerDataModel.Instance.checkHatchShape = true;
2217
                            }
2218
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2219
                            {
2220
                                ViewerDataModel.Instance.checkFillShape = true;
2221
                            }
2222
                            else
2223
                            {
2224
                                ViewerDataModel.Instance.checkHatchShape = false;
2225
                                ViewerDataModel.Instance.checkFillShape = false;
2226
                            }
2227
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2228
                        }
2229

    
2230
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2231

    
2232
                        if ((control as TextControl) != null)
2233
                        {
2234
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2235
                            {
2236
                                ViewerDataModel.Instance.checkTextStyle = true;
2237
                            }
2238
                            else
2239
                            {
2240
                                ViewerDataModel.Instance.checkTextStyle = false;
2241
                            }
2242

    
2243
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2244
                            {
2245
                                ViewerDataModel.Instance.checkTextStyle = true;
2246
                            }
2247
                            else
2248
                            {
2249
                                ViewerDataModel.Instance.checkTextStyle = false;
2250
                            }
2251
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2252
                            {
2253
                                ViewerDataModel.Instance.checkTextWeight = true;
2254
                            }
2255
                            else
2256
                            {
2257
                                ViewerDataModel.Instance.checkTextWeight = false;
2258
                            }
2259
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2260
                            {
2261
                                ViewerDataModel.Instance.checkUnderLine = true;
2262
                            }
2263
                            else
2264
                            {
2265
                                ViewerDataModel.Instance.checkUnderLine = false;
2266
                            }
2267
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2268
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2269

    
2270
                        }
2271
                        else if ((control as ArrowTextControl) != null)
2272
                        {
2273
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2274
                            {
2275
                                ViewerDataModel.Instance.checkTextStyle = true;
2276
                            }
2277
                            else
2278
                            {
2279
                                ViewerDataModel.Instance.checkTextStyle = false;
2280
                            }
2281

    
2282
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2283
                            {
2284
                                ViewerDataModel.Instance.checkTextStyle = true;
2285
                            }
2286
                            else
2287
                            {
2288
                                ViewerDataModel.Instance.checkTextStyle = false;
2289
                            }
2290
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2291
                            {
2292
                                ViewerDataModel.Instance.checkTextWeight = true;
2293
                            }
2294
                            else
2295
                            {
2296
                                ViewerDataModel.Instance.checkTextWeight = false;
2297
                            }
2298
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2299
                            {
2300
                                ViewerDataModel.Instance.checkUnderLine = true;
2301
                            }
2302
                            else
2303
                            {
2304
                                ViewerDataModel.Instance.checkUnderLine = false;
2305
                            }
2306
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2307
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2308
                        }
2309
                        else if ((control as RectCloudControl) != null)
2310
                        {
2311
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2312
                        }
2313
                        else if ((control as CloudControl) != null)
2314
                        {
2315
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2316
                        }
2317
                    }
2318
                    else
2319
                    {
2320
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2321
                        SelectionSet.Instance.UnSelect(this);
2322
                        comment.Add(control);
2323

    
2324
                        Control_Style(control);
2325

    
2326
                        final = new AdornerFinal(comment);
2327
                    }
2328

    
2329
                    if (final != null)
2330
                    {
2331
                        this.SelectLayer.Children.Add(final);
2332
                    }
2333
                }              
2334
            }
2335
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2336
            {               
2337
                init();
2338
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2339
                if (cursor != Cursors.SizeAll)
2340
                {
2341
                    cursor = Cursors.Cross;
2342
                    SetCursor();
2343
                }
2344
                bool init_user = false;
2345
                foreach (var user in gridViewMarkup.Items)
2346
                {
2347
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2348
                    {
2349
                        init_user = true;
2350
                    }
2351
                }
2352
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2353
                {
2354
                    RadWindow.Alert(new DialogParameters
2355
                    {
2356
                        Owner = Application.Current.MainWindow,
2357
                        Theme = new VisualStudio2013Theme(),
2358
                        Header = "안내",
2359
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2360
                    });
2361
                    return;
2362
                }
2363
                else
2364
                {
2365
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2366
                    if (item != null)
2367
                    {
2368
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2369
                    }
2370
                }
2371

    
2372
                switch (controlType)
2373
                {
2374
                    case ControlType.Coordinate:
2375
                        {
2376
                            if (e.LeftButton == MouseButtonState.Pressed)
2377
                            {
2378
                                if (currentControl is CoordinateControl)
2379
                                {
2380
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2381
                                    {
2382
                                        return;
2383
                                    }
2384

    
2385
                                    CreateCommand.Instance.Execute(currentControl);
2386

    
2387
                                    currentControl = null;
2388
                                    this.cursor = Cursors.Arrow;
2389
                                }
2390
                                else
2391
                                {
2392
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2393
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2394
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2395
                                    {
2396
                                        currentControl = null;
2397
                                        this.cursor = Cursors.Arrow;
2398
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2399
                                        return;
2400
                                    }
2401
                                    else
2402
                                    {
2403
                                        currentControl = new CoordinateControl
2404
                                        {
2405
                                            Background = new SolidColorBrush(Colors.Black),
2406
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2407
                                            ControlType = ControlType.Coordinate
2408
                                        };
2409

    
2410
                                        currentControl.CommentID = Commons.shortGuid();
2411
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2412
                                        currentControl.IsNew = true;
2413

    
2414
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2415

    
2416
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2417
                                    }
2418
                                }
2419
                            }
2420
                        }
2421
                        break;
2422
                    case ControlType.InsideWhite:
2423
                        {
2424
                            if (e.LeftButton == MouseButtonState.Pressed)
2425
                            {
2426
                                if (currentControl is InsideWhiteControl)
2427
                                {
2428
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2429
                                    {
2430
                                        return;
2431
                                    }
2432

    
2433
                                    CreateCommand.Instance.Execute(currentControl);
2434

    
2435
                                    currentControl = null;
2436
                                    this.cursor = Cursors.Arrow;
2437
                                }
2438
                                else
2439
                                {
2440
                                    currentControl = new InsideWhiteControl
2441
                                    {
2442
                                        Background = new SolidColorBrush(Colors.Black),
2443
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2444
                                        ControlType = ControlType.InsideWhite
2445
                                    };
2446

    
2447
                                    currentControl.CommentID = Commons.shortGuid();
2448
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2449
                                    currentControl.IsNew = true;
2450
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2451

    
2452
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2453
                                }
2454
                            }
2455
                        }
2456
                        break;
2457
                    case ControlType.OverlapWhite:
2458
                        {
2459
                            if (e.LeftButton == MouseButtonState.Pressed)
2460
                            {
2461
                                if (currentControl is OverlapWhiteControl)
2462
                                {
2463
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2464
                                    {
2465
                                        return;
2466
                                    }
2467

    
2468
                                    CreateCommand.Instance.Execute(currentControl);
2469

    
2470
                                    currentControl = null;
2471
                                    this.cursor = Cursors.Arrow;
2472
                                }
2473
                                else
2474
                                {
2475
                                    currentControl = new OverlapWhiteControl
2476
                                    {
2477
                                        Background = new SolidColorBrush(Colors.Black),
2478
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2479
                                        ControlType = ControlType.OverlapWhite
2480
                                    };
2481

    
2482
                                    currentControl.CommentID = Commons.shortGuid();
2483
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2484
                                    currentControl.IsNew = true;
2485
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2486

    
2487
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2488
                                }
2489
                            }
2490
                        }
2491
                        break;
2492
                    case ControlType.ClipWhite:
2493
                        {
2494
                            if (e.LeftButton == MouseButtonState.Pressed)
2495
                            {
2496
                                if (currentControl is ClipWhiteControl)
2497
                                {
2498
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2499
                                    {
2500
                                        return;
2501
                                    }
2502

    
2503
                                    CreateCommand.Instance.Execute(currentControl);
2504

    
2505
                                    currentControl = null;
2506
                                    this.cursor = Cursors.Arrow;
2507
                                }
2508
                                else
2509
                                {
2510
                                    currentControl = new ClipWhiteControl
2511
                                    {
2512
                                        Background = new SolidColorBrush(Colors.Black),
2513
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2514
                                        ControlType = ControlType.ClipWhite
2515
                                    };
2516

    
2517
                                    currentControl.CommentID = Commons.shortGuid();
2518
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2519
                                    currentControl.IsNew = true;
2520
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2521

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

    
2539
                                    CreateCommand.Instance.Execute(currentControl);
2540
                                    currentControl = null;
2541
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2542
                                }
2543
                                else
2544
                                {
2545
                                    currentControl = new RectangleControl
2546
                                    {
2547
                                        Background = new SolidColorBrush(Colors.Black),
2548
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2549
                                        ControlType = ControlType.Rectangle
2550
                                    };
2551

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

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

    
2574
                                    CreateCommand.Instance.Execute(currentControl);
2575

    
2576
                                    currentControl = null;
2577
                                
2578
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2579
                                }
2580
                                else
2581
                                {
2582
                                    currentControl = new RectCloudControl
2583
                                    {
2584
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2585
                                        ControlType = ControlType.RectCloud,
2586
                                        Background = new SolidColorBrush(Colors.Black)
2587
                                    };
2588

    
2589
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2590
                                    currentControl.CommentID = Commons.shortGuid();
2591
                                    currentControl.IsNew = true;
2592
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2593
                                }
2594
                            }
2595
                        }
2596
                        break;
2597
                    case ControlType.Circle:
2598
                        {
2599
                            if (e.LeftButton == MouseButtonState.Pressed)
2600
                            {
2601
                                if (currentControl is CircleControl)
2602
                                {
2603
                                    //20180906 LJY TEST IsRotationDrawingEnable
2604
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2605
                                    {
2606
                                        return;
2607
                                    }
2608

    
2609
                                    CreateCommand.Instance.Execute(currentControl);
2610

    
2611
                                    currentControl = null;
2612
                                }
2613
                                else
2614
                                {
2615
                                    currentControl = new CircleControl
2616
                                    {
2617
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2618
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2619
                                        Background = new SolidColorBrush(Colors.Black)
2620
                                    };
2621

    
2622
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2623
                                    currentControl.CommentID = Commons.shortGuid();
2624
                                    currentControl.IsNew = true;
2625
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2626
                                }
2627
                            }
2628
                        }
2629
                        break;
2630
                    case ControlType.Triangle:
2631
                        {
2632
                            if (e.LeftButton == MouseButtonState.Pressed)
2633
                            {
2634
                                if (currentControl is TriControl)
2635
                                {
2636
                                    var content = currentControl as TriControl;
2637
                                    if (content.MidPoint == new Point(0, 0))
2638
                                    {
2639
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2640
                                    }
2641
                                    else
2642
                                    {
2643
                                        //20180906 LJY TEST IsRotationDrawingEnable
2644
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2645
                                        {
2646
                                            return;
2647
                                        }
2648

    
2649
                                        CreateCommand.Instance.Execute(currentControl);
2650

    
2651
                                        currentControl = null;
2652
                                    }
2653
                                }
2654
                                else
2655
                                {
2656
                                    currentControl = new TriControl
2657
                                    {
2658
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2659
                                        Background = new SolidColorBrush(Colors.Black),
2660
                                    };
2661

    
2662
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2663
                                    currentControl.CommentID = Commons.shortGuid();
2664
                                    currentControl.IsNew = true;
2665
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2666
                                }
2667
                            }
2668
                        }
2669
                        break;
2670
                    case ControlType.CancelLine:
2671
                    case ControlType.SingleLine:
2672
                    case ControlType.ArrowLine:
2673
                    case ControlType.TwinLine:
2674
                    case ControlType.DimLine:
2675
                        {
2676
                            if (e.LeftButton == MouseButtonState.Pressed)
2677
                            {
2678
                                if (currentControl is LineControl)
2679
                                {
2680
                                    //20180906 LJY TEST IsRotationDrawingEnable
2681
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2682
                                    {
2683
                                        return;
2684
                                    }
2685

    
2686
                                    CreateCommand.Instance.Execute(currentControl);
2687
                                    currentControl = null;
2688
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2689
                                }
2690
                                else
2691
                                {
2692
                                    currentControl = new LineControl
2693
                                    {
2694
                                        ControlType = this.controlType,
2695
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2696
                                        Background = new SolidColorBrush(Colors.Black)
2697
                                    };
2698

    
2699
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2700
                                    currentControl.CommentID = Commons.shortGuid();
2701
                                    currentControl.IsNew = true;
2702
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2703
                                    this.MainAngle.Visibility = Visibility.Visible;
2704
                                }
2705
                            }
2706
                        }
2707
                        break;
2708
                    case ControlType.PolygonControl:
2709
                        {
2710
                            if (currentControl is PolygonControl)
2711
                            {
2712
                                var control = currentControl as PolygonControl;
2713

    
2714
                                if (e.RightButton == MouseButtonState.Pressed)
2715
                                {
2716
                                    control.IsCompleted = true;
2717
                                }
2718

    
2719
                                if (!control.IsCompleted)
2720
                                {
2721
                                    control.PointSet.Add(control.EndPoint);
2722
                                }
2723
                                else
2724
                                {
2725
                                    //20180906 LJY TEST IsRotationDrawingEnable
2726
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2727
                                    {
2728
                                        return;
2729
                                    }
2730

    
2731
                                    var firstPoint = control.PointSet.First();
2732
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2733
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2734
                                    control.PointSet.Add(firstPoint);
2735

    
2736
                                    control.ApplyOverViewData();
2737

    
2738
                                    CreateCommand.Instance.Execute(currentControl);
2739
                                    control.updateControl();
2740
                                    currentControl = null;
2741
                                }
2742
                            }
2743
                            else
2744
                            {
2745
                                if (e.LeftButton == MouseButtonState.Pressed)
2746
                                {
2747
                                    currentControl = new PolygonControl
2748
                                    {
2749
                                        PointSet = new List<Point>(),
2750
                                    };
2751

    
2752
                                    var polygonControl = (currentControl as PolygonControl);
2753
                                    currentControl.CommentID = Commons.shortGuid();
2754
                                    currentControl.IsNew = true;
2755
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2756
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2757
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2758
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2759
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2760
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2761
                                    polygonControl.ApplyTemplate();
2762
                                    polygonControl.Visibility = Visibility.Visible;
2763
                                }
2764
                            }
2765
                        }
2766
                        break;
2767
                    case ControlType.ChainLine:
2768
                        {
2769
                            if (currentControl is PolygonControl)
2770
                            {
2771
                                var control = currentControl as PolygonControl;
2772

    
2773
                                if (e.RightButton == MouseButtonState.Pressed)
2774
                                {
2775
                                    //20180906 LJY TEST IsRotationDrawingEnable
2776
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2777
                                    {
2778
                                        return;
2779
                                    }
2780

    
2781
                                    CreateCommand.Instance.Execute(currentControl);
2782

    
2783
                                    currentControl = null;
2784
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2785
                                    return;
2786
                                }
2787

    
2788
                                if (!control.IsCompleted)
2789
                                {
2790
                                    control.PointSet.Add(control.EndPoint);
2791
                                    this.MainAngle.Visibility = Visibility.Visible;
2792
                                }
2793
                            }
2794
                            else
2795
                            {
2796
                                if (e.LeftButton == MouseButtonState.Pressed)
2797
                                {
2798
                                    MainAngle.Visibility = Visibility.Visible;
2799
                                    currentControl = new PolygonControl
2800
                                    {
2801
                                        PointSet = new List<Point>(),
2802
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2803
                                        ControlType = ControlType.ChainLine,
2804
                                        DashSize = ViewerDataModel.Instance.DashSize,
2805
                                        LineSize = ViewerDataModel.Instance.LineSize,
2806
                                        //PointC = new StylusPointSet()
2807
                                    };
2808

    
2809
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2810
                                    //{
2811
                                        var polygonControl = (currentControl as PolygonControl);
2812
                                        currentControl.CommentID = Commons.shortGuid();
2813
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2814
                                        currentControl.IsNew = true;
2815
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2816
                                        //currentControl.OnApplyTemplate();
2817
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2818
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2819
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2820
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2821
                                    //}
2822
                                }
2823
                            }
2824
                        }
2825
                        break;
2826
                    case ControlType.ArcLine:
2827
                        {
2828
                            if (e.LeftButton == MouseButtonState.Pressed)
2829
                            {
2830
                                if (currentControl is ArcControl)
2831
                                {
2832
                                    //20180906 LJY TEST IsRotationDrawingEnable
2833
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2834
                                    {
2835
                                        return;
2836
                                    }
2837

    
2838
                                    CreateCommand.Instance.Execute(currentControl);
2839

    
2840
                                    currentControl = null;
2841
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2842
                                }
2843
                                else
2844
                                {
2845
                                    currentControl = new ArcControl
2846
                                    {
2847
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2848
                                        Background = new SolidColorBrush(Colors.Black)
2849
                                    };
2850
                                    currentControl.CommentID = Commons.shortGuid();
2851
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2852
                                    currentControl.IsNew = true;
2853
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2854
                                    this.MainAngle.Visibility = Visibility.Visible;
2855
                                }
2856
                            }
2857
                            else if (e.RightButton == MouseButtonState.Pressed)
2858
                            {
2859
                                if (currentControl != null)
2860
                                {
2861
                                    (currentControl as ArcControl).setClock();
2862
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2863
                                }
2864
                            }
2865
                        }
2866
                        break;
2867
                    case ControlType.ArcArrow:
2868
                        {
2869
                            if (e.LeftButton == MouseButtonState.Pressed)
2870
                            {
2871
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2872
                                //{
2873
                                if (currentControl is ArrowArcControl)
2874
                                {
2875
                                    //20180906 LJY TEST IsRotationDrawingEnable
2876
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2877
                                    {
2878
                                        return;
2879
                                    }
2880

    
2881
                                    CreateCommand.Instance.Execute(currentControl);
2882

    
2883
                                    currentControl = null;
2884
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2885
                                }
2886
                                else
2887
                                {
2888
                                    currentControl = new ArrowArcControl
2889
                                    {
2890
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2891
                                        Background = new SolidColorBrush(Colors.Black)
2892
                                    };
2893
                                    currentControl.CommentID = Commons.shortGuid();
2894
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2895
                                    currentControl.IsNew = true;
2896
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2897
                                    this.MainAngle.Visibility = Visibility.Visible;
2898
                                }
2899
                                //}
2900
                            }
2901
                            else if (e.RightButton == MouseButtonState.Pressed)
2902
                            {
2903
                                if (currentControl != null)
2904
                                {
2905
                                    (currentControl as ArrowArcControl).setClock();
2906
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2907
                                    //(currentControl as ArcControl).ApplyTemplate();
2908
                                }
2909
                            }
2910
                        }
2911
                        break;
2912
                    case ControlType.ArrowMultiLine:
2913
                        {
2914
                            if (e.LeftButton == MouseButtonState.Pressed)
2915
                            {
2916
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2917
                                //{
2918

    
2919
                                    if (currentControl is ArrowControl_Multi)
2920
                                    {
2921
                                        var content = currentControl as ArrowControl_Multi;
2922
                                        if (content.MiddlePoint == new Point(0, 0))
2923
                                        {
2924
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2925
                                            {
2926
                                                content.MiddlePoint = content.EndPoint;
2927
                                            }
2928
                                            else
2929
                                            {
2930
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2931
                                            }
2932
                                        }
2933
                                        else
2934
                                        {
2935
                                            //20180906 LJY TEST IsRotationDrawingEnable
2936
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2937
                                            {
2938
                                                return;
2939
                                            }
2940

    
2941
                                            CreateCommand.Instance.Execute(currentControl);
2942

    
2943
                                            currentControl = null;
2944
                                            this.MainAngle.Visibility = Visibility.Collapsed;
2945
                                        }
2946
                                    }
2947
                                    else
2948
                                    {
2949
                                        currentControl = new ArrowControl_Multi
2950
                                        {
2951
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2952
                                            Background = new SolidColorBrush(Colors.Black)
2953
                                        };
2954
                                        currentControl.CommentID = Commons.shortGuid();
2955
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2956
                                        currentControl.IsNew = true;
2957
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2958
                                        this.MainAngle.Visibility = Visibility.Visible;
2959
                                    }
2960
                                //}
2961
                            }
2962
                        }
2963
                        break;
2964
                    case ControlType.PolygonCloud:
2965
                        {
2966
                            if (currentControl is CloudControl)
2967
                            {
2968
                                var control = currentControl as CloudControl;
2969
                                if (e.RightButton == MouseButtonState.Pressed)
2970
                                {
2971
                                    control.IsCompleted = true;
2972
                                }
2973

    
2974
                                if (!control.IsCompleted)
2975
                                {
2976
                                    control.PointSet.Add(control.EndPoint);
2977
                                }
2978
                                else
2979
                                {
2980
                                    //20180906 LJY TEST IsRotationDrawingEnable
2981
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2982
                                    {
2983
                                        return;
2984
                                    }
2985

    
2986
                                    CreateCommand.Instance.Execute(currentControl);
2987

    
2988
                                    control.isTransOn = true;
2989
                                    var firstPoint = control.PointSet.First();
2990

    
2991
                                    control.PointSet.Add(firstPoint);
2992
                                    control.DrawingCloud();
2993
                                    control.ApplyOverViewData();
2994

    
2995
                                    currentControl = null;
2996
                                }
2997
                            }
2998
                            else
2999
                            {
3000
                                if (e.LeftButton == MouseButtonState.Pressed)
3001
                                {
3002
                                    currentControl = new CloudControl
3003
                                    {
3004
                                        PointSet = new List<Point>(),
3005
                                        PointC = new StylusPointSet()
3006
                                    };
3007

    
3008
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3009
                                    //{
3010
                                        var polygonControl = (currentControl as CloudControl);
3011
                                        currentControl.CommentID = Commons.shortGuid();
3012
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3013
                                        currentControl.IsNew = true;
3014
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3015

    
3016
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3017
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3018
                                    
3019
                                    //}
3020
                                }
3021
                            }
3022
                        }
3023
                        break;
3024
                    case ControlType.ImgControl:
3025
                        {
3026
                            if (e.LeftButton == MouseButtonState.Pressed)
3027
                            {
3028
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3029
                                //{
3030
                                    if (currentControl is ImgControl)
3031
                                    {
3032
                                        //20180906 LJY TEST IsRotationDrawingEnable
3033
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3034
                                        {
3035
                                            return;
3036
                                        }
3037

    
3038
                                        CreateCommand.Instance.Execute(currentControl);
3039
                                        controlType = ControlType.ImgControl;
3040
                                        currentControl = null;
3041
                                    }
3042
                                    else
3043
                                    {
3044
                                        
3045
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3046
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3047
                                        {
3048
                                            Image img = new Image();
3049
                                            if (filename.Contains(".svg"))
3050
                                            {
3051
                                                byte[] imageData = null;
3052
                                                DrawingImage image = null;
3053
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3054
                                                {
3055
                                                    imageData = web.DownloadData(new Uri(filename));
3056
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3057
                                                    image = SvgReader.Load(stream);
3058
                                                }
3059
                                                img.Source = image;
3060
                                            }
3061
                                            else
3062
                                            {
3063
                                                img.Source = new BitmapImage(new Uri(filename));
3064
                                            }
3065

    
3066
                                            currentControl = new ImgControl
3067
                                            {
3068
                                                    Background = new SolidColorBrush(Colors.Black),
3069
                                                    PointSet = new List<Point>(),
3070
                                                    FilePath = filename,
3071
                                                    ImageData = img.Source,
3072
                                                    StartPoint = canvasDrawingMouseDownPoint,
3073
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3074
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3075
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3076
                                                    ControlType = ControlType.ImgControl
3077
                                                };
3078

    
3079
                                        
3080
                                                currentControl.CommentID = Commons.shortGuid();                                            
3081
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3082
                                                currentControl.IsNew = true;
3083
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3084

    
3085
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3086
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3087
                                        }
3088
                                    }
3089
                                //}
3090
                            }
3091
                        }
3092
                        break;
3093
                    case ControlType.Date:
3094
                        {
3095
                            if (e.LeftButton == MouseButtonState.Pressed)
3096
                            {
3097
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3098
                                //{
3099
                                    if (currentControl is DateControl)
3100
                                    {
3101
                                        //20180906 LJY TEST IsRotationDrawingEnable
3102
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3103
                                        {
3104
                                            return;
3105
                                        }
3106

    
3107
                                        CreateCommand.Instance.Execute(currentControl);
3108
                                        currentControl = null;
3109

    
3110
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3111
                                        {
3112
                                            controlType = ControlType.None;
3113
                                            IsSwingMode = false;
3114
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3115
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3116
                                            mouseHandlingMode = MouseHandlingMode.None;
3117
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3118
                                            txtBatch.Visibility = Visibility.Collapsed;
3119

    
3120
                                        }
3121
                                    }
3122
                                    else
3123
                                    {
3124
                                        currentControl = new DateControl
3125
                                        {
3126
                                            StartPoint = canvasDrawingMouseDownPoint,
3127
                                            Background = new SolidColorBrush(Colors.Black)
3128
                                        };
3129
                                        currentControl.CommentID = Commons.shortGuid();
3130
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3131
                                        currentControl.IsNew = true;
3132
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3133

    
3134
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3135
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3136
                                }
3137
                                //}
3138
                            }
3139
                        }
3140
                        break;
3141
                    case ControlType.TextControl:
3142
                        {
3143
                            if (e.LeftButton == MouseButtonState.Pressed)
3144
                            {
3145
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3146
                                {
3147
                                    currentControl = new TextControl
3148
                                    {
3149
                                        ControlType = controlType
3150
                                    };
3151
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3152
                                    currentControl.CommentID = Commons.shortGuid();
3153
                                    currentControl.IsNew = true;
3154
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3155
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3156
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3157

    
3158
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3159
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3160
                                    
3161
                                    (currentControl as TextControl).ControlType_No = 0;
3162
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3163
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3164
                                    (currentControl as TextControl).ApplyTemplate();
3165
                                    (currentControl as TextControl).Base_TextBox.Focus();
3166

    
3167
                                    CreateCommand.Instance.Execute(currentControl);
3168
                                }
3169
                            }
3170
                        }
3171
                        break;
3172
                    case ControlType.TextBorder:
3173
                        {
3174
                            if (e.LeftButton == MouseButtonState.Pressed)
3175
                            {
3176
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3177
                                {
3178
                                    currentControl = new TextControl
3179
                                    {
3180
                                        ControlType = controlType
3181
                                    };
3182

    
3183
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3184
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3185
                                    currentControl.CommentID = Commons.shortGuid();
3186
                                    currentControl.IsNew = true;
3187
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3188
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3189
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3190
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3191
                                    
3192
                                    (currentControl as TextControl).ControlType_No = 1;
3193
                                    (currentControl as TextControl).Angle = Ang;
3194
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3195
                                    (currentControl as TextControl).ApplyTemplate();
3196
                                    (currentControl as TextControl).Base_TextBox.Focus();
3197
                                    CreateCommand.Instance.Execute(currentControl);
3198
                                }
3199
                            }
3200
                        }
3201
                        break;
3202
                    case ControlType.TextCloud:
3203
                        {
3204
                            if (e.LeftButton == MouseButtonState.Pressed)
3205
                            {
3206
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3207
                                {
3208
                                    currentControl = new TextControl
3209
                                    {
3210
                                        ControlType = controlType
3211
                                    };
3212

    
3213
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3214
                                    currentControl.CommentID = Commons.shortGuid();
3215
                                    currentControl.IsNew = true;
3216
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3217
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3218

    
3219
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3220
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3221
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3222

    
3223
                                    (currentControl as TextControl).Angle = Ang;
3224
                                    (currentControl as TextControl).ControlType_No = 2;
3225
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3226
                                    (currentControl as TextControl).ApplyTemplate();
3227
                                    (currentControl as TextControl).Base_TextBox.Focus();
3228
                                    CreateCommand.Instance.Execute(currentControl);
3229
                                    //currentControl = null;
3230
                                }
3231
                            }
3232
                        }
3233
                        break;
3234
                    case ControlType.ArrowTextControl:
3235
                         {
3236
                            if (e.LeftButton == MouseButtonState.Pressed)
3237
                            {
3238
                                if (currentControl is ArrowTextControl)
3239
                                {
3240
                                    //20180906 LJY TEST IsRotationDrawingEnable
3241
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3242
                                    {
3243
                                        return;
3244
                                    }
3245

    
3246
                                    CreateCommand.Instance.Execute(currentControl);
3247

    
3248
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3249
                                    (currentControl as ArrowTextControl).IsEditing = false;
3250
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3251
                                    (currentControl as ArrowTextControl).IsNew = false;
3252
                                    currentControl = null;
3253
                                }
3254
                                else
3255
                                {
3256
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3257
                                    //{
3258
                                        currentControl = new ArrowTextControl();
3259
                                        currentControl.CommentID = Commons.shortGuid();
3260
                                        currentControl.IsNew = true;
3261
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3262
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3263

    
3264
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3265
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3266
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3267
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3268
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3269

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

    
3273
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3274
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3275
                                        this.MainAngle.Visibility = Visibility.Visible;
3276

    
3277
                                    
3278
                                    //}
3279
                                }
3280
                            }
3281
                        }
3282
                        break;
3283
                    case ControlType.ArrowTransTextControl:
3284
                        {
3285
                            if (e.LeftButton == MouseButtonState.Pressed)
3286
                            {
3287
                                if (currentControl is ArrowTextControl)
3288
                                {
3289
                                    //20180906 LJY TEST IsRotationDrawingEnable
3290
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3291
                                    {
3292
                                        return;
3293
                                    }
3294

    
3295
                                    CreateCommand.Instance.Execute(currentControl);
3296
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3297
                                    currentControl.IsNew = false;
3298
                                    currentControl = null;
3299
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3300
                                }
3301
                                else
3302
                                {
3303
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3304
                                    //{
3305
                                         currentControl = new ArrowTextControl();
3306
                                        currentControl.CommentID = Commons.shortGuid();
3307
                                        currentControl.IsNew = true;
3308
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3309
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3310
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3311
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3312
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3313
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3314
                                        (currentControl as ArrowTextControl).isFixed = true;
3315
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3316

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

    
3320
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3321
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3322
                                        (currentControl as ArrowTextControl).isTrans = true;
3323
                                }
3324
                            }
3325
                        }
3326
                        break;
3327
                    case ControlType.ArrowTextBorderControl:
3328
                         {
3329
                            if (e.LeftButton == MouseButtonState.Pressed)
3330
                            {
3331
                                if (currentControl is ArrowTextControl)
3332
                                {
3333
                                    //20180906 LJY TEST IsRotationDrawingEnable
3334
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3335
                                    {
3336
                                        return;
3337
                                    }
3338

    
3339
                                    CreateCommand.Instance.Execute(currentControl);
3340
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3341
                                    currentControl.IsNew = false;
3342
                                    currentControl = null;
3343
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3344
                                }
3345
                                else
3346
                                {
3347
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3348
                                    //{
3349
                                        currentControl = new ArrowTextControl()
3350
                                        {
3351
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3352
                                        };
3353
                                        currentControl.CommentID = Commons.shortGuid();
3354
                                        currentControl.IsNew = true;
3355
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3356
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3357

    
3358
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3359

    
3360
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3361

    
3362
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3363
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3364
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3365

    
3366
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3367
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3368
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3369
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3370
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3371
                                    //}
3372
                                }
3373
                            }
3374
                        }
3375
                        break;
3376
                    case ControlType.ArrowTransTextBorderControl:
3377
                        {
3378
                            if (e.LeftButton == MouseButtonState.Pressed)
3379
                            {
3380
                                if (currentControl is ArrowTextControl)
3381
                                {
3382
                                    //20180906 LJY TEST IsRotationDrawingEnable
3383
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3384
                                    {
3385
                                        return;
3386
                                    }
3387
                                    CreateCommand.Instance.Execute(currentControl);
3388
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3389
                                    currentControl.IsNew = false;
3390
                                    currentControl = null;
3391
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3392
                                }
3393
                                else
3394
                                {
3395
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3396
                                    //{
3397
                                    
3398

    
3399
                                    currentControl = new ArrowTextControl()
3400
                                        {
3401
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3402
                                        };
3403
                                        currentControl.CommentID = Commons.shortGuid();
3404
                                        currentControl.IsNew = true;
3405
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3406
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3407

    
3408
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3409

    
3410
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3411
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3412
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3413
                                        (currentControl as ArrowTextControl).isFixed = true;
3414
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3415
                                     
3416
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3417
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3418
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3419

    
3420
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3421
                                        this.MainAngle.Visibility = Visibility.Visible;
3422
                                    
3423
                                    //20180911 LJY
3424
                                        (currentControl as ArrowTextControl).isTrans = true;
3425
                                    
3426

    
3427
                                    //}
3428
                                }
3429
                            }
3430
                        }
3431
                        break;
3432
                    case ControlType.ArrowTextCloudControl:
3433
                        {
3434
                            if (e.LeftButton == MouseButtonState.Pressed)
3435
                            {
3436
                                if (currentControl is ArrowTextControl)
3437
                                {
3438
                                    //20180906 LJY TEST IsRotationDrawingEnable
3439
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3440
                                    {
3441
                                        return;
3442
                                    }
3443
                                    CreateCommand.Instance.Execute(currentControl);
3444
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3445
                                    currentControl.IsNew = false;
3446
                                    currentControl = null;
3447
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3448
                                }
3449
                                else
3450
                                {
3451
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3452
                                    //{
3453
                                        currentControl = new ArrowTextControl()
3454
                                        {
3455
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3456
                                        };
3457
                                        currentControl.CommentID = Commons.shortGuid();
3458
                                        currentControl.IsNew = true;
3459
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3460
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3461

    
3462
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3463
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3464
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3465
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3466
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3467

    
3468
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3469
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3470
                                    
3471
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3472
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3473
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3474
                                    //}
3475
                                }
3476
                            }
3477
                        }
3478
                        break;
3479
                    case ControlType.ArrowTransTextCloudControl:
3480
                        {
3481
                            if (e.LeftButton == MouseButtonState.Pressed)
3482
                            {
3483
                                if (currentControl is ArrowTextControl)
3484
                                {
3485
                                    //20180906 LJY TEST IsRotationDrawingEnable
3486
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3487
                                    {
3488
                                        return;
3489
                                    }
3490
                                    CreateCommand.Instance.Execute(currentControl);
3491
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3492
                                    currentControl.IsNew = false;
3493
                                    currentControl = null;
3494
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3495
                                }
3496
                                else
3497
                                {
3498
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3499
                                    //{
3500
                                        currentControl = new ArrowTextControl()
3501
                                        {
3502
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3503
                                        };
3504
                                        currentControl.CommentID = Commons.shortGuid();
3505
                                        currentControl.IsNew = true; 
3506
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3507
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3508
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3509

    
3510
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3511
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3512
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3513
                                        (currentControl as ArrowTextControl).isFixed = true;
3514
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3515

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

    
3519
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3520
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3521
                                        this.MainAngle.Visibility = Visibility.Visible;  
3522
                                    
3523
                                    //20180911 LJY
3524
                                        (currentControl as ArrowTextControl).isTrans = true;
3525
                                    //}
3526
                                }
3527
                            }
3528
                        }
3529
                        break;
3530
                    //강인구 추가
3531
                    case ControlType.Sign:
3532
                        {
3533
                            if (e.LeftButton == MouseButtonState.Pressed)
3534
                            {
3535
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3536
                                //{
3537
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3538

    
3539
                                    if (_sign == null)
3540
                                    {
3541
                                        txtBatch.Visibility = Visibility.Collapsed;
3542
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3543
                                        controlType = ControlType.None;
3544

    
3545
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3546
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3547
                                        return;
3548
                                    }
3549

    
3550
                                    if (currentControl is SignControl)
3551
                                    {
3552
                                        //20180906 LJY TEST IsRotationDrawingEnable
3553
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3554
                                        {
3555
                                            return;
3556
                                        }
3557

    
3558
                                        CreateCommand.Instance.Execute(currentControl);
3559
                                        currentControl = null;
3560
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3561
                                        {
3562
                                            txtBatch.Text = "Place Date";
3563
                                            controlType = ControlType.Date;
3564
                                        }
3565
                                    }
3566
                                    else
3567
                                    {
3568
                                        currentControl = new SignControl
3569
                                        {
3570
                                            Background = new SolidColorBrush(Colors.Black),
3571
                                            UserNumber = App.ViewInfo.UserID,
3572
                                            ProjectNO = App.ViewInfo.ProjectNO,
3573
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3574
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3575
                                            ControlType = ControlType.Sign
3576
                                        };
3577

    
3578
                                        currentControl.CommentID = Commons.shortGuid();
3579
                                        currentControl.IsNew = true;
3580
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3581
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3582

    
3583
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3584
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3585
                                }
3586
                                //}
3587
                            }
3588
                        }
3589
                        break;
3590
                    case ControlType.Mark:
3591
                        {
3592
                            if (e.LeftButton == MouseButtonState.Pressed)
3593
                            {
3594
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3595
                                //{
3596
                                    if (currentControl is RectangleControl)
3597
                                    {
3598
                                        //20180906 LJY TEST IsRotationDrawingEnable
3599
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3600
                                        {
3601
                                            return;
3602
                                        }
3603

    
3604
                                        CreateCommand.Instance.Execute(currentControl);
3605
                                        (currentControl as RectangleControl).ApplyOverViewData();
3606
                                        currentControl = null;
3607
                                    
3608
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3609

    
3610
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3611
                                        {
3612
                                            txtBatch.Text = "Place Signature";
3613
                                            controlType = ControlType.Sign;
3614
                                        }
3615
                                    }
3616
                                    else
3617
                                    {
3618
                                        currentControl = new RectangleControl
3619
                                        {
3620
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3621
                                            Background = new SolidColorBrush(Colors.Black),
3622
                                            ControlType = ControlType.Mark ,
3623
                                            Paint = PaintSet.Fill
3624
                                        };
3625

    
3626
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3627
                                        currentControl.CommentID = Commons.shortGuid();
3628
                                        currentControl.IsNew = true;
3629
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3630
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3631
                                    }
3632
                                //}
3633
                            }
3634
                        }
3635
                        break;
3636
                    case ControlType.Symbol:
3637
                        {
3638
                            if (e.LeftButton == MouseButtonState.Pressed)
3639
                            {
3640
                                if (currentControl is SymControl)
3641
                                {
3642
                                    //20180906 LJY TEST IsRotationDrawingEnable
3643
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3644
                                    {
3645
                                        return;
3646
                                    }
3647
                                    CreateCommand.Instance.Execute(currentControl);
3648
                                    currentControl = null;
3649
                                
3650
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3651
                                }
3652
                                else
3653
                                {
3654
                                    currentControl = new SymControl
3655
                                    {
3656
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3657
                                        Background = new SolidColorBrush(Colors.Black),
3658
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3659
                                        ControlType = ControlType.Symbol
3660
                                    };
3661

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

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

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

    
3692
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3693
                                    }
3694
                                    else
3695
                                    {
3696
                                        currentControl = new SymControlN
3697
                                        {
3698
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3699
                                            Background = new SolidColorBrush(Colors.Black),
3700
                                            STAMP = App.SystemInfo.STAMP,
3701
                                            ControlType = ControlType.Stamp
3702
                                        };
3703

    
3704
                                        currentControl.IsNew = true;
3705
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3706
                                        currentControl.CommentID = Commons.shortGuid();
3707
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3708
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3709
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3710
                                }                                    
3711
                                //}
3712
                            }
3713
                        }
3714
                        break;
3715
                    case ControlType.PenControl:
3716
                        {
3717
                            if (inkBoard.Tag.ToString() == "Ink")
3718
                            {
3719
                                inkBoard.IsEnabled = true;
3720
                                StartNewStroke(canvasDrawingMouseDownPoint);
3721
                            }
3722
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3723
                            {
3724
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3725
                            }
3726
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3727
                            {
3728
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3729
                            }
3730
                            IsDrawing = true;
3731
                            return;
3732
                        }
3733
                    default:
3734
                        if (currentControl != null)
3735
                        {
3736
                            currentControl.CommentID = null;
3737
                            currentControl.IsNew = false;
3738
                        }
3739
                        break;
3740
                }
3741
            }
3742
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3743
            {
3744
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3745
                {
3746
                    bool mouseOff = false;
3747
                    foreach (var item in SelectLayer.Children)
3748
                    {
3749
                        if (item is AdornerFinal)
3750
                        {
3751

    
3752
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3753
                            if (over != null)
3754
                            {
3755
                                mouseOff = true;
3756
                            }
3757
                        }
3758
                    }
3759

    
3760
                    if (!mouseOff)
3761
                    {
3762
                        SelectionSet.Instance.UnSelect(this);
3763
                    }
3764
                }
3765
                zoomAndPanControl.CaptureMouse();
3766
                e.Handled = true;
3767
            }
3768
        }
3769

    
3770
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3771
        {
3772
            ///mouseButtonDown = e.ChangedButton;
3773
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3774
        }
3775

    
3776
        private void RemoveLineStroke(Point P)
3777
        {
3778
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3779
            if (control != null)
3780
            {
3781
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3782
            }
3783
        }
3784

    
3785
        private void RemovePointStroke(Point P)
3786
        {
3787
            foreach (Stroke hits in inkBoard.Strokes)
3788
            {
3789
                foreach (StylusPoint sty in hits.StylusPoints)
3790
                {
3791

    
3792
                }
3793
                if (hits.HitTest(P))
3794
                {
3795
                    inkBoard.Strokes.Remove(hits);
3796
                    return;
3797
                }
3798
            }
3799
        }
3800

    
3801
        private void StartNewStroke(Point P)
3802
        {
3803
            strokePoints = new StylusPointCollection();
3804
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3805
            strokePoints.Add(segment1Start);
3806
            stroke = new Stroke(strokePoints);
3807

    
3808
            stroke.DrawingAttributes.Color = Colors.Red;
3809
            stroke.DrawingAttributes.Width = 4;
3810
            stroke.DrawingAttributes.Height = 4;
3811

    
3812
            inkBoard.Strokes.Add(stroke);
3813

    
3814
        }
3815

    
3816
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3817
        {
3818
            ConsolidationMethod();
3819
        }
3820

    
3821
        /// <summary>
3822
        /// execute TeamConsolidationCommand
3823
        /// </summary>
3824
        public void TeamConsolidationMethod()
3825
        {
3826
            this.UpdateMyMarkupList();
3827
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3828
            {
3829
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3830
            }
3831
            else
3832
            {
3833

    
3834
                ViewerDataModel.Instance.IsConsolidate = true;
3835
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3836

    
3837
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3838
                {
3839
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3840
                    {
3841
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3842
                        return;
3843
                    }                    
3844
                }
3845
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3846
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3847
                {
3848
                    MarkupInfoList.Add(item);
3849
                }
3850
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3851
            }
3852
        }
3853

    
3854
        public void ConsolidationMethod()
3855
        {
3856
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3857
            {
3858
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3859
            }
3860
            else
3861
            {
3862
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3863
                foreach (var item in this.gridViewMarkup.SelectedItems)
3864
                {
3865
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3866
                }
3867
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3868
                
3869
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3870
            }
3871
        }
3872

    
3873
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3874
        {
3875
            if (App.ViewInfo != null)
3876
            {
3877
                btnConsolidate = (sender as RadRibbonButton);
3878
                if (!App.ViewInfo.NewCommentPermission)
3879
                {
3880
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3881
                }
3882
            }
3883
        }
3884

    
3885
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3886
        {
3887
            TeamConsolidationMethod();
3888
        }
3889

    
3890
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3891
        {
3892
            btnTeamConsolidate = sender as RadRibbonButton;
3893
            if (App.ViewInfo != null)
3894
            {
3895
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3896
                {
3897
                    if (btnConsolidate != null)
3898
                    {
3899
                        btnConsolidate.Visibility = Visibility.Collapsed;
3900
                    }
3901

    
3902
                    if (!App.ViewInfo.NewCommentPermission)
3903
                    {
3904
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3905
                    }
3906
                }
3907
                else
3908
                {
3909
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3910
                }
3911
            }
3912
        }
3913

    
3914
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3915
        {
3916
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3917
            if (item != null)
3918
            {
3919
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3920

    
3921
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3922
            }
3923
            else
3924
            {
3925
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3926
            }
3927
        }
3928

    
3929
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3930
        {
3931
            btnFinalPDF = sender as RadRibbonButton;
3932
            if (App.ViewInfo != null)
3933
            {
3934
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3935
                {
3936
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3937
                    if (btnConsolidate != null)
3938
                    {
3939
                        btnConsolidate.Visibility = Visibility.Collapsed;
3940
                    }
3941
                }
3942
            }
3943
        }
3944

    
3945
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
3946
        {
3947
            UpdateMyMarkupList();
3948

    
3949
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3950
            {
3951
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3952
            }
3953
            else
3954
            {
3955
                ViewerDataModel.Instance.IsConsolidate = true;
3956
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3957
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
3958

    
3959
                string project_no = App.ViewInfo.ProjectNO;
3960
                string doc_id = _DocInfo.ID;
3961
                string user_id = App.ViewInfo.UserID;
3962
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
3963
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3964
                {
3965
                    markupInfoItems.Add(item);
3966
                }
3967
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
3968
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
3969
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
3970
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
3971

    
3972
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3973
                if (item2 != null)
3974
                {
3975
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3976

    
3977
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
3978
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
3979
                }
3980
                else
3981
                {
3982
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3983
                }
3984
            }
3985
        }
3986

    
3987
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
3988
        {
3989
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
3990

    
3991
            if (App.ViewInfo != null)
3992
            {
3993
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
3994
                {
3995
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3996
                }
3997
            }
3998
        }
3999

    
4000
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4001
        {
4002
            if (CompareMode.IsChecked)
4003
            {
4004
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4005
                {
4006
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4007
                }
4008
                if (ViewerDataModel.Instance.PageNumber == 0)
4009
                {
4010
                    ViewerDataModel.Instance.PageNumber = 1;
4011
                }
4012

    
4013
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4014
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4015
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4016

    
4017
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4018
            }
4019
            else
4020
            {
4021
                da.From = 1;
4022
                da.To = 1;
4023
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4024
                da.AutoReverse = false;
4025
                canvas_compareBorder.Children.Clear();
4026
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4027
            }
4028
        }
4029

    
4030
        private void Sync_Click(object sender, RoutedEventArgs e)
4031
        {
4032
            if (Sync.IsChecked)
4033
            {
4034
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4035
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4036
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4037
            }
4038
        }
4039

    
4040
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4041
        {
4042
            if (UserList.IsChecked)
4043
            {
4044
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4045
            }
4046
            else
4047
            {
4048
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4049
            }
4050
        }
4051

    
4052
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4053
        {
4054

    
4055
            if (BalanceMode.IsChecked)
4056
            {
4057
                ViewerDataModel.Instance.PageBalanceMode = true;
4058
            }
4059
            else
4060
            {
4061
                ViewerDataModel.Instance.PageBalanceMode = false;
4062
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4063
            }
4064
        }
4065

    
4066
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4067
        {
4068
            //초기화
4069
            testPanel2.IsHidden = true;
4070
            ViewerDataModel.Instance.PageBalanceMode = false;
4071
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4072
            ViewerDataModel.Instance.PageNumber = 0;
4073
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4074
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4075
            UserList.IsChecked = false;
4076
            BalanceMode.IsChecked = false;
4077
        }
4078

    
4079
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4080
        {
4081
            if ((sender as System.Windows.Controls.Control).Tag != null)
4082
            {
4083
                //Compare 초기화
4084
                CompareMode.IsChecked = false;
4085
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4086

    
4087
                if (ViewerDataModel.Instance.PageNumber == 0)
4088
                {
4089
                    ViewerDataModel.Instance.PageNumber = 1;
4090
                }
4091

    
4092
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4093
                {
4094
                }
4095
                else
4096
                {
4097
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4098
                }
4099

    
4100
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4101
                {
4102

    
4103
                }
4104
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4105
                {
4106
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4107
                }
4108

    
4109
                if (!testPanel2.IsHidden)
4110
                {
4111
                    if (IsSyncPDFMode)
4112
                    {
4113
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4114
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4115

    
4116
                        if (pdfpath.IsDownloading)
4117
                        {
4118
                            pdfpath.DownloadCompleted += (ex, arg) =>
4119
                            {
4120
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4121
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4122
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4123
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4124
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4125
                            };
4126
                        }
4127
                        else
4128
                        {
4129
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4130
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4131
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4132

    
4133
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4134
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4135
                        }
4136

    
4137
                    }
4138
                    else
4139
                    {
4140
                        string uri = "";
4141

    
4142
                        if (userData.COMPANY != "EXT")
4143
                        {
4144
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4145
                        }
4146
                        else
4147
                        {
4148
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4149
                        }
4150

    
4151
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4152

    
4153
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4154
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4155
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4156

    
4157
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4158
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4159

    
4160
                        if (defaultBitmapImage_Compare.IsDownloading)
4161
                        {
4162
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4163
                            {
4164
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4165
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4166
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4167

    
4168
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4169
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4170
                            };
4171
                        }
4172
                    }
4173

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

    
4178
                    foreach (var item in gridSelectionRevItem)
4179
                    {
4180
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4181
                        {
4182
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4183
                        });
4184
                    }
4185

    
4186
                    //강인구 추가
4187
                    zoomAndPanControl2.ZoomTo(new Rect
4188
                    {
4189
                        X = 0,
4190
                        Y = 0,
4191
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4192
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4193
                    });
4194

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

    
4197
                }
4198
            }
4199
        }
4200

    
4201
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4202
        {
4203
            if (MarkupMode.IsChecked)
4204
            {
4205
                IsSyncPDFMode = true;
4206

    
4207
                var uri = CurrentRev.TO_VENDOR;
4208

    
4209
                if (ViewerDataModel.Instance.PageNumber == 0)
4210
                {
4211
                    ViewerDataModel.Instance.PageNumber = 1;
4212
                }
4213

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

    
4218
                if (pdfpath.IsDownloading)
4219
                {
4220
                    pdfpath.DownloadCompleted += (ex, arg) =>
4221
                    {
4222
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4223
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4224
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4225
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4226
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4227
                    };
4228
                }
4229
                else
4230
                {
4231
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4232
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4233
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4234

    
4235
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4236
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4237
                }
4238
            }
4239
            else
4240
            {
4241
                IsSyncPDFMode = false;
4242
                string uri = "";
4243
                if (userData.COMPANY != "EXT")
4244
                {
4245
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4246
                }
4247
                else
4248
                {
4249
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4250
                }
4251

    
4252
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4253

    
4254
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4255
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4256
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4257

    
4258
                if (defaultBitmapImage_Compare.IsDownloading)
4259
                {
4260
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4261
                    {
4262
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4263
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4264
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4265
                    };
4266
                }
4267
                zoomAndPanControl2.ApplyTemplate();
4268
                zoomAndPanControl2.UpdateLayout();
4269
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4270
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4271
            }
4272
        }
4273

    
4274
        private void RadButton_Click(object sender, RoutedEventArgs e)
4275
        {
4276
            gridViewHistory_Busy.IsBusy = true;
4277

    
4278
            RadButton instance = sender as RadButton;
4279
            if (instance.CommandParameter != null)
4280
            {
4281
                CurrentRev = instance.CommandParameter as VPRevision;
4282
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4283
                {
4284
                    if (ea.Error == null && ea.Result != null)
4285
                    {
4286
                        testPanel2.IsHidden = false;
4287

    
4288
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4289
                        foreach(var info in ea.Result)
4290
                        {
4291
                            if(info.UserID == App.ViewInfo.UserID)
4292
                            {
4293
                                info.userDelete = true;
4294
                                info.DisplayColor = "FFFF0000";
4295
                            }
4296
                            else
4297
                            {
4298
                                info.userDelete = false;
4299
                            }
4300
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4301
                        }
4302
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4303

    
4304
                        string uri = "";
4305
                        if (userData.COMPANY != "EXT")
4306
                        {
4307
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4308
                        }
4309
                        else
4310
                        {
4311
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4312
                        }
4313

    
4314
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4315

    
4316
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4317

    
4318
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4319
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4320
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4321

    
4322
                        if (defaultBitmapImage_Compare.IsDownloading)
4323
                        {
4324
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4325
                            {
4326
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4327
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4328
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4329
                            };
4330
                        }
4331

    
4332
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4333
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4334
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4335
                        zoomAndPanControl2.ApplyTemplate();
4336
                        zoomAndPanControl2.UpdateLayout();
4337

    
4338
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4339
                        {
4340
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4341
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4342
                        }
4343

    
4344
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4345
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4346
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4347

    
4348
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4349
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4350
                        gridViewHistory_Busy.IsBusy = false;
4351
                    }
4352

    
4353
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4354
                };
4355
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4356
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4357
            }
4358
        }
4359

    
4360
        public void Sync_Event(VPRevision Currnet_Rev)
4361
        {
4362
            CurrentRev = Currnet_Rev;
4363

    
4364
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4365
            {
4366
                if (ea.Error == null && ea.Result != null)
4367
                {
4368
                    testPanel2.IsHidden = false;
4369

    
4370
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4371
                    foreach(var info in ea.Result)
4372
                    {
4373
                        if(info.UserID == App.ViewInfo.UserID)
4374
                        {
4375
                            info.userDelete = true;
4376
                            info.DisplayColor = "FFFF0000";
4377
                        }
4378
                        else
4379
                        {
4380
                            info.userDelete = false;
4381
                        }
4382
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4383
                    }
4384
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4385

    
4386
                    string uri = "";
4387
                    if (userData.COMPANY != "EXT")
4388
                    {
4389
                        uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4390
                    }
4391
                    else
4392
                    {
4393
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4394
                    }
4395

    
4396
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4397

    
4398
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4399

    
4400
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4401
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4402
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4403

    
4404
                    if (defaultBitmapImage_Compare.IsDownloading)
4405
                    {
4406
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4407
                        {
4408
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4409
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4410
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4411
                        };
4412
                    }
4413

    
4414

    
4415
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4416
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4417
                    zoomAndPanControl2.ApplyTemplate();
4418
                    zoomAndPanControl2.UpdateLayout();
4419

    
4420
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4421
                    {
4422
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4423
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4424
                    }
4425
                    //}
4426

    
4427
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4428
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4429
                    gridViewHistory_Busy.IsBusy = false;
4430
                }
4431
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4432

    
4433
            };
4434
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4435
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4436
        }
4437

    
4438
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4439
        {
4440
            if (sender is Image)
4441
            {
4442
                if ((sender as Image).Tag != null)
4443
                {
4444
                    var pdfUrl = (sender as Image).Tag.ToString();
4445
                    System.Diagnostics.Process.Start(pdfUrl);
4446
                }
4447
                else
4448
                {
4449
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4450
                }
4451
            }
4452
        }
4453

    
4454
        private void Create_Symbol(object sender, RoutedEventArgs e)
4455
        {
4456
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4457

    
4458
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4459
            {
4460
                DialogMessage_Alert("Please Select Controls", "Alert");
4461
            }
4462
            else //선택된 것이 있으면
4463
            {
4464
                string MarkupData = "";
4465
                adorner_ = new AdornerFinal();
4466

    
4467
                foreach (var item in SelectLayer.Children)
4468
                {
4469
                    if (item.GetType().Name == "AdornerFinal")
4470
                    {
4471
                        adorner_ = (item as Controls.AdornerFinal);
4472
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4473
                        {
4474
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4475
                            {
4476
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4477
                                MarkupData += markupReturn.ConvertData;
4478
                            }
4479
                        }
4480
                    }
4481
                }
4482
                DialogParameters parameters = new DialogParameters()
4483
                {
4484
                    Owner = Application.Current.MainWindow,
4485
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4486
                    DefaultPromptResultValue = "Custom State",
4487
                    Content = "Name :",
4488
                    Header = "Insert Custom Symbol Name",
4489
                    Theme = new VisualStudio2013Theme(),
4490
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4491
                };
4492
                RadWindow.Prompt(parameters);
4493
            }
4494

    
4495
        }
4496
        public int symbolselectindex = 0;
4497
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4498
        {
4499
            //Save save = new Save();
4500
            try
4501
            {
4502
                string svgfilename = null;
4503
                if (symbolname != null)
4504
                {
4505
                    if (symbolpng == true || symbolsvg == true)
4506
                    {
4507
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4508
                        string guid = Commons.shortGuid();
4509

    
4510
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4511
                        //Check_Uri.UriCheck();
4512
                        fileUploader.RunCompleted += (ex, arg) =>
4513
                        {
4514
                            filename = arg.Result;
4515
                            if (symbolpng == true)
4516
                            {
4517
                                if (filename != null)
4518
                                { 
4519
                                    if (symbolselectindex == 0)
4520
                                    {
4521
                                        SymbolSave(symbolname, filename, data);
4522
                                    }
4523
                                    else
4524
                                    {
4525
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4526
                                    }
4527
                                    DataBind();
4528
                                }                                
4529
                            }
4530

    
4531
                            if (symbolsvg == true)
4532
                            {
4533
                                try
4534
                                {
4535
                                    var defaultBitmapImage = new BitmapImage();
4536
                                    defaultBitmapImage.BeginInit();
4537
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4538
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4539
                                    Check_Uri.UriCheck(filename);
4540
                                    defaultBitmapImage.UriSource = new Uri(filename);
4541
                                    defaultBitmapImage.EndInit();
4542

    
4543
                                    System.Drawing.Bitmap image;
4544

    
4545
                                    if (defaultBitmapImage.IsDownloading)
4546
                                    {
4547
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4548
                                        {
4549
                                            defaultBitmapImage.Freeze();
4550
                                            image = GetBitmap(defaultBitmapImage);
4551
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4552
                                            Process potrace = new Process
4553
                                            {
4554
                                                StartInfo = new ProcessStartInfo
4555
                                                {
4556
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4557
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4558
                                                    RedirectStandardInput = true,
4559
                                                    RedirectStandardOutput = true,
4560
                                                    RedirectStandardError = true,
4561
                                                    UseShellExecute = false,
4562
                                                    CreateNoWindow = true,
4563
                                                    WindowStyle = ProcessWindowStyle.Hidden
4564
                                                },
4565
                                            };
4566

    
4567
                                            StringBuilder svgBuilder = new StringBuilder();
4568
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4569
                                            {
4570
                                                svgBuilder.AppendLine(e2.Data);
4571
                                            };
4572

    
4573
                                            potrace.EnableRaisingEvents = true;
4574
                                            potrace.Start();
4575
                                            potrace.Exited += (sender, e) =>
4576
                                            {
4577
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4578
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4579
                                                Check_Uri.UriCheck(svgfilename);
4580
                                                if (symbolselectindex == 0)
4581
                                                {
4582
                                                    SymbolSave(symbolname, svgfilename, data);
4583
                                                }
4584
                                                else
4585
                                                {
4586
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4587
                                                }
4588

    
4589
                                                DataBind();
4590
                                            };
4591
                                            potrace.WaitForExit();
4592
                                        };
4593
                                    }
4594
                                    else
4595
                                    {
4596
                                        //GC.Collect();
4597
                                    }
4598
                                }
4599
                                catch(Exception ee)
4600
                                {
4601
                                    DialogMessage_Alert("" + ee, "Alert");
4602
                                }
4603
                            }
4604
                        };                                             
4605
                    }
4606
                }
4607
            }
4608
            catch (Exception e)
4609
            {
4610
                //DialogMessage_Alert(e + "", "Alert");
4611
            }            
4612
        }
4613

    
4614
        public void SymbolSave(string Name, string Url, string Data)
4615
        {
4616
            try
4617
            {
4618
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4619
                {
4620
                    ID = Commons.shortGuid(),
4621
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4622
                    NAME = Name,
4623
                    IMAGE_URL = Url,
4624
                    DATA = Data
4625
                };
4626

    
4627
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4628
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4629
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4630
            }
4631
            catch (Exception)
4632
            {
4633
                throw;
4634
            }
4635
        }
4636

    
4637
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4638
        {
4639
            try
4640
            {
4641
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4642
                {
4643
                    ID = Commons.shortGuid(),
4644
                    DEPARTMENT = Department,
4645
                    NAME = Name,
4646
                    IMAGE_URL = Url,
4647
                    DATA = Data
4648
                };
4649
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4650
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4651
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4652
            }
4653
            catch (Exception)
4654
            {
4655
                throw;
4656
            }
4657
        }
4658

    
4659
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4660
        {           
4661
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4662
            DataBind();
4663
        }
4664

    
4665
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4666
        {
4667
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4668
            DataBind();
4669
        }
4670
        private void DataBind()
4671
        {
4672
            try
4673
            {
4674
                Symbol_Custom Custom = new Symbol_Custom();
4675
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4676
                
4677
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4678
                foreach (var item in symbol_Private)
4679
                {
4680
                    Custom.Name = item.NAME;
4681
                    Custom.ImageUri = item.IMAGE_URL;
4682
                    Custom.ID = item.ID;
4683
                    Custom_List.Add(Custom);
4684
                    Custom = new Symbol_Custom();
4685
                }
4686
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4687
                
4688
                Custom = new Symbol_Custom();
4689
                Custom_List = new List<Symbol_Custom>();
4690

    
4691
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4692

    
4693
                List<SYMBOL_PUBLIC> symbol_Public;
4694

    
4695
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4696
                {
4697
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4698
                }
4699
                else
4700
                {
4701
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4702
                }
4703
                foreach (var item in symbol_Public)
4704
                {
4705
                    Custom.Name = item.NAME;
4706
                    Custom.ImageUri = item.IMAGE_URL;
4707
                    Custom.ID = item.ID;
4708
                    Custom_List.Add(Custom);
4709
                    Custom = new Symbol_Custom();
4710
                }
4711
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4712
                BaseClient.Close();                
4713
            }
4714
            catch(Exception e)
4715
            {
4716
                //DialogMessage_Alert("DataBind", "Alert");
4717
            }
4718
            
4719
        }
4720
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4721
        {
4722
            try
4723
            {
4724
                if (args.PromptResult != null)
4725
                {
4726
                    if (args.DialogResult.Value)
4727
                    {
4728
                        PngBitmapEncoder _Encoder = symImage(data);
4729

    
4730
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4731
                        _Encoder.Save(fs);
4732
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4733

    
4734
                        byte[] Img_byte = fs.ToArray();
4735

    
4736
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4737
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4738
                        Check_Uri.UriCheck(filename);
4739
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4740
                        {
4741
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4742
                        }
4743
                        else
4744
                        {
4745
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4746
                        }
4747
                        DataBind();
4748
                    }
4749
                }
4750
            }
4751
            catch(Exception ex)
4752
            {
4753
                DialogMessage_Alert("" + ex, "Alert");
4754
            }
4755
        }
4756

    
4757
        public PngBitmapEncoder symImage(string data)
4758
        {
4759

    
4760
            Canvas _canvas = new Canvas();
4761
            _canvas.Background = Brushes.White;
4762
            _canvas.Width = adorner_.BorderSize.Width;
4763
            _canvas.Height = adorner_.BorderSize.Height;
4764
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4765

    
4766
            BitmapEncoder encoder = new PngBitmapEncoder();
4767

    
4768

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

    
4771
            DrawingVisual dv = new DrawingVisual();
4772

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

    
4776
            using (DrawingContext ctx = dv.RenderOpen())
4777
            {
4778
                VisualBrush vb = new VisualBrush(_canvas);
4779
                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)));
4780
            }
4781

    
4782
            try
4783
            {
4784
                renderBitmap.Render(dv);
4785

    
4786
                //GC.Collect();
4787
                GC.WaitForPendingFinalizers();
4788
                //GC.Collect();
4789
                // encode png data
4790
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4791
                // puch rendered bitmap into it
4792
                pngEncoder.Interlace = PngInterlaceOption.Off;
4793
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4794
                return pngEncoder;
4795

    
4796
            }
4797
            catch //(Exception ex)
4798
            {
4799
                return null;
4800
            }
4801

    
4802
        }
4803

    
4804
        public void DialogMessage_Alert(string content, string header)
4805
        {
4806
            var box = new TextBlock();
4807
            box.MinWidth = 400;
4808
            box.FontSize = 11;
4809
            //box.FontSize = 12;
4810
            box.Text = content;
4811
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4812

    
4813
            DialogParameters parameters = new DialogParameters()
4814
            {
4815
                Owner = Application.Current.MainWindow,
4816
                Content = box,
4817
                Header = header,
4818
                Theme = new VisualStudio2013Theme(),
4819
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4820
            };            
4821
            RadWindow.Alert(parameters);
4822
        }
4823

    
4824
        #region 캡쳐 기능
4825

    
4826
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4827
        {
4828
            if (x < 0)
4829
            {
4830
                width += x;
4831
                x = 0;
4832
            }
4833
            if (y < 0)
4834
            {
4835
                height += y;
4836
                y = 0;
4837

    
4838
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4839
            }
4840
            if (x + width > zoomAndPanCanvas.ActualWidth)
4841
            {
4842
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4843
            }
4844
            if (y + height > zoomAndPanCanvas.ActualHeight)
4845
            {
4846
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4847
            }
4848

    
4849
            byte[] pixels = CopyPixels(x, y, width, height);
4850

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

    
4853
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4854
        }
4855

    
4856
        public byte[] CopyPixels(int x, int y, int width, int height)
4857
        {
4858
            byte[] pixels = new byte[width * height * 4];
4859
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4860

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

    
4864
            return pixels;
4865
        }
4866

    
4867
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4868
        {
4869
            DrawingVisual drawingVisual = new DrawingVisual();
4870
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4871

    
4872
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4873
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4874
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4875
            drawingContext.Close();
4876

    
4877
            // 비트맵으로 변환합니다.
4878
            RenderTargetBitmap target =
4879
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4880
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4881

    
4882
            target.Render(drawingVisual);
4883
            return target;
4884
        }
4885

    
4886
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4887
        {
4888
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4889
            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);
4890
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4891
            bmp.UnlockBits(data);
4892
            return bmp;
4893
        }
4894
        public string symbolname = null;
4895
        public bool symbolsvg = true;
4896
        public bool symbolpng = true;
4897

    
4898
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4899
        {
4900
            System.Drawing.Bitmap image = GetBitmap(source);
4901
            //흰색 제거
4902
            //image.MakeTransparent(System.Drawing.Color.White);
4903

    
4904
            var imageStream = new System.IO.MemoryStream();
4905
            byte[] imageBytes = null;
4906
            using (imageStream)
4907
            {
4908
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4909
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
4910
                imageStream.Position = 0;
4911
                imageBytes = imageStream.ToArray();
4912
            }
4913

    
4914
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4915

    
4916
            RadWindow CheckPop = new RadWindow();
4917
            //Alert check = new Alert(Msg);
4918

    
4919
            CheckPop = new RadWindow
4920
            {
4921
                MinWidth = 400,
4922
                MinHeight = 100,
4923
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4924
                Header = "Alert",
4925
                Content = symbolPrompt,
4926
                //DialogResult = 
4927
                ResizeMode = System.Windows.ResizeMode.NoResize,
4928
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
4929
                IsTopmost = true,
4930
            };
4931
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
4932
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
4933
            CheckPop.ShowDialog();
4934

    
4935
            /*
4936
            DialogParameters parameters = new DialogParameters()
4937
            {
4938
                Owner = Application.Current.MainWindow,
4939
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4940
                DefaultPromptResultValue = "Custom State",
4941
                Content = "Name :",
4942
                Header = "Insert Custom Symbol Name",
4943
                Theme = new VisualStudio2013Theme(),
4944
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4945
            };            
4946
            RadWindow.Prompt(parameters);
4947
            */
4948
        }
4949

    
4950
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4951
        {
4952
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4953
            KCOMDataModel.DataModel.CHECK_LIST check_;
4954
            string Result = streamToBase64.ImageToBase64(source);
4955
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4956
            string projectno = App.ViewInfo.ProjectNO;
4957
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
4958

    
4959
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
4960
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
4961
            if (Item != null)
4962
            {
4963
                Logger.sendResLog("GetCheckList", "TRUE", 1);
4964
            }
4965
            else
4966
            {
4967
                Logger.sendResLog("GetCheckList", "FALSE", 1);
4968
            }
4969

    
4970
            if (Item == null)
4971
            {
4972
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
4973
                {
4974
                    ID = Commons.shortGuid(),
4975
                    USER_ID = App.ViewInfo.UserID,
4976
                    IMAGE_URL = Result,
4977
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
4978
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
4979
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
4980
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
4981
                    PROJECT_NO = App.ViewInfo.ProjectNO,
4982
                    STATUS = "False",
4983
                    CREATE_TIME = DateTime.Now,
4984
                    UPDATE_TIME = DateTime.Now,
4985
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
4986
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
4987
                };
4988
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
4989
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
4990
                //this.BaseClient.AddCheckList(projectno, check_);
4991
            }
4992
            else
4993
            {
4994
                Item.IMAGE_URL = Result;
4995
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
4996
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
4997
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
4998
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
4999
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5000
            }
5001

    
5002
        }
5003

    
5004
        public void Set_Capture()
5005
        {
5006
            double x = canvasDrawingMouseDownPoint.X;
5007
            double y = canvasDrawingMouseDownPoint.Y;
5008
            double width = dragCaptureBorder.Width;
5009
            double height = dragCaptureBorder.Height;
5010

    
5011
            if (width > 5 || height > 5)
5012
            {
5013
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5014
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5015
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5016
            }
5017
        }
5018
        #endregion
5019

    
5020
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5021
        {
5022
            multi_Undo_Data = new Multi_Undo_data();
5023

    
5024
            multi_Undo_Data.Markup = control;
5025

    
5026
            if ((control as IShapeControl) != null)
5027
            {
5028
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5029
            }
5030
            if ((control as IDashControl) != null)
5031
            {
5032
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5033
            }
5034
            if ((control as IPath) != null)
5035
            {
5036
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5037
            }
5038
            if ((control as UIElement) != null)
5039
            {
5040
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5041
            }
5042

    
5043
            return multi_Undo_Data;
5044
        }
5045

    
5046
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5047
        {
5048
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5049
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5050
            {
5051
                if (items.UserID == Select_ID)
5052
                {
5053
                    foreach (var item in items.MarkupList)
5054
                    {
5055
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5056
                        {
5057
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5058
                                items.MarkupInfoID, Commons.shortGuid());
5059
                        }
5060
                    }
5061
                }
5062
            }
5063
        }
5064

    
5065
        public void InkControl_Convert()
5066
        {
5067
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
5068
            if (inkBoard.Strokes.Count > 0)
5069
            {
5070
                inkBoard.Strokes.ToList().ForEach(stroke =>
5071
                {
5072
                    List<Stroke> removingStroke = new List<Stroke>();
5073
                    StrokeCollection stC = new StrokeCollection();
5074

    
5075
                    removingStroke.Add(stroke);
5076

    
5077
                    InkToPath ip = new InkToPath();
5078
                    List<Point> inkPointSet = new List<Point>();
5079
                    PolygonControl pc = null;
5080
                    pc = new PolygonControl()
5081
                    {
5082
                        Angle = 0,
5083
                        PointSet = new List<Point>(),
5084
                        ControlType = ControlType.Ink
5085
                    };
5086
                    foreach (var item in removingStroke)
5087
                    {
5088
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5089
                        inkBoard.Strokes.Remove(item);
5090
                    }
5091
                    if (inkPointSet.Count != 0)
5092
                    {
5093
                        //강인구 추가(PenControl Undo Redo 추가)
5094
                        UndoData = new Undo_data()
5095
                        {
5096
                            IsUndo = false,
5097
                            Event = Event_Type.Create,
5098
                            EventTime = DateTime.Now,
5099
                            Markup_List = new List<Multi_Undo_data>()
5100
                        };
5101

    
5102
                        pc.StartPoint = inkPointSet[0];
5103
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5104
                        pc.PointSet = inkPointSet;
5105
                        pc.LineSize = 3;
5106
                        pc.CommentID = Commons.shortGuid();
5107
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5108
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5109
                        ///pc.SetPolyPath();
5110

    
5111
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5112
                        {
5113
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5114
                        });
5115
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5116
                        UndoData.Markup_List.Add(multi_Undo_Data);
5117
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5118
                    }
5119
                });
5120
            }
5121
        }
5122

    
5123
        /// <summary>
5124
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5125
        /// </summary>
5126
        /// <author>ingu</author>
5127
        /// <date>2018.06.05</date>
5128
        /// <param name="getPoint"></param>
5129
        /// <returns></returns>
5130
        private bool IsGetoutpoint(Point getPoint)
5131
        {
5132
            if (getPoint == new Point())
5133
            {
5134
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5135
                currentControl = null;
5136
                return true;
5137
            }
5138

    
5139
            return false;
5140
        }
5141

    
5142
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5143
        {
5144
            e.Effects = DragDropEffects.Copy;
5145
        }
5146

    
5147
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5148
        {
5149
            e.Effects = DragDropEffects.Copy;
5150
        }
5151

    
5152
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5153
        {
5154
            e.Effects = DragDropEffects.None;
5155
        }
5156

    
5157
        /*
5158
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5159
        {
5160
            try
5161
            {
5162
                if (e.Data.GetDataPresent(typeof(string)))
5163
                {
5164
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5165
                    string dragData = e.Data.GetData(typeof(string)) as string;
5166
                    Move_Symbol(sender, dragData);
5167
                }
5168
            }
5169
            catch (Exception ex)
5170
            {
5171
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5172
            }            
5173
        }
5174
        */
5175
    }
5176
}
클립보드 이미지 추가 (최대 크기: 500 MB)