프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 497bbe52

이력 | 보기 | 이력해설 | 다운로드 (247 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
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
385

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

    
399
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
400
                {
401
                    this.SymbolPane.Visibility = Visibility.Collapsed;
402
                    this.FavoritePane.Visibility = Visibility.Collapsed;
403
                    this.drawingRotateCanvas.IsHitTestVisible = false;
404
                }
405
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
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
            SetCommentPages(true);            
549
        }
550

    
551
        /// <summary>
552
        /// start page changing
553
        ///  - save controls if page is modified
554
        ///  - starting download page image
555
        /// </summary>
556
        /// <param name="sender"></param>
557
        /// <param name="e"></param>
558
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
559
        {
560
            this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
561

    
562
            CompareMode.IsChecked = false;
563
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
564

    
565
            #region 페이지가 벗어난 경우
566

    
567
            if (BalancePoint < 1)
568
            {
569
                BalancePoint = 1;
570
                ViewerDataModel.Instance.PageBalanceNumber = 0;
571
            }
572

    
573
            if (pageNavigator.PageCount < BalancePoint)
574
            {
575
                BalancePoint = pageNavigator.PageCount;
576
                ViewerDataModel.Instance.PageBalanceNumber = 0;
577
            }
578

    
579
            #endregion
580

    
581
            ViewerDataModel.Instance.PageNumber = BalancePoint;
582

    
583
            string uri = "";
584
            if (userData.COMPANY != "EXT")
585
            {
586
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
587
            }
588
            else
589
            {
590
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
591
            }
592

    
593
            var defaultBitmapImage = new BitmapImage();
594
            defaultBitmapImage.BeginInit();
595
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
596
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
597
            defaultBitmapImage.UriSource = new Uri(uri);
598
            defaultBitmapImage.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
599
            defaultBitmapImage.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
600
            defaultBitmapImage.EndInit();
601

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

    
622
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
623
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
624

    
625

    
626
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
627
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
628
            inkBoard.Width = zoomAndPanCanvas.Width;
629
            inkBoard.Height = zoomAndPanCanvas.Height;
630

    
631

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

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

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

    
678
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
679
                    var defaultBitmapImage_Compare = new BitmapImage();
680
                    defaultBitmapImage_Compare.BeginInit();
681
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
682
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
683
                    defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
684
                    defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
685
                    defaultBitmapImage_Compare.EndInit();
686

    
687
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
688

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

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

    
710
                            zoomAndPanControl.ZoomTo(new Rect
711
                            {
712
                                X = 0,
713
                                Y = 0,
714
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
715
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
716
                            });
717

    
718
                            //defaultBitmapImage_Compare dispose
719
                            defaultBitmapImage_Compare = null;
720
                            GC.Collect();
721
                        };
722
                    }
723
                }
724
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
725
            }
726

    
727
        }
728

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

    
755
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
756
        {
757
            if (e.MiddleButton == MouseButtonState.Pressed)
758
            {
759

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

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

    
789
        #region ZoomIn & ZoomOut
790

    
791
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
792
        {
793
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
794
                zoomAndPanControl.ContentZoomFocusY));
795
        }
796

    
797
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
798
        {
799
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
800
                zoomAndPanControl.ContentZoomFocusY));
801
        }
802

    
803

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

    
817
            if (zoomAndPanControl2 != null && Sync.IsChecked)
818
            {
819
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
820
            }
821
        }
822

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

    
834
            if (zoomAndPanControl2 != null && Sync.IsChecked)
835
            {
836
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
837
            }
838

    
839
        }
840

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

    
852
            if (Sync.IsChecked)
853
            {
854
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
855
            }
856
        }
857

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

    
869
            if (Sync.IsChecked)
870
            {
871
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
872
            }
873
        }
874

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

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

    
893
        #endregion
894

    
895
        private void init()
896
        {
897
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
898
            {
899

    
900
                ControlList.Clear();
901
                listBox.Items.Clear();
902
                selected_item.Clear();
903

    
904
                (item as IMarkupCommonData).IsSelected = false;
905
            }
906

    
907
        }
908

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

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

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

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

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

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

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

    
1058
        [StructLayout(LayoutKind.Sequential)]
1059
        internal struct Win32Point
1060
        {
1061
            public Int32 X;
1062
            public Int32 Y;
1063
        };
1064
        /*
1065
       public string symbol_id = null;
1066
       public long symbol_group_id;
1067
       public int symbol_SelectedIndex;
1068
       public ImageSource symbol_img;
1069
       public string symbol_Data = null;
1070
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1071
       {
1072
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1073
               zoomAndPanCanvas.ActualHeight / 2));
1074

    
1075

    
1076
               if (this._dragdropWindow != null)
1077
               {
1078
                   this._dragdropWindow.Close();
1079
                   this._dragdropWindow = null;
1080
               }
1081

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

    
1088

    
1089
               CreateDragDropWindow2(img);
1090
              
1091
    }
1092

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

    
1113
            Win32Point w32Mouse = new Win32Point();
1114
            GetCursorPos(ref w32Mouse);
1115

    
1116
            //w32Mouse.X = getCurrentPoint.X;
1117
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1118
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1119
            this._dragdropWindow.Show();
1120
        }
1121
         */
1122
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1123
        {
1124
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1125
            {
1126
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1127

    
1128
                Point currentPos = e.GetPosition(rect);
1129

    
1130
                floatingTip.HorizontalOffset = currentPos.X + 20;
1131
                floatingTip.VerticalOffset = currentPos.Y;
1132
            }
1133

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

    
1142
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1143
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1144
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1145

    
1146
                if (Sync.IsChecked)
1147
                {
1148
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1149
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1150
                }
1151
            }
1152

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1504
                    if (dragDistance > DragThreshold)
1505
                    {
1506
                        isDraggingSelectionRect = true;
1507
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1508
                    }
1509

    
1510
                    e.Handled = true;
1511
                }
1512

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

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

    
1554
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1555
        {
1556
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1557
            {
1558
                SetCursor();
1559
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1560
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1561

    
1562
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1563

    
1564
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1565
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1566

    
1567
                if (Sync.IsChecked)
1568
                {
1569
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1570
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1571
                }
1572
            }
1573
        }
1574

    
1575
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1576

    
1577
        private EllipseGeometry hitArea = new EllipseGeometry();
1578

    
1579
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1580
        {
1581
            IsDrawing = false;
1582

    
1583
            if (mouseHandlingMode != MouseHandlingMode.None)
1584
            {
1585
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1586
                {
1587
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1588

    
1589
                    SetCursor();
1590

    
1591
                    switch (controlType)
1592
                    {
1593
                        case ControlType.None:
1594
                            break;
1595
                        case ControlType.Rectangle:
1596
                            {
1597

    
1598
                            }
1599
                            break;
1600
                        case ControlType.PenControl:
1601
                            {
1602

    
1603
                            }
1604
                            break;
1605
                        default:
1606
                            break;
1607
                    }
1608
                }
1609
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1610
                {
1611
                    if (isLeftMouseButtonDownOnWindow)
1612
                    {
1613
                        bool wasDragSelectionApplied = false;
1614

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

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

    
1650
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1651

    
1652
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1653
                            }
1654

    
1655
                            isDraggingSelectionRect = false;
1656
                            e.Handled = true;
1657
                            wasDragSelectionApplied = true;
1658
                        }
1659

    
1660
                        if (isLeftMouseButtonDownOnWindow)
1661
                        {
1662
                            isLeftMouseButtonDownOnWindow = false;
1663
                            this.ReleaseMouseCapture();
1664
                            e.Handled = true;
1665
                        }
1666

    
1667
                        if (!wasDragSelectionApplied)
1668
                        {
1669
                            init();
1670
                        }
1671
                    }
1672
                }
1673
                else if (e.RightButton == MouseButtonState.Pressed)
1674
                {
1675
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1676
                    SetCursor();
1677
                }
1678

    
1679
                zoomAndPanControl.ReleaseMouseCapture();
1680

    
1681

    
1682
                e.Handled = true;
1683
            }
1684
            else
1685
            {
1686
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1687
                SetCursor();
1688
            }
1689

    
1690
            ///mouseButtonDown = MouseButton.Left;
1691
            //controlType = ControlType.SingleLine;
1692
        }
1693

    
1694
        public void Set_Symbol_Capture(Point endPoint)
1695
        {       
1696
            double x = canvasDrawingMouseDownPoint.X;
1697
            double y = canvasDrawingMouseDownPoint.Y;
1698
            if(x > endPoint.X)
1699
            {
1700
                x = endPoint.X;
1701
                y = endPoint.Y;
1702
            }
1703

    
1704
            double width = dragCaptureBorder.Width;
1705
            double height = dragCaptureBorder.Height;
1706

    
1707
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1708

    
1709
            if (x < 0)
1710
            {
1711
                width += x;
1712
                x = 0;
1713
            }
1714
            if (y < 0)
1715
            {
1716
                height += y;
1717
                y = 0;
1718

    
1719
                width = (int)canvasImage.PixelWidth - x;
1720
            }
1721
            if (x + width > canvasImage.PixelWidth)
1722
            {
1723
                width = (int)canvasImage.PixelWidth - x;
1724
            }
1725
            if (y + height > canvasImage.PixelHeight)
1726
            {
1727
                height = (int)canvasImage.PixelHeight - y;
1728
            }
1729
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1730

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

    
1743
            var defaultBitmapImage = new BitmapImage();
1744
            defaultBitmapImage.BeginInit();
1745
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1746
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1747
            defaultBitmapImage.UriSource = new Uri(uri);
1748
            defaultBitmapImage.EndInit();
1749

    
1750
            //GC.Collect();
1751

    
1752
            if (defaultBitmapImage.IsDownloading)
1753
            {
1754
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1755
                {
1756
                    defaultBitmapImage.Freeze();
1757
                    //GC.Collect();
1758
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1759
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1760
                };
1761
            }
1762
        }
1763

    
1764
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1765
        {
1766
            ///mouseButtonDown = MouseButton.Left;
1767
        }
1768

    
1769
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1770
        {
1771
            ///mouseButtonDown = MouseButton.Left;
1772
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1773
        }
1774

    
1775
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1776
        {
1777

    
1778
        }
1779

    
1780
        /// <summary>
1781
        /// select items by dragging
1782
        /// </summary>
1783
        private void ApplyDragSelectionRect()
1784
        {
1785
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1786

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

    
1795
            Rect dragRect = new Rect(x, y, width, height);
1796
            ///dragRect.Inflate(width / 10, height / 10);
1797

    
1798
            foreach (var item in Items)
1799
            {
1800
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1801

    
1802
                if (Flag)
1803
                {
1804
                    adornerSet.Add(item);
1805
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1806
                    Control_Style(item);
1807
                }
1808
            }
1809
            if (adornerSet.Count > 0)
1810
            {
1811
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1812
                SelectLayer.Children.Add(final);
1813
            }
1814
        }
1815

    
1816
        private void InitDragSelectionRect(Point pt1, Point pt2)
1817
        {
1818
            //캡쳐 중
1819
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1820
            {
1821
                dragCaptureBorder.Visibility = Visibility.Visible;
1822
            }
1823
            //선택 중
1824
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1825
            {
1826

    
1827
                dragSelectionBorder.Visibility = Visibility.Visible;
1828
            }
1829
            else
1830
            {
1831
                dragZoomBorder.Visibility = Visibility.Visible;
1832
            }
1833
            UpdateDragSelectionRect(pt1, pt2);
1834
        }
1835

    
1836
        /// <summary>
1837
        /// Update the position and size of the rectangle used for drag selection.
1838
        /// </summary>
