프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (245 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
            App.splashString(ISplashMessage.MAINMENU_0);
240
            //InitializeComponent();    
241
            this.Loaded += MainMenu_Loaded;
242
        }
243

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

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

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

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

    
271
            return false;
272
        }
273

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

    
297
            return false;
298
        }
299

    
300

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

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

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

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

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

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

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

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

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

    
374
            DeleteItem(item);
375
        }
376

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

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

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

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

    
410
        
411

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

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

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

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

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

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

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

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

    
500
        bool ComingNewBieEnd = false;
501

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

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

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

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

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

    
530

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

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

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

    
548
            //}
549
            SetCommentPages(true);
550
        }
551
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
552
        {
553
            
554
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
555
            {            
556
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
557
            }
558
            
559
            ViewerDataModel.Instance.UndoDataList.Clear();
560

    
561
            ConvertInkControlToPolygon();
562

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

    
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
            string uri = "";
589
            if (userData.COMPANY != "EXT")
590
            {
591
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
592
            }
593
            else
594
            {
595
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
596
            }
597

    
598
            var defaultBitmapImage = new BitmapImage();
599
            defaultBitmapImage.BeginInit();
600
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
601
            defaultBitmapImage.UriSource = new Uri(uri);
602
            defaultBitmapImage.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
603
            defaultBitmapImage.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
604
            defaultBitmapImage.EndInit();
605

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

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

    
629

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

    
635

    
636

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

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

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

    
683
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
684
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
685
                    defaultBitmapImage_Compare.BeginInit();
686
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
687
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
688
                    defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
689
                    defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
690
                    defaultBitmapImage_Compare.EndInit();
691

    
692
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
693

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

    
703
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
704
                    if (defaultBitmapImage_Compare.IsDownloading)
705
                    {
706
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
707
                        {
708
                            defaultBitmapImage_Compare.Freeze();
709
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
710
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
711
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
712
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
713
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
714

    
715
                            zoomAndPanControl.ZoomTo(new Rect
716
                            {
717
                                X = 0,
718
                                Y = 0,
719
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
720
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
721
                            });
722

    
723
                            //defaultBitmapImage_Compare dispose
724
                            defaultBitmapImage_Compare = null;
725
                            GC.Collect();
726
                        };
727
                    }
728
                }
729
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
730
            }
731

    
732
        }
733

    
734

    
735
        
736

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

    
763
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
764
        {
765
            if (e.MiddleButton == MouseButtonState.Pressed)
766
            {
767

    
768
            }
769
            e.Handled = true;
770
            if (e.Delta > 0)
771
            {
772
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
773
                ZoomIn(currentContentMousePoint);
774
            }
775
            else
776
            {
777
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
778
                ZoomOut(currentContentMousePoint);
779
            }
780
        }
781

    
782
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
783
        {
784
            e.Handled = true;
785
            if (e.Delta > 0)
786
            {
787
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
788
                ZoomIn_Sync(currentContentMousePoint);
789
            }
790
            else
791
            {
792
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
793
                ZoomOut_Sync(currentContentMousePoint);
794
            }
795
        }
796

    
797
        #region ZoomIn & ZoomOut
798

    
799
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
800
        {
801
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
802
                zoomAndPanControl.ContentZoomFocusY));
803
        }
804

    
805
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
806
        {
807
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
808
                zoomAndPanControl.ContentZoomFocusY));
809
        }
810

    
811

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

    
825
            if (zoomAndPanControl2 != null && Sync.IsChecked)
826
            {
827
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
828
            }
829
        }
830

    
831
        private void ZoomIn(Point contentZoomCenter)
832
        {
833
            if (zoomAndPanControl.ContentScale > 0.19)
834
            {
835
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
836
            }
837
            else
838
            {
839
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
840
            }
841

    
842
            if (zoomAndPanControl2 != null && Sync.IsChecked)
843
            {
844
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
845
            }
846

    
847
        }
848

    
849
        private void ZoomOut_Sync(Point contentZoomCenter)
850
        {
851
            if (zoomAndPanControl2.ContentScale > 0.39)
852
            {
853
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
854
            }
855
            else
856
            {
857
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
858
            }
859

    
860
            if (Sync.IsChecked)
861
            {
862
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
863
            }
864
        }
865

    
866
        private void ZoomIn_Sync(Point contentZoomCenter)
867
        {
868
            if (zoomAndPanControl2.ContentScale > 0.19)
869
            {
870
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
871
            }
872
            else
873
            {
874
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
875
            }
876

    
877
            if (Sync.IsChecked)
878
            {
879
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
880
            }
881
        }
882

    
883
        private void ZoomOut()
884
        {
885
            zoomAndPanControl.ContentScale -= 0.1;
886
            //if (zoomAndPanControl2 != null)
887
            //{
888
            //    zoomAndPanControl2.ContentScale -= 0.1;
889
            //}
890
        }
891

    
892
        private void ZoomIn()
893
        {
894
            zoomAndPanControl.ContentScale += 0.1;
895
            //if (zoomAndPanControl2 != null)
896
            //{
897
            //    zoomAndPanControl2.ContentScale += 0.1;
898
            //}
899
        }
900

    
901
        #endregion
902

    
903
        private void init()
904
        {
905
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
906
            {
907

    
908
                ControlList.Clear();
909
                listBox.Items.Clear();
910
                selected_item.Clear();
911

    
912
                (item as IMarkupCommonData).IsSelected = false;
913
            }
914

    
915
        }
916

    
917
        private HitTestResultBehavior MyCallback(HitTestResult result)
918
        {
919
            //this.cursor = Cursors.UpArrow;
920
            var element = result.VisualHit;
921
            while (element != null && !(element is CommentUserInfo))
922
                element = VisualTreeHelper.GetParent(element);
923

    
924
            if (element == null)
925
            {
926
                return HitTestResultBehavior.Stop;
927
            }
928
            else
929
            {
930
                if (element is CommentUserInfo)
931
                {
932
                    if (!hitList.Contains(element))
933
                    {
934
                        hitList.Add((CommentUserInfo)element);
935
                    }
936
                    else
937
                    {
938
                        return HitTestResultBehavior.Stop;
939
                    }
940
                }
941
            }
942
            return HitTestResultBehavior.Continue;
943
        }
944

    
945
        public void ReleaseSelectPath()
946
        {
947
            if (SelectionPath == null)
948
            {
949
                SelectionPath = new Path();
950
                SelectionPath.Name = "";
951
            }
952
            if (SelectionPath.Name != "")
953
            {
954
                SelectionPath.Name = "None";
955
            }
956
            SelectionPath.Opacity = 0.01;
957
            SelectionPath.RenderTransform = null;
958
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
959
        }
960

    
961
        #region 컨트롤 초기화 
962
        public void Control_Init(object control)