1839
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1840
        {
1841
            double x, y, width, height;
1842

    
1843
            //
1844
            // Determine x,y,width and height of the rect inverting the points if necessary.
1845
            // 
1846

    
1847
            if (pt2.X < pt1.X)
1848
            {
1849
                x = pt2.X;
1850
                width = pt1.X - pt2.X;
1851
            }
1852
            else
1853
            {
1854
                x = pt1.X;
1855
                width = pt2.X - pt1.X;
1856
            }
1857

    
1858
            if (pt2.Y < pt1.Y)
1859
            {
1860
                y = pt2.Y;
1861
                height = pt1.Y - pt2.Y;
1862
            }
1863
            else
1864
            {
1865
                y = pt1.Y;
1866
                height = pt2.Y - pt1.Y;
1867
            }
1868

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

    
1897
        private void drawingPannelRotate(double angle)
1898
        {
1899
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1900
            rotate.Angle = angle;
1901
            var rotationNum = Math.Abs((rotate.Angle / 90));
1902

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

    
1930
            zoomAndPanControl.RotationAngle = rotate.Angle;
1931

    
1932

    
1933
            if (!testPanel2.IsHidden)
1934
            {
1935
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1936
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1937
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1938
            }
1939

    
1940
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1941
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1942
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1943
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1944
            ViewerDataModel.Instance.Angle = rotate.Angle;
1945
        }
1946

    
1947
        private void syncPannelRotate(double angle)
1948
        {
1949
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1950
            rotate.Angle = angle;
1951
            var rotationNum = Math.Abs((rotate.Angle / 90));
1952

    
1953
            if (angle == 90 || angle == 270)
1954
            {
1955
                double emptySize = zoomAndPanCanvas2.Width;
1956
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
1957
                zoomAndPanCanvas2.Height = emptySize;
1958
            }
1959
            if (angle == 0)
1960
            {
1961
                translate2.X = 0;
1962
                translate2.Y = 0;
1963
            }
1964
            else if (angle == 90)
1965
            {
1966
                translate2.X = zoomAndPanCanvas2.Width;
1967
                translate2.Y = 0;
1968
            }
1969
            else if (angle == 180)
1970
            {
1971
                translate2.X = zoomAndPanCanvas2.Width;
1972
                translate2.Y = zoomAndPanCanvas2.Height;
1973
            }
1974
            else
1975
            {
1976
                translate2.X = 0;
1977
                translate2.Y = zoomAndPanCanvas2.Height;
1978
            }
1979

    
1980
            zoomAndPanControl2.RotationAngle = rotate.Angle;
1981
        }
1982

    
1983
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1984
        {
1985
            string Data_ = "";
1986

    
1987
            try
1988
            {
1989
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
1990
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
1991
                if (Data_ != null || Data_ != "")
1992
                {
1993
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
1994
                }
1995
                else
1996
                {
1997
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
1998
                }
1999

    
2000
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2001
                //{
2002
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2003
                //    STATE = 0,
2004
                //};
2005
                if (Data_ != null)
2006
                {
2007
                    Image img = new Image();
2008
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2009
                    if (Data_.Contains(".svg"))
2010
                    {
2011
                        byte[] imageData = null;
2012
                        DrawingImage image = null;
2013
                        using (System.Net.WebClient web = new System.Net.WebClient())
2014
                        {
2015
                            imageData = web.DownloadData(new Uri(Data_));
2016
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2017
                            image = SvgReader.Load(stream);
2018
                        }
2019
                        img.Source = image;
2020
                    }
2021
                    else
2022
                    {
2023
                        img.Source = new BitmapImage(new Uri(Data_));
2024
                    }
2025

    
2026
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2027
                    {
2028
                        PointSet = new List<Point>(),
2029
                        FilePath = Data_,
2030
                        ImageData = img.Source,
2031
                        StartPoint = canvasZoomPanningMouseDownPoint,
2032
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2033
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2034
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2035
                        canvasZoomPanningMouseDownPoint.Y),
2036
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2037
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2038
                    };
2039

    
2040
                    currentControl.PointSet = new List<Point>
2041
                                        {
2042
                                            currentControl.StartPoint,
2043
                                            currentControl.LeftBottomPoint,
2044
                                            currentControl.EndPoint,
2045
                                            currentControl.TopRightPoint,
2046
                                        };
2047
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2048
                    UndoData = new Undo_data()
2049
                    {
2050
                        IsUndo = false,
2051
                        Event = Event_Type.Create,
2052
                        EventTime = DateTime.Now,
2053
                        Markup_List = new List<Multi_Undo_data>()
2054
                    };
2055
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2056
                    {
2057
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2058
                    });
2059

    
2060
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2061
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2062
                    UndoData.Markup_List.Add(multi_Undo_Data);
2063
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2064

    
2065
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2066
                    currentControl.CommentID = Commons.shortGuid();
2067
                    currentControl.SymbolID = id;
2068
                    currentControl.GroupID = group_id;
2069
                    currentControl.ApplyTemplate();
2070
                    currentControl.SetImage();
2071

    
2072
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2073
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2074
                    SelectLayer.Children.Add(final);
2075
                }
2076
            }
2077
            catch (Exception ex)
2078
            {
2079
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2080
            }
2081
        }
2082

    
2083
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2084
        {            
2085
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2086
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2087
            {
2088
                set_option.Value = double.Parse(set_option.ContentText);
2089
            }
2090

    
2091
            ConvertInkControlToPolygon();
2092

    
2093
            ///TODO:
2094
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2095
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2096

    
2097
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2098
            {
2099
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2100
            }
2101
            /// up to here
2102

    
2103
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2104
            {
2105
                if (arrow_text as ArrowTextControl != null)
2106
                {
2107
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2108
                }
2109
            }
2110

    
2111
            //if (currentControl != null)
2112
            {
2113
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2114
                if (text_item_ != null)
2115
                {
2116
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2117
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2118
                    (text_item_ as TextControl).EnableEditing = false;
2119
                    currentControl = null;
2120
                }
2121

    
2122
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2123
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2124
                {
2125
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2126
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2127
                    currentControl = null;
2128
                }
2129
            }
2130

    
2131
            double Ang = 0;                                          
2132
            if (rotate.Angle != 0)
2133
            {
2134
                Ang = 360 - rotate.Angle;
2135
            }
2136

    
2137
            if (e.OriginalSource is System.Windows.Controls.Image)
2138
            {
2139
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2140
            }
2141
            /*
2142
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2143
            {                
2144
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2145
                if(symbol_id != null)
2146
                {
2147
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2148
                }                
2149
            }
2150

    
2151
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2152
            {
2153
                if (this._dragdropWindow != null)
2154
                {
2155
                    this._dragdropWindow.Close();
2156
                    this._dragdropWindow = null;
2157
                    symbol_id = null;
2158
                }
2159
            }
2160
            */
2161

    
2162
            if (e.LeftButton == MouseButtonState.Pressed)
2163
            {
2164
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2165
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2166

    
2167
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2168
                SetCursor();
2169

    
2170
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2171
            }
2172

    
2173
            if (e.MiddleButton == MouseButtonState.Pressed)
2174
            {
2175
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2176
                cursor = Cursors.SizeAll;
2177
                SetCursor();
2178
            }
2179
            if (e.RightButton == MouseButtonState.Pressed)
2180
            {
2181
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2182
                cursor = Cursors.SizeAll;
2183
                SetCursor();
2184
            }
2185
            else if (e.XButton1 == MouseButtonState.Pressed)
2186
            {
2187
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2188
                {
2189
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2190
                }
2191

    
2192
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2193

    
2194
            }
2195
            else if (e.XButton2 == MouseButtonState.Pressed)
2196
            {
2197
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2198
                {
2199
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2200
                }
2201
            }
2202

    
2203
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2204
            {
2205
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2206
                {
2207
                    if (SelectLayer.Children.Count == 0)
2208
                    {
2209
                        isLeftMouseButtonDownOnWindow = true;
2210
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2211
                    }
2212

    
2213
                    if (controlType == ControlType.None)
2214
                    {
2215
                        isLeftMouseButtonDownOnWindow = true;
2216
                    }
2217
                }
2218

    
2219
                /// 캡쳐 모드 설정
2220
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2221
                {
2222
                    dragCaptureBorder.Visibility = Visibility.Visible;
2223
                    isLeftMouseButtonDownOnWindow = true;
2224
                }
2225

    
2226
                /// 줌 모드 설정
2227
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2228
                {
2229
                    isLeftMouseButtonDownOnWindow = true;
2230
                }
2231

    
2232
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2233
                if (control != null)
2234
                {
2235
                    AdornerFinal final = null;
2236

    
2237
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2238
                    {
2239
                        /// 기존 selection 해제
2240
                        SelectionSet.Instance.UnSelect(this);
2241

    
2242
                        final = new AdornerFinal(control);
2243

    
2244
                        this.Control_Style(control);
2245

    
2246
                        if ((control as IPath) != null)
2247
                        {
2248
                            if ((control as IPath).LineSize != 0)
2249
                            {
2250
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2251
                            }
2252
                        }
2253
                        if ((control as IShapeControl) != null)
2254
                        {
2255
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2256
                            {
2257
                                ViewerDataModel.Instance.checkHatchShape = true;
2258
                            }
2259
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2260
                            {
2261
                                ViewerDataModel.Instance.checkFillShape = true;
2262
                            }
2263
                            else
2264
                            {
2265
                                ViewerDataModel.Instance.checkHatchShape = false;
2266
                                ViewerDataModel.Instance.checkFillShape = false;
2267
                            }
2268
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2269
                        }
2270

    
2271
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2272

    
2273
                        if ((control as TextControl) != null)
2274
                        {
2275
                            if(!((control as TextControl).EnableEditing)) {
2276
                                (control as TextControl).EnableEditing = true;
2277
                            }
2278

    
2279
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2280
                            {
2281
                                ViewerDataModel.Instance.checkTextStyle = true;
2282
                            }
2283
                            else
2284
                            {
2285
                                ViewerDataModel.Instance.checkTextStyle = false;
2286
                            }
2287

    
2288
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2289
                            {
2290
                                ViewerDataModel.Instance.checkTextStyle = true;
2291
                            }
2292
                            else
2293
                            {
2294
                                ViewerDataModel.Instance.checkTextStyle = false;
2295
                            }
2296
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2297
                            {
2298
                                ViewerDataModel.Instance.checkTextWeight = true;
2299
                            }
2300
                            else
2301
                            {
2302
                                ViewerDataModel.Instance.checkTextWeight = false;
2303
                            }
2304
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2305
                            {
2306
                                ViewerDataModel.Instance.checkUnderLine = true;
2307
                            }
2308
                            else
2309
                            {
2310
                                ViewerDataModel.Instance.checkUnderLine = false;
2311
                            }
2312
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2313
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2314

    
2315
                        }
2316
                        else if ((control as ArrowTextControl) != null)
2317
                        {
2318
                            if (!((control as ArrowTextControl).EnableEditing))
2319
                            {
2320
                                (control as ArrowTextControl).EnableEditing = true;
2321
                            }
2322
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2323
                            {
2324
                                ViewerDataModel.Instance.checkTextStyle = true;
2325
                            }
2326
                            else
2327
                            {
2328
                                ViewerDataModel.Instance.checkTextStyle = false;
2329
                            }
2330

    
2331
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2332
                            {
2333
                                ViewerDataModel.Instance.checkTextStyle = true;
2334
                            }
2335
                            else
2336
                            {
2337
                                ViewerDataModel.Instance.checkTextStyle = false;
2338
                            }
2339
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2340
                            {
2341
                                ViewerDataModel.Instance.checkTextWeight = true;
2342
                            }
2343
                            else
2344
                            {
2345
                                ViewerDataModel.Instance.checkTextWeight = false;
2346
                            }
2347
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2348
                            {
2349
                                ViewerDataModel.Instance.checkUnderLine = true;
2350
                            }
2351
                            else
2352
                            {
2353
                                ViewerDataModel.Instance.checkUnderLine = false;
2354
                            }
2355
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2356
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2357
                        }
2358
                        else if ((control as RectCloudControl) != null)
2359
                        {
2360
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2361
                        }
2362
                        else if ((control as CloudControl) != null)
2363
                        {
2364
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2365
                        }
2366
                    }
2367
                    else
2368
                    {
2369
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2370
                        SelectionSet.Instance.UnSelect(this);
2371
                        comment.Add(control);
2372

    
2373
                        Control_Style(control);
2374

    
2375
                        final = new AdornerFinal(comment);
2376
                    }
2377

    
2378
                    if (final != null)
2379
                    {
2380
                        this.SelectLayer.Children.Add(final);
2381
                    }
2382
                }              
2383
            }
2384
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2385
            {               
2386
                init();
2387
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2388
                if (cursor != Cursors.SizeAll)
2389
                {
2390
                    cursor = Cursors.Cross;
2391
                    SetCursor();
2392
                }
2393
                bool init_user = false;
2394
                foreach (var user in gridViewMarkup.Items)
2395
                {
2396
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2397
                    {
2398
                        init_user = true;
2399
                    }
2400
                }
2401
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2402
                {
2403
                    RadWindow.Alert(new DialogParameters
2404
                    {
2405
                        Owner = Application.Current.MainWindow,
2406
                        Theme = new VisualStudio2013Theme(),
2407
                        Header = "안내",
2408
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2409
                    });
2410
                    return;
2411
                }
2412
                else
2413
                {
2414
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2415
                    if (item != null)
2416
                    {
2417
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2418
                    }
2419
                }
2420

    
2421
                switch (controlType)
2422
                {
2423
                    case ControlType.Coordinate:
2424
                        {
2425
                            if (e.LeftButton == MouseButtonState.Pressed)
2426
                            {
2427
                                if (currentControl is CoordinateControl)
2428
                                {
2429
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2430
                                    {
2431
                                        return;
2432
                                    }
2433

    
2434
                                    CreateCommand.Instance.Execute(currentControl);
2435

    
2436
                                    currentControl = null;
2437
                                    this.cursor = Cursors.Arrow;
2438
                                }
2439
                                else
2440
                                {
2441
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2442
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2443
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2444
                                    {
2445
                                        currentControl = null;
2446
                                        this.cursor = Cursors.Arrow;
2447
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2448
                                        return;
2449
                                    }
2450
                                    else
2451
                                    {
2452
                                        currentControl = new CoordinateControl
2453
                                        {
2454
                                            Background = new SolidColorBrush(Colors.Black),
2455
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2456
                                            ControlType = ControlType.Coordinate
2457
                                        };
2458

    
2459
                                        currentControl.CommentID = Commons.shortGuid();
2460
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2461
                                        currentControl.IsNew = true;
2462

    
2463
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2464

    
2465
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2466
                                    }
2467
                                }
2468
                            }
2469
                        }
2470
                        break;
2471
                    case ControlType.InsideWhite:
2472
                        {
2473
                            if (e.LeftButton == MouseButtonState.Pressed)
2474
                            {
2475
                                if (currentControl is InsideWhiteControl)
2476
                                {
2477
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2478
                                    {
2479
                                        return;
2480
                                    }
2481

    
2482
                                    CreateCommand.Instance.Execute(currentControl);
2483

    
2484
                                    currentControl = null;
2485
                                    this.cursor = Cursors.Arrow;
2486
                                }
2487
                                else
2488
                                {
2489
                                    currentControl = new InsideWhiteControl
2490
                                    {
2491
                                        Background = new SolidColorBrush(Colors.Black),
2492
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2493
                                        ControlType = ControlType.InsideWhite
2494
                                    };
2495

    
2496
                                    currentControl.CommentID = Commons.shortGuid();
2497
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2498
                                    currentControl.IsNew = true;
2499
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2500

    
2501
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2502
                                }
2503
                            }
2504
                        }
2505
                        break;
2506
                    case ControlType.OverlapWhite:
2507
                        {
2508
                            if (e.LeftButton == MouseButtonState.Pressed)
2509
                            {
2510
                                if (currentControl is OverlapWhiteControl)
2511
                                {
2512
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2513
                                    {
2514
                                        return;
2515
                                    }
2516

    
2517
                                    CreateCommand.Instance.Execute(currentControl);
2518

    
2519
                                    currentControl = null;
2520
                                    this.cursor = Cursors.Arrow;
2521
                                }
2522
                                else
2523
                                {
2524
                                    currentControl = new OverlapWhiteControl
2525
                                    {
2526
                                        Background = new SolidColorBrush(Colors.Black),
2527
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2528
                                        ControlType = ControlType.OverlapWhite
2529
                                    };
2530

    
2531
                                    currentControl.CommentID = Commons.shortGuid();
2532
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2533
                                    currentControl.IsNew = true;
2534
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2535

    
2536
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2537
                                }
2538
                            }
2539
                        }
2540
                        break;
2541
                    case ControlType.ClipWhite:
2542
                        {
2543
                            if (e.LeftButton == MouseButtonState.Pressed)
2544
                            {
2545
                                if (currentControl is ClipWhiteControl)
2546
                                {
2547
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2548
                                    {
2549
                                        return;
2550
                                    }
2551

    
2552
                                    CreateCommand.Instance.Execute(currentControl);
2553

    
2554
                                    currentControl = null;
2555
                                    this.cursor = Cursors.Arrow;
2556
                                }
2557
                                else
2558
                                {
2559
                                    currentControl = new ClipWhiteControl
2560
                                    {
2561
                                        Background = new SolidColorBrush(Colors.Black),
2562
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2563
                                        ControlType = ControlType.ClipWhite
2564
                                    };
2565

    
2566
                                    currentControl.CommentID = Commons.shortGuid();
2567
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2568
                                    currentControl.IsNew = true;
2569
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2570

    
2571
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2572
                                }
2573
                            }
2574
                        }
2575
                        break;
2576
                    case ControlType.Rectangle:
2577
                        {
2578
                            if (e.LeftButton == MouseButtonState.Pressed)
2579
                            {
2580
                                if (currentControl is RectangleControl)
2581
                                {
2582
                                    //20180906 LJY TEST IsRotationDrawingEnable
2583
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2584
                                    {
2585
                                        return;
2586
                                    }
2587

    
2588
                                    CreateCommand.Instance.Execute(currentControl);
2589
                                    currentControl = null;
2590
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2591
                                }
2592
                                else
2593
                                {
2594
                                    currentControl = new RectangleControl
2595
                                    {
2596
                                        Background = new SolidColorBrush(Colors.Black),
2597
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2598
                                        ControlType = ControlType.Rectangle
2599
                                    };
2600

    
2601
                                    currentControl.CommentID = Commons.shortGuid();
2602
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2603
                                    currentControl.IsNew = true;
2604
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2605

    
2606
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2607
                                }
2608
                            }
2609
                        }
2610
                        break;
2611
                    case ControlType.RectCloud:
2612
                        {
2613
                            if (e.LeftButton == MouseButtonState.Pressed)
2614
                            {
2615
                                if (currentControl is RectCloudControl)
2616
                                {
2617
                                    //20180906 LJY TEST IsRotationDrawingEnable
2618
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2619
                                    {
2620
                                        return;
2621
                                    }
2622

    
2623
                                    CreateCommand.Instance.Execute(currentControl);
2624

    
2625
                                    currentControl = null;
2626
                                
2627
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2628
                                }
2629
                                else
2630
                                {
2631
                                    currentControl = new RectCloudControl
2632
                                    {
2633
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2634
                                        ControlType = ControlType.RectCloud,
2635
                                        Background = new SolidColorBrush(Colors.Black)
2636
                                    };
2637

    
2638
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2639
                                    currentControl.CommentID = Commons.shortGuid();
2640
                                    currentControl.IsNew = true;
2641
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2642
                                }
2643
                            }
2644
                        }
2645
                        break;
2646
                    case ControlType.Circle:
2647
                        {
2648
                            if (e.LeftButton == MouseButtonState.Pressed)
2649
                            {
2650
                                if (currentControl is CircleControl)
2651
                                {
2652
                                    //20180906 LJY TEST IsRotationDrawingEnable
2653
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2654
                                    {
2655
                                        return;
2656
                                    }
2657

    
2658
                                    CreateCommand.Instance.Execute(currentControl);
2659

    
2660
                                    currentControl = null;
2661
                                }
2662
                                else
2663
                                {
2664
                                    currentControl = new CircleControl
2665
                                    {
2666
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2667
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2668
                                        Background = new SolidColorBrush(Colors.Black)
2669
                                    };
2670

    
2671
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2672
                                    currentControl.CommentID = Commons.shortGuid();
2673
                                    currentControl.IsNew = true;
2674
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2675
                                }
2676
                            }
2677
                        }
2678
                        break;
2679
                    case ControlType.Triangle:
2680
                        {
2681
                            if (e.LeftButton == MouseButtonState.Pressed)
2682
                            {
2683
                                if (currentControl is TriControl)
2684
                                {
2685
                                    var content = currentControl as TriControl;
2686
                                    if (content.MidPoint == new Point(0, 0))
2687
                                    {
2688
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2689
                                    }
2690
                                    else
2691
                                    {
2692
                                        //20180906 LJY TEST IsRotationDrawingEnable
2693
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2694
                                        {
2695
                                            return;
2696
                                        }
2697

    
2698
                                        CreateCommand.Instance.Execute(currentControl);
2699

    
2700
                                        currentControl = null;
2701
                                    }
2702
                                }
2703
                                else
2704
                                {
2705
                                    currentControl = new TriControl
2706
                                    {
2707
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2708
                                        Background = new SolidColorBrush(Colors.Black),
2709
                                    };
2710

    
2711
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2712
                                    currentControl.CommentID = Commons.shortGuid();
2713
                                    currentControl.IsNew = true;
2714
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2715
                                }
2716
                            }
2717
                        }
2718
                        break;
2719
                    case ControlType.CancelLine:
2720
                    case ControlType.SingleLine:
2721
                    case ControlType.ArrowLine:
2722
                    case ControlType.TwinLine:
2723
                    case ControlType.DimLine:
2724
                        {
2725
                            if (e.LeftButton == MouseButtonState.Pressed)
2726
                            {
2727
                                if (currentControl is LineControl)
2728
                                {
2729
                                    //20180906 LJY TEST IsRotationDrawingEnable
2730
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2731
                                    {
2732
                                        return;
2733
                                    }
2734

    
2735
                                    CreateCommand.Instance.Execute(currentControl);
2736
                                    currentControl = null;
2737
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2738
                                }
2739
                                else
2740
                                {
2741
                                    currentControl = new LineControl
2742
                                    {
2743
                                        ControlType = this.controlType,
2744
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2745
                                        Background = new SolidColorBrush(Colors.Black)
2746
                                    };
2747

    
2748
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2749
                                    currentControl.CommentID = Commons.shortGuid();
2750
                                    currentControl.IsNew = true;
2751
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2752
                                    this.MainAngle.Visibility = Visibility.Visible;
2753
                                }
2754
                            }
2755
                        }
2756
                        break;
2757
                    case ControlType.PolygonControl:
2758
                        {
2759
                            if (currentControl is PolygonControl)
2760
                            {
2761
                                var control = currentControl as PolygonControl;
2762

    
2763
                                if (e.RightButton == MouseButtonState.Pressed)
2764
                                {
2765
                                    control.IsCompleted = true;
2766
                                }
2767

    
2768
                                if (!control.IsCompleted)
2769
                                {
2770
                                    control.PointSet.Add(control.EndPoint);
2771
                                }
2772
                                else
2773
                                {
2774
                                    //20180906 LJY TEST IsRotationDrawingEnable
2775
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2776
                                    {
2777
                                        return;
2778
                                    }
2779

    
2780
                                    var firstPoint = control.PointSet.First();
2781
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2782
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2783
                                    control.PointSet.Add(firstPoint);
2784

    
2785
                                    control.ApplyOverViewData();
2786

    
2787
                                    CreateCommand.Instance.Execute(currentControl);
2788
                                    control.UpdateControl();
2789
                                    currentControl = null;
2790
                                }
2791
                            }
2792
                            else
2793
                            {
2794
                                if (e.LeftButton == MouseButtonState.Pressed)
2795
                                {
2796
                                    currentControl = new PolygonControl
2797
                                    {
2798
                                        PointSet = new List<Point>(),
2799
                                    };
2800

    
2801
                                    var polygonControl = (currentControl as PolygonControl);
2802
                                    currentControl.CommentID = Commons.shortGuid();
2803
                                    currentControl.IsNew = true;
2804
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2805
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2806
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2807
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2808
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2809
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2810
                                    polygonControl.ApplyTemplate();
2811
                                    polygonControl.Visibility = Visibility.Visible;
2812
                                }
2813
                            }
2814
                        }
2815
                        break;
2816
                    case ControlType.ChainLine:
2817
                        {
2818
                            if (currentControl is PolygonControl)
2819
                            {
2820
                                var control = currentControl as PolygonControl;
2821

    
2822
                                if (e.RightButton == MouseButtonState.Pressed)
2823
                                {
2824
                                    //20180906 LJY TEST IsRotationDrawingEnable
2825
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2826
                                    {
2827
                                        return;
2828
                                    }
2829

    
2830
                                    CreateCommand.Instance.Execute(currentControl);
2831

    
2832
                                    currentControl = null;
2833
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2834
                                    return;
2835
                                }
2836

    
2837
                                if (!control.IsCompleted)
2838
                                {
2839
                                    control.PointSet.Add(control.EndPoint);
2840
                                    this.MainAngle.Visibility = Visibility.Visible;
2841
                                }
2842
                            }
2843
                            else
2844
                            {
2845
                                if (e.LeftButton == MouseButtonState.Pressed)
2846
                                {
2847
                                    MainAngle.Visibility = Visibility.Visible;
2848
                                    currentControl = new PolygonControl
2849
                                    {
2850
                                        PointSet = new List<Point>(),
2851
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2852
                                        ControlType = ControlType.ChainLine,
2853
                                        DashSize = ViewerDataModel.Instance.DashSize,
2854
                                        LineSize = ViewerDataModel.Instance.LineSize,
2855
                                        //PointC = new StylusPointSet()
2856
                                    };
2857

    
2858
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2859
                                    //{
2860
                                        var polygonControl = (currentControl as PolygonControl);
2861
                                        currentControl.CommentID = Commons.shortGuid();
2862
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2863
                                        currentControl.IsNew = true;
2864
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2865
                                        //currentControl.OnApplyTemplate();
2866
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2867
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2868
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2869
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2870
                                    //}
2871
                                }
2872
                            }
2873
                        }
2874
                        break;
2875
                    case ControlType.ArcLine:
2876
                        {
2877
                            if (e.LeftButton == MouseButtonState.Pressed)
2878
                            {
2879
                                if (currentControl is ArcControl)
2880
                                {
2881
                                    //20180906 LJY TEST IsRotationDrawingEnable
2882
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2883
                                    {
2884
                                        return;
2885
                                    }
2886

    
2887
                                    CreateCommand.Instance.Execute(currentControl);
2888

    
2889
                                    currentControl = null;
2890
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2891
                                }
2892
                                else
2893
                                {
2894
                                    currentControl = new ArcControl
2895
                                    {
2896
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2897
                                        Background = new SolidColorBrush(Colors.Black)
2898
                                    };
2899
                                    currentControl.CommentID = Commons.shortGuid();
2900
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2901
                                    currentControl.IsNew = true;
2902
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2903
                                    this.MainAngle.Visibility = Visibility.Visible;
2904
                                }
2905
                            }
2906
                            else if (e.RightButton == MouseButtonState.Pressed)
2907
                            {
2908
                                if (currentControl != null)
2909
                                {
2910
                                    (currentControl as ArcControl).setClock();
2911
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2912
                                }
2913
                            }
2914
                        }
2915
                        break;
2916
                    case ControlType.ArcArrow:
2917
                        {
2918
                            if (e.LeftButton == MouseButtonState.Pressed)
2919
                            {
2920
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2921
                                //{
2922
                                if (currentControl is ArrowArcControl)
2923
                                {
2924
                                    //20180906 LJY TEST IsRotationDrawingEnable
2925
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2926
                                    {
2927
                                        return;
2928
                                    }
2929

    
2930
                                    CreateCommand.Instance.Execute(currentControl);
2931

    
2932
                                    currentControl = null;
2933
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2934
                                }
2935
                                else
2936
                                {
2937
                                    currentControl = new ArrowArcControl
2938
                                    {
2939
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2940
                                        Background = new SolidColorBrush(Colors.Black)
2941
                                    };
2942
                                    currentControl.CommentID = Commons.shortGuid();
2943
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2944
                                    currentControl.IsNew = true;
2945
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2946
                                    this.MainAngle.Visibility = Visibility.Visible;
2947
                                }
2948
                                //}
2949
                            }
2950
                            else if (e.RightButton == MouseButtonState.Pressed)
2951
                            {
2952
                                if (currentControl != null)
2953
                                {
2954
                                    (currentControl as ArrowArcControl).setClock();
2955
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2956
                                    //(currentControl as ArcControl).ApplyTemplate();
2957
                                }
2958
                            }
2959
                        }
2960
                        break;
2961
                    case ControlType.ArrowMultiLine:
2962
                        {
2963
                            if (e.LeftButton == MouseButtonState.Pressed)
2964
                            {
2965
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2966
                                //{
2967

    
2968
                                    if (currentControl is ArrowControl_Multi)
2969
                                    {
2970
                                        var content = currentControl as ArrowControl_Multi;
2971
                                        if (content.MiddlePoint == new Point(0, 0))
2972
                                        {
2973
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2974
                                            {
2975
                                                content.MiddlePoint = content.EndPoint;
2976
                                            }
2977
                                            else
2978
                                            {
2979
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2980
                                            }
2981
                                        }
2982
                                        else
2983
                                        {
2984
                                            //20180906 LJY TEST IsRotationDrawingEnable
2985
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2986
                                            {
2987
                                                return;
2988
                                            }
2989

    
2990
                                            CreateCommand.Instance.Execute(currentControl);
2991

    
2992
                                            currentControl = null;
2993
                                            this.MainAngle.Visibility = Visibility.Collapsed;
2994
                                        }
2995
                                    }
2996
                                    else
2997
                                    {
2998
                                        currentControl = new ArrowControl_Multi
2999
                                        {
3000
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3001
                                            Background = new SolidColorBrush(Colors.Black)
3002
                                        };
3003
                                        currentControl.CommentID = Commons.shortGuid();
3004
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3005
                                        currentControl.IsNew = true;
3006
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3007
                                        this.MainAngle.Visibility = Visibility.Visible;
3008
                                    }
3009
                                //}
3010
                            }
3011
                        }
3012
                        break;
3013
                    case ControlType.PolygonCloud:
3014
                        {
3015
                            if (currentControl is CloudControl)
3016
                            {
3017
                                var control = currentControl as CloudControl;
3018
                                if (e.RightButton == MouseButtonState.Pressed)
3019
                                {
3020
                                    control.IsCompleted = true;
3021
                                }
3022

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

    
3035
                                    CreateCommand.Instance.Execute(currentControl);
3036

    
3037
                                    control.isTransOn = true;
3038
                                    var firstPoint = control.PointSet.First();
3039

    
3040
                                    control.PointSet.Add(firstPoint);
3041
                                    control.DrawingCloud();
3042
                                    control.ApplyOverViewData();
3043

    
3044
                                    currentControl = null;
3045
                                }
3046
                            }
3047
                            else
3048
                            {
3049
                                if (e.LeftButton == MouseButtonState.Pressed)
3050
                                {
3051
                                    currentControl = new CloudControl
3052
                                    {
3053
                                        PointSet = new List<Point>(),
3054
                                        PointC = new StylusPointSet()
3055
                                    };
3056

    
3057
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3058
                                    //{
3059
                                        var polygonControl = (currentControl as CloudControl);
3060
                                        currentControl.CommentID = Commons.shortGuid();
3061
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3062
                                        currentControl.IsNew = true;
3063
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3064

    
3065
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3066
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3067
                                    
3068
                                    //}
3069
                                }
3070
                            }
3071
                        }
3072
                        break;
3073
                    case ControlType.ImgControl:
3074
                        {
3075
                            if (e.LeftButton == MouseButtonState.Pressed)
3076
                            {
3077
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3078
                                //{
3079
                                    if (currentControl is ImgControl)
3080
                                    {
3081
                                        //20180906 LJY TEST IsRotationDrawingEnable
3082
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3083
                                        {
3084
                                            return;
3085
                                        }
3086

    
3087
                                        CreateCommand.Instance.Execute(currentControl);
3088
                                        controlType = ControlType.ImgControl;
3089
                                        currentControl = null;
3090
                                    }
3091
                                    else
3092
                                    {
3093
                                        
3094
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3095
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3096
                                        {
3097
                                            Image img = new Image();
3098
                                            if (filename.Contains(".svg"))
3099
                                            {
3100
                                                byte[] imageData = null;
3101
                                                DrawingImage image = null;
3102
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3103
                                                {
3104
                                                    imageData = web.DownloadData(new Uri(filename));
3105
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3106
                                                    image = SvgReader.Load(stream);
3107
                                                }
3108
                                                img.Source = image;
3109
                                            }
3110
                                            else
3111
                                            {
3112
                                                img.Source = new BitmapImage(new Uri(filename));
3113
                                            }
3114

    
3115
                                            currentControl = new ImgControl
3116
                                            {
3117
                                                    Background = new SolidColorBrush(Colors.Black),
3118
                                                    PointSet = new List<Point>(),
3119
                                                    FilePath = filename,
3120
                                                    ImageData = img.Source,
3121
                                                    StartPoint = canvasDrawingMouseDownPoint,
3122
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3123
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3124
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3125
                                                    ControlType = ControlType.ImgControl
3126
                                                };
3127

    
3128
                                        
3129
                                                currentControl.CommentID = Commons.shortGuid();                                            
3130
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3131
                                                currentControl.IsNew = true;
3132
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3133

    
3134
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3135
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3136
                                        }
3137
                                    }
3138
                                //}
3139
                            }
3140
                        }
3141
                        break;
3142
                    case ControlType.Date:
3143
                        {
3144
                            if (e.LeftButton == MouseButtonState.Pressed)
3145
                            {
3146
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3147
                                //{
3148
                                    if (currentControl is DateControl)
3149
                                    {
3150
                                        //20180906 LJY TEST IsRotationDrawingEnable
3151
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3152
                                        {
3153
                                            return;
3154
                                        }
3155

    
3156
                                        CreateCommand.Instance.Execute(currentControl);
3157
                                        currentControl = null;
3158

    
3159
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3160
                                        {
3161
                                            controlType = ControlType.None;
3162
                                            IsSwingMode = false;
3163
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3164
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3165
                                            mouseHandlingMode = MouseHandlingMode.None;
3166
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3167
                                            txtBatch.Visibility = Visibility.Collapsed;
3168

    
3169
                                        }
3170
                                    }
3171
                                    else
3172
                                    {
3173
                                        currentControl = new DateControl
3174
                                        {
3175
                                            StartPoint = canvasDrawingMouseDownPoint,
3176
                                            Background = new SolidColorBrush(Colors.Black)
3177
                                        };
3178
                                        currentControl.CommentID = Commons.shortGuid();
3179
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3180
                                        currentControl.IsNew = true;
3181
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3182

    
3183
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3184
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3185
                                }
3186
                                //}
3187
                            }
3188
                        }
3189
                        break;
3190
                    case ControlType.TextControl:
3191
                        {
3192
                            if (e.LeftButton == MouseButtonState.Pressed)
3193
                            {
3194
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3195
                                {
3196
                                    currentControl = new TextControl
3197
                                    {
3198
                                        ControlType = controlType
3199
                                    };
3200
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3201
                                    currentControl.CommentID = Commons.shortGuid();
3202
                                    currentControl.IsNew = true;
3203
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3204
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3205
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3206

    
3207
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3208
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3209
                                    
3210
                                    (currentControl as TextControl).ControlType_No = 0;
3211
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3212
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3213
                                    (currentControl as TextControl).ApplyTemplate();
3214
                                    (currentControl as TextControl).Base_TextBox.Focus();
3215

    
3216
                                    CreateCommand.Instance.Execute(currentControl);
3217
                                }
3218
                            }
3219
                        }
3220
                        break;
3221
                    case ControlType.TextBorder:
3222
                        {
3223
                            if (e.LeftButton == MouseButtonState.Pressed)
3224
                            {
3225
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3226
                                {
3227
                                    currentControl = new TextControl
3228
                                    {
3229
                                        ControlType = controlType
3230
                                    };
3231

    
3232
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3233
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3234
                                    currentControl.CommentID = Commons.shortGuid();
3235
                                    currentControl.IsNew = true;
3236
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3237
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3238
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3239
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3240
                                    
3241
                                    (currentControl as TextControl).ControlType_No = 1;
3242
                                    (currentControl as TextControl).Angle = Ang;
3243
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3244
                                    (currentControl as TextControl).ApplyTemplate();
3245
                                    (currentControl as TextControl).Base_TextBox.Focus();
3246
                                    CreateCommand.Instance.Execute(currentControl);
3247
                                }
3248
                            }
3249
                        }
3250
                        break;
3251
                    case ControlType.TextCloud:
3252
                        {
3253
                            if (e.LeftButton == MouseButtonState.Pressed)
3254
                            {
3255
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3256
                                {
3257
                                    currentControl = new TextControl
3258
                                    {
3259
                                        ControlType = controlType
3260
                                    };
3261

    
3262
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3263
                                    currentControl.CommentID = Commons.shortGuid();
3264
                                    currentControl.IsNew = true;
3265
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3266
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3267

    
3268
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3269
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3270
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3271

    
3272
                                    (currentControl as TextControl).Angle = Ang;
3273
                                    (currentControl as TextControl).ControlType_No = 2;
3274
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3275
                                    (currentControl as TextControl).ApplyTemplate();
3276
                                    (currentControl as TextControl).Base_TextBox.Focus();
3277
                                    CreateCommand.Instance.Execute(currentControl);
3278
                                    //currentControl = null;
3279
                                }
3280
                            }
3281
                        }
3282
                        break;
3283
                    case ControlType.ArrowTextControl:
3284
                         {
3285
                            if (e.LeftButton == MouseButtonState.Pressed)
3286
                            {
3287
                                if (currentControl is ArrowTextControl)
3288
                                {
3289
                                    //20180906 LJY TEST IsRotationDrawingEnable
3290
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3291
                                    {
3292
                                        return;
3293
                                    }
3294

    
3295
                                    CreateCommand.Instance.Execute(currentControl);
3296

    
3297
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3298
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3299
                                    (currentControl as ArrowTextControl).IsNew = false;
3300
                                    currentControl = null;
3301
                                }
3302
                                else
3303
                                {
3304
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3305
                                    //{
3306
                                        currentControl = new ArrowTextControl();
3307
                                        currentControl.CommentID = Commons.shortGuid();
3308
                                        currentControl.IsNew = true;
3309
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3310
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3311

    
3312
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3313
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3314
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3315
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3316
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3317

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

    
3321
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3322
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3323
                                        this.MainAngle.Visibility = Visibility.Visible;
3324

    
3325
                                    
3326
                                    //}
3327
                                }
3328
                            }
3329
                        }
3330
                        break;
3331
                    case ControlType.ArrowTransTextControl:
3332
                        {
3333
                            if (e.LeftButton == MouseButtonState.Pressed)
3334
                            {
3335
                                if (currentControl is ArrowTextControl)
3336
                                {
3337
                                    //20180906 LJY TEST IsRotationDrawingEnable
3338
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3339
                                    {
3340
                                        return;
3341
                                    }
3342

    
3343
                                    CreateCommand.Instance.Execute(currentControl);
3344
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3345
                                    currentControl.IsNew = false;
3346
                                    currentControl = null;
3347
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3348
                                }
3349
                                else
3350
                                {
3351
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3352
                                    //{
3353
                                    currentControl = new ArrowTextControl()
3354
                                    {
3355
                                        ControlType = ControlType.ArrowTransTextControl
3356
                                    };
3357
                                    currentControl.CommentID = Commons.shortGuid();
3358
                                    currentControl.IsNew = true;
3359
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3360
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3361
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3362
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3363
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3364
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3365
                                    (currentControl as ArrowTextControl).isFixed = true;
3366
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3367

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

    
3371
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3372
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3373
                                    (currentControl as ArrowTextControl).isTrans = true;
3374
                                }
3375
                            }
3376
                        }
3377
                        break;
3378
                    case ControlType.ArrowTextBorderControl:
3379
                         {
3380
                            if (e.LeftButton == MouseButtonState.Pressed)
3381
                            {
3382
                                if (currentControl is ArrowTextControl)
3383
                                {
3384
                                    //20180906 LJY TEST IsRotationDrawingEnable
3385
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3386
                                    {
3387
                                        return;
3388
                                    }
3389

    
3390
                                    CreateCommand.Instance.Execute(currentControl);
3391
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3392
                                    currentControl.IsNew = false;
3393
                                    currentControl = null;
3394
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3395
                                }
3396
                                else
3397
                                {
3398
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3399
                                    //{
3400
                                        currentControl = new ArrowTextControl()
3401
                                        {
3402
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3403
                                        };
3404
                                        currentControl.CommentID = Commons.shortGuid();
3405
                                        currentControl.IsNew = true;
3406
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3407
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3408

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

    
3411
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3412

    
3413
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3414
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3415
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3416

    
3417
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3418
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3419
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3420
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3421
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3422
                                    //}
3423
                                }
3424
                            }
3425
                        }
3426
                        break;
3427
                    case ControlType.ArrowTransTextBorderControl:
3428
                        {
3429
                            if (e.LeftButton == MouseButtonState.Pressed)
3430
                            {
3431
                                if (currentControl is ArrowTextControl)
3432
                                {
3433
                                    //20180906 LJY TEST IsRotationDrawingEnable
3434
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3435
                                    {
3436
                                        return;
3437
                                    }
3438
                                    CreateCommand.Instance.Execute(currentControl);
3439
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3440
                                    currentControl.IsNew = false;
3441
                                    currentControl = null;
3442
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3443
                                }
3444
                                else
3445
                                {
3446
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3447
                                    //{
3448
                                    
3449

    
3450
                                    currentControl = new ArrowTextControl()
3451
                                    {
3452
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3453
                                        ControlType = ControlType.ArrowTransTextBorderControl
3454

    
3455
                                    };
3456
                                        currentControl.CommentID = Commons.shortGuid();
3457
                                        currentControl.IsNew = true;
3458
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3459
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3460

    
3461
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3462

    
3463
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3464
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3465
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3466
                                        (currentControl as ArrowTextControl).isFixed = true;
3467
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3468
                                     
3469
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3470
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3471
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3472

    
3473
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3474
                                        this.MainAngle.Visibility = Visibility.Visible;
3475
                                    
3476
                                    //20180911 LJY
3477
                                        (currentControl as ArrowTextControl).isTrans = true;
3478
                                    
3479

    
3480
                                    //}
3481
                                }
3482
                            }
3483
                        }
3484
                        break;
3485
                    case ControlType.ArrowTextCloudControl:
3486
                        {
3487
                            if (e.LeftButton == MouseButtonState.Pressed)
3488
                            {
3489
                                if (currentControl is ArrowTextControl)
3490
                                {
3491
                                    //20180906 LJY TEST IsRotationDrawingEnable
3492
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3493
                                    {
3494
                                        return;
3495
                                    }
3496
                                    CreateCommand.Instance.Execute(currentControl);
3497
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3498
                                    currentControl.IsNew = false;
3499
                                    currentControl = null;
3500
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3501
                                }
3502
                                else
3503
                                {
3504
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3505
                                    //{
3506
                                        currentControl = new ArrowTextControl()
3507
                                        {
3508
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3509
                                        };
3510
                                        currentControl.CommentID = Commons.shortGuid();
3511
                                        currentControl.IsNew = true;
3512
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3513
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3514

    
3515
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3516
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3517
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3518
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3519
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3520

    
3521
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3522
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3523
                                    
3524
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3525
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3526
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3527
                                    //}
3528
                                }
3529
                            }
3530
                        }
3531
                        break;
3532
                    case ControlType.ArrowTransTextCloudControl:
3533
                        {
3534
                            if (e.LeftButton == MouseButtonState.Pressed)
3535
                            {
3536
                                if (currentControl is ArrowTextControl)
3537
                                {
3538
                                    //20180906 LJY TEST IsRotationDrawingEnable
3539
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3540
                                    {
3541
                                        return;
3542
                                    }
3543
                                    CreateCommand.Instance.Execute(currentControl);
3544
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3545
                                    currentControl.IsNew = false;
3546
                                    currentControl = null;
3547
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3548
                                }
3549
                                else
3550
                                {
3551
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3552
                                    //{
3553
                                        currentControl = new ArrowTextControl()
3554
                                        {
3555
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3556
                                            ControlType = ControlType.ArrowTransTextCloudControl
3557

    
3558
                                        };
3559
                                        currentControl.CommentID = Commons.shortGuid();
3560
                                        currentControl.IsNew = true; 
3561
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3562
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3563
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3564

    
3565
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3566
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3567
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3568
                                        (currentControl as ArrowTextControl).isFixed = true;
3569
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3570

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

    
3574
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3575
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3576
                                        this.MainAngle.Visibility = Visibility.Visible;  
3577
                                    
3578
                                    //20180911 LJY
3579
                                        (currentControl as ArrowTextControl).isTrans = true;
3580
                                    //}
3581
                                }
3582
                            }
3583
                        }
3584
                        break;
3585
                    //강인구 추가
3586
                    case ControlType.Sign:
3587
                        {
3588
                            if (e.LeftButton == MouseButtonState.Pressed)
3589
                            {
3590
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3591
                                //{
3592
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3593

    
3594
                                    if (_sign == null)
3595
                                    {
3596
                                        txtBatch.Visibility = Visibility.Collapsed;
3597
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3598
                                        controlType = ControlType.None;
3599

    
3600
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3601
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3602
                                        return;
3603
                                    }
3604

    
3605
                                    if (currentControl is SignControl)
3606
                                    {
3607
                                        //20180906 LJY TEST IsRotationDrawingEnable
3608
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3609
                                        {
3610
                                            return;
3611
                                        }
3612

    
3613
                                        CreateCommand.Instance.Execute(currentControl);
3614
                                        currentControl = null;
3615
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3616
                                        {
3617
                                            txtBatch.Text = "Place Date";
3618
                                            controlType = ControlType.Date;
3619
                                        }
3620
                                    }
3621
                                    else
3622
                                    {
3623
                                        currentControl = new SignControl
3624
                                        {
3625
                                            Background = new SolidColorBrush(Colors.Black),
3626
                                            UserNumber = App.ViewInfo.UserID,
3627
                                            ProjectNO = App.ViewInfo.ProjectNO,
3628
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3629
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3630
                                            ControlType = ControlType.Sign
3631
                                        };
3632

    
3633
                                        currentControl.CommentID = Commons.shortGuid();
3634
                                        currentControl.IsNew = true;
3635
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3636
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3637

    
3638
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3639
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3640
                                }
3641
                                //}
3642
                            }
3643
                        }
3644
                        break;
3645
                    case ControlType.Mark:
3646
                        {
3647
                            if (e.LeftButton == MouseButtonState.Pressed)
3648
                            {
3649
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3650
                                //{
3651
                                    if (currentControl is RectangleControl)
3652
                                    {
3653
                                        //20180906 LJY TEST IsRotationDrawingEnable
3654
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3655
                                        {
3656
                                            return;
3657
                                        }
3658

    
3659
                                        CreateCommand.Instance.Execute(currentControl);
3660
                                        (currentControl as RectangleControl).ApplyOverViewData();
3661
                                        currentControl = null;
3662
                                    
3663
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3664

    
3665
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3666
                                        {
3667
                                            txtBatch.Text = "Place Signature";
3668
                                            controlType = ControlType.Sign;
3669
                                        }
3670
                                    }
3671
                                    else
3672
                                    {
3673
                                        currentControl = new RectangleControl
3674
                                        {
3675
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3676
                                            Background = new SolidColorBrush(Colors.Black),
3677
                                            ControlType = ControlType.Mark ,
3678
                                            Paint = PaintSet.Fill
3679
                                        };
3680

    
3681
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3682
                                        currentControl.CommentID = Commons.shortGuid();
3683
                                        currentControl.IsNew = true;
3684
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3685
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3686
                                    }
3687
                                //}
3688
                            }
3689
                        }
3690
                        break;
3691
                    case ControlType.Symbol:
3692
                        {
3693
                            if (e.LeftButton == MouseButtonState.Pressed)
3694
                            {
3695
                                if (currentControl is SymControl)
3696
                                {
3697
                                    //20180906 LJY TEST IsRotationDrawingEnable
3698
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3699
                                    {
3700
                                        return;
3701
                                    }
3702
                                    CreateCommand.Instance.Execute(currentControl);
3703
                                    currentControl = null;
3704
                                
3705
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3706
                                }
3707
                                else
3708
                                {
3709
                                    currentControl = new SymControl
3710
                                    {
3711
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3712
                                        Background = new SolidColorBrush(Colors.Black),
3713
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3714
                                        ControlType = ControlType.Symbol
3715
                                    };
3716

    
3717
                                    currentControl.IsNew = true;
3718
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3719
                                    currentControl.CommentID = Commons.shortGuid();
3720
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3721

    
3722
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3723
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3724
                                }
3725
                                //}
3726
                            }
3727
                        }
3728
                        break;
3729
                    case ControlType.Stamp:
3730
                        {
3731
                            if (e.LeftButton == MouseButtonState.Pressed)
3732
                            {
3733
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3734
                                //{
3735
                                    if (currentControl is SymControlN)
3736
                                    {
3737
                                        //20180906 LJY TEST IsRotationDrawingEnable
3738
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3739
                                        {
3740
                                            return;
3741
                                        }
3742

    
3743
                                        CreateCommand.Instance.Execute(currentControl);
3744
                                        currentControl = null;
3745
                                   
3746

    
3747
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3748
                                    }
3749
                                    else
3750
                                    {
3751
                                        currentControl = new SymControlN
3752
                                        {
3753
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3754
                                            Background = new SolidColorBrush(Colors.Black),
3755
                                            STAMP = App.SystemInfo.STAMP,
3756
                                            ControlType = ControlType.Stamp
3757
                                        };
3758

    
3759
                                        currentControl.IsNew = true;
3760
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3761
                                        currentControl.CommentID = Commons.shortGuid();
3762
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3763
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3764
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3765
                                }                                    
3766
                                //}
3767
                            }
3768
                        }
3769
                        break;
3770
                    case ControlType.PenControl:
3771
                        {
3772
                            if (inkBoard.Tag.ToString() == "Ink")
3773
                            {
3774
                                inkBoard.IsEnabled = true;
3775
                                StartNewStroke(canvasDrawingMouseDownPoint);
3776
                            }
3777
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3778
                            {
3779
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3780
                            }
3781
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3782
                            {
3783
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3784
                            }
3785
                            IsDrawing = true;
3786
                            return;
3787
                        }
3788
                    default:
3789
                        if (currentControl != null)
3790
                        {
3791
                            currentControl.CommentID = null;
3792
                            currentControl.IsNew = false;
3793
                        }
3794
                        break;
3795
                }
3796
            }