963
        {
964
            if (L_Size != 0 && (control as IPath) != null)
965
            {
966
                (control as IPath).LineSize = L_Size;
967
                L_Size = 0;
968
            }
969

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

    
1056
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1057
        {
1058
            //Control_Init(e.Source);
1059
        }
1060
        //private Window _dragdropWindow = null;
1061

    
1062
        [DllImport("user32.dll")]
1063
        [return: MarshalAs(UnmanagedType.Bool)]
1064
        internal static extern bool GetCursorPos(ref Win32Point pt);
1065

    
1066
        [StructLayout(LayoutKind.Sequential)]
1067
        internal struct Win32Point
1068
        {
1069
            public Int32 X;
1070
            public Int32 Y;
1071
        };
1072
        /*
1073
       public string symbol_id = null;
1074
       public long symbol_group_id;
1075
       public int symbol_SelectedIndex;
1076
       public ImageSource symbol_img;
1077
       public string symbol_Data = null;
1078
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1079
       {
1080
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1081
               zoomAndPanCanvas.ActualHeight / 2));
1082

    
1083

    
1084
               if (this._dragdropWindow != null)
1085
               {
1086
                   this._dragdropWindow.Close();
1087
                   this._dragdropWindow = null;
1088
               }
1089

    
1090
               symbol_id = id;
1091
               symbol_group_id = group_id;
1092
               symbol_SelectedIndex = SelectedIndex;
1093
               symbol_Data = Data_;
1094
               symbol_img = img;
1095

    
1096

    
1097
               CreateDragDropWindow2(img);
1098
              
1099
    }
1100

    
1101
    private void CreateDragDropWindow2(ImageSource image)
1102
        {
1103
            this._dragdropWindow = new Window();
1104
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1105
            _dragdropWindow.WindowStyle = WindowStyle.None;
1106
            _dragdropWindow.AllowsTransparency = true;           
1107
            _dragdropWindow.AllowDrop = false;
1108
            _dragdropWindow.Background = null;
1109
            _dragdropWindow.IsHitTestVisible = false;
1110
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1111
            _dragdropWindow.Topmost = true;
1112
            _dragdropWindow.ShowInTaskbar = false;
1113
            
1114
            Rectangle r = new Rectangle();
1115
            r.Width = image.Width;
1116
            r.Height = image.Height;
1117
            r.Opacity = 0.5;            
1118
            r.Fill = new ImageBrush(image);
1119
            this._dragdropWindow.Content = r;
1120

    
1121
            Win32Point w32Mouse = new Win32Point();
1122
            GetCursorPos(ref w32Mouse);
1123

    
1124
            //w32Mouse.X = getCurrentPoint.X;
1125
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1126
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1127
            this._dragdropWindow.Show();
1128
        }
1129
         */
1130
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1131
        {
1132
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1133
            {
1134
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1135

    
1136
                Point currentPos = e.GetPosition(rect);
1137

    
1138
                floatingTip.HorizontalOffset = currentPos.X + 20;
1139
                floatingTip.VerticalOffset = currentPos.Y;
1140
            }
1141

    
1142
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1143
            
1144
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1145
            {
1146
                SetCursor();
1147
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1148
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1149

    
1150
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1151
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1152
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1153

    
1154
                if (Sync.IsChecked)
1155
                {
1156
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1157
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1158
                }
1159
            }
1160

    
1161
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1162
            {
1163
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1164
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1165
                SetCursor();
1166

    
1167
                if (currentControl != null)
1168
                {
1169
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1170
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1171
                    //강인구 추가
1172
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1173

    
1174
                    if ((currentControl as IPath) != null)
1175
                    {
1176
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1177
                    }
1178
                    if ((currentControl as LineControl) != null)
1179
                    {
1180
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1181
                    }
1182

    
1183
                    if ((currentControl as IShapeControl) != null)
1184
                    {
1185
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1186
                    }
1187
                    if ((currentControl as TextControl) != null)
1188
                    {
1189
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1190
                        {
1191
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1192
                        }
1193
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1194
                        {
1195
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1196
                        }
1197
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1198
                        {
1199
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1200
                        }
1201
                    }
1202
                    else if ((currentControl as ArrowTextControl) != null)
1203
                    {
1204
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1205
                        {
1206
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1207
                        }
1208
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1209
                        {
1210
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1211
                        }
1212
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1213
                        {
1214
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1215
                        }
1216
                    }
1217
                    else if ((currentControl as RectCloudControl) != null)
1218
                    {
1219
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1220
                    }
1221
                    else if ((currentControl as CloudControl) != null)
1222
                    {
1223
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1224
                    }
1225

    
1226
                    switch (controlType)
1227
                    {
1228
                        case (ControlType.Coordinate):
1229
                            {
1230
                                var control = currentControl as CoordinateControl;
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
                                }
1237
                            }
1238
                            break;
1239
                        case (ControlType.InsideWhite):
1240
                            {
1241
                                var control = currentControl as InsideWhiteControl;
1242
                                if (control != null)
1243
                                {
1244
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1245
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1246
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1247
                                    control.Paint = PaintSet.Fill;
1248
                                }
1249
                            }
1250
                            break;
1251
                        case ControlType.OverlapWhite:
1252
                            {
1253
                                var control = currentControl as OverlapWhiteControl;
1254
                                if (control != null)
1255
                                {
1256
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1257
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1258
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1259
                                    control.Paint = PaintSet.Fill;
1260
                                }
1261
                            }
1262
                            break;
1263
                        case ControlType.ClipWhite:
1264
                            {
1265
                                var control = currentControl as ClipWhiteControl;
1266
                                if (control != null)
1267
                                {
1268
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1269
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1270
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1271
                                    control.Paint = PaintSet.Fill;
1272
                                }
1273
                            }
1274
                            break;
1275
                        case ControlType.RectCloud:
1276
                            {
1277
                                var control = currentControl as RectCloudControl;
1278
                                if (control != null)
1279
                                {
1280
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1281
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1282
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1283
                                }
1284
                            }
1285
                            break;
1286
                        case ControlType.SingleLine:
1287
                        case ControlType.CancelLine:
1288
                        case ControlType.ArrowLine:
1289
                        case ControlType.TwinLine:
1290
                        case ControlType.DimLine:
1291
                            {
1292
                                var control = currentControl as LineControl;
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.ArcLine:
1302
                            {
1303
                                var control = currentControl as ArcControl;
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.ArcArrow:
1313
                            {
1314
                                var control = currentControl as ArrowArcControl;
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.ArrowMultiLine:
1324
                            {
1325
                                var control = currentControl as ArrowControl_Multi;
1326
                                if (control != null)
1327
                                {
1328
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1329
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1330
                                }
1331
                            }
1332
                            break;
1333

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

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

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

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

    
1379
                        case ControlType.Date:
1380
                            {
1381
                                var control = currentControl as DateControl;
1382
                                if (control != null)
1383
                                {
1384
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1385
                                }
1386
                            }
1387
                            break;
1388

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

    
1489
                                //inkBoard.Strokes.Add(stroke);
1490
                            }
1491
                            break;
1492
                    }
1493
                    return;
1494
                }
1495
            }
1496
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1497
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1498
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1499
            {
1500
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1501

    
1502
                if (isDraggingSelectionRect)
1503
                {
1504
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1505
                    e.Handled = true;
1506
                }
1507
                else if (isLeftMouseButtonDownOnWindow)
1508
                {
1509
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1510
                    double dragDistance = Math.Abs(dragDelta.Length);
1511

    
1512
                    if (dragDistance > DragThreshold)
1513
                    {
1514
                        isDraggingSelectionRect = true;
1515
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1516
                    }
1517

    
1518
                    e.Handled = true;
1519
                }
1520

    
1521
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1522
                {
1523
                }
1524
                else
1525
                {
1526
                    e.Handled = true;
1527
                }
1528
            }
1529
            /*
1530
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1531
            { //symbol      
1532
                if(_dragdropWindow != null)
1533
                {
1534
                    Win32Point w32Mouse = new Win32Point();
1535
                    GetCursorPos(ref w32Mouse);
1536

    
1537
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1538
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1539
                }                
1540
            }
1541
            */
1542
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1543
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1544
            {
1545
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1546
                if(control != null)
1547
                {
1548
                    this.cursor = Cursors.Hand;
1549
                    SetCursor();
1550
                }
1551
                else
1552
                {
1553
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1554
                    SetCursor();
1555
                }
1556
            }
1557
            else
1558
            {
1559
            }
1560
        }
1561

    
1562
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1563
        {
1564
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1565
            {
1566
                SetCursor();
1567
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1568
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1569

    
1570
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1571

    
1572
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1573
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1574

    
1575
                if (Sync.IsChecked)
1576
                {
1577
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1578
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1579
                }
1580
            }
1581
        }
1582

    
1583
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1584

    
1585
        private EllipseGeometry hitArea = new EllipseGeometry();
1586

    
1587
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1588
        {
1589
            IsDrawing = false;
1590

    
1591
            if (mouseHandlingMode != MouseHandlingMode.None)
1592
            {
1593
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1594
                {
1595
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1596

    
1597
                    SetCursor();
1598

    
1599
                    switch (controlType)
1600
                    {
1601
                        case ControlType.None:
1602
                            break;
1603
                        case ControlType.Rectangle:
1604
                            {
1605

    
1606
                            }
1607
                            break;
1608
                        case ControlType.PenControl:
1609
                            {
1610

    
1611
                            }
1612
                            break;
1613
                        default:
1614
                            break;
1615
                    }
1616
                }
1617
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1618
                {
1619
                    if (isLeftMouseButtonDownOnWindow)
1620
                    {
1621
                        bool wasDragSelectionApplied = false;
1622

    
1623
                        if (isDraggingSelectionRect)
1624
                        {
1625
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1626
                            {
1627
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1628
                                mouseHandlingMode = MouseHandlingMode.None;
1629
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1630
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1631
                                Set_Symbol_Capture(endPoint);
1632
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1633
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1634
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1635
                            }
1636
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1637
                            {
1638
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1639
                                mouseHandlingMode = MouseHandlingMode.None;
1640
                                Set_Capture();
1641

    
1642
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1643
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1644
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1645
                            }
1646
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1647
                            {
1648
                                ApplyDragSelectionRect();
1649
                            }
1650
                            else
1651
                            {
1652
                                double x = Canvas.GetLeft(dragZoomBorder);
1653
                                double y = Canvas.GetTop(dragZoomBorder);
1654
                                double width = dragZoomBorder.Width;
1655
                                double height = dragZoomBorder.Height;
1656
                                Rect dragRect = new Rect(x, y, width, height);
1657

    
1658
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1659

    
1660
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1661
                            }
1662

    
1663
                            isDraggingSelectionRect = false;
1664
                            e.Handled = true;
1665
                            wasDragSelectionApplied = true;
1666
                        }
1667

    
1668
                        if (isLeftMouseButtonDownOnWindow)
1669
                        {
1670
                            isLeftMouseButtonDownOnWindow = false;
1671
                            this.ReleaseMouseCapture();
1672
                            e.Handled = true;
1673
                        }
1674

    
1675
                        if (!wasDragSelectionApplied)
1676
                        {
1677
                            init();
1678
                        }
1679
                    }
1680
                }
1681
                else if (e.RightButton == MouseButtonState.Pressed)
1682
                {
1683
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1684
                    SetCursor();
1685
                }
1686

    
1687
                zoomAndPanControl.ReleaseMouseCapture();
1688

    
1689

    
1690
                e.Handled = true;
1691
            }
1692
            else
1693
            {
1694
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1695
                SetCursor();
1696
            }
1697

    
1698
            ///mouseButtonDown = MouseButton.Left;
1699
            //controlType = ControlType.SingleLine;
1700
        }
1701

    
1702
        public void Set_Symbol_Capture(Point endPoint)
1703
        {       
1704
            double x = canvasDrawingMouseDownPoint.X;
1705
            double y = canvasDrawingMouseDownPoint.Y;
1706
            if(x > endPoint.X)
1707
            {
1708
                x = endPoint.X;
1709
                y = endPoint.Y;
1710
            }
1711

    
1712
            double width = dragCaptureBorder.Width;
1713
            double height = dragCaptureBorder.Height;
1714

    
1715
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1716

    
1717
            if (x < 0)
1718
            {
1719
                width += x;
1720
                x = 0;
1721
            }
1722
            if (y < 0)
1723
            {
1724
                height += y;
1725
                y = 0;
1726

    
1727
                width = (int)canvasImage.PixelWidth - x;
1728
            }
1729
            if (x + width > canvasImage.PixelWidth)
1730
            {
1731
                width = (int)canvasImage.PixelWidth - x;
1732
            }
1733
            if (y + height > canvasImage.PixelHeight)
1734
            {
1735
                height = (int)canvasImage.PixelHeight - y;
1736
            }
1737
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1738

    
1739
            string uri = "";
1740
            if (userData.COMPANY != "EXT")
1741
            {
1742
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1743
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1744
            }
1745
            else
1746
            {
1747
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1748
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1749
            }
1750

    
1751
            var defaultBitmapImage = new BitmapImage();
1752
            defaultBitmapImage.BeginInit();
1753
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1754
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1755
            defaultBitmapImage.UriSource = new Uri(uri);
1756
            defaultBitmapImage.EndInit();
1757

    
1758
            //GC.Collect();
1759

    
1760
            if (defaultBitmapImage.IsDownloading)
1761
            {
1762
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1763
                {
1764
                    defaultBitmapImage.Freeze();
1765
                    //GC.Collect();
1766
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1767
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1768
                };
1769
            }
1770
        }
1771

    
1772
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1773
        {
1774
            ///mouseButtonDown = MouseButton.Left;
1775
        }
1776

    
1777
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1778
        {
1779
            ///mouseButtonDown = MouseButton.Left;
1780
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1781
        }
1782

    
1783
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1784
        {
1785

    
1786
        }
1787

    
1788
        /// <summary>
1789
        /// select items by dragging
1790
        /// </summary>
1791
        private void ApplyDragSelectionRect()
1792
        {
1793
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1794

    
1795
            double x = Canvas.GetLeft(dragSelectionBorder);
1796
            double y = Canvas.GetTop(dragSelectionBorder);
1797
            double width = dragSelectionBorder.Width;
1798
            double height = dragSelectionBorder.Height;
1799
            Boolean Flag = false;
1800
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1801
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1802

    
1803
            Rect dragRect = new Rect(x, y, width, height);
1804
            ///dragRect.Inflate(width / 10, height / 10);
1805

    
1806
            foreach (var item in Items)
1807
            {
1808
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1809

    
1810
                if (Flag)
1811
                {
1812
                    adornerSet.Add(item);
1813
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1814
                    Control_Style(item);
1815
                }
1816
            }
1817
            if (adornerSet.Count > 0)
1818
            {
1819
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1820
                SelectLayer.Children.Add(final);
1821
            }
1822
        }
1823

    
1824
        private void InitDragSelectionRect(Point pt1, Point pt2)
1825
        {
1826
            //캡쳐 중
1827
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1828
            {
1829
                dragCaptureBorder.Visibility = Visibility.Visible;
1830
            }
1831
            //선택 중
1832
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1833
            {
1834

    
1835
                dragSelectionBorder.Visibility = Visibility.Visible;
1836
            }
1837
            else
1838
            {
1839
                dragZoomBorder.Visibility = Visibility.Visible;
1840
            }
1841
            UpdateDragSelectionRect(pt1, pt2);
1842
        }
1843

    
1844
        /// <summary>
1845
        /// Update the position and size of the rectangle used for drag selection.
1846
        /// </summary>
1847
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1848
        {
1849
            double x, y, width, height;
1850

    
1851
            //
1852
            // Determine x,y,width and height of the rect inverting the points if necessary.
1853
            // 
1854

    
1855
            if (pt2.X < pt1.X)
1856
            {
1857
                x = pt2.X;
1858
                width = pt1.X - pt2.X;
1859
            }
1860
            else
1861
            {
1862
                x = pt1.X;
1863
                width = pt2.X - pt1.X;
1864
            }
1865

    
1866
            if (pt2.Y < pt1.Y)
1867
            {
1868
                y = pt2.Y;
1869
                height = pt1.Y - pt2.Y;
1870
            }
1871
            else
1872
            {
1873
                y = pt1.Y;
1874
                height = pt2.Y - pt1.Y;
1875
            }
1876

    
1877
            //
1878
            // Update the coordinates of the rectangle used for drag selection.
1879
            //
1880
            //캡쳐 중
1881
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1882
            {
1883
                Canvas.SetLeft(dragCaptureBorder, x);
1884
                Canvas.SetTop(dragCaptureBorder, y);
1885
                dragCaptureBorder.Width = width;
1886
                dragCaptureBorder.Height = height;
1887
            }
1888
            //선택 중
1889
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1890
            {
1891
                Canvas.SetLeft(dragSelectionBorder, x);
1892
                Canvas.SetTop(dragSelectionBorder, y);
1893
                dragSelectionBorder.Width = width;
1894
                dragSelectionBorder.Height = height;
1895
            }
1896
            else
1897
            {
1898
                Canvas.SetLeft(dragZoomBorder, x);
1899
                Canvas.SetTop(dragZoomBorder, y);
1900
                dragZoomBorder.Width = width;
1901
                dragZoomBorder.Height = height;
1902
            }
1903
        }
1904

    
1905
        private void drawingPannelRotate(double angle)
1906
        {
1907
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1908
            rotate.Angle = angle;
1909
            var rotationNum = Math.Abs((rotate.Angle / 90));
1910

    
1911
            if (angle == 90 || angle == 270)
1912
            {
1913
                double emptySize = zoomAndPanCanvas.Width;
1914
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1915
                zoomAndPanCanvas.Height = emptySize;
1916
            }
1917
            if (angle == 0)
1918
            {
1919
                translate.X = 0;
1920
                translate.Y = 0;
1921
            }
1922
            else if (angle == 90)
1923
            {
1924
                translate.X = zoomAndPanCanvas.Width;
1925
                translate.Y = 0;
1926
            }
1927
            else if (angle == 180)
1928
            {
1929
                translate.X = zoomAndPanCanvas.Width;
1930
                translate.Y = zoomAndPanCanvas.Height;
1931
            }
1932
            else
1933
            {
1934
                translate.X = 0;
1935
                translate.Y = zoomAndPanCanvas.Height;
1936
            }
1937

    
1938
            zoomAndPanControl.RotationAngle = rotate.Angle;
1939

    
1940

    
1941
            if (!testPanel2.IsHidden)
1942
            {
1943
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1944
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1945
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1946
            }
1947

    
1948
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1949
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1950
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1951
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1952
            ViewerDataModel.Instance.Angle = rotate.Angle;
1953
        }
1954

    
1955
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1956
        {
1957
            string Data_ = "";
1958

    
1959
            try
1960
            {
1961
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1962
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1963
                if (Data_ != null || Data_ != "")
1964
                {
1965
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1966
                }
1967
                else
1968
                {
1969
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1970
                }
1971

    
1972
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
1973
                //{
1974
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
1975
                //    STATE = 0,
1976
                //};
1977
                if (Data_ != null)
1978
                {
1979
                    Image img = new Image();
1980
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
1981
                    if (Data_.Contains(".svg"))
1982
                    {
1983
                        byte[] imageData = null;
1984
                        DrawingImage image = null;
1985
                        using (System.Net.WebClient web = new System.Net.WebClient())
1986
                        {
1987
                            imageData = web.DownloadData(new Uri(Data_));
1988
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
1989
                            image = SvgReader.Load(stream);
1990
                        }
1991
                        img.Source = image;
1992
                    }
1993
                    else
1994
                    {
1995
                        img.Source = new BitmapImage(new Uri(Data_));
1996
                    }
1997

    
1998
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
1999
                    {
2000
                        PointSet = new List<Point>(),
2001
                        FilePath = Data_,
2002
                        ImageData = img.Source,
2003
                        StartPoint = canvasZoomPanningMouseDownPoint,
2004
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2005
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2006
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2007
                        canvasZoomPanningMouseDownPoint.Y),
2008
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2009
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2010
                    };
2011

    
2012
                    currentControl.PointSet = new List<Point>
2013
                                        {
2014
                                            currentControl.StartPoint,
2015
                                            currentControl.LeftBottomPoint,
2016
                                            currentControl.EndPoint,
2017
                                            currentControl.TopRightPoint,
2018
                                        };
2019
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2020
                    UndoData = new Undo_data()
2021
                    {
2022
                        IsUndo = false,
2023
                        Event = Event_Type.Create,
2024
                        EventTime = DateTime.Now,
2025
                        Markup_List = new List<Multi_Undo_data>()
2026
                    };
2027
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2028
                    {
2029
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2030
                    });
2031

    
2032
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2033
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2034
                    UndoData.Markup_List.Add(multi_Undo_Data);
2035
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2036

    
2037
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2038
                    currentControl.CommentID = Commons.shortGuid();
2039
                    currentControl.SymbolID = id;
2040
                    currentControl.GroupID = group_id;
2041
                    currentControl.ApplyTemplate();
2042
                    currentControl.SetImage();
2043

    
2044
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2045
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2046
                    SelectLayer.Children.Add(final);
2047
                }
2048
            }
2049
            catch (Exception ex)
2050
            {
2051
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2052
            }
2053
        }