3797
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3798
            {
3799
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3800
                {
3801
                    bool mouseOff = false;
3802
                    foreach (var item in SelectLayer.Children)
3803
                    {
3804
                        if (item is AdornerFinal)
3805
                        {
3806

    
3807
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3808
                            if (over != null)
3809
                            {
3810
                                mouseOff = true;
3811
                            }
3812
                        }
3813
                    }
3814

    
3815
                    if (!mouseOff)
3816
                    {
3817
                        SelectionSet.Instance.UnSelect(this);
3818
                    }
3819
                }
3820
                zoomAndPanControl.CaptureMouse();
3821
                e.Handled = true;
3822
            }
3823
        }
3824

    
3825
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3826
        {
3827
            ///mouseButtonDown = e.ChangedButton;
3828
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3829
        }
3830

    
3831
        private void RemoveLineStroke(Point P)
3832
        {
3833
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3834
            if (control != null)
3835
            {
3836
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3837
            }
3838
        }
3839

    
3840
        private void RemovePointStroke(Point P)
3841
        {
3842
            foreach (Stroke hits in inkBoard.Strokes)
3843
            {
3844
                foreach (StylusPoint sty in hits.StylusPoints)
3845
                {
3846

    
3847
                }
3848
                if (hits.HitTest(P))
3849
                {
3850
                    inkBoard.Strokes.Remove(hits);
3851
                    return;
3852
                }
3853
            }
3854
        }