2054

    
2055
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2056
        {            
2057
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2058
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2059
            {
2060
                set_option.Value = double.Parse(set_option.ContentText);
2061
            }
2062

    
2063
            ConvertInkControlToPolygon();
2064

    
2065
            ///TODO:
2066
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2067
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2068

    
2069
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2070
            {
2071
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2072
            }
2073
            /// up to here
2074

    
2075
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2076
            {
2077
                if (arrow_text as ArrowTextControl != null)
2078
                {
2079
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2080
                }
2081
            }
2082

    
2083
            //if (currentControl != null)
2084
            {
2085
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2086
                if (text_item_ != null)
2087
                {
2088
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2089
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2090
                    (text_item_ as TextControl).EnableEditing = false;
2091
                    currentControl = null;
2092
                }
2093

    
2094
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2095
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2096
                {
2097
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2098
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2099
                    currentControl = null;
2100
                }
2101
            }
2102

    
2103
            double Ang = 0;                                          
2104
            if (rotate.Angle != 0)
2105
            {
2106
                Ang = 360 - rotate.Angle;
2107
            }
2108

    
2109
            if (e.OriginalSource is System.Windows.Controls.Image)
2110
            {
2111
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2112
            }
2113
            /*
2114
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2115
            {                
2116
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2117
                if(symbol_id != null)
2118
                {
2119
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2120
                }                
2121
            }
2122

    
2123
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2124
            {
2125
                if (this._dragdropWindow != null)
2126
                {
2127
                    this._dragdropWindow.Close();
2128
                    this._dragdropWindow = null;
2129
                    symbol_id = null;
2130
                }
2131
            }
2132
            */
2133

    
2134
            if (e.LeftButton == MouseButtonState.Pressed)
2135
            {
2136
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2137
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2138

    
2139
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2140
                SetCursor();
2141

    
2142
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2143
            }
2144

    
2145
            if (e.MiddleButton == MouseButtonState.Pressed)
2146
            {
2147
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2148
                cursor = Cursors.SizeAll;
2149
                SetCursor();
2150
            }
2151
            if (e.RightButton == MouseButtonState.Pressed)
2152
            {
2153
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2154
                cursor = Cursors.SizeAll;
2155
                SetCursor();
2156
            }
2157
            else if (e.XButton1 == MouseButtonState.Pressed)
2158
            {
2159
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2160
                {
2161
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2162
                }
2163

    
2164
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2165

    
2166
            }
2167
            else if (e.XButton2 == MouseButtonState.Pressed)
2168
            {
2169
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2170
                {
2171
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2172
                }
2173
            }
2174

    
2175
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2176
            {
2177
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2178
                {
2179
                    if (SelectLayer.Children.Count == 0)
2180
                    {
2181
                        isLeftMouseButtonDownOnWindow = true;
2182
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2183
                    }
2184

    
2185
                    if (controlType == ControlType.None)
2186
                    {
2187
                        isLeftMouseButtonDownOnWindow = true;
2188
                    }
2189
                }
2190

    
2191
                /// 캡쳐 모드 설정
2192
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2193
                {
2194
                    dragCaptureBorder.Visibility = Visibility.Visible;
2195
                    isLeftMouseButtonDownOnWindow = true;
2196
                }
2197

    
2198
                /// 줌 모드 설정
2199
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2200
                {
2201
                    isLeftMouseButtonDownOnWindow = true;
2202
                }
2203

    
2204
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2205
                if (control != null)
2206
                {
2207
                    AdornerFinal final = null;
2208

    
2209
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2210
                    {
2211
                        /// 기존 selection 해제
2212
                        SelectionSet.Instance.UnSelect(this);
2213

    
2214
                        final = new AdornerFinal(control);
2215

    
2216
                        this.Control_Style(control);
2217

    
2218
                        if ((control as IPath) != null)
2219
                        {
2220
                            if ((control as IPath).LineSize != 0)
2221
                            {
2222
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2223
                            }
2224
                        }
2225
                        if ((control as IShapeControl) != null)
2226
                        {
2227
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2228
                            {
2229
                                ViewerDataModel.Instance.checkHatchShape = true;
2230
                            }
2231
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2232
                            {
2233
                                ViewerDataModel.Instance.checkFillShape = true;
2234
                            }
2235
                            else
2236
                            {
2237
                                ViewerDataModel.Instance.checkHatchShape = false;
2238
                                ViewerDataModel.Instance.checkFillShape = false;
2239
                            }
2240
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2241
                        }
2242

    
2243
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2244

    
2245
                        if ((control as TextControl) != null)
2246
                        {
2247
                            if(!((control as TextControl).EnableEditing)) {
2248
                                (control as TextControl).EnableEditing = true;
2249
                            }
2250

    
2251
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2252
                            {
2253
                                ViewerDataModel.Instance.checkTextStyle = true;
2254
                            }
2255
                            else
2256
                            {
2257
                                ViewerDataModel.Instance.checkTextStyle = false;
2258
                            }
2259

    
2260
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2261
                            {
2262
                                ViewerDataModel.Instance.checkTextStyle = true;
2263
                            }
2264
                            else
2265
                            {
2266
                                ViewerDataModel.Instance.checkTextStyle = false;
2267
                            }
2268
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2269
                            {
2270
                                ViewerDataModel.Instance.checkTextWeight = true;
2271
                            }
2272
                            else
2273
                            {
2274
                                ViewerDataModel.Instance.checkTextWeight = false;
2275
                            }
2276
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2277
                            {
2278
                                ViewerDataModel.Instance.checkUnderLine = true;
2279
                            }
2280
                            else
2281
                            {
2282
                                ViewerDataModel.Instance.checkUnderLine = false;
2283
                            }
2284
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2285
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2286

    
2287
                        }
2288
                        else if ((control as ArrowTextControl) != null)
2289
                        {
2290
                            if (!((control as ArrowTextControl).EnableEditing))
2291
                            {
2292
                                (control as ArrowTextControl).EnableEditing = true;
2293
                            }
2294
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2295
                            {
2296
                                ViewerDataModel.Instance.checkTextStyle = true;
2297
                            }
2298
                            else
2299
                            {
2300
                                ViewerDataModel.Instance.checkTextStyle = false;
2301
                            }
2302

    
2303
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2304
                            {
2305
                                ViewerDataModel.Instance.checkTextStyle = true;
2306
                            }
2307
                            else
2308
                            {
2309
                                ViewerDataModel.Instance.checkTextStyle = false;
2310
                            }
2311
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2312
                            {
2313
                                ViewerDataModel.Instance.checkTextWeight = true;
2314
                            }
2315
                            else
2316
                            {
2317
                                ViewerDataModel.Instance.checkTextWeight = false;
2318
                            }
2319
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2320
                            {
2321
                                ViewerDataModel.Instance.checkUnderLine = true;
2322
                            }
2323
                            else
2324
                            {
2325
                                ViewerDataModel.Instance.checkUnderLine = false;
2326
                            }
2327
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2328
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2329
                        }
2330
                        else if ((control as RectCloudControl) != null)
2331
                        {
2332
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2333
                        }
2334
                        else if ((control as CloudControl) != null)
2335
                        {
2336
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2337
                        }
2338
                    }
2339
                    else
2340
                    {
2341
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2342
                        SelectionSet.Instance.UnSelect(this);
2343
                        comment.Add(control);
2344

    
2345
                        Control_Style(control);
2346

    
2347
                        final = new AdornerFinal(comment);
2348
                    }
2349

    
2350
                    if (final != null)
2351
                    {
2352
                        this.SelectLayer.Children.Add(final);
2353
                    }
2354
                }              
2355
            }
2356
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2357
            {               
2358
                init();
2359
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2360
                if (cursor != Cursors.SizeAll)
2361
                {
2362
                    cursor = Cursors.Cross;
2363
                    SetCursor();
2364
                }
2365
                bool init_user = false;
2366
                foreach (var user in gridViewMarkup.Items)
2367
                {
2368
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2369
                    {
2370
                        init_user = true;
2371
                    }
2372
                }
2373
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2374
                {
2375
                    RadWindow.Alert(new DialogParameters
2376
                    {
2377
                        Owner = Application.Current.MainWindow,
2378
                        Theme = new VisualStudio2013Theme(),
2379
                        Header = "안내",
2380
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2381
                    });
2382
                    return;
2383
                }
2384
                else
2385
                {
2386
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2387
                    if (item != null)
2388
                    {
2389
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2390
                    }
2391
                }
2392

    
2393
                switch (controlType)
2394
                {
2395
                    case ControlType.Coordinate:
2396
                        {
2397
                            if (e.LeftButton == MouseButtonState.Pressed)
2398
                            {
2399
                                if (currentControl is CoordinateControl)
2400
                                {
2401
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2402
                                    {
2403
                                        return;
2404
                                    }
2405

    
2406
                                    CreateCommand.Instance.Execute(currentControl);
2407

    
2408
                                    currentControl = null;
2409
                                    this.cursor = Cursors.Arrow;
2410
                                }
2411
                                else
2412
                                {
2413
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2414
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2415
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2416
                                    {
2417
                                        currentControl = null;
2418
                                        this.cursor = Cursors.Arrow;
2419
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2420
                                        return;
2421
                                    }
2422
                                    else
2423
                                    {
2424
                                        currentControl = new CoordinateControl
2425
                                        {
2426
                                            Background = new SolidColorBrush(Colors.Black),
2427
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2428
                                            ControlType = ControlType.Coordinate
2429
                                        };
2430

    
2431
                                        currentControl.CommentID = Commons.shortGuid();
2432
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2433
                                        currentControl.IsNew = true;
2434

    
2435
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2436

    
2437
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2438
                                    }
2439
                                }
2440
                            }
2441
                        }
2442
                        break;
2443
                    case ControlType.InsideWhite:
2444
                        {
2445
                            if (e.LeftButton == MouseButtonState.Pressed)
2446
                            {
2447
                                if (currentControl is InsideWhiteControl)
2448
                                {
2449
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2450
                                    {
2451
                                        return;
2452
                                    }
2453

    
2454
                                    CreateCommand.Instance.Execute(currentControl);
2455

    
2456
                                    currentControl = null;
2457
                                    this.cursor = Cursors.Arrow;
2458
                                }
2459
                                else
2460
                                {
2461
                                    currentControl = new InsideWhiteControl
2462
                                    {
2463
                                        Background = new SolidColorBrush(Colors.Black),
2464
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2465
                                        ControlType = ControlType.InsideWhite
2466
                                    };
2467

    
2468
                                    currentControl.CommentID = Commons.shortGuid();
2469
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2470
                                    currentControl.IsNew = true;
2471
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2472

    
2473
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2474
                                }
2475
                            }
2476
                        }
2477
                        break;
2478
                    case ControlType.OverlapWhite:
2479
                        {
2480
                            if (e.LeftButton == MouseButtonState.Pressed)
2481
                            {
2482
                                if (currentControl is OverlapWhiteControl)
2483
                                {
2484
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2485
                                    {
2486
                                        return;
2487
                                    }
2488

    
2489
                                    CreateCommand.Instance.Execute(currentControl);
2490

    
2491
                                    currentControl = null;
2492
                                    this.cursor = Cursors.Arrow;
2493
                                }
2494
                                else
2495
                                {
2496
                                    currentControl = new OverlapWhiteControl
2497
                                    {
2498
                                        Background = new SolidColorBrush(Colors.Black),
2499
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2500
                                        ControlType = ControlType.OverlapWhite
2501
                                    };
2502

    
2503
                                    currentControl.CommentID = Commons.shortGuid();
2504
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2505
                                    currentControl.IsNew = true;
2506
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2507

    
2508
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2509
                                }
2510
                            }
2511
                        }
2512
                        break;
2513
                    case ControlType.ClipWhite:
2514
                        {
2515
                            if (e.LeftButton == MouseButtonState.Pressed)
2516
                            {
2517
                                if (currentControl is ClipWhiteControl)
2518
                                {
2519
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2520
                                    {
2521
                                        return;
2522
                                    }
2523

    
2524
                                    CreateCommand.Instance.Execute(currentControl);
2525

    
2526
                                    currentControl = null;
2527
                                    this.cursor = Cursors.Arrow;
2528
                                }
2529
                                else
2530
                                {
2531
                                    currentControl = new ClipWhiteControl
2532
                                    {
2533
                                        Background = new SolidColorBrush(Colors.Black),
2534
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2535
                                        ControlType = ControlType.ClipWhite
2536
                                    };
2537

    
2538
                                    currentControl.CommentID = Commons.shortGuid();
2539
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2540
                                    currentControl.IsNew = true;
2541
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2542

    
2543
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2544
                                }
2545
                            }
2546
                        }
2547
                        break;
2548
                    case ControlType.Rectangle:
2549
                        {
2550
                            if (e.LeftButton == MouseButtonState.Pressed)
2551
                            {
2552
                                if (currentControl is RectangleControl)
2553
                                {
2554
                                    //20180906 LJY TEST IsRotationDrawingEnable
2555
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2556
                                    {
2557
                                        return;
2558
                                    }
2559

    
2560
                                    CreateCommand.Instance.Execute(currentControl);
2561
                                    currentControl = null;
2562
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2563
                                }
2564
                                else
2565
                                {
2566
                                    currentControl = new RectangleControl
2567
                                    {
2568
                                        Background = new SolidColorBrush(Colors.Black),
2569
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2570
                                        ControlType = ControlType.Rectangle
2571
                                    };
2572

    
2573
                                    currentControl.CommentID = Commons.shortGuid();
2574
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2575
                                    currentControl.IsNew = true;
2576
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2577

    
2578
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2579
                                }
2580
                            }
2581
                        }
2582
                        break;
2583
                    case ControlType.RectCloud:
2584
                        {
2585
                            if (e.LeftButton == MouseButtonState.Pressed)
2586
                            {
2587
                                if (currentControl is RectCloudControl)
2588
                                {
2589
                                    //20180906 LJY TEST IsRotationDrawingEnable
2590
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2591
                                    {
2592
                                        return;
2593
                                    }
2594

    
2595
                                    CreateCommand.Instance.Execute(currentControl);
2596

    
2597
                                    currentControl = null;
2598
                                
2599
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2600
                                }
2601
                                else
2602
                                {
2603
                                    currentControl = new RectCloudControl
2604
                                    {
2605
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2606
                                        ControlType = ControlType.RectCloud,
2607
                                        Background = new SolidColorBrush(Colors.Black)
2608
                                    };
2609

    
2610
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2611
                                    currentControl.CommentID = Commons.shortGuid();
2612
                                    currentControl.IsNew = true;
2613
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2614
                                }
2615
                            }
2616
                        }
2617
                        break;
2618
                    case ControlType.Circle:
2619
                        {
2620
                            if (e.LeftButton == MouseButtonState.Pressed)
2621
                            {
2622
                                if (currentControl is CircleControl)
2623
                                {
2624
                                    //20180906 LJY TEST IsRotationDrawingEnable
2625
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2626
                                    {
2627
                                        return;
2628
                                    }
2629

    
2630
                                    CreateCommand.Instance.Execute(currentControl);
2631

    
2632
                                    currentControl = null;
2633
                                }
2634
                                else
2635
                                {
2636
                                    currentControl = new CircleControl
2637
                                    {
2638
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2639
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2640
                                        Background = new SolidColorBrush(Colors.Black)
2641
                                    };
2642

    
2643
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2644
                                    currentControl.CommentID = Commons.shortGuid();
2645
                                    currentControl.IsNew = true;
2646
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2647
                                }
2648
                            }
2649
                        }
2650
                        break;
2651
                    case ControlType.Triangle:
2652
                        {
2653
                            if (e.LeftButton == MouseButtonState.Pressed)
2654
                            {
2655
                                if (currentControl is TriControl)
2656
                                {
2657
                                    var content = currentControl as TriControl;
2658
                                    if (content.MidPoint == new Point(0, 0))
2659
                                    {
2660
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2661
                                    }
2662
                                    else
2663
                                    {
2664
                                        //20180906 LJY TEST IsRotationDrawingEnable
2665
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2666
                                        {
2667
                                            return;
2668
                                        }
2669

    
2670
                                        CreateCommand.Instance.Execute(currentControl);
2671

    
2672
                                        currentControl = null;
2673
                                    }
2674
                                }
2675
                                else
2676
                                {
2677
                                    currentControl = new TriControl
2678
                                    {
2679
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2680
                                        Background = new SolidColorBrush(Colors.Black),
2681
                                    };
2682

    
2683
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2684
                                    currentControl.CommentID = Commons.shortGuid();
2685
                                    currentControl.IsNew = true;
2686
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2687
                                }
2688
                            }
2689
                        }
2690
                        break;
2691
                    case ControlType.CancelLine:
2692
                    case ControlType.SingleLine:
2693
                    case ControlType.ArrowLine:
2694
                    case ControlType.TwinLine:
2695
                    case ControlType.DimLine:
2696
                        {
2697
                            if (e.LeftButton == MouseButtonState.Pressed)
2698
                            {
2699
                                if (currentControl is LineControl)
2700
                                {
2701
                                    //20180906 LJY TEST IsRotationDrawingEnable
2702
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2703
                                    {
2704
                                        return;
2705
                                    }
2706

    
2707
                                    CreateCommand.Instance.Execute(currentControl);
2708
                                    currentControl = null;
2709
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2710
                                }
2711
                                else
2712
                                {
2713
                                    currentControl = new LineControl
2714
                                    {
2715
                                        ControlType = this.controlType,
2716
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2717
                                        Background = new SolidColorBrush(Colors.Black)
2718
                                    };
2719

    
2720
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2721
                                    currentControl.CommentID = Commons.shortGuid();
2722
                                    currentControl.IsNew = true;
2723
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2724
                                    this.MainAngle.Visibility = Visibility.Visible;
2725
                                }
2726
                            }
2727
                        }
2728
                        break;
2729
                    case ControlType.PolygonControl:
2730
                        {
2731
                            if (currentControl is PolygonControl)
2732
                            {
2733
                                var control = currentControl as PolygonControl;
2734

    
2735
                                if (e.RightButton == MouseButtonState.Pressed)
2736
                                {
2737
                                    control.IsCompleted = true;
2738
                                }
2739

    
2740
                                if (!control.IsCompleted)
2741
                                {
2742
                                    control.PointSet.Add(control.EndPoint);
2743
                                }
2744
                                else
2745
                                {
2746
                                    //20180906 LJY TEST IsRotationDrawingEnable
2747
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2748
                                    {
2749
                                        return;
2750
                                    }
2751

    
2752
                                    var firstPoint = control.PointSet.First();
2753
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2754
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2755
                                    control.PointSet.Add(firstPoint);
2756

    
2757
                                    control.ApplyOverViewData();
2758

    
2759
                                    CreateCommand.Instance.Execute(currentControl);
2760
                                    control.UpdateControl();
2761
                                    currentControl = null;
2762
                                }
2763
                            }
2764
                            else
2765
                            {
2766
                                if (e.LeftButton == MouseButtonState.Pressed)
2767
                                {
2768
                                    currentControl = new PolygonControl
2769
                                    {
2770
                                        PointSet = new List<Point>(),
2771
                                    };
2772

    
2773
                                    var polygonControl = (currentControl as PolygonControl);
2774
                                    currentControl.CommentID = Commons.shortGuid();
2775
                                    currentControl.IsNew = true;
2776
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2777
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2778
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2779
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2780
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2781
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2782
                                    polygonControl.ApplyTemplate();
2783
                                    polygonControl.Visibility = Visibility.Visible;
2784
                                }
2785
                            }
2786
                        }
2787
                        break;
2788
                    case ControlType.ChainLine:
2789
                        {
2790
                            if (currentControl is PolygonControl)
2791
                            {
2792
                                var control = currentControl as PolygonControl;
2793

    
2794
                                if (e.RightButton == MouseButtonState.Pressed)
2795
                                {
2796
                                    //20180906 LJY TEST IsRotationDrawingEnable
2797
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2798
                                    {
2799
                                        return;
2800
                                    }
2801

    
2802
                                    CreateCommand.Instance.Execute(currentControl);
2803

    
2804
                                    currentControl = null;
2805
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2806
                                    return;
2807
                                }
2808

    
2809
                                if (!control.IsCompleted)
2810
                                {
2811
                                    control.PointSet.Add(control.EndPoint);
2812
                                    this.MainAngle.Visibility = Visibility.Visible;
2813
                                }
2814
                            }
2815
                            else
2816
                            {
2817
                                if (e.LeftButton == MouseButtonState.Pressed)
2818
                                {
2819
                                    MainAngle.Visibility = Visibility.Visible;
2820
                                    currentControl = new PolygonControl
2821
                                    {
2822
                                        PointSet = new List<Point>(),
2823
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2824
                                        ControlType = ControlType.ChainLine,
2825
                                        DashSize = ViewerDataModel.Instance.DashSize,
2826
                                        LineSize = ViewerDataModel.Instance.LineSize,
2827
                                        //PointC = new StylusPointSet()
2828
                                    };
2829

    
2830
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2831
                                    //{
2832
                                        var polygonControl = (currentControl as PolygonControl);
2833
                                        currentControl.CommentID = Commons.shortGuid();
2834
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2835
                                        currentControl.IsNew = true;
2836
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2837
                                        //currentControl.OnApplyTemplate();
2838
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2839
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2840
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2841
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2842
                                    //}
2843
                                }
2844
                            }
2845
                        }
2846
                        break;
2847
                    case ControlType.ArcLine:
2848
                        {
2849
                            if (e.LeftButton == MouseButtonState.Pressed)
2850
                            {
2851
                                if (currentControl is ArcControl)
2852
                                {
2853
                                    //20180906 LJY TEST IsRotationDrawingEnable
2854
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2855
                                    {
2856
                                        return;
2857
                                    }
2858

    
2859
                                    CreateCommand.Instance.Execute(currentControl);
2860

    
2861
                                    currentControl = null;
2862
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2863
                                }
2864
                                else
2865
                                {
2866
                                    currentControl = new ArcControl
2867
                                    {
2868
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2869
                                        Background = new SolidColorBrush(Colors.Black)
2870
                                    };
2871
                                    currentControl.CommentID = Commons.shortGuid();
2872
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2873
                                    currentControl.IsNew = true;
2874
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2875
                                    this.MainAngle.Visibility = Visibility.Visible;
2876
                                }
2877
                            }
2878
                            else if (e.RightButton == MouseButtonState.Pressed)
2879
                            {
2880
                                if (currentControl != null)
2881
                                {
2882
                                    (currentControl as ArcControl).setClock();
2883
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2884
                                }
2885
                            }
2886
                        }
2887
                        break;
2888
                    case ControlType.ArcArrow:
2889
                        {
2890
                            if (e.LeftButton == MouseButtonState.Pressed)
2891
                            {
2892
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2893
                                //{
2894
                                if (currentControl is ArrowArcControl)
2895
                                {
2896
                                    //20180906 LJY TEST IsRotationDrawingEnable
2897
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2898
                                    {
2899
                                        return;
2900
                                    }
2901

    
2902
                                    CreateCommand.Instance.Execute(currentControl);
2903

    
2904
                                    currentControl = null;
2905
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2906
                                }
2907
                                else
2908
                                {
2909
                                    currentControl = new ArrowArcControl
2910
                                    {
2911
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2912
                                        Background = new SolidColorBrush(Colors.Black)
2913
                                    };
2914
                                    currentControl.CommentID = Commons.shortGuid();
2915
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2916
                                    currentControl.IsNew = true;
2917
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2918
                                    this.MainAngle.Visibility = Visibility.Visible;
2919
                                }
2920
                                //}
2921
                            }
2922
                            else if (e.RightButton == MouseButtonState.Pressed)
2923
                            {
2924
                                if (currentControl != null)
2925
                                {
2926
                                    (currentControl as ArrowArcControl).setClock();
2927
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2928
                                    //(currentControl as ArcControl).ApplyTemplate();
2929
                                }
2930
                            }
2931
                        }
2932
                        break;
2933
                    case ControlType.ArrowMultiLine:
2934
                        {
2935
                            if (e.LeftButton == MouseButtonState.Pressed)
2936
                            {
2937
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2938
                                //{
2939

    
2940
                                    if (currentControl is ArrowControl_Multi)
2941
                                    {
2942
                                        var content = currentControl as ArrowControl_Multi;
2943
                                        if (content.MiddlePoint == new Point(0, 0))
2944
                                        {
2945
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2946
                                            {
2947
                                                content.MiddlePoint = content.EndPoint;
2948
                                            }
2949
                                            else
2950
                                            {
2951
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2952
                                            }
2953
                                        }
2954
                                        else
2955
                                        {
2956
                                            //20180906 LJY TEST IsRotationDrawingEnable
2957
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2958
                                            {
2959
                                                return;
2960
                                            }
2961

    
2962
                                            CreateCommand.Instance.Execute(currentControl);
2963

    
2964
                                            currentControl = null;
2965
                                            this.MainAngle.Visibility = Visibility.Collapsed;
2966
                                        }
2967
                                    }
2968
                                    else
2969
                                    {
2970
                                        currentControl = new ArrowControl_Multi
2971
                                        {
2972
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2973
                                            Background = new SolidColorBrush(Colors.Black)
2974
                                        };
2975
                                        currentControl.CommentID = Commons.shortGuid();
2976
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2977
                                        currentControl.IsNew = true;
2978
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2979
                                        this.MainAngle.Visibility = Visibility.Visible;
2980
                                    }
2981
                                //}
2982
                            }
2983
                        }
2984
                        break;
2985
                    case ControlType.PolygonCloud:
2986
                        {
2987
                            if (currentControl is CloudControl)
2988
                            {
2989
                                var control = currentControl as CloudControl;
2990
                                if (e.RightButton == MouseButtonState.Pressed)
2991
                                {
2992
                                    control.IsCompleted = true;
2993
                                }
2994

    
2995
                                if (!control.IsCompleted)
2996
                                {
2997
                                    control.PointSet.Add(control.EndPoint);
2998
                                }
2999
                                else
3000
                                {
3001
                                    //20180906 LJY TEST IsRotationDrawingEnable
3002
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3003
                                    {
3004
                                        return;
3005
                                    }
3006

    
3007
                                    CreateCommand.Instance.Execute(currentControl);
3008

    
3009
                                    control.isTransOn = true;
3010
                                    var firstPoint = control.PointSet.First();
3011

    
3012
                                    control.PointSet.Add(firstPoint);
3013
                                    control.DrawingCloud();
3014
                                    control.ApplyOverViewData();
3015

    
3016
                                    currentControl = null;
3017
                                }
3018
                            }
3019
                            else
3020
                            {
3021
                                if (e.LeftButton == MouseButtonState.Pressed)
3022
                                {
3023
                                    currentControl = new CloudControl
3024
                                    {
3025
                                        PointSet = new List<Point>(),
3026
                                        PointC = new StylusPointSet()
3027
                                    };
3028

    
3029
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3030
                                    //{
3031
                                        var polygonControl = (currentControl as CloudControl);
3032
                                        currentControl.CommentID = Commons.shortGuid();
3033
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3034
                                        currentControl.IsNew = true;
3035
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3036

    
3037
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3038
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3039
                                    
3040
                                    //}
3041
                                }
3042
                            }
3043
                        }
3044
                        break;
3045
                    case ControlType.ImgControl:
3046
                        {
3047
                            if (e.LeftButton == MouseButtonState.Pressed)
3048
                            {
3049
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3050
                                //{
3051
                                    if (currentControl is ImgControl)
3052
                                    {
3053
                                        //20180906 LJY TEST IsRotationDrawingEnable
3054
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3055
                                        {
3056
                                            return;
3057
                                        }
3058

    
3059
                                        CreateCommand.Instance.Execute(currentControl);
3060
                                        controlType = ControlType.ImgControl;
3061
                                        currentControl = null;
3062
                                    }
3063
                                    else
3064
                                    {
3065
                                        
3066
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3067
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3068
                                        {
3069
                                            Image img = new Image();
3070
                                            if (filename.Contains(".svg"))
3071
                                            {
3072
                                                byte[] imageData = null;
3073
                                                DrawingImage image = null;
3074
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3075
                                                {
3076
                                                    imageData = web.DownloadData(new Uri(filename));
3077
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3078
                                                    image = SvgReader.Load(stream);
3079
                                                }
3080
                                                img.Source = image;
3081
                                            }
3082
                                            else
3083
                                            {
3084
                                                img.Source = new BitmapImage(new Uri(filename));
3085
                                            }
3086

    
3087
                                            currentControl = new ImgControl
3088
                                            {
3089
                                                    Background = new SolidColorBrush(Colors.Black),
3090
                                                    PointSet = new List<Point>(),
3091
                                                    FilePath = filename,
3092
                                                    ImageData = img.Source,
3093
                                                    StartPoint = canvasDrawingMouseDownPoint,
3094
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3095
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3096
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3097
                                                    ControlType = ControlType.ImgControl
3098
                                                };
3099

    
3100
                                        
3101
                                                currentControl.CommentID = Commons.shortGuid();                                            
3102
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3103
                                                currentControl.IsNew = true;
3104
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3105

    
3106
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3107
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3108
                                        }
3109
                                    }
3110
                                //}
3111
                            }
3112
                        }
3113
                        break;
3114
                    case ControlType.Date:
3115
                        {
3116
                            if (e.LeftButton == MouseButtonState.Pressed)
3117
                            {
3118
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3119
                                //{
3120
                                    if (currentControl is DateControl)
3121
                                    {
3122
                                        //20180906 LJY TEST IsRotationDrawingEnable
3123
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3124
                                        {
3125
                                            return;
3126
                                        }
3127

    
3128
                                        CreateCommand.Instance.Execute(currentControl);
3129
                                        currentControl = null;
3130

    
3131
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3132
                                        {
3133
                                            controlType = ControlType.None;
3134
                                            IsSwingMode = false;
3135
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3136
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3137
                                            mouseHandlingMode = MouseHandlingMode.None;
3138
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3139
                                            txtBatch.Visibility = Visibility.Collapsed;
3140

    
3141
                                        }
3142
                                    }
3143
                                    else
3144
                                    {
3145
                                        currentControl = new DateControl
3146
                                        {
3147
                                            StartPoint = canvasDrawingMouseDownPoint,
3148
                                            Background = new SolidColorBrush(Colors.Black)
3149
                                        };
3150
                                        currentControl.CommentID = Commons.shortGuid();
3151
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3152
                                        currentControl.IsNew = true;
3153
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3154

    
3155
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3156
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3157
                                }
3158
                                //}
3159
                            }
3160
                        }
3161
                        break;
3162
                    case ControlType.TextControl:
3163
                        {
3164
                            if (e.LeftButton == MouseButtonState.Pressed)
3165
                            {
3166
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3167
                                {
3168
                                    currentControl = new TextControl
3169
                                    {
3170
                                        ControlType = controlType
3171
                                    };
3172
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3173
                                    currentControl.CommentID = Commons.shortGuid();
3174
                                    currentControl.IsNew = true;
3175
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3176
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3177
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3178

    
3179
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3180
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3181
                                    
3182
                                    (currentControl as TextControl).ControlType_No = 0;
3183
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3184
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3185
                                    (currentControl as TextControl).ApplyTemplate();
3186
                                    (currentControl as TextControl).Base_TextBox.Focus();
3187

    
3188
                                    CreateCommand.Instance.Execute(currentControl);
3189
                                }
3190
                            }
3191
                        }
3192
                        break;
3193
                    case ControlType.TextBorder:
3194
                        {
3195
                            if (e.LeftButton == MouseButtonState.Pressed)
3196
                            {
3197
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3198
                                {
3199
                                    currentControl = new TextControl
3200
                                    {
3201
                                        ControlType = controlType
3202
                                    };
3203

    
3204
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3205
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3206
                                    currentControl.CommentID = Commons.shortGuid();
3207
                                    currentControl.IsNew = true;
3208
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3209
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3210
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3211
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3212
                                    
3213
                                    (currentControl as TextControl).ControlType_No = 1;
3214
                                    (currentControl as TextControl).Angle = Ang;
3215
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3216
                                    (currentControl as TextControl).ApplyTemplate();
3217
                                    (currentControl as TextControl).Base_TextBox.Focus();
3218
                                    CreateCommand.Instance.Execute(currentControl);
3219
                                }
3220
                            }
3221
                        }
3222
                        break;
3223
                    case ControlType.TextCloud:
3224
                        {
3225
                            if (e.LeftButton == MouseButtonState.Pressed)
3226
                            {
3227
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3228
                                {
3229
                                    currentControl = new TextControl
3230
                                    {
3231
                                        ControlType = controlType
3232
                                    };
3233

    
3234
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3235
                                    currentControl.CommentID = Commons.shortGuid();
3236
                                    currentControl.IsNew = true;
3237
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3238
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3239

    
3240
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3241
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3242
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3243

    
3244
                                    (currentControl as TextControl).Angle = Ang;
3245
                                    (currentControl as TextControl).ControlType_No = 2;
3246
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3247
                                    (currentControl as TextControl).ApplyTemplate();
3248
                                    (currentControl as TextControl).Base_TextBox.Focus();
3249
                                    CreateCommand.Instance.Execute(currentControl);
3250
                                    //currentControl = null;
3251
                                }
3252
                            }
3253
                        }
3254
                        break;
3255
                    case ControlType.ArrowTextControl:
3256
                         {
3257
                            if (e.LeftButton == MouseButtonState.Pressed)
3258
                            {
3259
                                if (currentControl is ArrowTextControl)
3260
                                {
3261
                                    //20180906 LJY TEST IsRotationDrawingEnable
3262
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3263
                                    {
3264
                                        return;
3265
                                    }
3266

    
3267
                                    CreateCommand.Instance.Execute(currentControl);
3268

    
3269
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3270
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3271
                                    (currentControl as ArrowTextControl).IsNew = false;
3272
                                    currentControl = null;
3273
                                }
3274
                                else
3275
                                {
3276
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3277
                                    //{
3278
                                        currentControl = new ArrowTextControl();
3279
                                        currentControl.CommentID = Commons.shortGuid();
3280
                                        currentControl.IsNew = true;
3281
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3282
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3283

    
3284
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3285
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3286
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3287
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3288
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3289

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

    
3293
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3294
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3295
                                        this.MainAngle.Visibility = Visibility.Visible;
3296

    
3297
                                    
3298
                                    //}
3299
                                }
3300
                            }
3301
                        }
3302
                        break;
3303
                    case ControlType.ArrowTransTextControl:
3304
                        {
3305
                            if (e.LeftButton == MouseButtonState.Pressed)
3306
                            {
3307
                                if (currentControl is ArrowTextControl)
3308
                                {
3309
                                    //20180906 LJY TEST IsRotationDrawingEnable
3310
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3311
                                    {
3312
                                        return;
3313
                                    }
3314

    
3315
                                    CreateCommand.Instance.Execute(currentControl);
3316
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3317
                                    currentControl.IsNew = false;
3318
                                    currentControl = null;
3319
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3320
                                }
3321
                                else
3322
                                {
3323
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3324
                                    //{
3325
                                    currentControl = new ArrowTextControl()
3326
                                    {
3327
                                        ControlType = ControlType.ArrowTransTextControl
3328
                                    };
3329
                                    currentControl.CommentID = Commons.shortGuid();
3330
                                    currentControl.IsNew = true;
3331
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3332
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3333
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3334
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3335
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3336
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3337
                                    (currentControl as ArrowTextControl).isFixed = true;
3338
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3339

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

    
3343
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3344
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3345
                                    (currentControl as ArrowTextControl).isTrans = true;
3346
                                }
3347
                            }
3348
                        }
3349
                        break;
3350
                    case ControlType.ArrowTextBorderControl:
3351
                         {
3352
                            if (e.LeftButton == MouseButtonState.Pressed)
3353
                            {
3354
                                if (currentControl is ArrowTextControl)
3355
                                {
3356
                                    //20180906 LJY TEST IsRotationDrawingEnable
3357
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3358
                                    {
3359
                                        return;
3360
                                    }
3361

    
3362
                                    CreateCommand.Instance.Execute(currentControl);
3363
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3364
                                    currentControl.IsNew = false;
3365
                                    currentControl = null;
3366
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3367
                                }
3368
                                else
3369
                                {
3370
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3371
                                    //{
3372
                                        currentControl = new ArrowTextControl()
3373
                                        {
3374
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3375
                                        };
3376
                                        currentControl.CommentID = Commons.shortGuid();
3377
                                        currentControl.IsNew = true;
3378
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3379
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3380

    
3381
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3382

    
3383
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3384

    
3385
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3386
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3387
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3388

    
3389
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3390
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3391
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3392
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3393
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3394
                                    //}
3395
                                }
3396
                            }
3397
                        }
3398
                        break;
3399
                    case ControlType.ArrowTransTextBorderControl:
3400
                        {
3401
                            if (e.LeftButton == MouseButtonState.Pressed)
3402
                            {
3403
                                if (currentControl is ArrowTextControl)
3404
                                {
3405
                                    //20180906 LJY TEST IsRotationDrawingEnable
3406
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3407
                                    {
3408
                                        return;
3409
                                    }
3410
                                    CreateCommand.Instance.Execute(currentControl);
3411
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3412
                                    currentControl.IsNew = false;
3413
                                    currentControl = null;
3414
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3415
                                }
3416
                                else
3417
                                {
3418
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3419
                                    //{
3420
                                    
3421

    
3422
                                    currentControl = new ArrowTextControl()
3423
                                    {
3424
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3425
                                        ControlType = ControlType.ArrowTransTextBorderControl
3426

    
3427
                                    };
3428
                                        currentControl.CommentID = Commons.shortGuid();
3429
                                        currentControl.IsNew = true;
3430
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3431
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3432

    
3433
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3434

    
3435
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3436
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3437
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3438
                                        (currentControl as ArrowTextControl).isFixed = true;
3439
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3440
                                     
3441
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3442
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3443
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3444

    
3445
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3446
                                        this.MainAngle.Visibility = Visibility.Visible;
3447
                                    
3448
                                    //20180911 LJY
3449
                                        (currentControl as ArrowTextControl).isTrans = true;
3450
                                    
3451

    
3452
                                    //}
3453
                                }
3454
                            }
3455
                        }
3456
                        break;
3457
                    case ControlType.ArrowTextCloudControl:
3458
                        {
3459
                            if (e.LeftButton == MouseButtonState.Pressed)
3460
                            {
3461
                                if (currentControl is ArrowTextControl)
3462
                                {
3463
                                    //20180906 LJY TEST IsRotationDrawingEnable
3464
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3465
                                    {
3466
                                        return;
3467
                                    }
3468
                                    CreateCommand.Instance.Execute(currentControl);
3469
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3470
                                    currentControl.IsNew = false;
3471
                                    currentControl = null;
3472
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3473
                                }
3474
                                else
3475
                                {
3476
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3477
                                    //{
3478
                                        currentControl = new ArrowTextControl()
3479
                                        {
3480
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3481
                                        };
3482
                                        currentControl.CommentID = Commons.shortGuid();
3483
                                        currentControl.IsNew = true;
3484
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3485
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3486

    
3487
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3488
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3489
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3490
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3491
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3492

    
3493
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3494
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3495
                                    
3496
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3497
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3498
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3499
                                    //}
3500
                                }
3501
                            }
3502
                        }
3503
                        break;
3504
                    case ControlType.ArrowTransTextCloudControl:
3505
                        {
3506
                            if (e.LeftButton == MouseButtonState.Pressed)
3507
                            {
3508
                                if (currentControl is ArrowTextControl)
3509
                                {
3510
                                    //20180906 LJY TEST IsRotationDrawingEnable
3511
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3512
                                    {
3513
                                        return;
3514
                                    }
3515
                                    CreateCommand.Instance.Execute(currentControl);
3516
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3517
                                    currentControl.IsNew = false;
3518
                                    currentControl = null;
3519
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3520
                                }
3521
                                else
3522
                                {
3523
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3524
                                    //{
3525
                                        currentControl = new ArrowTextControl()
3526
                                        {
3527
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3528
                                            ControlType = ControlType.ArrowTransTextCloudControl
3529

    
3530
                                        };
3531
                                        currentControl.CommentID = Commons.shortGuid();
3532
                                        currentControl.IsNew = true; 
3533
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3534
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3535
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3536

    
3537
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3538
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3539
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3540
                                        (currentControl as ArrowTextControl).isFixed = true;
3541
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3542

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

    
3546
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3547
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3548
                                        this.MainAngle.Visibility = Visibility.Visible;  
3549
                                    
3550
                                    //20180911 LJY
3551
                                        (currentControl as ArrowTextControl).isTrans = true;
3552
                                    //}
3553
                                }
3554
                            }
3555
                        }
3556
                        break;
3557
                    //강인구 추가
3558
                    case ControlType.Sign:
3559
                        {
3560
                            if (e.LeftButton == MouseButtonState.Pressed)
3561
                            {
3562
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3563
                                //{
3564
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3565

    
3566
                                    if (_sign == null)
3567
                                    {
3568
                                        txtBatch.Visibility = Visibility.Collapsed;
3569
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3570
                                        controlType = ControlType.None;
3571

    
3572
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3573
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3574
                                        return;
3575
                                    }
3576

    
3577
                                    if (currentControl is SignControl)
3578
                                    {
3579
                                        //20180906 LJY TEST IsRotationDrawingEnable
3580
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3581
                                        {
3582
                                            return;
3583
                                        }
3584

    
3585
                                        CreateCommand.Instance.Execute(currentControl);
3586
                                        currentControl = null;
3587
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3588
                                        {
3589
                                            txtBatch.Text = "Place Date";
3590
                                            controlType = ControlType.Date;
3591
                                        }
3592
                                    }
3593
                                    else
3594
                                    {
3595
                                        currentControl = new SignControl
3596
                                        {
3597
                                            Background = new SolidColorBrush(Colors.Black),
3598
                                            UserNumber = App.ViewInfo.UserID,
3599
                                            ProjectNO = App.ViewInfo.ProjectNO,
3600
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3601
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3602
                                            ControlType = ControlType.Sign
3603
                                        };
3604

    
3605
                                        currentControl.CommentID = Commons.shortGuid();
3606
                                        currentControl.IsNew = true;
3607
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3608
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3609

    
3610
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3611
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3612
                                }
3613
                                //}
3614
                            }
3615
                        }
3616
                        break;
3617
                    case ControlType.Mark:
3618
                        {
3619
                            if (e.LeftButton == MouseButtonState.Pressed)
3620
                            {
3621
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3622
                                //{
3623
                                    if (currentControl is RectangleControl)
3624
                                    {
3625
                                        //20180906 LJY TEST IsRotationDrawingEnable
3626
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3627
                                        {
3628
                                            return;
3629
                                        }
3630

    
3631
                                        CreateCommand.Instance.Execute(currentControl);
3632
                                        (currentControl as RectangleControl).ApplyOverViewData();
3633
                                        currentControl = null;
3634
                                    
3635
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3636

    
3637
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3638
                                        {
3639
                                            txtBatch.Text = "Place Signature";
3640
                                            controlType = ControlType.Sign;
3641
                                        }
3642
                                    }
3643
                                    else
3644
                                    {
3645
                                        currentControl = new RectangleControl
3646
                                        {
3647
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3648
                                            Background = new SolidColorBrush(Colors.Black),
3649
                                            ControlType = ControlType.Mark ,
3650
                                            Paint = PaintSet.Fill
3651
                                        };
3652

    
3653
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3654
                                        currentControl.CommentID = Commons.shortGuid();
3655
                                        currentControl.IsNew = true;
3656
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3657
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3658
                                    }
3659
                                //}
3660
                            }
3661
                        }
3662
                        break;
3663
                    case ControlType.Symbol:
3664
                        {
3665
                            if (e.LeftButton == MouseButtonState.Pressed)
3666
                            {
3667
                                if (currentControl is SymControl)
3668
                                {
3669
                                    //20180906 LJY TEST IsRotationDrawingEnable
3670
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3671
                                    {
3672
                                        return;
3673
                                    }
3674
                                    CreateCommand.Instance.Execute(currentControl);
3675
                                    currentControl = null;
3676
                                
3677
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3678
                                }
3679
                                else
3680
                                {
3681
                                    currentControl = new SymControl
3682
                                    {
3683
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3684
                                        Background = new SolidColorBrush(Colors.Black),
3685
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3686
                                        ControlType = ControlType.Symbol
3687
                                    };
3688

    
3689
                                    currentControl.IsNew = true;
3690
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3691
                                    currentControl.CommentID = Commons.shortGuid();
3692
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3693

    
3694
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3695
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3696
                                }
3697
                                //}
3698
                            }
3699
                        }
3700
                        break;
3701
                    case ControlType.Stamp:
3702
                        {
3703
                            if (e.LeftButton == MouseButtonState.Pressed)
3704
                            {
3705
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3706
                                //{
3707
                                    if (currentControl is SymControlN)
3708
                                    {
3709
                                        //20180906 LJY TEST IsRotationDrawingEnable
3710
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3711
                                        {
3712
                                            return;
3713
                                        }
3714

    
3715
                                        CreateCommand.Instance.Execute(currentControl);
3716
                                        currentControl = null;
3717
                                   
3718

    
3719
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3720
                                    }
3721
                                    else
3722
                                    {
3723
                                        currentControl = new SymControlN
3724
                                        {
3725
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3726
                                            Background = new SolidColorBrush(Colors.Black),
3727
                                            STAMP = App.SystemInfo.STAMP,
3728
                                            ControlType = ControlType.Stamp
3729
                                        };
3730

    
3731
                                        currentControl.IsNew = true;
3732
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3733
                                        currentControl.CommentID = Commons.shortGuid();
3734
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3735
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3736
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3737
                                }                                    
3738
                                //}
3739
                            }
3740
                        }
3741
                        break;
3742
                    case ControlType.PenControl:
3743
                        {
3744
                            if (inkBoard.Tag.ToString() == "Ink")
3745
                            {
3746
                                inkBoard.IsEnabled = true;
3747
                                StartNewStroke(canvasDrawingMouseDownPoint);
3748
                            }
3749
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3750
                            {
3751
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3752
                            }
3753
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3754
                            {
3755
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3756
                            }
3757
                            IsDrawing = true;
3758
                            return;
3759
                        }
3760
                    default:
3761
                        if (currentControl != null)
3762
                        {
3763
                            currentControl.CommentID = null;
3764
                            currentControl.IsNew = false;
3765
                        }
3766
                        break;
3767
                }
3768
            }
3769
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3770
            {
3771
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3772
                {
3773
                    bool mouseOff = false;
3774
                    foreach (var item in SelectLayer.Children)
3775
                    {
3776
                        if (item is AdornerFinal)
3777
                        {
3778

    
3779
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3780
                            if (over != null)
3781
                            {
3782
                                mouseOff = true;
3783
                            }
3784
                        }
3785
                    }
3786

    
3787
                    if (!mouseOff)
3788
                    {
3789
                        SelectionSet.Instance.UnSelect(this);
3790
                    }
3791
                }
3792
                zoomAndPanControl.CaptureMouse();
3793
                e.Handled = true;
3794
            }
3795
        }
3796

    
3797
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3798
        {
3799
            ///mouseButtonDown = e.ChangedButton;
3800
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3801
        }
3802

    
3803
        private void RemoveLineStroke(Point P)
3804
        {
3805
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3806
            if (control != null)
3807
            {
3808
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3809
            }
3810
        }
3811

    
3812
        private void RemovePointStroke(Point P)
3813
        {
3814
            foreach (Stroke hits in inkBoard.Strokes)
3815
            {
3816
                foreach (StylusPoint sty in hits.StylusPoints)
3817
                {
3818

    
3819
                }
3820
                if (hits.HitTest(P))
3821
                {
3822
                    inkBoard.Strokes.Remove(hits);
3823
                    return;
3824
                }
3825
            }
3826
        }
3827

    
3828
        private void StartNewStroke(Point P)
3829
        {
3830
            strokePoints = new StylusPointCollection();
3831
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3832
            strokePoints.Add(segment1Start);
3833
            stroke = new Stroke(strokePoints);
3834

    
3835
            stroke.DrawingAttributes.Color = Colors.Red;
3836
            stroke.DrawingAttributes.Width = 4;
3837
            stroke.DrawingAttributes.Height = 4;
3838

    
3839
            inkBoard.Strokes.Add(stroke);
3840
        }