3855

    
3856
        private void StartNewStroke(Point P)
3857
        {
3858
            strokePoints = new StylusPointCollection();
3859
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3860
            strokePoints.Add(segment1Start);
3861
            stroke = new Stroke(strokePoints);
3862

    
3863
            stroke.DrawingAttributes.Color = Colors.Red;
3864
            stroke.DrawingAttributes.Width = 4;
3865
            stroke.DrawingAttributes.Height = 4;
3866

    
3867
            inkBoard.Strokes.Add(stroke);
3868
        }
3869

    
3870
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3871
        {
3872
            ConsolidationMethod();
3873
        }
3874

    
3875
        /// <summary>
3876
        /// execute TeamConsolidationCommand
3877
        /// </summary>
3878
        public void TeamConsolidationMethod()
3879
        {
3880
            this.UpdateMyMarkupList();
3881
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3882
            {
3883
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3884
            }
3885
            else
3886
            {
3887

    
3888
                ViewerDataModel.Instance.IsConsolidate = true;
3889
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3890

    
3891
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3892
                {
3893
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3894
                    {
3895
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3896
                        return;
3897
                    }                    
3898
                }
3899
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3900
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3901
                {
3902
                    MarkupInfoList.Add(item);
3903
                }
3904
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3905
            }
3906
        }