3841

    
3842
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3843
        {
3844
            ConsolidationMethod();
3845
        }
3846

    
3847
        /// <summary>
3848
        /// execute TeamConsolidationCommand
3849
        /// </summary>
3850
        public void TeamConsolidationMethod()
3851
        {
3852
            this.UpdateMyMarkupList();
3853
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3854
            {
3855
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3856
            }
3857
            else
3858
            {
3859

    
3860
                ViewerDataModel.Instance.IsConsolidate = true;
3861
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3862

    
3863
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3864
                {
3865
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3866
                    {
3867
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3868
                        return;
3869
                    }                    
3870
                }
3871
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3872
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3873
                {
3874
                    MarkupInfoList.Add(item);
3875
                }
3876
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3877
            }
3878
        }
3879

    
3880
        public void ConsolidationMethod()
3881
        {
3882
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3883
            {
3884
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3885
            }
3886
            else
3887
            {
3888
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3889
                foreach (var item in this.gridViewMarkup.SelectedItems)
3890
                {
3891
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3892
                }
3893
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3894
                
3895
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3896
            }
3897
        }
3898

    
3899
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3900
        {
3901
            if (App.ViewInfo != null)
3902
            {
3903
                btnConsolidate = (sender as RadRibbonButton);
3904
                if (!App.ViewInfo.NewCommentPermission)
3905
                {
3906
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3907
                }
3908
            }
3909
        }