3907

    
3908
        public void ConsolidationMethod()
3909
        {
3910
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3911
            {
3912
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3913
            }
3914
            else
3915
            {
3916
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3917
                foreach (var item in this.gridViewMarkup.SelectedItems)
3918
                {
3919
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3920
                }
3921
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3922
                
3923
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3924
            }
3925
        }
3926

    
3927
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3928
        {
3929
            if (App.ViewInfo != null)
3930
            {
3931
                btnConsolidate = (sender as RadRibbonButton);
3932
                if (!App.ViewInfo.NewCommentPermission)
3933
                {
3934
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3935
                }
3936
            }
3937
        }
3938

    
3939
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3940
        {
3941
            TeamConsolidationMethod();
3942
        }
3943

    
3944
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3945
        {
3946
            btnTeamConsolidate = sender as RadRibbonButton;
3947
            if (App.ViewInfo != null)
3948
            {
3949
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3950
                {
3951
                    if (btnConsolidate != null)
3952
                    {
3953
                        btnConsolidate.Visibility = Visibility.Collapsed;
3954
                    }
3955

    
3956
                    if (!App.ViewInfo.NewCommentPermission)
3957
                    {
3958
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3959
                    }
3960
                }
3961
                else
3962
                {
3963
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3964
                }
3965
            }
3966
        }
3967

    
3968
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3969
        {
3970
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3971
            if (item != null)
3972
            {
3973
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3974

    
3975
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3976
            }
3977
            else
3978
            {
3979
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3980
            }
3981
        }
3982

    
3983
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3984
        {
3985
            btnFinalPDF = sender as RadRibbonButton;
3986
            if (App.ViewInfo != null)
3987
            {
3988
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3989
                {
3990
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
3991
                    if (btnConsolidate != null)
3992
                    {
3993
                        btnConsolidate.Visibility = Visibility.Collapsed;
3994
                    }
3995
                }
3996
            }
3997
        }
3998

    
3999
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4000
        {
4001
            UpdateMyMarkupList();
4002

    
4003
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4004
            {
4005
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4006
            }
4007
            else
4008
            {
4009
                ViewerDataModel.Instance.IsConsolidate = true;
4010
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4011
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4012

    
4013
                string project_no = App.ViewInfo.ProjectNO;
4014
                string doc_id = _DocInfo.ID;
4015
                string user_id = App.ViewInfo.UserID;
4016
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4017
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4018
                {
4019
                    markupInfoItems.Add(item);
4020
                }
4021
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4022
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4023
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4024
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4025

    
4026
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4027
                if (item2 != null)
4028
                {
4029
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4030

    
4031
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4032
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4033
                }
4034
                else
4035
                {
4036
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4037
                }
4038
            }
4039
        }
4040

    
4041
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4042
        {
4043
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4044

    
4045
            if (App.ViewInfo != null)
4046
            {
4047
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4048
                {
4049
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4050
                }
4051
            }
4052
        }
4053

    
4054
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4055
        {
4056
            if (CompareMode.IsChecked)
4057
            {
4058
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4059
                {
4060
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4061
                }
4062
                if (ViewerDataModel.Instance.PageNumber == 0)
4063
                {
4064
                    ViewerDataModel.Instance.PageNumber = 1;
4065
                }
4066

    
4067
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
4068
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
4069
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
4070

    
4071
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4072
            }
4073
            else
4074
            {
4075
                da.From = 1;
4076
                da.To = 1;
4077
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4078
                da.AutoReverse = false;
4079
                canvas_compareBorder.Children.Clear();
4080
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4081
            }
4082
        }
4083

    
4084
        private void Sync_Click(object sender, RoutedEventArgs e)
4085
        {
4086
            if (Sync.IsChecked)
4087
            {
4088
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4089
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4090
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4091
            }
4092
        }
4093

    
4094
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4095
        {
4096
            if (UserList.IsChecked)
4097
            {
4098
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4099
            }
4100
            else
4101
            {
4102
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4103
            }
4104
        }
4105

    
4106
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4107
        {
4108

    
4109
            if (BalanceMode.IsChecked)
4110
            {
4111
                ViewerDataModel.Instance.PageBalanceMode = true;
4112
            }
4113
            else
4114
            {
4115
                ViewerDataModel.Instance.PageBalanceMode = false;
4116
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4117
            }
4118
        }
4119

    
4120
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4121
        {
4122
            //초기화
4123
            testPanel2.IsHidden = true;
4124
            ViewerDataModel.Instance.PageBalanceMode = false;
4125
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4126
            ViewerDataModel.Instance.PageNumber = 0;
4127
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4128
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4129
            UserList.IsChecked = false;
4130
            BalanceMode.IsChecked = false;
4131
        }
4132

    
4133
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4134
        {
4135
            if ((sender as System.Windows.Controls.Control).Tag != null)
4136
            {
4137
                //Compare 초기화
4138
                CompareMode.IsChecked = false;
4139
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4140

    
4141
                if (ViewerDataModel.Instance.PageNumber == 0)
4142
                {
4143
                    ViewerDataModel.Instance.PageNumber = 1;
4144
                }
4145

    
4146
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4147
                {
4148
                }
4149
                else
4150
                {
4151
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4152
                }
4153

    
4154
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4155
                {
4156

    
4157
                }
4158
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4159
                {
4160
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4161
                }
4162

    
4163
                if (!testPanel2.IsHidden)
4164
                {
4165
                    if (IsSyncPDFMode)
4166
                    {
4167
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4168
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4169

    
4170
                        if (pdfpath.IsDownloading)
4171
                        {
4172
                            pdfpath.DownloadCompleted += (ex, arg) =>
4173
                            {
4174
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4175
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4176
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4177
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4178
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4179
                            };
4180
                        }
4181
                        else
4182
                        {
4183
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4184
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4185
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4186

    
4187
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4188
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4189
                        }
4190

    
4191
                    }
4192
                    else
4193
                    {
4194
                        string uri = "";
4195

    
4196
                        if (userData.COMPANY != "EXT")
4197
                        {
4198
                            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);
4199
                        }
4200
                        else
4201
                        {
4202
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4203
                        }
4204

    
4205
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4206

    
4207
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4208
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4209
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4210

    
4211
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4212
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4213

    
4214
                        if (defaultBitmapImage_Compare.IsDownloading)
4215
                        {
4216
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4217
                            {
4218
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4219
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4220
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4221

    
4222
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4223
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4224
                            };
4225
                        }
4226
                    }
4227

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

    
4232
                    foreach (var item in gridSelectionRevItem)
4233
                    {
4234
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4235
                        {
4236
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4237
                        });
4238
                    }
4239

    
4240
                    //강인구 추가
4241
                    zoomAndPanControl2.ZoomTo(new Rect
4242
                    {
4243
                        X = 0,
4244
                        Y = 0,
4245
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4246
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4247
                    });
4248

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

    
4251
                }