3910

    
3911
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3912
        {
3913
            TeamConsolidationMethod();
3914
        }
3915

    
3916
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3917
        {
3918
            btnTeamConsolidate = sender as RadRibbonButton;
3919
            if (App.ViewInfo != null)
3920
            {
3921
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3922
                {
3923
                    if (btnConsolidate != null)
3924
                    {
3925
                        btnConsolidate.Visibility = Visibility.Collapsed;
3926
                    }
3927

    
3928
                    if (!App.ViewInfo.NewCommentPermission)
3929
                    {
3930
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3931
                    }
3932
                }
3933
                else
3934
                {
3935
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3936
                }
3937
            }
3938
        }
3939

    
3940
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3941
        {
3942
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3943
            if (item != null)
3944
            {
3945
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3946

    
3947
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3948
            }
3949
            else
3950
            {
3951
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3952
            }
3953
        }
3954

    
3955
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3956
        {
3957
            btnFinalPDF = sender as RadRibbonButton;
3958
            if (App.ViewInfo != null)
3959
            {
3960
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3961
                {
3962
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3963
                    if (btnConsolidate != null)
3964
                    {
3965
                        btnConsolidate.Visibility = Visibility.Collapsed;
3966
                    }
3967
                }
3968
            }
3969
        }
3970

    
3971
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
3972
        {
3973
            UpdateMyMarkupList();
3974

    
3975
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3976
            {
3977
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3978
            }
3979
            else
3980
            {
3981
                ViewerDataModel.Instance.IsConsolidate = true;
3982
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3983
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
3984

    
3985
                string project_no = App.ViewInfo.ProjectNO;
3986
                string doc_id = _DocInfo.ID;
3987
                string user_id = App.ViewInfo.UserID;
3988
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
3989
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3990
                {
3991
                    markupInfoItems.Add(item);
3992
                }
3993
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
3994
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
3995
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
3996
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
3997

    
3998
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3999
                if (item2 != null)
4000
                {
4001
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4002

    
4003
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4004
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4005
                }
4006
                else
4007
                {
4008
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4009
                }
4010
            }
4011
        }