4252
            }
4253
        }
4254

    
4255
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4256
        {
4257
            if (MarkupMode.IsChecked)
4258
            {
4259
                IsSyncPDFMode = true;
4260

    
4261
                var uri = CurrentRev.TO_VENDOR;
4262

    
4263
                if (ViewerDataModel.Instance.PageNumber == 0)
4264
                {
4265
                    ViewerDataModel.Instance.PageNumber = 1;
4266
                }
4267

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

    
4272
                if (pdfpath.IsDownloading)
4273
                {
4274
                    pdfpath.DownloadCompleted += (ex, arg) =>
4275
                    {
4276
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4277
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4278
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4279
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4280
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4281
                    };
4282
                }
4283
                else
4284
                {
4285
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4286
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4287
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4288

    
4289
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4290
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4291
                }
4292
            }
4293
            else
4294
            {
4295
                IsSyncPDFMode = false;
4296
                string uri = "";
4297
                if (userData.COMPANY != "EXT")
4298
                {
4299
                    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);
4300
                }
4301
                else
4302
                {
4303
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4304
                }
4305

    
4306
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4307

    
4308
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4309
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4310
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4311

    
4312
                if (defaultBitmapImage_Compare.IsDownloading)
4313
                {
4314
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4315
                    {
4316
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4317
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4318
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4319
                    };
4320
                }
4321
                zoomAndPanControl2.ApplyTemplate();
4322
                zoomAndPanControl2.UpdateLayout();
4323
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4324
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4325
            }
4326
        }
4327

    
4328
        private void RadButton_Click(object sender, RoutedEventArgs e)
4329
        {
4330
            gridViewHistory_Busy.IsBusy = true;
4331

    
4332
            RadButton instance = sender as RadButton;
4333
            if (instance.CommandParameter != null)
4334
            {
4335
                CurrentRev = instance.CommandParameter as VPRevision;
4336
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4337
                {
4338
                    if (ea.Error == null && ea.Result != null)
4339
                    {
4340
                        testPanel2.IsHidden = false;
4341

    
4342
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4343
                        foreach(var info in ea.Result)
4344
                        {
4345
                            if(info.UserID == App.ViewInfo.UserID)
4346
                            {
4347
                                info.userDelete = true;
4348
                                info.DisplayColor = "FFFF0000";
4349
                            }
4350
                            else
4351
                            {
4352
                                info.userDelete = false;
4353
                            }
4354
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4355
                        }
4356
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4357

    
4358
                        string uri = "";
4359
                        if (userData.COMPANY != "EXT")
4360
                        {
4361
                            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);
4362
                        }
4363
                        else
4364
                        {
4365
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4366
                        }
4367

    
4368
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4369

    
4370
                        var defaultBitmapImage_Compare = new BitmapImage();
4371
                        defaultBitmapImage_Compare.BeginInit();
4372
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4373
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4374
                        defaultBitmapImage_Compare.EndInit();
4375

    
4376
                        if (defaultBitmapImage_Compare.IsDownloading)
4377
                        {
4378
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4379
                            {
4380
                                defaultBitmapImage_Compare.Freeze();
4381
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4382
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4383
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4384
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4385
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4386
                            };
4387
                        }                        
4388
                        zoomAndPanControl2.ApplyTemplate();
4389
                        zoomAndPanControl2.UpdateLayout();
4390
                        //syncPannelRotate(zoomAndPanControl.RotationAngle);
4391
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4392
                        {
4393
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4394
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4395
                        }
4396

    
4397
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4398
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4399
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4400

    
4401
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4402
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4403
                        gridViewHistory_Busy.IsBusy = false;
4404
                    }
4405

    
4406
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4407
                };
4408
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4409
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4410
            }
4411
        }
4412

    
4413
        public void Sync_Event(VPRevision Currnet_Rev)
4414
        {
4415
            CurrentRev = Currnet_Rev;
4416

    
4417
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4418
            {
4419
                if (ea.Error == null && ea.Result != null)
4420
                {
4421
                    testPanel2.IsHidden = false;
4422

    
4423
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4424
                    foreach(var info in ea.Result)
4425
                    {
4426
                        if(info.UserID == App.ViewInfo.UserID)
4427
                        {
4428
                            info.userDelete = true;
4429
                            info.DisplayColor = "FFFF0000";
4430
                        }
4431
                        else
4432
                        {
4433
                            info.userDelete = false;
4434
                        }
4435
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4436
                    }
4437
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4438

    
4439
                    string uri = "";
4440
                    if (userData.COMPANY != "EXT")
4441
                    {
4442
                        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);
4443
                    }
4444
                    else
4445
                    {
4446
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4447
                    }
4448

    
4449
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4450

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

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

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

    
4467

    
4468
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4469
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4470
                    zoomAndPanControl2.ApplyTemplate();
4471
                    zoomAndPanControl2.UpdateLayout();
4472

    
4473
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4474
                    {
4475
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4476
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4477
                    }
4478
                    //}
4479

    
4480
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4481
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4482
                    gridViewHistory_Busy.IsBusy = false;
4483
                }
4484
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4485

    
4486
            };
4487
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4488
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4489
        }
4490

    
4491
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4492
        {
4493
            if (sender is Image)
4494
            {
4495
                if ((sender as Image).Tag != null)
4496
                {
4497
                    var pdfUrl = (sender as Image).Tag.ToString();
4498
                    System.Diagnostics.Process.Start(pdfUrl);
4499
                }
4500
                else
4501
                {
4502
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4503
                }
4504
            }
4505
        }
4506

    
4507
        private void Create_Symbol(object sender, RoutedEventArgs e)
4508
        {
4509
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4510

    
4511
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4512
            {
4513
                DialogMessage_Alert("Please Select Controls", "Alert");
4514
            }
4515
            else //선택된 것이 있으면
4516
            {
4517
                string MarkupData = "";
4518
                adorner_ = new AdornerFinal();
4519

    
4520
                foreach (var item in SelectLayer.Children)
4521
                {
4522
                    if (item.GetType().Name == "AdornerFinal")
4523
                    {
4524
                        adorner_ = (item as Controls.AdornerFinal);
4525
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4526
                        {
4527
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4528
                            {
4529
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4530
                                MarkupData += markupReturn.ConvertData;
4531
                            }
4532
                        }
4533
                    }
4534
                }
4535
                DialogParameters parameters = new DialogParameters()
4536
                {
4537
                    Owner = Application.Current.MainWindow,
4538
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4539
                    DefaultPromptResultValue = "Custom State",
4540
                    Content = "Name :",
4541
                    Header = "Insert Custom Symbol Name",
4542
                    Theme = new VisualStudio2013Theme(),
4543
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4544
                };
4545
                RadWindow.Prompt(parameters);
4546
            }
4547

    
4548
        }
4549
        public int symbolselectindex = 0;
4550
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4551
        {
4552
            //Save save = new Save();
4553
            try
4554
            {
4555
                string svgfilename = null;
4556
                if (symbolname != null)
4557
                {
4558
                    if (symbolpng == true || symbolsvg == true)
4559
                    {
4560
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4561
                        string guid = Commons.shortGuid();
4562

    
4563
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4564
                        //Check_Uri.UriCheck();
4565
                        fileUploader.RunCompleted += (ex, arg) =>
4566
                        {
4567
                            filename = arg.Result;
4568
                            if (symbolpng == true)
4569
                            {
4570
                                if (filename != null)
4571
                                { 
4572
                                    if (symbolselectindex == 0)
4573
                                    {
4574
                                        SymbolSave(symbolname, filename, data);
4575
                                    }
4576
                                    else
4577
                                    {
4578
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4579
                                    }
4580
                                    DataBind();
4581
                                }                                
4582
                            }
4583

    
4584
                            if (symbolsvg == true)
4585
                            {
4586
                                try
4587
                                {
4588
                                    var defaultBitmapImage = new BitmapImage();
4589
                                    defaultBitmapImage.BeginInit();
4590
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4591
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4592
                                    Check_Uri.UriCheck(filename);
4593
                                    defaultBitmapImage.UriSource = new Uri(filename);
4594
                                    defaultBitmapImage.EndInit();
4595

    
4596
                                    System.Drawing.Bitmap image;
4597

    
4598
                                    if (defaultBitmapImage.IsDownloading)
4599
                                    {
4600
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4601
                                        {
4602
                                            defaultBitmapImage.Freeze();
4603
                                            image = GetBitmap(defaultBitmapImage);
4604
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4605
                                            Process potrace = new Process
4606
                                            {
4607
                                                StartInfo = new ProcessStartInfo
4608
                                                {
4609
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4610
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4611
                                                    RedirectStandardInput = true,
4612
                                                    RedirectStandardOutput = true,
4613
                                                    RedirectStandardError = true,
4614
                                                    UseShellExecute = false,
4615
                                                    CreateNoWindow = true,
4616
                                                    WindowStyle = ProcessWindowStyle.Hidden
4617
                                                },
4618
                                            };
4619

    
4620
                                            StringBuilder svgBuilder = new StringBuilder();
4621
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4622
                                            {
4623
                                                svgBuilder.AppendLine(e2.Data);
4624
                                            };
4625

    
4626
                                            potrace.EnableRaisingEvents = true;
4627
                                            potrace.Start();
4628
                                            potrace.Exited += (sender, e) =>
4629
                                            {
4630
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4631
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4632
                                                Check_Uri.UriCheck(svgfilename);
4633
                                                if (symbolselectindex == 0)
4634
                                                {
4635
                                                    SymbolSave(symbolname, svgfilename, data);
4636
                                                }
4637
                                                else
4638
                                                {
4639
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4640
                                                }
4641

    
4642
                                                DataBind();
4643
                                            };
4644
                                            potrace.WaitForExit();
4645
                                        };
4646
                                    }
4647
                                    else
4648
                                    {
4649
                                        //GC.Collect();
4650
                                    }
4651
                                }
4652
                                catch(Exception ee)
4653
                                {
4654
                                    DialogMessage_Alert("" + ee, "Alert");
4655
                                }
4656
                            }
4657
                        };                                             
4658
                    }
4659
                }
4660
            }
4661
            catch (Exception e)
4662
            {
4663
                //DialogMessage_Alert(e + "", "Alert");
4664
            }            
4665
        }
4666

    
4667
        public void SymbolSave(string Name, string Url, string Data)
4668
        {
4669
            try
4670
            {
4671
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4672
                {
4673
                    ID = Commons.shortGuid(),
4674
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4675
                    NAME = Name,
4676
                    IMAGE_URL = Url,
4677
                    DATA = Data
4678
                };
4679

    
4680
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4681
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4682
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4683
            }
4684
            catch (Exception)
4685
            {
4686
                throw;
4687
            }
4688
        }
4689

    
4690
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4691
        {
4692
            try
4693
            {
4694
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4695
                {
4696
                    ID = Commons.shortGuid(),
4697
                    DEPARTMENT = Department,
4698
                    NAME = Name,
4699
                    IMAGE_URL = Url,
4700
                    DATA = Data
4701
                };
4702
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4703
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4704
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4705
            }
4706
            catch (Exception)
4707
            {
4708
                throw;
4709
            }
4710
        }
4711

    
4712
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4713
        {           
4714
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4715
            DataBind();
4716
        }
4717

    
4718
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4719
        {
4720
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4721
            DataBind();
4722
        }
4723
        private void DataBind()