4012

    
4013
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4014
        {
4015
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4016

    
4017
            if (App.ViewInfo != null)
4018
            {
4019
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4020
                {
4021
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4022
                }
4023
            }
4024
        }
4025

    
4026
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4027
        {
4028
            if (CompareMode.IsChecked)
4029
            {
4030
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4031
                {
4032
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4033
                }
4034
                if (ViewerDataModel.Instance.PageNumber == 0)
4035
                {
4036
                    ViewerDataModel.Instance.PageNumber = 1;
4037
                }
4038

    
4039
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4040
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4041
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4042

    
4043
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4044
            }
4045
            else
4046
            {
4047
                da.From = 1;
4048
                da.To = 1;
4049
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4050
                da.AutoReverse = false;
4051
                canvas_compareBorder.Children.Clear();
4052
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4053
            }
4054
        }
4055

    
4056
        private void Sync_Click(object sender, RoutedEventArgs e)
4057
        {
4058
            if (Sync.IsChecked)
4059
            {
4060
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4061
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4062
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4063
            }
4064
        }
4065

    
4066
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4067
        {
4068
            if (UserList.IsChecked)
4069
            {
4070
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4071
            }
4072
            else
4073
            {
4074
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4075
            }
4076
        }
4077

    
4078
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4079
        {
4080

    
4081
            if (BalanceMode.IsChecked)
4082
            {
4083
                ViewerDataModel.Instance.PageBalanceMode = true;
4084
            }
4085
            else
4086
            {
4087
                ViewerDataModel.Instance.PageBalanceMode = false;
4088
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4089
            }
4090
        }
4091

    
4092
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4093
        {
4094
            //초기화
4095
            testPanel2.IsHidden = true;
4096
            ViewerDataModel.Instance.PageBalanceMode = false;
4097
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4098
            ViewerDataModel.Instance.PageNumber = 0;
4099
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4100
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4101
            UserList.IsChecked = false;
4102
            BalanceMode.IsChecked = false;
4103
        }
4104

    
4105
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4106
        {
4107
            if ((sender as System.Windows.Controls.Control).Tag != null)
4108
            {
4109
                //Compare 초기화
4110
                CompareMode.IsChecked = false;
4111
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4112

    
4113
                if (ViewerDataModel.Instance.PageNumber == 0)
4114
                {
4115
                    ViewerDataModel.Instance.PageNumber = 1;
4116
                }
4117

    
4118
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4119
                {
4120
                }
4121
                else
4122
                {
4123
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4124
                }
4125

    
4126
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4127
                {
4128

    
4129
                }
4130
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4131
                {
4132
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4133
                }
4134

    
4135
                if (!testPanel2.IsHidden)
4136
                {
4137
                    if (IsSyncPDFMode)
4138
                    {
4139
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4140
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4141

    
4142
                        if (pdfpath.IsDownloading)
4143
                        {
4144
                            pdfpath.DownloadCompleted += (ex, arg) =>
4145
                            {
4146
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4147
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4148
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4149
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4150
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4151
                            };
4152
                        }
4153
                        else
4154
                        {
4155
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4156
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4157
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4158

    
4159
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4160
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4161
                        }
4162

    
4163
                    }
4164
                    else
4165
                    {
4166
                        string uri = "";
4167

    
4168
                        if (userData.COMPANY != "EXT")
4169
                        {
4170
                            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);
4171
                        }
4172
                        else
4173
                        {
4174
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4175
                        }
4176

    
4177
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4178

    
4179
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4180
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4181
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4182

    
4183
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4184
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4185

    
4186
                        if (defaultBitmapImage_Compare.IsDownloading)
4187
                        {
4188
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4189
                            {
4190
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4191
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4192
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4193

    
4194
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4195
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4196
                            };
4197
                        }
4198
                    }
4199

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

    
4204
                    foreach (var item in gridSelectionRevItem)
4205
                    {
4206
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4207
                        {
4208
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4209
                        });
4210
                    }
4211

    
4212
                    //강인구 추가
4213
                    zoomAndPanControl2.ZoomTo(new Rect
4214
                    {
4215
                        X = 0,
4216
                        Y = 0,
4217
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4218
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4219
                    });
4220

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

    
4223
                }
4224
            }
4225
        }
4226

    
4227
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4228
        {
4229
            if (MarkupMode.IsChecked)
4230
            {
4231
                IsSyncPDFMode = true;
4232

    
4233
                var uri = CurrentRev.TO_VENDOR;
4234

    
4235
                if (ViewerDataModel.Instance.PageNumber == 0)
4236
                {
4237
                    ViewerDataModel.Instance.PageNumber = 1;
4238
                }
4239

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

    
4244
                if (pdfpath.IsDownloading)
4245
                {
4246
                    pdfpath.DownloadCompleted += (ex, arg) =>
4247
                    {
4248
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4249
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4250
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4251
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4252
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4253
                    };
4254
                }
4255
                else
4256
                {
4257
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4258
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4259
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4260

    
4261
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4262
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4263
                }
4264
            }
4265
            else
4266
            {
4267
                IsSyncPDFMode = false;
4268
                string uri = "";
4269
                if (userData.COMPANY != "EXT")
4270
                {
4271
                    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);
4272
                }
4273
                else
4274
                {
4275
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4276
                }
4277

    
4278
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4279

    
4280
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4281
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4282
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4283

    
4284
                if (defaultBitmapImage_Compare.IsDownloading)
4285
                {
4286
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4287
                    {
4288
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4289
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4290
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4291
                    };
4292
                }
4293
                zoomAndPanControl2.ApplyTemplate();
4294
                zoomAndPanControl2.UpdateLayout();
4295
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4296
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4297
            }
4298
        }
4299

    
4300
        private void RadButton_Click(object sender, RoutedEventArgs e)
4301
        {
4302
            gridViewHistory_Busy.IsBusy = true;
4303

    
4304
            RadButton instance = sender as RadButton;
4305
            if (instance.CommandParameter != null)
4306
            {
4307
                CurrentRev = instance.CommandParameter as VPRevision;
4308
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4309
                {
4310
                    if (ea.Error == null && ea.Result != null)
4311
                    {
4312
                        testPanel2.IsHidden = false;
4313

    
4314
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4315
                        foreach(var info in ea.Result)
4316
                        {
4317
                            if(info.UserID == App.ViewInfo.UserID)
4318
                            {
4319
                                info.userDelete = true;
4320
                                info.DisplayColor = "FFFF0000";
4321
                            }
4322
                            else
4323
                            {
4324
                                info.userDelete = false;
4325
                            }
4326
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4327
                        }
4328
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4329

    
4330
                        string uri = "";
4331
                        if (userData.COMPANY != "EXT")
4332
                        {
4333
                            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);
4334
                        }
4335
                        else
4336
                        {
4337
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4338
                        }
4339

    
4340
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4341

    
4342
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4343

    
4344
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4345
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4346
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4347

    
4348
                        if (defaultBitmapImage_Compare.IsDownloading)
4349
                        {
4350
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4351
                            {
4352
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4353
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4354
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4355
                            };
4356
                        }
4357

    
4358
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4359
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4360
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4361
                        zoomAndPanControl2.ApplyTemplate();
4362
                        zoomAndPanControl2.UpdateLayout();
4363

    
4364
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4365
                        {
4366
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4367
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4368
                        }
4369

    
4370
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4371
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4372
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4373

    
4374
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4375
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4376
                        gridViewHistory_Busy.IsBusy = false;
4377
                    }
4378

    
4379
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4380
                };
4381
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4382
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4383
            }
4384
        }
4385

    
4386
        public void Sync_Event(VPRevision Currnet_Rev)
4387
        {
4388
            CurrentRev = Currnet_Rev;
4389

    
4390
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4391
            {
4392
                if (ea.Error == null && ea.Result != null)
4393
                {
4394
                    testPanel2.IsHidden = false;
4395

    
4396
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4397
                    foreach(var info in ea.Result)
4398
                    {
4399
                        if(info.UserID == App.ViewInfo.UserID)
4400
                        {
4401
                            info.userDelete = true;
4402
                            info.DisplayColor = "FFFF0000";
4403
                        }
4404
                        else
4405
                        {
4406
                            info.userDelete = false;
4407
                        }
4408
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4409
                    }
4410
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4411

    
4412
                    string uri = "";
4413
                    if (userData.COMPANY != "EXT")
4414
                    {
4415
                        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);
4416
                    }
4417
                    else
4418
                    {
4419
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4420
                    }
4421

    
4422
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4423

    
4424
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4425

    
4426
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4427
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4428
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4429

    
4430
                    if (defaultBitmapImage_Compare.IsDownloading)
4431
                    {
4432
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4433
                        {
4434
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4435
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4436
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4437
                        };
4438
                    }
4439

    
4440

    
4441
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4442
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4443
                    zoomAndPanControl2.ApplyTemplate();
4444
                    zoomAndPanControl2.UpdateLayout();
4445

    
4446
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4447
                    {
4448
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4449
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4450
                    }
4451
                    //}
4452

    
4453
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4454
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4455
                    gridViewHistory_Busy.IsBusy = false;
4456
                }
4457
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4458

    
4459
            };
4460
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4461
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4462
        }
4463

    
4464
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4465
        {
4466
            if (sender is Image)
4467
            {
4468
                if ((sender as Image).Tag != null)
4469
                {
4470
                    var pdfUrl = (sender as Image).Tag.ToString();
4471
                    System.Diagnostics.Process.Start(pdfUrl);
4472
                }
4473
                else
4474
                {
4475
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4476
                }
4477
            }
4478
        }
4479

    
4480
        private void Create_Symbol(object sender, RoutedEventArgs e)
4481
        {
4482
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4483

    
4484
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4485
            {
4486
                DialogMessage_Alert("Please Select Controls", "Alert");
4487
            }
4488
            else //선택된 것이 있으면
4489
            {
4490
                string MarkupData = "";
4491
                adorner_ = new AdornerFinal();
4492

    
4493
                foreach (var item in SelectLayer.Children)
4494
                {
4495
                    if (item.GetType().Name == "AdornerFinal")
4496
                    {
4497
                        adorner_ = (item as Controls.AdornerFinal);
4498
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4499
                        {
4500
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4501
                            {
4502
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4503
                                MarkupData += markupReturn.ConvertData;
4504
                            }
4505
                        }
4506
                    }
4507
                }
4508
                DialogParameters parameters = new DialogParameters()
4509
                {
4510
                    Owner = Application.Current.MainWindow,
4511
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4512
                    DefaultPromptResultValue = "Custom State",
4513
                    Content = "Name :",
4514
                    Header = "Insert Custom Symbol Name",
4515
                    Theme = new VisualStudio2013Theme(),
4516
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4517
                };
4518
                RadWindow.Prompt(parameters);
4519
            }
4520

    
4521
        }
4522
        public int symbolselectindex = 0;
4523
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4524
        {
4525
            //Save save = new Save();
4526
            try
4527
            {
4528
                string svgfilename = null;
4529
                if (symbolname != null)
4530
                {
4531
                    if (symbolpng == true || symbolsvg == true)
4532
                    {
4533
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4534
                        string guid = Commons.shortGuid();
4535

    
4536
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4537
                        //Check_Uri.UriCheck();
4538
                        fileUploader.RunCompleted += (ex, arg) =>
4539
                        {
4540
                            filename = arg.Result;
4541
                            if (symbolpng == true)
4542
                            {
4543
                                if (filename != null)
4544
                                { 
4545
                                    if (symbolselectindex == 0)
4546
                                    {
4547
                                        SymbolSave(symbolname, filename, data);
4548
                                    }
4549
                                    else
4550
                                    {
4551
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4552
                                    }
4553
                                    DataBind();
4554
                                }                                
4555
                            }
4556

    
4557
                            if (symbolsvg == true)
4558
                            {
4559
                                try
4560
                                {
4561
                                    var defaultBitmapImage = new BitmapImage();
4562
                                    defaultBitmapImage.BeginInit();
4563
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4564
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4565
                                    Check_Uri.UriCheck(filename);
4566
                                    defaultBitmapImage.UriSource = new Uri(filename);
4567
                                    defaultBitmapImage.EndInit();
4568

    
4569
                                    System.Drawing.Bitmap image;
4570

    
4571
                                    if (defaultBitmapImage.IsDownloading)
4572
                                    {
4573
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4574
                                        {
4575
                                            defaultBitmapImage.Freeze();
4576
                                            image = GetBitmap(defaultBitmapImage);
4577
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4578
                                            Process potrace = new Process
4579
                                            {
4580
                                                StartInfo = new ProcessStartInfo
4581
                                                {
4582
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4583
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4584
                                                    RedirectStandardInput = true,
4585
                                                    RedirectStandardOutput = true,
4586
                                                    RedirectStandardError = true,
4587
                                                    UseShellExecute = false,
4588
                                                    CreateNoWindow = true,
4589
                                                    WindowStyle = ProcessWindowStyle.Hidden
4590
                                                },
4591
                                            };
4592

    
4593
                                            StringBuilder svgBuilder = new StringBuilder();
4594
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4595
                                            {
4596
                                                svgBuilder.AppendLine(e2.Data);
4597
                                            };
4598

    
4599
                                            potrace.EnableRaisingEvents = true;
4600
                                            potrace.Start();
4601
                                            potrace.Exited += (sender, e) =>
4602
                                            {
4603
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4604
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4605
                                                Check_Uri.UriCheck(svgfilename);
4606
                                                if (symbolselectindex == 0)
4607
                                                {
4608
                                                    SymbolSave(symbolname, svgfilename, data);
4609
                                                }
4610
                                                else
4611
                                                {
4612
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4613
                                                }
4614

    
4615
                                                DataBind();
4616
                                            };
4617
                                            potrace.WaitForExit();
4618
                                        };
4619
                                    }
4620
                                    else
4621
                                    {
4622
                                        //GC.Collect();
4623
                                    }
4624
                                }
4625
                                catch(Exception ee)
4626
                                {
4627
                                    DialogMessage_Alert("" + ee, "Alert");
4628
                                }
4629
                            }
4630
                        };                                             
4631
                    }
4632
                }
4633
            }
4634
            catch (Exception e)
4635
            {
4636
                //DialogMessage_Alert(e + "", "Alert");
4637
            }            
4638
        }
4639

    
4640
        public void SymbolSave(string Name, string Url, string Data)
4641
        {
4642
            try
4643
            {
4644
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4645
                {
4646
                    ID = Commons.shortGuid(),
4647
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4648
                    NAME = Name,
4649
                    IMAGE_URL = Url,
4650
                    DATA = Data
4651
                };
4652

    
4653
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4654
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4655
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4656
            }
4657
            catch (Exception)
4658
            {
4659
                throw;
4660
            }
4661
        }
4662

    
4663
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4664
        {
4665
            try
4666
            {
4667
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4668
                {
4669
                    ID = Commons.shortGuid(),
4670
                    DEPARTMENT = Department,
4671
                    NAME = Name,
4672
                    IMAGE_URL = Url,
4673
                    DATA = Data
4674
                };
4675
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4676
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4677
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4678
            }
4679
            catch (Exception)
4680
            {
4681
                throw;
4682
            }
4683
        }
4684

    
4685
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4686
        {           
4687
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4688
            DataBind();
4689
        }
4690

    
4691
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4692
        {
4693
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4694
            DataBind();
4695
        }
4696
        private void DataBind()
4697
        {
4698
            try
4699
            {
4700
                Symbol_Custom Custom = new Symbol_Custom();
4701
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4702
                
4703
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4704
                foreach (var item in symbol_Private)
4705
                {
4706
                    Custom.Name = item.NAME;
4707
                    Custom.ImageUri = item.IMAGE_URL;
4708
                    Custom.ID = item.ID;
4709
                    Custom_List.Add(Custom);
4710
                    Custom = new Symbol_Custom();
4711
                }
4712
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4713
                
4714
                Custom = new Symbol_Custom();
4715
                Custom_List = new List<Symbol_Custom>();
4716

    
4717
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4718

    
4719
                List<SYMBOL_PUBLIC> symbol_Public;
4720

    
4721
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4722
                {
4723
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4724
                }
4725
                else
4726
                {
4727
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4728
                }
4729
                foreach (var item in symbol_Public)
4730
                {
4731
                    Custom.Name = item.NAME;
4732
                    Custom.ImageUri = item.IMAGE_URL;
4733
                    Custom.ID = item.ID;
4734
                    Custom_List.Add(Custom);
4735
                    Custom = new Symbol_Custom();
4736
                }
4737
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4738
                BaseClient.Close();                
4739
            }
4740
            catch(Exception e)
4741
            {
4742
                //DialogMessage_Alert("DataBind", "Alert");
4743
            }
4744
            
4745
        }
4746
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4747
        {
4748
            try
4749
            {
4750
                if (args.PromptResult != null)
4751
                {
4752
                    if (args.DialogResult.Value)
4753
                    {
4754
                        PngBitmapEncoder _Encoder = symImage(data);
4755

    
4756
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4757
                        _Encoder.Save(fs);
4758
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4759

    
4760
                        byte[] Img_byte = fs.ToArray();
4761

    
4762
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4763
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4764
                        Check_Uri.UriCheck(filename);
4765
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4766
                        {
4767
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4768
                        }
4769
                        else
4770
                        {
4771
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4772
                        }
4773
                        DataBind();
4774
                    }
4775
                }
4776
            }
4777
            catch(Exception ex)
4778
            {
4779
                DialogMessage_Alert("" + ex, "Alert");
4780
            }
4781
        }
4782

    
4783
        public PngBitmapEncoder symImage(string data)
4784
        {
4785

    
4786
            Canvas _canvas = new Canvas();
4787
            _canvas.Background = Brushes.White;
4788
            _canvas.Width = adorner_.BorderSize.Width;
4789
            _canvas.Height = adorner_.BorderSize.Height;
4790
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4791

    
4792
            BitmapEncoder encoder = new PngBitmapEncoder();
4793

    
4794

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

    
4797
            DrawingVisual dv = new DrawingVisual();
4798

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

    
4802
            using (DrawingContext ctx = dv.RenderOpen())
4803
            {
4804
                VisualBrush vb = new VisualBrush(_canvas);
4805
                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)));
4806
            }
4807

    
4808
            try
4809
            {
4810
                renderBitmap.Render(dv);
4811

    
4812
                //GC.Collect();
4813
                GC.WaitForPendingFinalizers();
4814
                //GC.Collect();
4815
                // encode png data
4816
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4817
                // puch rendered bitmap into it
4818
                pngEncoder.Interlace = PngInterlaceOption.Off;
4819
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4820
                return pngEncoder;
4821

    
4822
            }
4823
            catch //(Exception ex)
4824
            {
4825
                return null;
4826
            }
4827

    
4828
        }
4829

    
4830
        public void DialogMessage_Alert(string content, string header)
4831
        {
4832
            var box = new TextBlock();
4833
            box.MinWidth = 400;
4834
            box.FontSize = 11;
4835
            //box.FontSize = 12;
4836
            box.Text = content;
4837
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4838

    
4839
            DialogParameters parameters = new DialogParameters()
4840
            {
4841
                Owner = Application.Current.MainWindow,
4842
                Content = box,
4843
                Header = header,
4844
                Theme = new VisualStudio2013Theme(),
4845
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4846
            };            
4847
            RadWindow.Alert(parameters);
4848
        }
4849

    
4850
        #region 캡쳐 기능
4851

    
4852
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4853
        {
4854
            if (x < 0)
4855
            {
4856
                width += x;
4857
                x = 0;
4858
            }
4859
            if (y < 0)
4860
            {
4861
                height += y;
4862
                y = 0;
4863

    
4864
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4865
            }
4866
            if (x + width > zoomAndPanCanvas.ActualWidth)
4867
            {
4868
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4869
            }
4870
            if (y + height > zoomAndPanCanvas.ActualHeight)
4871
            {
4872
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4873
            }
4874

    
4875
            byte[] pixels = CopyPixels(x, y, width, height);
4876

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

    
4879
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4880
        }
4881

    
4882
        public byte[] CopyPixels(int x, int y, int width, int height)
4883
        {
4884
            byte[] pixels = new byte[width * height * 4];
4885
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4886

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

    
4890
            return pixels;
4891
        }
4892

    
4893
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4894
        {
4895
            DrawingVisual drawingVisual = new DrawingVisual();
4896
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4897

    
4898
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4899
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4900
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4901
            drawingContext.Close();
4902

    
4903
            // 비트맵으로 변환합니다.
4904
            RenderTargetBitmap target =
4905
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4906
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4907

    
4908
            target.Render(drawingVisual);
4909
            return target;
4910
        }
4911

    
4912
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4913
        {
4914
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4915
            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);
4916
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4917
            bmp.UnlockBits(data);
4918
            return bmp;
4919
        }
4920
        public string symbolname = null;
4921
        public bool symbolsvg = true;
4922
        public bool symbolpng = true;
4923

    
4924
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4925
        {
4926
            System.Drawing.Bitmap image = GetBitmap(source);
4927
            //흰색 제거
4928
            //image.MakeTransparent(System.Drawing.Color.White);
4929

    
4930
            var imageStream = new System.IO.MemoryStream();
4931
            byte[] imageBytes = null;
4932
            using (imageStream)
4933
            {
4934
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4935
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
4936
                imageStream.Position = 0;
4937
                imageBytes = imageStream.ToArray();
4938
            }
4939

    
4940
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4941

    
4942
            RadWindow CheckPop = new RadWindow();
4943
            //Alert check = new Alert(Msg);
4944

    
4945
            CheckPop = new RadWindow
4946
            {
4947
                MinWidth = 400,
4948
                MinHeight = 100,
4949
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4950
                Header = "Alert",
4951
                Content = symbolPrompt,
4952
                //DialogResult = 
4953
                ResizeMode = System.Windows.ResizeMode.NoResize,
4954
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
4955
                IsTopmost = true,
4956
            };
4957
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
4958
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
4959
            CheckPop.ShowDialog();
4960

    
4961
            /*
4962
            DialogParameters parameters = new DialogParameters()
4963
            {
4964
                Owner = Application.Current.MainWindow,
4965
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4966
                DefaultPromptResultValue = "Custom State",
4967
                Content = "Name :",
4968
                Header = "Insert Custom Symbol Name",
4969
                Theme = new VisualStudio2013Theme(),
4970
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4971
            };            
4972
            RadWindow.Prompt(parameters);
4973
            */
4974
        }
4975

    
4976
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4977
        {
4978
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4979
            KCOMDataModel.DataModel.CHECK_LIST check_;
4980
            string Result = streamToBase64.ImageToBase64(source);
4981
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4982
            string projectno = App.ViewInfo.ProjectNO;
4983
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
4984

    
4985
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
4986
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
4987
            if (Item != null)
4988
            {
4989
                Logger.sendResLog("GetCheckList", "TRUE", 1);
4990
            }
4991
            else
4992
            {
4993
                Logger.sendResLog("GetCheckList", "FALSE", 1);
4994
            }
4995

    
4996
            if (Item == null)
4997
            {
4998
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
4999
                {
5000
                    ID = Commons.shortGuid(),
5001
                    USER_ID = App.ViewInfo.UserID,
5002
                    IMAGE_URL = Result,
5003
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5004
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5005
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5006
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5007
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5008
                    STATUS = "False",
5009
                    CREATE_TIME = DateTime.Now,
5010
                    UPDATE_TIME = DateTime.Now,
5011
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5012
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5013
                };
5014
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5015
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5016
                //this.BaseClient.AddCheckList(projectno, check_);
5017
            }
5018
            else
5019
            {
5020
                Item.IMAGE_URL = Result;
5021
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5022
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5023
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5024
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5025
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5026
            }
5027

    
5028
        }
5029

    
5030
        public void Set_Capture()
5031
        {
5032
            double x = canvasDrawingMouseDownPoint.X;
5033
            double y = canvasDrawingMouseDownPoint.Y;
5034
            double width = dragCaptureBorder.Width;
5035
            double height = dragCaptureBorder.Height;
5036

    
5037
            if (width > 5 || height > 5)
5038
            {
5039
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5040
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5041
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5042
            }
5043
        }
5044
        #endregion
5045

    
5046
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5047
        {
5048
            multi_Undo_Data = new Multi_Undo_data();
5049

    
5050
            multi_Undo_Data.Markup = control;
5051

    
5052
            if ((control as IShapeControl) != null)
5053
            {
5054
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5055
            }
5056
            if ((control as IDashControl) != null)
5057
            {
5058
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5059
            }
5060
            if ((control as IPath) != null)
5061
            {
5062
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5063
            }
5064
            if ((control as UIElement) != null)
5065
            {
5066
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5067
            }
5068

    
5069
            return multi_Undo_Data;
5070
        }
5071

    
5072
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5073
        {
5074
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5075
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5076
            {
5077
                if (items.UserID == Select_ID)
5078
                {
5079
                    foreach (var item in items.MarkupList)
5080
                    {
5081
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5082
                        {
5083
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5084
                                items.MarkupInfoID, Commons.shortGuid());
5085
                        }
5086
                    }
5087
                }
5088
            }
5089
        }
5090

    
5091
        /// <summary>
5092
        /// convert inkcontrol to polygoncontrol
5093
        /// </summary>
5094
        public void ConvertInkControlToPolygon()
5095
        {
5096
            if (inkBoard.Strokes.Count > 0)
5097
            {
5098
                inkBoard.Strokes.ToList().ForEach(stroke =>
5099
                {
5100
                    InkToPath ip = new InkToPath();
5101

    
5102
                    List<Point> inkPointSet = new List<Point>();
5103
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5104

    
5105
                    PolygonControl pc = new PolygonControl()
5106
                    {
5107
                        Angle = 0,
5108
                        PointSet = inkPointSet,
5109
                        ControlType = ControlType.Ink
5110
                    };
5111
                    pc.StartPoint = inkPointSet[0];
5112
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5113
                    pc.LineSize = 3;
5114
                    pc.CommentID = Commons.shortGuid();
5115
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5116

    
5117
                    if (pc.PointSet.Count > 0)
5118
                    {
5119
                        CreateCommand.Instance.Execute(pc);
5120
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5121
                    }
5122
                });
5123
                inkBoard.Strokes.Clear();
5124
            }
5125
        }
5126

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

    
5143
            return false;
5144
        }
5145

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

    
5151
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5152
        {
5153
            e.Effects = DragDropEffects.Copy;
5154
        }
5155

    
5156
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5157
        {
5158
            e.Effects = DragDropEffects.None;
5159
        }
5160

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