4724
        {
4725
            try
4726
            {
4727
                Symbol_Custom Custom = new Symbol_Custom();
4728
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4729
                
4730
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4731
                foreach (var item in symbol_Private)
4732
                {
4733
                    Custom.Name = item.NAME;
4734
                    Custom.ImageUri = item.IMAGE_URL;
4735
                    Custom.ID = item.ID;
4736
                    Custom_List.Add(Custom);
4737
                    Custom = new Symbol_Custom();
4738
                }
4739
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4740
                
4741
                Custom = new Symbol_Custom();
4742
                Custom_List = new List<Symbol_Custom>();
4743

    
4744
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4745

    
4746
                List<SYMBOL_PUBLIC> symbol_Public;
4747

    
4748
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4749
                {
4750
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4751
                }
4752
                else
4753
                {
4754
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4755
                }
4756
                foreach (var item in symbol_Public)
4757
                {
4758
                    Custom.Name = item.NAME;
4759
                    Custom.ImageUri = item.IMAGE_URL;
4760
                    Custom.ID = item.ID;
4761
                    Custom_List.Add(Custom);
4762
                    Custom = new Symbol_Custom();
4763
                }
4764
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4765
                BaseClient.Close();                
4766
            }
4767
            catch(Exception e)
4768
            {
4769
                //DialogMessage_Alert("DataBind", "Alert");
4770
            }
4771
            
4772
        }
4773
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4774
        {
4775
            try
4776
            {
4777
                if (args.PromptResult != null)
4778
                {
4779
                    if (args.DialogResult.Value)
4780
                    {
4781
                        PngBitmapEncoder _Encoder = symImage(data);
4782

    
4783
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4784
                        _Encoder.Save(fs);
4785
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4786

    
4787
                        byte[] Img_byte = fs.ToArray();
4788

    
4789
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4790
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4791
                        Check_Uri.UriCheck(filename);
4792
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4793
                        {
4794
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4795
                        }
4796
                        else
4797
                        {
4798
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4799
                        }
4800
                        DataBind();
4801
                    }
4802
                }
4803
            }
4804
            catch(Exception ex)
4805
            {
4806
                DialogMessage_Alert("" + ex, "Alert");
4807
            }
4808
        }
4809

    
4810
        public PngBitmapEncoder symImage(string data)
4811
        {
4812

    
4813
            Canvas _canvas = new Canvas();
4814
            _canvas.Background = Brushes.White;
4815
            _canvas.Width = adorner_.BorderSize.Width;
4816
            _canvas.Height = adorner_.BorderSize.Height;
4817
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4818

    
4819
            BitmapEncoder encoder = new PngBitmapEncoder();
4820

    
4821

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

    
4824
            DrawingVisual dv = new DrawingVisual();
4825

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

    
4829
            using (DrawingContext ctx = dv.RenderOpen())
4830
            {
4831
                VisualBrush vb = new VisualBrush(_canvas);
4832
                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)));
4833
            }
4834

    
4835
            try
4836
            {
4837
                renderBitmap.Render(dv);
4838

    
4839
                //GC.Collect();
4840
                GC.WaitForPendingFinalizers();
4841
                //GC.Collect();
4842
                // encode png data
4843
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4844
                // puch rendered bitmap into it
4845
                pngEncoder.Interlace = PngInterlaceOption.Off;
4846
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4847
                return pngEncoder;
4848

    
4849
            }
4850
            catch //(Exception ex)
4851
            {
4852
                return null;
4853
            }
4854

    
4855
        }
4856

    
4857
        public void DialogMessage_Alert(string content, string header)
4858
        {
4859
            var box = new TextBlock();
4860
            box.MinWidth = 400;
4861
            box.FontSize = 11;
4862
            //box.FontSize = 12;
4863
            box.Text = content;
4864
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4865

    
4866
            DialogParameters parameters = new DialogParameters()
4867
            {
4868
                Owner = Application.Current.MainWindow,
4869
                Content = box,
4870
                Header = header,
4871
                Theme = new VisualStudio2013Theme(),
4872
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4873
            };            
4874
            RadWindow.Alert(parameters);
4875
        }
4876

    
4877
        #region 캡쳐 기능
4878

    
4879
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4880
        {
4881
            if (x < 0)
4882
            {
4883
                width += x;
4884
                x = 0;
4885
            }
4886
            if (y < 0)
4887
            {
4888
                height += y;
4889
                y = 0;
4890

    
4891
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4892
            }
4893
            if (x + width > zoomAndPanCanvas.ActualWidth)
4894
            {
4895
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4896
            }
4897
            if (y + height > zoomAndPanCanvas.ActualHeight)
4898
            {
4899
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4900
            }
4901

    
4902
            byte[] pixels = CopyPixels(x, y, width, height);
4903

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

    
4906
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4907
        }
4908

    
4909
        public byte[] CopyPixels(int x, int y, int width, int height)
4910
        {
4911
            byte[] pixels = new byte[width * height * 4];
4912
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4913

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

    
4917
            return pixels;
4918
        }
4919

    
4920
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4921
        {
4922
            DrawingVisual drawingVisual = new DrawingVisual();
4923
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4924

    
4925
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4926
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4927
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4928
            drawingContext.Close();
4929

    
4930
            // 비트맵으로 변환합니다.
4931
            RenderTargetBitmap target =
4932
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4933
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4934

    
4935
            target.Render(drawingVisual);
4936
            return target;
4937
        }
4938

    
4939
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4940
        {
4941
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4942
            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);
4943
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4944
            bmp.UnlockBits(data);
4945
            return bmp;
4946
        }
4947
        public string symbolname = null;
4948
        public bool symbolsvg = true;
4949
        public bool symbolpng = true;
4950

    
4951
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4952
        {
4953
            System.Drawing.Bitmap image = GetBitmap(source);
4954
            //흰색 제거
4955
            //image.MakeTransparent(System.Drawing.Color.White);
4956

    
4957
            var imageStream = new System.IO.MemoryStream();
4958
            byte[] imageBytes = null;
4959
            using (imageStream)
4960
            {
4961
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4962
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
4963
                imageStream.Position = 0;
4964
                imageBytes = imageStream.ToArray();
4965
            }
4966

    
4967
            SymbolPrompt symbolPrompt = new SymbolPrompt();
4968

    
4969
            RadWindow CheckPop = new RadWindow();
4970
            //Alert check = new Alert(Msg);
4971

    
4972
            CheckPop = new RadWindow
4973
            {
4974
                MinWidth = 400,
4975
                MinHeight = 100,
4976
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4977
                Header = "Alert",
4978
                Content = symbolPrompt,
4979
                //DialogResult = 
4980
                ResizeMode = System.Windows.ResizeMode.NoResize,
4981
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
4982
                IsTopmost = true,
4983
            };
4984
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
4985
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
4986
            CheckPop.ShowDialog();
4987

    
4988
            /*
4989
            DialogParameters parameters = new DialogParameters()
4990
            {
4991
                Owner = Application.Current.MainWindow,
4992
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
4993
                DefaultPromptResultValue = "Custom State",
4994
                Content = "Name :",
4995
                Header = "Insert Custom Symbol Name",
4996
                Theme = new VisualStudio2013Theme(),
4997
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4998
            };            
4999
            RadWindow.Prompt(parameters);
5000
            */
5001
        }
5002

    
5003
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5004
        {
5005
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5006
            KCOMDataModel.DataModel.CHECK_LIST check_;
5007
            string Result = streamToBase64.ImageToBase64(source);
5008
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5009
            string projectno = App.ViewInfo.ProjectNO;
5010
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5011

    
5012
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5013
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5014
            if (Item != null)
5015
            {
5016
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5017
            }
5018
            else
5019
            {
5020
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5021
            }
5022

    
5023
            if (Item == null)
5024
            {
5025
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5026
                {
5027
                    ID = Commons.shortGuid(),
5028
                    USER_ID = App.ViewInfo.UserID,
5029
                    IMAGE_URL = Result,
5030
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5031
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5032
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5033
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5034
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5035
                    STATUS = "False",
5036
                    CREATE_TIME = DateTime.Now,
5037
                    UPDATE_TIME = DateTime.Now,
5038
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5039
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5040
                };
5041
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5042
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5043
                //this.BaseClient.AddCheckList(projectno, check_);
5044
            }
5045
            else
5046
            {
5047
                Item.IMAGE_URL = Result;
5048
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5049
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5050
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5051
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5052
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5053
            }
5054

    
5055
        }
5056

    
5057
        public void Set_Capture()
5058
        {
5059
            double x = canvasDrawingMouseDownPoint.X;
5060
            double y = canvasDrawingMouseDownPoint.Y;
5061
            double width = dragCaptureBorder.Width;
5062
            double height = dragCaptureBorder.Height;
5063

    
5064
            if (width > 5 || height > 5)
5065
            {
5066
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5067
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5068
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5069
            }
5070
        }
5071
        #endregion
5072

    
5073
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5074
        {
5075
            multi_Undo_Data = new Multi_Undo_data();
5076

    
5077
            multi_Undo_Data.Markup = control;
5078

    
5079
            if ((control as IShapeControl) != null)
5080
            {
5081
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5082
            }
5083
            if ((control as IDashControl) != null)
5084
            {
5085
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5086
            }
5087
            if ((control as IPath) != null)
5088
            {
5089
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5090
            }
5091
            if ((control as UIElement) != null)
5092
            {
5093
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5094
            }
5095

    
5096
            return multi_Undo_Data;
5097
        }
5098

    
5099
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5100
        {
5101
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5102
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5103
            {
5104
                if (items.UserID == Select_ID)
5105
                {
5106
                    foreach (var item in items.MarkupList)
5107
                    {
5108
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5109
                        {
5110
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5111
                                items.MarkupInfoID, Commons.shortGuid());
5112
                        }
5113
                    }
5114
                }
5115
            }
5116
        }
5117

    
5118
        /// <summary>
5119
        /// convert inkcontrol to polygoncontrol
5120
        /// </summary>
5121
        public void ConvertInkControlToPolygon()
5122
        {
5123
            if (inkBoard.Strokes.Count > 0)
5124
            {
5125
                inkBoard.Strokes.ToList().ForEach(stroke =>
5126
                {
5127
                    InkToPath ip = new InkToPath();
5128

    
5129
                    List<Point> inkPointSet = new List<Point>();
5130
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5131

    
5132
                    PolygonControl pc = new PolygonControl()
5133
                    {
5134
                        Angle = 0,
5135
                        PointSet = inkPointSet,
5136
                        ControlType = ControlType.Ink
5137
                    };
5138
                    pc.StartPoint = inkPointSet[0];
5139
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5140
                    pc.LineSize = 3;
5141
                    pc.CommentID = Commons.shortGuid();
5142
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5143

    
5144
                    if (pc.PointSet.Count > 0)
5145
                    {
5146
                        CreateCommand.Instance.Execute(pc);
5147
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5148
                    }
5149
                });
5150
                inkBoard.Strokes.Clear();
5151
            }
5152
        }
5153

    
5154
        /// <summary>
5155
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5156
        /// </summary>
5157
        /// <author>ingu</author>
5158
        /// <date>2018.06.05</date>
5159
        /// <param name="getPoint"></param>
5160
        /// <returns></returns>
5161
        private bool IsGetoutpoint(Point getPoint)
5162
        {
5163
            if (getPoint == new Point())
5164
            {
5165
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5166
                currentControl = null;
5167
                return true;
5168
            }
5169

    
5170
            return false;
5171
        }
5172

    
5173
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5174
        {
5175
            e.Effects = DragDropEffects.Copy;
5176
        }
5177

    
5178
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5179
        {
5180
            e.Effects = DragDropEffects.Copy;
5181
        }
5182

    
5183
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5184
        {
5185
            e.Effects = DragDropEffects.None;
5186
        }
5187

    
5188
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5189
        {
5190
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5191
        }
5192

    
5193
        /*
5194
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5195
        {
5196
            try
5197
            {
5198
                if (e.Data.GetDataPresent(typeof(string)))
5199
                {
5200
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5201
                    string dragData = e.Data.GetData(typeof(string)) as string;
5202
                    Move_Symbol(sender, dragData);
5203
                }
5204
            }
5205
            catch (Exception ex)
5206
            {
5207
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5208
            }            
5209
        }
5210
        */
5211
    }
5212
}
클립보드 이미지 추가 (최대 크기: 500 MB)