프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 2a824927

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

1 233ef333 taeseongkim
using IKCOM;
2 2b9b3656 taeseongkim
using KCOM.Common;
3
using KCOM.Controls;
4
using KCOM.Events;
5
using KCOMDataModel.DataModel;
6
using MarkupToPDF.Common;
7
using MarkupToPDF.Controls.Cad;
8 787a4489 KangIngu
using MarkupToPDF.Controls.Common;
9 2b9b3656 taeseongkim
using MarkupToPDF.Controls.Etc;
10 787a4489 KangIngu
using MarkupToPDF.Controls.Line;
11 2b9b3656 taeseongkim
using MarkupToPDF.Controls.Parsing;
12 787a4489 KangIngu
using MarkupToPDF.Controls.Polygon;
13
using MarkupToPDF.Controls.Shape;
14
using MarkupToPDF.Controls.Text;
15
using System;
16
using System.Collections.Generic;
17 2b9b3656 taeseongkim
using System.Diagnostics;
18 787a4489 KangIngu
using System.Linq;
19 2b9b3656 taeseongkim
using System.Reflection;
20
using System.Runtime.InteropServices;
21 787a4489 KangIngu
using System.Text;
22 2b9b3656 taeseongkim
using System.Threading;
23
using System.Threading.Tasks;
24
using System.Web;
25 787a4489 KangIngu
using System.Windows;
26
using System.Windows.Controls;
27 2b9b3656 taeseongkim
using System.Windows.Ink;
28 787a4489 KangIngu
using System.Windows.Input;
29
using System.Windows.Media;
30
using System.Windows.Media.Imaging;
31
using System.Windows.Shapes;
32 6707a5c7 ljiyeon
using System.Windows.Threading;
33 2b9b3656 taeseongkim
using Telerik.Windows.Controls;
34 552af7c7 swate0609
using Telerik.Windows.Controls.GridView;
35 fddb48f7 ljiyeon
using Telerik.Windows.Data;
36 0d97ab05 humkyung
using ZoomAndPan;
37 787a4489 KangIngu
38
namespace KCOM.Views
39
{
40
    public static class ControlExtensions
41
    {
42
        public static T Clone<T>(this T controlToClone)
43
            where T : System.Windows.Controls.Control
44
        {
45
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
46
47
            T instance = Activator.CreateInstance<T>();
48
49
            foreach (PropertyInfo propInfo in controlProperties)
50
            {
51
                if (propInfo.CanWrite)
52
                {
53
                    if (propInfo.Name != "WindowTarget")
54
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
55
                }
56
            }
57
            return instance;
58
        }
59
    }
60
61 a0bab669 KangIngu
    public class MyConsole
62
    {
63
        private readonly System.Threading.ManualResetEvent _readLineSignal;
64
        private string _lastLine;
65 233ef333 taeseongkim
66 a0bab669 KangIngu
        public MyConsole()
67
        {
68
            _readLineSignal = new System.Threading.ManualResetEvent(false);
69
            Gui = new TextBox();
70
            Gui.AcceptsReturn = true;
71
            Gui.KeyUp += OnKeyUp;
72
        }
73
74
        private void OnKeyUp(object sender, KeyEventArgs e)
75
        {
76
            // this is always fired on UI thread
77
            if (e.Key == Key.Enter)
78
            {
79
                // quick and dirty, but that is not relevant to your question
80
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
81
                // now, when you detected that user typed a line, set signal
82
                _readLineSignal.Set();
83
            }
84
        }
85
86
        public TextBox Gui { get; private set; }
87
88
        public string ReadLine()
89
        {
90
            // that should always be called from non-ui thread
91
            if (Gui.Dispatcher.CheckAccess())
92
                throw new Exception("Cannot be called on UI thread");
93
            // reset signal
94
            _readLineSignal.Reset();
95
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
96
            _readLineSignal.WaitOne();
97
            // we got signalled - return line user typed.
98
            return _lastLine;
99
        }
100
101
        public void WriteLine(string line)
102
        {
103
            if (!Gui.Dispatcher.CheckAccess())
104
            {
105
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
106
                return;
107
            }
108
109
            Gui.Text += line + Environment.NewLine;
110
        }
111
    }
112
113 787a4489 KangIngu
    /// <summary>
114
    /// MainMenu.xaml에 대한 상호 작용 논리
115
    /// </summary>
116
    public partial class MainMenu : UserControl
117
    {
118
        #region 프로퍼티
119 233ef333 taeseongkim
120 2b1f30fe taeseongkim
        private BitmapFrame tempPageImage =null;
121 f5f788c2 taeseongkim
122 873011c4 humkyung
        public UndoDataGroup UndoDataGroup { get; set; }
123 9380813b swate0609
        public CommentUserInfo previousControl { get; set; }
124 787a4489 KangIngu
        public CommentUserInfo currentControl { get; set; }
125
        public ControlType controlType { get; set; }
126 e6a9ddaf humkyung
        private Move move = new Move();
127 787a4489 KangIngu
        private double[] rotateValue = { 0, 90, 180, 270 };
128
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
129
        private static readonly double DragThreshold = 5;
130 eb2b9248 KangIngu
        private System.Windows.Input.Cursor cursor { get; set; }
131 c7fde400 taeseongkim
132
        /// <summary>
133
        ///  문서의 마우스 위치
134
        /// </summary>
135
        public Point CanvasDrawingMouseDownPoint;
136
137 787a4489 KangIngu
        public string filename { get; set; }
138 0d97ab05 humkyung
        private Point canvasZoomPanningMouseDownPoint { get; set; }
139
        private Point zoomAndPanControlMouseDownPoint { get; set; }
140
141 787a4489 KangIngu
        public Point getCurrentPoint;
142
        private Point canvasZoommovingMouseDownPoint;
143 233ef333 taeseongkim
        private List<object> ControlList = new List<object>();
144 787a4489 KangIngu
        private ListBox listBox = new ListBox();
145
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
146
        private bool isDraggingSelectionRect = false;
147 233ef333 taeseongkim
        private DrawingAttributes inkDA = new DrawingAttributes();
148 787a4489 KangIngu
        private VPRevision CurrentRev { get; set; }
149
        public RadRibbonButton btnConsolidate { get; set; }
150
        public RadRibbonButton btnFinalPDF { get; set; }
151
        public RadRibbonButton btnTeamConsolidate { get; set; }
152 80458c15 ljiyeon
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
153
154 787a4489 KangIngu
        public string Filename_ { get; set; }
155
        public double L_Size = 0;
156
        public AdornerFinal adorner_;
157 b79d6e7f humkyung
        public UndoData multi_UndoData;
158 5ce56a3a KangIngu
        public string Symbol_ID = "";
159 233ef333 taeseongkim
160 787a4489 KangIngu
        /// <summary>
161
        /// Set to 'true' when the left mouse-button is down.
162
        /// </summary>
163 9f473fb7 KangIngu
        public bool isLeftMouseButtonDownOnWindow = false;
164 787a4489 KangIngu
165
        public InkPresenter _InkBoard = null;
166 233ef333 taeseongkim
        private Stroke stroke;
167
        private Boolean IsDrawing = false;
168
        private StylusPointCollection strokePoints;
169
170 53880c83 ljiyeon
        //StylusPointCollection erasePoints;
171 233ef333 taeseongkim
        private RenderTargetBitmap canvasImage;
172
173
        private Point Sync_Offset_Point;
174 787a4489 KangIngu
175
        //강인구 테스트
176
        private Path _SelectionPath { get; set; }
177 233ef333 taeseongkim
178 787a4489 KangIngu
        public Path SelectionPath
179
        {
180
            get
181
            {
182
                return _SelectionPath;
183
            }
184
            set
185
            {
186
                if (_SelectionPath != value)
187
                {
188
                    _SelectionPath = value;
189
                    RaisePropertyChanged("SelectionPath");
190
                }
191
            }
192
        }
193
194
        private System.Windows.Controls.Image _imageViewer { get; set; }
195 233ef333 taeseongkim
196 787a4489 KangIngu
        public System.Windows.Controls.Image imageViewer
197
        {
198
            get
199
            {
200
                if (_imageViewer == null)
201
                {
202
                    _imageViewer = new System.Windows.Controls.Image();
203
                    return _imageViewer;
204
                }
205
                else
206
                {
207
                    return _imageViewer;
208
                }
209
            }
210
            set
211
            {
212
                if (_imageViewer != value)
213
                {
214
                    _imageViewer = value;
215
                }
216
            }
217
        }
218
219
        public bool IsSyncPDFMode { get; set; }
220
221
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
222 233ef333 taeseongkim
223 787a4489 KangIngu
        public System.Windows.Controls.Image imageViewer_Compare
224
        {
225
            get
226
            {
227
                if (_imageViewer_Compare == null)
228
                {
229
                    _imageViewer_Compare = new System.Windows.Controls.Image();
230
                    return _imageViewer_Compare;
231
                }
232
                else
233
                {
234
                    return _imageViewer_Compare;
235
                }
236
            }
237
            set
238
            {
239
                if (_imageViewer_Compare != value)
240
                {
241
                    _imageViewer_Compare = value;
242
                }
243
            }
244
        }
245
246 233ef333 taeseongkim
        #endregion 프로퍼티
247 90e7968d ljiyeon
248 787a4489 KangIngu
        public MainMenu()
249
        {
250 233ef333 taeseongkim
            //App.splashString(ISplashMessage.MAINMENU_0);
251
            InitializeComponent();
252 f65e6c02 taeseongkim
253 f5f788c2 taeseongkim
            tempPageImage = BitmapFrame.Create(new Uri(@"pack://application:,,,/KCOM;component/Resources/Images/ExtImage/blank.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
254 dea506e2 taeseongkim
            //List<testItem> testItems = new List<testItem>
255
            //{
256
            //    new testItem{Title = "test1"},
257
            //    new testItem{Title = "test2"},
258
            //    new testItem{Title = "test3"},
259
            //    new testItem{Title = "test4"},
260
            //};
261 f65e6c02 taeseongkim
262 dea506e2 taeseongkim
            //lstSymbolPrivate.ItemsSource = testItems;
263 f65e6c02 taeseongkim
264 90e7968d ljiyeon
            this.Loaded += MainMenu_Loaded;
265 787a4489 KangIngu
        }
266 6707a5c7 ljiyeon
267
        public class TempDt
268
        {
269
            public int PageNumber { get; set; }
270
            public string CommentID { get; set; }
271
            public string ConvertData { get; set; }
272
            public int DATA_TYPE { get; set; }
273
            public string MarkupInfoID { get; set; }
274
            public int IsUpdate { get; set; }
275
        }
276
277 233ef333 taeseongkim
        private List<TempDt> tempDtList = new List<TempDt>();
278 90e7968d ljiyeon
279 38d69491 taeseongkim
        public void SetCursor()
280 787a4489 KangIngu
        {
281
            this.Cursor = cursor;
282
        }
283
284 69f41aab humkyung
        /// <summary>
285
        /// get image url
286
        /// </summary>
287
        /// <author>humkyung</author>
288
        /// <param name="sDocumentID"></param>
289
        /// <returns></returns>
290 6dcbe4a7 humkyung
        public string GetImageURL(string sDocumentID, int iPageNo)
291 69f41aab humkyung
        {
292
            string uri = string.Empty;
293
294 fdfa126d taeseongkim
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt64(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
295 69f41aab humkyung
            if (userData.COMPANY != "EXT")
296
            {
297
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
298
            }
299
            else
300
            {
301
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
302
            }
303
304
            return uri;
305
        }
306
307 52827a4c djkim
        /// <summary>
308
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
309
        /// </summary>
310
        /// <returns></returns>
311
        public string GetOriginalPDFURL()
312
        {
313
            string uri = string.Empty;
314
            string sDocumentID = this._DocItem.DOCUMENT_ID;
315
            string filename = string.Empty;
316
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
317
            {
318
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
319
            }
320
            else
321
            {
322
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
323
            }
324 0f26a9aa taeseongkim
325 77cdac33 taeseongkim
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
326
327
            if (!string.IsNullOrWhiteSpace(directUri))
328 52827a4c djkim
            {
329 77cdac33 taeseongkim
                uri = string.Format(directUri, filename);
330 52827a4c djkim
            }
331
            else
332
            {
333 fdfa126d taeseongkim
                string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt64(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
334 77cdac33 taeseongkim
                if (userData.COMPANY != "EXT")
335
                {
336
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
337
                }
338
                else
339
                {
340
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
341
                }
342
                uri = uri.Replace(".png", "");
343 52827a4c djkim
            }
344 77cdac33 taeseongkim
345 52827a4c djkim
            return uri;
346
        }
347 0f26a9aa taeseongkim
348 787a4489 KangIngu
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
349
        {
350
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
351 ca40e004 ljiyeon
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
352
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
353
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
354 787a4489 KangIngu
            {
355
                return true;
356
            }
357
358
            return false;
359
        }
360
361 ca40e004 ljiyeon
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
362
        {
363
            if (rotate.Angle == 90 || rotate.Angle == 270)
364
            {
365
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
366
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
367
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
368
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
369
                {
370
                    return true;
371
                }
372
            }
373
            else
374
            {
375
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
376
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
377
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
378
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
379
                {
380
                    return true;
381
                }
382 90e7968d ljiyeon
            }
383 ca40e004 ljiyeon
384
            return false;
385
        }
386
387 f258d884 humkyung
        /// <summary>
388
        /// 주어진 레이어를 삭제한다.
389
        /// </summary>
390
        /// <param name="item"></param>
391 787a4489 KangIngu
        public void DeleteItem(MarkupInfoItem item)
392
        {
393
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
394
            {
395 233ef333 taeseongkim
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
396
            }
397 787a4489 KangIngu
398 ecf8a079 이지연
            #region Consolidate 또는 AvoidConsolidate한 레이어만 삭제한다. Team Consolidate 추가
399
            if (item.Consolidate == 1 || item.AvoidConsolidate == 1 || item.PartConsolidate == 1)
400 55b32920 humkyung
            {
401
                ViewerDataModel.Instance._markupInfoList.Remove(item);
402 ecf8a079 이지연
                if(item.PartConsolidate == 1)
403
                {
404
                    if(ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1).Count() > 0)
405
                    {
406
                        foreach (var comment in ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID && x.PartConsolidate == 1))
407
                        {
408
                            comment.userDelete = true;
409
                        }
410
                    }
411
                    else
412
                    {
413
                        foreach (var comment in ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID))
414
                        {
415
                            comment.userDelete = true;                            
416
                        }
417
                    }
418
                }
419 55b32920 humkyung
                gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
420 ecf8a079 이지연
                gridViewMarkup.Rebind();
421 55b32920 humkyung
            }
422 f258d884 humkyung
            #endregion
423 787a4489 KangIngu
424 f258d884 humkyung
            #region item에 속한 컨트롤들을 삭제한다.
425 787a4489 KangIngu
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
426
            {
427
                ViewerDataModel.Instance.MarkupControls.Remove(a);
428
            });
429
430
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
431
            {
432
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
433 39f0624f ljiyeon
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
434 873011c4 humkyung
                null, EventType.Delete, a.CommentID, null);
435 787a4489 KangIngu
            });
436 f258d884 humkyung
            #endregion
437 787a4489 KangIngu
438 d62c0439 humkyung
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
439 787a4489 KangIngu
            {
440 d62c0439 humkyung
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
441 6707a5c7 ljiyeon
                //임시파일에서도 삭제
442 2b1f30fe taeseongkim
                //TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
443 787a4489 KangIngu
            });
444
445 f258d884 humkyung
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) == null)
446 787a4489 KangIngu
            {
447 f258d884 humkyung
                if (!gridViewMarkup.Items.Cast<MarkupInfoItem>().Any(d => d.UserID == App.ViewInfo.UserID))
448 787a4489 KangIngu
                {
449 5a223b60 humkyung
                    var infoId = Commons.ShortGuid();
450 787a4489 KangIngu
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
451
                    {
452
                        CreateTime = DateTime.Now,
453
                        Depatment = userData.DEPARTMENT,
454 992a98b4 KangIngu
                        UpdateTime = DateTime.Now,
455 787a4489 KangIngu
                        DisplayColor = "#FFFF0000",
456
                        UserID = userData.ID,
457
                        UserName = userData.NAME,
458
                        PageCount = 1,
459
                        Description = "",
460
                        MarkupInfoID = infoId,
461
                        MarkupList = null,
462 5a223b60 humkyung
                        MarkupVersionID = Commons.ShortGuid(),
463 787a4489 KangIngu
                        Consolidate = 0,
464
                        PartConsolidate = 0,
465
                        userDelete = true,
466
                        AvoidConsolidate = 0,
467
                        IsPreviewUser = true
468
                    };
469
                    App.Custom_ViewInfoId = infoId;
470
                }
471
            }
472 f258d884 humkyung
473 233ef333 taeseongkim
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
474 787a4489 KangIngu
        }
475
476 959b3ef2 humkyung
        /// <summary>
477
        /// delete selected comments
478
        /// </summary>
479
        /// <param name="sender"></param>
480
        /// <param name="e"></param>
481 787a4489 KangIngu
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
482
        {
483 552af7c7 swate0609
            //ReadOnly 권한이 어떻게 들어오는지 모르겠음.
484
            //NewCommentPermission으로 일단 처리 함. (2024-06-05 IRON)
485
            if (App.ViewInfo.NewCommentPermission)
486 c35e49f5 ljiyeon
            {
487 552af7c7 swate0609
                //정말 삭제 하시겠습니까?
488
                DialogParameters parameters = new DialogParameters()
489 17202508 ljiyeon
                {
490 552af7c7 swate0609
                    Owner = Application.Current.MainWindow,
491
                    Content = new TextBlock()
492 17202508 ljiyeon
                    {
493 552af7c7 swate0609
                        MinWidth = 400,
494
                        FontSize = 11,
495
                        Text = "Are you sure you want to delete?",
496
                        TextWrapping = System.Windows.TextWrapping.Wrap
497
                    },
498
                    Header = "Confirm",
499
                    Theme = new VisualStudio2013Theme(),
500
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
501
                    OkButtonContent = "Yes",
502
                    CancelButtonContent = "No",
503
                    Closed = delegate (object windowSender, WindowClosedEventArgs wc)
504
                    {
505
                        if (wc.DialogResult == true)
506
                        {
507
                            //선택된 어도너가 있을시 삭제가 되지 않음
508
                            SelectionSet.Instance.UnSelect(this);
509 787a4489 KangIngu
510 552af7c7 swate0609
                            Button content = (sender as Button);
511
                            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
512 787a4489 KangIngu
513 552af7c7 swate0609
                            DeleteItem(item);
514
                        }
515 17202508 ljiyeon
                    }
516 552af7c7 swate0609
                };
517
                RadWindow.Confirm(parameters);
518
            }
519 787a4489 KangIngu
        }
520
521 233ef333 taeseongkim
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
522 787a4489 KangIngu
523 6707a5c7 ljiyeon
        private static Timer timer;
524
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
525 233ef333 taeseongkim
526 d1f35ad3 swate0609
        private ContextMenu m_ContextMenu = null;
527
528 787a4489 KangIngu
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
529 90e7968d ljiyeon
        {
530 233ef333 taeseongkim
            //InitializeComponent();
531 90e7968d ljiyeon
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
532
533 787a4489 KangIngu
            if (App.ParameterMode)
534 6707a5c7 ljiyeon
            {
535 e59e6c8e 이지연
                
536 f7caaaaf ljiyeon
                App.splashString(ISplashMessage.MAINMENU_1);
537 54a28343 taeseongkim
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
538 6707a5c7 ljiyeon
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
539 afaa7c92 djkim
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
540 2007ecaa taeseongkim
541 6707a5c7 ljiyeon
                imageViewer_Compare = new Image();
542
                ViewerDataModel.Instance.Capture_Opacity = 0;
543
                da.From = 0.8;
544
                da.To = 0;
545
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
546
                da.AutoReverse = true;
547 e0204db0 djkim
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
548 e59e6c8e 이지연
               
549 e0204db0 djkim
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
550 90e7968d ljiyeon
                {
551 e0204db0 djkim
                    this.SymbolPane.Visibility = Visibility.Collapsed;
552
                    this.FavoritePane.Visibility = Visibility.Collapsed;
553
                    this.drawingRotateCanvas.IsHitTestVisible = false;
554 90e7968d ljiyeon
                }
555 8411f02d ljiyeon
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
556 d1f35ad3 swate0609
557
                InitContextMenu();
558 6707a5c7 ljiyeon
            }
559 6af42ff0 taeseongkim
560 2007ecaa taeseongkim
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
561 ccf944bb ljiyeon
        }
562
563 f258d884 humkyung
        /// <summary>
564
        /// 검색을 위해 원본 PDF 파일을 다운로드한다.
565
        /// </summary>
566 2007ecaa taeseongkim
        private void DownloadOriginalFile()
567 6af42ff0 taeseongkim
        {
568 2007ecaa taeseongkim
            #region 임시파일 다운로드
569 9d5b4bc2 taeseongkim
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
570 77cdac33 taeseongkim
       
571
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
572 058a4c0d taeseongkim
573
            bool isRestDownload = Convert.ToBoolean(CommonLib.Common.GetConfigString("DocumentDownloadPath", "IsRest", "False"));
574
575 77cdac33 taeseongkim
576
            if (!string.IsNullOrWhiteSpace(directUri))
577
            {
578 058a4c0d taeseongkim
                if (directUri.ToLower() == "full")
579 92c9cab8 taeseongkim
                {
580
                    downloadurl = this._DocInfo.ORIGINAL_FILE;
581
                }
582
                else
583
                {
584
                    isRestDownload = true;
585
                    filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
586 77cdac33 taeseongkim
587 92c9cab8 taeseongkim
                    downloadurl = string.Format(directUri, filename);
588
                }
589 77cdac33 taeseongkim
             }
590
            else
591
            {
592
                downloadurl = GetOriginalPDFURL();
593
            }
594 9d5b4bc2 taeseongkim
595
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
596
            
597 5a223b60 humkyung
            string endpoint = Common.Commons.ShortGuid() + "file";
598 2007ecaa taeseongkim
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
599
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
600
            wcfServer.Start();
601 9d5b4bc2 taeseongkim
            
602 77cdac33 taeseongkim
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
603 2007ecaa taeseongkim
            #endregion
604
        }
605 6af42ff0 taeseongkim
606 2007ecaa taeseongkim
        string instnaceFile;
607
        string downloadurl;
608 6af42ff0 taeseongkim
609 2007ecaa taeseongkim
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
610
        {
611 6a19b48d taeseongkim
            try
612
            {
613 26ec6226 taeseongkim
                Dispatcher.BeginInvoke((Action)delegate ()
614
                {
615
                    if ((sender as IIpc.WcfServer).IsOpen)
616
                    {
617
                        ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress;
618
                    }
619
620
                });
621 6af42ff0 taeseongkim
622 26ec6226 taeseongkim
                if ((sender as IIpc.WcfServer).IsOpen)
623 6a19b48d taeseongkim
                {
624 26ec6226 taeseongkim
                    if (e.IsFinish)
625
                    {
626
                        ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
627
                        ViewerDataModel.Instance.IsDownloadOriginal = true;
628
                        (sender as IIpc.WcfServer).Stop();
629
                        (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
630
                    }
631 6a19b48d taeseongkim
                }
632
            }
633
            catch (Exception ex)
634 6af42ff0 taeseongkim
            {
635 6a19b48d taeseongkim
                throw;
636 6af42ff0 taeseongkim
            }
637
        }
638 afaa7c92 djkim
639 d62c0439 humkyung
        /// <summary>
640
        /// update my markuplist
641
        ///  - update existing markup data if already exist
642
        ///  - add new markup data if control is new
643
        /// </summary>
644
        public void UpdateMyMarkupList()
645 787a4489 KangIngu
        {
646 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
647 787a4489 KangIngu
648 b2d0f316 humkyung
            #region 선택된 객체를 선택 해제한다.(그래야 작업 내용이 적용됨)
649
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
650
            #endregion
651
652 d62c0439 humkyung
            /// add or update markup list
653
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
654 787a4489 KangIngu
            {
655 b2d0f316 humkyung
                var markup = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
656 90e7968d ljiyeon
657 b2d0f316 humkyung
                var exist = ViewerDataModel.Instance.MyMarkupList.Find(data => data.ID == markup.CommentID);
658
                #region 기존 코멘트
659
                if (exist != null) 
660 d62c0439 humkyung
                {
661 b2d0f316 humkyung
                    if (exist.Data != markup.ConvertData) //코멘트가 같은지
662 6707a5c7 ljiyeon
                    {
663 b2d0f316 humkyung
                        exist.Data = markup.ConvertData;
664
                        exist.ZIndex = control.ZIndex;
665 d62c0439 humkyung
                        exist.IsUpdate = true;
666 6707a5c7 ljiyeon
                    }
667 d62c0439 humkyung
                }
668 b2d0f316 humkyung
                #endregion
669
                else if (markup.CommentID != null)
670 d62c0439 humkyung
                {
671
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
672 6707a5c7 ljiyeon
                    {
673 d62c0439 humkyung
                        ID = control.CommentID,
674 b2d0f316 humkyung
                        Data = markup.ConvertData,
675
                        Data_Type = markup.DATA_TYPE,
676 d62c0439 humkyung
                        MarkupInfoID = App.Custom_ViewInfoId,
677
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
678
                        Symbol_ID = control.SymbolID,
679 b2d0f316 humkyung
                        ZIndex = control.ZIndex,
680 d62c0439 humkyung
                    });
681 787a4489 KangIngu
                }
682
            }
683
        }
684
685 cb5c7f06 humkyung
        /// <summary>
686
        /// start page changing
687
        ///  - save controls if page is modified
688
        ///  - starting download page image
689
        /// </summary>
690
        /// <param name="sender"></param>
691
        /// <param name="e"></param>
692 cdfb57ff taeseongkim
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
693 548c696e ljiyeon
        {
694 5c64268e taeseongkim
            System.Diagnostics.Debug.WriteLine("pageNavigator PageChanging");
695 f5f788c2 taeseongkim
            //    await PageLoadAsync(e.CurrentPage,e.PageNumber);
696
            //}
697
            //private async Task PageLoadAsync(DOCPAGE page, int PageNo)
698
            //{
699
            DOCPAGE page = e.CurrentPage;
700
            int PageNo = e.PageNumber;
701 24c5e56c taeseongkim
702 f5f788c2 taeseongkim
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
703 e8557bd7 taeseongkim
704 dea506e2 taeseongkim
            // 페이지 이미지 변경
705 f5f788c2 taeseongkim
706
            /// 컨트롤을 새로 생성한다.
707
            ViewerDataModel.Instance.ImageViewPath = tempPageImage;
708
            ViewerDataModel.Instance.ImageViewWidth = 1;
709
            ViewerDataModel.Instance.ImageViewHeight = 1;
710
711 5c64268e taeseongkim
            ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Clear();
712
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
713
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
714
715 45ac2822 taeseongkim
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
716
            
717 f5f788c2 taeseongkim
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
718
719
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
720
721
            //var markupLoadTask = MarkupLoadAsync(page.PAGE_NUMBER, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
722
723
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
724 d7e20d2d taeseongkim
        }
725
726 24c5e56c taeseongkim
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber,CancellationToken token)
727 233ef333 taeseongkim
        {
728 d7e20d2d taeseongkim
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
729 233ef333 taeseongkim
730 787a4489 KangIngu
            #region 페이지가 벗어난 경우
731
732
            if (BalancePoint < 1)
733
            {
734
                BalancePoint = 1;
735
                ViewerDataModel.Instance.PageBalanceNumber = 0;
736
            }
737
738
            if (pageNavigator.PageCount < BalancePoint)
739
            {
740
                BalancePoint = pageNavigator.PageCount;
741
                ViewerDataModel.Instance.PageBalanceNumber = 0;
742
            }
743
744 233ef333 taeseongkim
            #endregion 페이지가 벗어난 경우
745 787a4489 KangIngu
746 752b18ef taeseongkim
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
747 787a4489 KangIngu
748 d7e20d2d taeseongkim
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
749
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
750 cdfb57ff taeseongkim
            var contentScale = zoomAndPanControl.ContentScale;
751 8614f701 taeseongkim
752 92442e4a taeseongkim
            #region 페이지 이미지 로딩 수정
753 f5f788c2 taeseongkim
            
754 8a9f6742 djkim
755 24c5e56c taeseongkim
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
756 233ef333 taeseongkim
757 f5f788c2 taeseongkim
            if(token.IsCancellationRequested)
758
            {
759
                return;
760
            }
761
762 d48260a2 djkim
            ScaleImage(pageWidth, pageHeight);
763
764
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
765
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
766
767
            zoomAndPanCanvas.Width = pageWidth;
768
            zoomAndPanCanvas.Height = pageHeight;
769
770
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
771
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
772
773
            inkBoard.Width = pageWidth;
774
            inkBoard.Height = pageHeight;
775 cdfb57ff taeseongkim
776 233ef333 taeseongkim
            #endregion 페이지 이미지 로딩 수정
777 90e7968d ljiyeon
778 787a4489 KangIngu
            if (!testPanel2.IsHidden)
779
            {
780 548c696e ljiyeon
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
781 787a4489 KangIngu
                //PDF모드일때 잠시 대기(강인구)
782
                if (IsSyncPDFMode)
783
                {
784
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
785 752b18ef taeseongkim
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
786 787a4489 KangIngu
787 548c696e ljiyeon
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
788 787a4489 KangIngu
                    if (pdfpath.IsDownloading)
789
                    {
790
                        pdfpath.DownloadCompleted += (ex, arg) =>
791
                        {
792 548c696e ljiyeon
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
793 787a4489 KangIngu
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
794
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
795
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
796
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
797
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
798
                        };
799
                    }
800
                    else
801
                    {
802 548c696e ljiyeon
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
803 787a4489 KangIngu
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
804
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
805
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
806
807
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
808
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
809
                    }
810
                }
811
                else
812
                {
813 752b18ef taeseongkim
                    Logger.sendCheckLog("Compare Image Download", 1);
814
                    string compareImageUri = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
815
                    ComparePageLoad(compareImageUri,false);
816 787a4489 KangIngu
                }
817 752b18ef taeseongkim
818 787a4489 KangIngu
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
819
            }
820
821 f4ec4218 taeseongkim
            SearchFocusBorder.Visibility = Visibility.Collapsed;
822
823 d7e20d2d taeseongkim
            this.pageNavigator.ChangePage(changePageNumber);
824 cdfb57ff taeseongkim
        }
825
826 752b18ef taeseongkim
        private void ComparePageLoad(string pageUri, bool IsOriginalSize)
827
        {
828
            /// 현재 보고 있는 VP와 같은 크기로 로딩
829
            ViewerDataModel.Instance.ImageViewPath_C = null;
830
831
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
832
            {
833
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
834
            }
835
            else
836
            {
837
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
838
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
839
            }
840
841
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
842
            {
843
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
844
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
845
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
846
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
847
848
                zoomAndPanControl.ZoomTo(new Rect
849
                {
850
                    X = 0,
851
                    Y = 0,
852
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
853
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
854
                });
855
856
                if (Sync.IsChecked)
857
                {
858
                    Sync_Click(null, new RoutedEventArgs());
859
                }
860
861
                if (CompareMode.IsChecked)
862
                {
863
                    SyncCompare_Click(null, new RoutedEventArgs());
864
                }
865
            }
866
        }
867
868 3ffd4b2d humkyung
        /// <summary>
869
        /// called after page is changed
870
        /// </summary>
871
        /// <param name="sender"></param>
872
        /// <param name="e"></param>
873 a1142a6b taeseongkim
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
874 3ffd4b2d humkyung
        {
875 a1142a6b taeseongkim
            //if (zoomAndPanCanvas.Width.IsNaN())
876
            //{
877 d5096d58 taeseongkim
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
878
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
879
            //    );
880 a1142a6b taeseongkim
            //}
881 233ef333 taeseongkim
882 d7e20d2d taeseongkim
            var instanceMain = ViewerDataModel.Instance.SystemMain;
883
884 315ae55e taeseongkim
            instanceMain.dzMainMenu.CanvasDrawingMouseDownPoint = new Point(ViewerDataModel.Instance.ImageViewWidth / 2, ViewerDataModel.Instance.ImageViewHeight / 2);
885
886 d7e20d2d taeseongkim
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
887
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
888
889
            instanceMain.dzTopMenu.rotateOffSet = 0;
890 b2d0f316 humkyung
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.FirstOrDefault(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER);
891 d7e20d2d taeseongkim
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
892
893
            /// 페이지의 모든 마크업을 로드한 후 호출
894
            /// 좌측 마크업 list의 아이템을 클릭하는 경우 MarkupControls_USER가 0으로 나와서 추가함.
895 d5096d58 taeseongkim
            ViewerDataModel.Instance.LoadPageMarkupFinish(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
896 e1c892f7 taeseongkim
        }
897
898
        private void SetTextControl(TextControl textControl)
899
        {
900
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
901
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
902
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
903
        }
904
905
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
906
        {
907
            SymControlN result = null;
908
909
            try
910
            {
911
                double height = 80;
912
                double itemWidth = 180;
913
914
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
915
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
916
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
917
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
918
919
                result = new SymControlN
920
                {
921 5a223b60 humkyung
                    CommentID = Commons.ShortGuid(),
922 e1c892f7 taeseongkim
                    MarkupInfoID = markupInfoId,
923
                    UserID = userId,
924
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
925
                    StartPoint = startPoint,
926
                    EndPoint = endPoint,
927
                    CommentAngle = 0,
928
                    LeftBottomPoint = leftBottomPoint,
929
                    TopRightPoint = topRightPoint,
930
                    Opacity = 1,
931
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
932
                    Memo = null
933
                };
934
            }
935
            catch (Exception ex)
936
            {
937
                System.Diagnostics.Debug.WriteLine(ex.ToString());
938
            }
939
940
            return result;
941
        }
942
943 233ef333 taeseongkim
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
944 e1c892f7 taeseongkim
        {
945
            RectangleControl result = null;
946
947
            try
948
            {
949
                double height = 80;
950
                double itemWidth = 180;
951
952
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
953
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
954
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
955
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
956
957
                result = new RectangleControl
958
                {
959 5a223b60 humkyung
                    CommentID = Commons.ShortGuid(),
960 e1c892f7 taeseongkim
                    MarkupInfoID = markupInfoId,
961
                    LineSize = 5,
962
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
963
                    StartPoint = startPoint,
964
                    EndPoint = endPoint,
965
                    CommentAngle = 0,
966
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
967
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
968
                    FillColor = null,
969
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
970
                    Opacity = 1,
971
                    LeftBottomPoint = leftBottomPoint,
972
                    TopRightPoint = topRightPoint,
973 233ef333 taeseongkim
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
974 e1c892f7 taeseongkim
                    UserID = userId,
975
                    Memo = null
976
                };
977
            }
978
            catch (Exception ex)
979
            {
980
                System.Diagnostics.Debug.WriteLine(ex.ToString());
981
            }
982
983
            return result;
984
        }
985
986 233ef333 taeseongkim
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
987 e1c892f7 taeseongkim
        {
988
            TextControl result = null;
989
990
            try
991
            {
992 233ef333 taeseongkim
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
993 e1c892f7 taeseongkim
994
                double startPositionX = parentRect.X;
995
996
                switch (textAlignment)
997
                {
998
                    case TextAlignment.Right:
999
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1000
                        break;
1001 233ef333 taeseongkim
1002 e1c892f7 taeseongkim
                    case TextAlignment.Center:
1003
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1004
                        break;
1005
                }
1006
1007
                Point startPosition = new Point
1008
                {
1009
                    X = startPositionX,
1010
                    Y = positionY
1011
                };
1012 233ef333 taeseongkim
1013 e1c892f7 taeseongkim
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1014
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1015
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1016
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1017
1018
                result = new TextControl
1019
                {
1020 5a223b60 humkyung
                    CommentID = Commons.ShortGuid(),
1021 e1c892f7 taeseongkim
                    MarkupInfoID = markupInfoId,
1022
                    Text = Text,
1023
                    StartPoint = startPoint,
1024
                    EndPoint = endPoint,
1025
                    CanvasX = startPosition.X,
1026
                    CanvasY = startPosition.Y,
1027
                    BoxWidth = txtSize.Width,
1028
                    BoxHeight = txtSize.Height,
1029
                    ControlType_No = 0,
1030
                    LineSize = new Thickness(5),
1031
                    TextSize = fontSize,
1032
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1033
                    FontSize = 10,
1034
                    UserID = userId,
1035
                    IsHighLight = false,
1036
                    CommentAngle = 0,
1037
                    PointSet = new List<Point>(),
1038
                    Opacity = 1,
1039
                    IsSelected = false,
1040
                    TextFamily = new FontFamily("Tahoma"),
1041
                    TextStyle = FontStyles.Normal,
1042
                    TextWeight = FontWeights.Bold
1043
                };
1044
            }
1045
            catch (Exception ex)
1046
            {
1047
            }
1048
1049
            return result;
1050
        }
1051 233ef333 taeseongkim
1052 e1c892f7 taeseongkim
        public static Size ShapeMeasure(UIElement e)
1053
        {
1054
            // Measured Size is bounded to be less than maxSize
1055
            Size maxSize = new Size(
1056
                 double.PositiveInfinity,
1057
                 double.PositiveInfinity);
1058
            e.Measure(maxSize);
1059
            return e.DesiredSize;
1060 d7e20d2d taeseongkim
        }
1061
1062 b2d0f316 humkyung
        /// <summary>
1063
        /// 주어진 pageNumber의 마크업 데이터를 읽어 화면에 표시한다.
1064
        /// </summary>
1065
        /// <param name="pageNumber"></param>
1066
        /// <param name="PageAngle"></param>
1067
        /// <param name="cts"></param>
1068
        /// <returns></returns>
1069 4f017ed3 taeseongkim
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1070 ac4f1e13 taeseongkim
        {
1071
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1072
            stopwatch.Start();
1073
1074 b2d0f316 humkyung
            #region 컨트롤을 새로 생성한다.
1075 3ffd4b2d humkyung
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1076
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1077 e8557bd7 taeseongkim
1078 ac4f1e13 taeseongkim
            System.Diagnostics.Debug.WriteLine("MarkupLoad - Clear " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
1079
1080 d7e20d2d taeseongkim
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1081 233ef333 taeseongkim
            {
1082 24c5e56c taeseongkim
                if (cts.IsCancellationRequested)
1083
                {
1084
                    return;
1085
                }
1086
1087 b2d0f316 humkyung
                var info = ViewerDataModel.Instance._markupInfoList.FirstOrDefault(param => param.MarkupInfoID == markup.MarkupInfoID);
1088 3ffd4b2d humkyung
                if (info != null)
1089
                {
1090
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1091
                    if (info.UserID == App.ViewInfo.UserID)
1092
                    {
1093 a1e2ba68 taeseongkim
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1094 58dd9e89 humkyung
                                        markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1095 ef7ba61f humkyung
                        if (control != null)
1096
                        {
1097
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1098
                            control.Visibility = Visibility.Hidden;
1099
                        }
1100 3ffd4b2d humkyung
                    }
1101
                    else
1102
                    {
1103 a1e2ba68 taeseongkim
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1104 58dd9e89 humkyung
                                                                markup.MarkupInfoID, markup.ID, STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1105 ef7ba61f humkyung
                        if (control != null)
1106
                        {
1107
                            Canvas.SetZIndex(control, (control as CommentUserInfo).ZIndex);
1108
                            control.Visibility = Visibility.Hidden;
1109
                        }
1110 3ffd4b2d humkyung
                    }
1111
                }
1112 b2d0f316 humkyung
            }
1113
            #endregion
1114 3ffd4b2d humkyung
1115 ac4f1e13 taeseongkim
            System.Diagnostics.Debug.WriteLine("MarkupLoad - MarkupParser " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
1116
1117 3ffd4b2d humkyung
            /// fire selection event
1118
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1119
            this.gridViewMarkup.UnselectAll();
1120
            this.gridViewMarkup.Select(gridSelectionItem);
1121
1122
            if (!testPanel2.IsHidden)
1123
            {
1124
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1125
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1126
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1127
1128
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1129
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1130
1131
                foreach (var item in gridSelectionRevItem)
1132
                {
1133 ac4f1e13 taeseongkim
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1134
1135
                    foreach (var markupitem in markupitems)
1136 3ffd4b2d humkyung
                    {
1137 58dd9e89 humkyung
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID,
1138
                            STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
1139 24c5e56c taeseongkim
1140 5639752b taeseongkim
                        //if (cts.IsCancellationRequested)
1141
                        //{
1142
                        //    return;
1143
                        //}
1144 ac4f1e13 taeseongkim
                    }
1145 3ffd4b2d humkyung
                }
1146
            }
1147 ac4f1e13 taeseongkim
1148 24c5e56c taeseongkim
            SetCommentPages(cts);
1149 3ffd4b2d humkyung
        }
1150
1151 24c5e56c taeseongkim
        public void SetCommentPages(CancellationToken? cts)
1152 787a4489 KangIngu
        {
1153 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1154 787a4489 KangIngu
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1155
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1156 ed3740c4 djkim
            {
1157
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1158 233ef333 taeseongkim
                if (item.MarkupList != null)
1159 787a4489 KangIngu
                {
1160 ed3740c4 djkim
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1161
                    instance.UserName = item.UserName;
1162
                    instance.Depart = item.Depatment;
1163
                    instance.MarkupInfoID = item.MarkupInfoID;
1164
                    instance.IsSelected = true;
1165
                    instance.isConSolidation = item.Consolidate;
1166
                    instance.SetColor = item.DisplayColor;
1167
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1168
                    {
1169
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1170
                    }
1171
                    else
1172
                    {
1173
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1174
                    }
1175
                    _pages.Add(instance);
1176 233ef333 taeseongkim
                }
1177 24c5e56c taeseongkim
1178
                if (cts != null)
1179
                {
1180
                    if (cts.Value.IsCancellationRequested)
1181
                        return;
1182
                }
1183 ed3740c4 djkim
            }
1184 233ef333 taeseongkim
1185 24c5e56c taeseongkim
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1186 ed3740c4 djkim
        }
1187
1188
        public void MarkupitemViewUpdate(string markupinfo_id)
1189
        {
1190
            //db에 업데이트 한 list 를 view 에 업데이트
1191
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1192
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1193
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1194
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1195
            if (dbinfo.MarkupList.Count > 0)
1196
            {
1197
                if (viewinfo.MarkupList != null)
1198
                {
1199
                    viewinfo.MarkupList.Clear();
1200
                    viewinfo.MarkupList = null;
1201 e05fe8ab djkim
                }
1202 6a19b48d taeseongkim
1203 ed3740c4 djkim
                viewinfo.MarkupList = new List<MarkupItem>();
1204
                foreach (var item in dbinfo.MarkupList)
1205 e05fe8ab djkim
                {
1206 6a19b48d taeseongkim
                    System.Diagnostics.Debug.WriteLine(item.ID);
1207 ed3740c4 djkim
                    viewinfo.MarkupList.Add(item);
1208 e05fe8ab djkim
                }
1209 787a4489 KangIngu
            }
1210
        }
1211
1212 d1f35ad3 swate0609
        private void InitContextMenu()
1213
        {
1214
            MenuItem menuBringForward = new MenuItem();
1215
            menuBringForward.Header = "Bring Forward";
1216
            menuBringForward.Click += MenuBringForward_Click;
1217
1218
            MenuItem menuBringToForward = new MenuItem();
1219
            menuBringToForward.Header = "Bring To Forward";
1220
            menuBringToForward.Click += MenuBringToForward_Click;
1221
1222
            MenuItem menuSendBackward = new MenuItem();
1223
            menuSendBackward.Header = "Send Backward";
1224
            menuSendBackward.Click += MenuSendBackward_Click;
1225
1226
            MenuItem menuSendToBackward = new MenuItem();
1227
            menuSendToBackward.Header = "Send To Backward";
1228
            menuSendToBackward.Click += MenuSendToBackward_Click; ;
1229
1230
1231
            ContextMenu cm = new ContextMenu();
1232
            cm.Items.Add(menuBringForward);
1233
            cm.Items.Add(menuBringToForward);
1234
            cm.Items.Add(new System.Windows.Controls.Separator());
1235
            cm.Items.Add(menuSendBackward);
1236
            cm.Items.Add(menuSendToBackward);
1237
1238
            m_ContextMenu = cm;
1239
1240
            if (this.zoomAndPanControl.ContextMenu == null)
1241
                this.zoomAndPanControl.ContextMenu = m_ContextMenu;
1242
        }
1243
1244
1245 a1142a6b taeseongkim
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1246 787a4489 KangIngu
        {
1247 f06cce07 taeseongkim
            var instance = ViewerDataModel.Instance;
1248
1249 233ef333 taeseongkim
            if (instance.IsWheelPageChanage)
1250 787a4489 KangIngu
            {
1251 a1142a6b taeseongkim
                return;
1252
            }
1253
1254
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1255
            {
1256
                int changePage = 0;
1257 233ef333 taeseongkim
1258 f87dfb18 taeseongkim
                if (e.Delta > 0)
1259
                {
1260 a1142a6b taeseongkim
                    if (0 < instance.ContentOffsetY)
1261 f06cce07 taeseongkim
                    {
1262
                        Vector dragOffset = new Vector(0, e.Delta);
1263
                        MoveZoomAndPanControl(dragOffset);
1264
                    }
1265
                    //else
1266
                    //{
1267 a1142a6b taeseongkim
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1268
                    //    {
1269
                    //        instance.IsWheelPageChanage = true;
1270
                    //        changePage -= 1;
1271
                    //    }
1272 f06cce07 taeseongkim
                    //}
1273 f87dfb18 taeseongkim
                }
1274 233ef333 taeseongkim
                else if (e.Delta < 0)
1275 f87dfb18 taeseongkim
                {
1276 f06cce07 taeseongkim
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1277
                    {
1278 233ef333 taeseongkim
                        Vector dragOffset = new Vector(0, e.Delta);
1279 f06cce07 taeseongkim
                        MoveZoomAndPanControl(dragOffset);
1280
                    }
1281
                    //else
1282
                    //{
1283 a1142a6b taeseongkim
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1284
                    //    {
1285
                    //        instance.IsWheelPageChanage = true;
1286
                    //        changePage += 1;
1287
                    //    }
1288 f06cce07 taeseongkim
                    //}
1289 f87dfb18 taeseongkim
                }
1290 a1142a6b taeseongkim
1291
                //if (changePage != 0)
1292
                //{
1293
                //    await Task.Factory.StartNew(() =>
1294
                //    {
1295
                //        double beforeScale = instance.ContentScale;
1296
1297
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1298
1299
                //        handler = (snd, evt) =>
1300
                //        {
1301
                //            /// 최상단으로 이전 zoomScale로 위치한다
1302
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1303
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1304
                //            instance.IsWheelPageChanage = false;
1305
                //            pageNavigator.PageChanged -= handler;
1306
                //        };
1307
1308
                //        pageNavigator.PageChanged += handler;
1309
1310
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1311
                //    });
1312
1313
                //}
1314 787a4489 KangIngu
            }
1315
            else
1316
            {
1317 f87dfb18 taeseongkim
                e.Handled = true;
1318
                if (e.Delta > 0)
1319
                {
1320
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1321
                    ZoomIn(currentContentMousePoint);
1322
                }
1323
                else
1324
                {
1325
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1326
                    ZoomOut(currentContentMousePoint);
1327
                }
1328 787a4489 KangIngu
            }
1329
        }
1330
1331 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1332
        {
1333
            e.Handled = true;
1334
            if (e.Delta > 0)
1335
            {
1336
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1337
                ZoomIn_Sync(currentContentMousePoint);
1338
            }
1339
            else
1340
            {
1341
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1342
                ZoomOut_Sync(currentContentMousePoint);
1343
            }
1344
        }
1345
1346 787a4489 KangIngu
        #region ZoomIn & ZoomOut
1347
1348
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1349
        {
1350
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1351
                zoomAndPanControl.ContentZoomFocusY));
1352
        }
1353
1354
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1355
        {
1356
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1357
                zoomAndPanControl.ContentZoomFocusY));
1358
        }
1359
1360
        //강인구 추가 (줌 인아웃 수치 변경)
1361
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1362
        private void ZoomOut(Point contentZoomCenter)
1363
        {
1364
            if (zoomAndPanControl.ContentScale > 0.39)
1365
            {
1366
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1367
            }
1368
            else
1369
            {
1370
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1371
            }
1372
1373 9cd2865b KangIngu
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1374 787a4489 KangIngu
            {
1375 9cd2865b KangIngu
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1376 787a4489 KangIngu
            }
1377
        }
1378
1379
        private void ZoomIn(Point contentZoomCenter)
1380
        {
1381
            if (zoomAndPanControl.ContentScale > 0.19)
1382
            {
1383
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1384
            }
1385
            else
1386
            {
1387
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1388
            }
1389
1390 9cd2865b KangIngu
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1391 787a4489 KangIngu
            {
1392 9cd2865b KangIngu
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1393 787a4489 KangIngu
            }
1394 a1716fa5 KangIngu
        }
1395
1396
        private void ZoomOut_Sync(Point contentZoomCenter)
1397
        {
1398
            if (zoomAndPanControl2.ContentScale > 0.39)
1399
            {
1400
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1401
            }
1402
            else
1403
            {
1404
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1405
            }
1406
1407
            if (Sync.IsChecked)
1408
            {
1409
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1410
            }
1411
        }
1412
1413
        private void ZoomIn_Sync(Point contentZoomCenter)
1414
        {
1415
            if (zoomAndPanControl2.ContentScale > 0.19)
1416
            {
1417
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1418
            }
1419
            else
1420
            {
1421
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1422
            }
1423
1424
            if (Sync.IsChecked)
1425
            {
1426
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1427
            }
1428 787a4489 KangIngu
        }
1429
1430
        private void ZoomOut()
1431
        {
1432
            zoomAndPanControl.ContentScale -= 0.1;
1433
            //if (zoomAndPanControl2 != null)
1434
            //{
1435
            //    zoomAndPanControl2.ContentScale -= 0.1;
1436
            //}
1437
        }
1438
1439
        private void ZoomIn()
1440
        {
1441
            zoomAndPanControl.ContentScale += 0.1;
1442
            //if (zoomAndPanControl2 != null)
1443
            //{
1444
            //    zoomAndPanControl2.ContentScale += 0.1;
1445
            //}
1446
        }
1447
1448 233ef333 taeseongkim
        #endregion ZoomIn & ZoomOut
1449 787a4489 KangIngu
1450 38d69491 taeseongkim
        public void init()
1451 787a4489 KangIngu
        {
1452
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1453
            {
1454
                ControlList.Clear();
1455
                listBox.Items.Clear();
1456
                selected_item.Clear();
1457
1458
                (item as IMarkupCommonData).IsSelected = false;
1459
            }
1460
        }
1461
1462
        private HitTestResultBehavior MyCallback(HitTestResult result)
1463
        {
1464
            //this.cursor = Cursors.UpArrow;
1465
            var element = result.VisualHit;
1466
            while (element != null && !(element is CommentUserInfo))
1467
                element = VisualTreeHelper.GetParent(element);
1468
1469
            if (element == null)
1470
            {
1471
                return HitTestResultBehavior.Stop;
1472
            }
1473
            else
1474
            {
1475
                if (element is CommentUserInfo)
1476
                {
1477
                    if (!hitList.Contains(element))
1478
                    {
1479
                        hitList.Add((CommentUserInfo)element);
1480
                    }
1481
                    else
1482
                    {
1483
                        return HitTestResultBehavior.Stop;
1484
                    }
1485
                }
1486
            }
1487
            return HitTestResultBehavior.Continue;
1488
        }
1489
1490
        public void ReleaseSelectPath()
1491
        {
1492
            if (SelectionPath == null)
1493
            {
1494
                SelectionPath = new Path();
1495
                SelectionPath.Name = "";
1496
            }
1497
            if (SelectionPath.Name != "")
1498
            {
1499
                SelectionPath.Name = "None";
1500
            }
1501
            SelectionPath.Opacity = 0.01;
1502
            SelectionPath.RenderTransform = null;
1503
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1504
        }
1505
1506 233ef333 taeseongkim
        #region 컨트롤 초기화
1507
1508 787a4489 KangIngu
        public void Control_Init(object control)
1509
        {
1510
            if (L_Size != 0 && (control as IPath) != null)
1511
            {
1512
                (control as IPath).LineSize = L_Size;
1513
                L_Size = 0;
1514
            }
1515
1516
            switch (control.GetType().Name)
1517
            {
1518
                case "RectangleControl":
1519
                    {
1520
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1521
                    }
1522
                    break;
1523 233ef333 taeseongkim
1524 787a4489 KangIngu
                case "CircleControl":
1525
                    {
1526
                        (control as CircleControl).StrokeColor = Brushes.Red;
1527
                    }
1528
                    break;
1529 233ef333 taeseongkim
1530 787a4489 KangIngu
                case "TriControl":
1531
                    {
1532
                        (control as TriControl).StrokeColor = Brushes.Red;
1533
                    }
1534
                    break;
1535 233ef333 taeseongkim
1536 787a4489 KangIngu
                case "RectCloudControl":
1537
                    {
1538
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1539
                    }
1540
                    break;
1541 233ef333 taeseongkim
1542 787a4489 KangIngu
                case "CloudControl":
1543
                    {
1544
                        (control as CloudControl).StrokeColor = Brushes.Red;
1545
                    }
1546
                    break;
1547 233ef333 taeseongkim
1548 787a4489 KangIngu
                case "PolygonControl":
1549
                    {
1550
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1551
                    }
1552
                    break;
1553 233ef333 taeseongkim
1554 787a4489 KangIngu
                case "ArcControl":
1555
                    {
1556
                        (control as ArcControl).StrokeColor = Brushes.Red;
1557
                    }
1558
                    break;
1559 233ef333 taeseongkim
1560 40b3ce25 ljiyeon
                case "ArrowArcControl":
1561
                    {
1562
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1563
                    }
1564
                    break;
1565 233ef333 taeseongkim
1566 787a4489 KangIngu
                case "LineControl":
1567
                    {
1568
                        (control as LineControl).StrokeColor = Brushes.Red;
1569
                    }
1570
                    break;
1571 233ef333 taeseongkim
1572 787a4489 KangIngu
                case "ArrowControl_Multi":
1573
                    {
1574
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1575
                    }
1576
                    break;
1577 233ef333 taeseongkim
1578 787a4489 KangIngu
                case "TextControl":
1579
                    {
1580
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1581
                    }
1582
                    break;
1583 233ef333 taeseongkim
1584 787a4489 KangIngu
                case "ArrowTextControl":
1585
                    {
1586
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1587
                    }
1588
                    break;
1589 233ef333 taeseongkim
1590 684ef11c ljiyeon
                case "InsideWhiteControl":
1591
                    {
1592
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1593
                    }
1594
                    break;
1595 233ef333 taeseongkim
1596 684ef11c ljiyeon
                case "OverlapWhiteControl":
1597
                    {
1598
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1599
                    }
1600
                    break;
1601 233ef333 taeseongkim
1602 684ef11c ljiyeon
                case "ClipWhiteControl":
1603
                    {
1604
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1605
                    }
1606
                    break;
1607 233ef333 taeseongkim
1608 684ef11c ljiyeon
                case "CoordinateControl":
1609
                    {
1610
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1611
                    }
1612
                    break;
1613 787a4489 KangIngu
            }
1614
        }
1615 233ef333 taeseongkim
1616
        #endregion 컨트롤 초기화
1617 787a4489 KangIngu
1618
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1619
        {
1620
            //Control_Init(e.Source);
1621
        }
1622 233ef333 taeseongkim
1623 7211e0c2 ljiyeon
        //private Window _dragdropWindow = null;
1624 53880c83 ljiyeon
1625
        [DllImport("user32.dll")]
1626
        [return: MarshalAs(UnmanagedType.Bool)]
1627
        internal static extern bool GetCursorPos(ref Win32Point pt);
1628
1629
        [StructLayout(LayoutKind.Sequential)]
1630
        internal struct Win32Point
1631
        {
1632
            public Int32 X;
1633
            public Int32 Y;
1634
        };
1635 233ef333 taeseongkim
1636 7211e0c2 ljiyeon
        /*
1637
       public string symbol_id = null;
1638
       public long symbol_group_id;
1639
       public int symbol_SelectedIndex;
1640
       public ImageSource symbol_img;
1641
       public string symbol_Data = null;
1642
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1643
       {
1644
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1645
               zoomAndPanCanvas.ActualHeight / 2));
1646
1647
               if (this._dragdropWindow != null)
1648
               {
1649
                   this._dragdropWindow.Close();
1650
                   this._dragdropWindow = null;
1651
               }
1652
1653
               symbol_id = id;
1654
               symbol_group_id = group_id;
1655
               symbol_SelectedIndex = SelectedIndex;
1656
               symbol_Data = Data_;
1657
               symbol_img = img;
1658
1659
               CreateDragDropWindow2(img);
1660
    }
1661 53880c83 ljiyeon
1662 7211e0c2 ljiyeon
    private void CreateDragDropWindow2(ImageSource image)
1663 53880c83 ljiyeon
        {
1664
            this._dragdropWindow = new Window();
1665 902faaea taeseongkim
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1666 53880c83 ljiyeon
            _dragdropWindow.WindowStyle = WindowStyle.None;
1667 233ef333 taeseongkim
            _dragdropWindow.AllowsTransparency = true;
1668 53880c83 ljiyeon
            _dragdropWindow.AllowDrop = false;
1669
            _dragdropWindow.Background = null;
1670
            _dragdropWindow.IsHitTestVisible = false;
1671
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1672
            _dragdropWindow.Topmost = true;
1673
            _dragdropWindow.ShowInTaskbar = false;
1674 233ef333 taeseongkim
1675 53880c83 ljiyeon
            Rectangle r = new Rectangle();
1676
            r.Width = image.Width;
1677
            r.Height = image.Height;
1678 233ef333 taeseongkim
            r.Opacity = 0.5;
1679 53880c83 ljiyeon
            r.Fill = new ImageBrush(image);
1680
            this._dragdropWindow.Content = r;
1681
1682
            Win32Point w32Mouse = new Win32Point();
1683
            GetCursorPos(ref w32Mouse);
1684
1685
            //w32Mouse.X = getCurrentPoint.X;
1686
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1687 233ef333 taeseongkim
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1688 53880c83 ljiyeon
            this._dragdropWindow.Show();
1689
        }
1690 f87dfb18 taeseongkim
1691 7211e0c2 ljiyeon
         */
1692 f87dfb18 taeseongkim
1693
        public void MoveZoomAndPanControl(Vector dragOffset)
1694
        {
1695
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1696
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1697
1698
            if (Sync.IsChecked)
1699
            {
1700
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1701
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1702
            }
1703
        }
1704
1705 787a4489 KangIngu
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1706
        {
1707 b74a9c91 taeseongkim
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1708
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1709
            //if(this.txtBatch.Visibility == Visibility.Visible)
1710 787a4489 KangIngu
            {
1711
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1712
1713
                Point currentPos = e.GetPosition(rect);
1714 d71ee575 djkim
1715 787a4489 KangIngu
                floatingTip.HorizontalOffset = currentPos.X + 20;
1716
                floatingTip.VerticalOffset = currentPos.Y;
1717
            }
1718
1719
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1720 233ef333 taeseongkim
1721 e6a9ddaf humkyung
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1722 787a4489 KangIngu
            {
1723 e54660e8 KangIngu
                SetCursor();
1724 787a4489 KangIngu
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1725
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1726
1727
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1728 9cd2865b KangIngu
1729 f87dfb18 taeseongkim
                MoveZoomAndPanControl(dragOffset);
1730 787a4489 KangIngu
            }
1731 992a98b4 KangIngu
1732 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1733 787a4489 KangIngu
            {
1734
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1735
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1736
                SetCursor();
1737
1738
                if (currentControl != null)
1739
                {
1740 c7fde400 taeseongkim
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1741
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1742 787a4489 KangIngu
                    //강인구 추가
1743
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1744
1745
                    if ((currentControl as IPath) != null)
1746
                    {
1747
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1748
                    }
1749 5ce56a3a KangIngu
                    if ((currentControl as LineControl) != null)
1750
                    {
1751
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1752
                    }
1753
1754 787a4489 KangIngu
                    if ((currentControl as IShapeControl) != null)
1755
                    {
1756
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1757
                    }
1758 f7ca524b humkyung
                    if (currentControl is TextControl TextCtrl)
1759 787a4489 KangIngu
                    {
1760
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1761
                        {
1762 f7ca524b humkyung
                            TextCtrl.TextStyle = FontStyles.Italic;
1763 787a4489 KangIngu
                        }
1764
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1765
                        {
1766 f7ca524b humkyung
                            TextCtrl.TextWeight = FontWeights.Bold;
1767 787a4489 KangIngu
                        }
1768
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1769
                        {
1770 f7ca524b humkyung
                            TextCtrl.UnderLine = TextDecorations.Underline;
1771 787a4489 KangIngu
                        }
1772 f7ca524b humkyung
1773
                        TextCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1774 787a4489 KangIngu
                    }
1775
                    else if ((currentControl as ArrowTextControl) != null)
1776
                    {
1777
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1778
                        {
1779
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1780
                        }
1781
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1782
                        {
1783 d4b0c723 KangIngu
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1784 787a4489 KangIngu
                        }
1785
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1786
                        {
1787
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1788
                        }
1789
                    }
1790 f7ca524b humkyung
                    else if (currentControl is RectCloudControl RectCloudCtrl)
1791 9f473fb7 KangIngu
                    {
1792 f7ca524b humkyung
                        RectCloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1793 9f473fb7 KangIngu
                    }
1794 f7ca524b humkyung
                    else if (currentControl is CloudControl CloudCtrl)
1795 9f473fb7 KangIngu
                    {
1796 f7ca524b humkyung
                        CloudCtrl.ArcLength = ViewerDataModel.Instance.ArcLength;
1797 9f473fb7 KangIngu
                    }
1798 787a4489 KangIngu
1799 168f8027 taeseongkim
                    #region // 모든 컨트롤의 공통기능 제어
1800 233ef333 taeseongkim
1801 168f8027 taeseongkim
                    if (controlType != ControlType.PenControl)
1802
                    {
1803 233ef333 taeseongkim
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1804 7a3b7ef3 swate0609
                        
1805
1806
                        if(currentControl is MarkupToPDF.Controls.Polygon.PolygonControl && ((MarkupToPDF.Controls.Polygon.PolygonControl)currentControl).IsCompleted)
1807
                        {
1808
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.PolygonControl;
1809
                            var firstPoint = vControl.PointSet.First();
1810
                            vControl.DashSize = ViewerDataModel.Instance.DashSize;
1811
                            vControl.LineSize = ViewerDataModel.Instance.LineSize;
1812
                            vControl.PointSet.Add(firstPoint);
1813
1814
                            vControl.ApplyOverViewData();
1815
1816
                            CreateCommand.Instance.Execute(currentControl);
1817
                            vControl.UpdateControl();
1818
                            currentControl = null;
1819
                        }
1820
                        else if(currentControl is MarkupToPDF.Controls.Polygon.CloudControl && ((MarkupToPDF.Controls.Polygon.CloudControl)currentControl).IsCompleted)
1821
                        {
1822
                            var vControl = currentControl as MarkupToPDF.Controls.Polygon.CloudControl;
1823
1824
                            CreateCommand.Instance.Execute(currentControl);
1825
1826
                            vControl.isTransOn = true;
1827
                            var firstPoint = vControl.PointSet.First();
1828
1829
                            vControl.PointSet.Add(firstPoint);
1830
                            vControl.DrawingCloud();
1831
                            vControl.ApplyOverViewData();
1832
1833
                            currentControl = null;
1834
                        }
1835
1836 43e1d368 taeseongkim
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1837 168f8027 taeseongkim
                    }
1838
1839 233ef333 taeseongkim
                    #endregion // 모든 컨트롤의 공통기능 제어
1840 168f8027 taeseongkim
1841
                    #region // 각 컨트롤의 특별한 기능을 제어한다.
1842
1843 787a4489 KangIngu
                    switch (controlType)
1844
                    {
1845 684ef11c ljiyeon
                        case (ControlType.Coordinate):
1846
                            {
1847
                                var control = currentControl as CoordinateControl;
1848
                                if (control != null)
1849
                                {
1850 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1851 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1852
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1853
                                }
1854
                            }
1855
                            break;
1856 233ef333 taeseongkim
1857 684ef11c ljiyeon
                        case (ControlType.InsideWhite):
1858
                            {
1859
                                var control = currentControl as InsideWhiteControl;
1860
                                if (control != null)
1861
                                {
1862 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1863 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1864
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1865
                                    control.Paint = PaintSet.Fill;
1866
                                }
1867
                            }
1868
                            break;
1869 233ef333 taeseongkim
1870 a6272c57 humkyung
                        case ControlType.OverlapWhite:
1871 684ef11c ljiyeon
                            {
1872
                                var control = currentControl as OverlapWhiteControl;
1873
                                if (control != null)
1874
                                {
1875 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1876 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1877
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1878
                                    control.Paint = PaintSet.Fill;
1879
                                }
1880
                            }
1881
                            break;
1882 233ef333 taeseongkim
1883 a6272c57 humkyung
                        case ControlType.ClipWhite:
1884 684ef11c ljiyeon
                            {
1885
                                var control = currentControl as ClipWhiteControl;
1886
                                if (control != null)
1887
                                {
1888 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1889 684ef11c ljiyeon
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1890
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1891
                                    control.Paint = PaintSet.Fill;
1892
                                }
1893
                            }
1894
                            break;
1895 233ef333 taeseongkim
1896 787a4489 KangIngu
                        case ControlType.RectCloud:
1897
                            {
1898
                                var control = currentControl as RectCloudControl;
1899
                                if (control != null)
1900
                                {
1901 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1902 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1903
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1904
                                }
1905
                            }
1906
                            break;
1907 233ef333 taeseongkim
1908 787a4489 KangIngu
                        case ControlType.SingleLine:
1909
                        case ControlType.CancelLine:
1910
                        case ControlType.ArrowLine:
1911
                        case ControlType.TwinLine:
1912
                        case ControlType.DimLine:
1913
                            {
1914 d71ee575 djkim
                                var control = currentControl as LineControl;
1915
                                if (control != null)
1916 787a4489 KangIngu
                                {
1917 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1918 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1919
                                }
1920
                            }
1921
                            break;
1922
1923
                        case ControlType.ArcLine:
1924
                            {
1925 d71ee575 djkim
                                var control = currentControl as ArcControl;
1926
                                if (control != null)
1927 787a4489 KangIngu
                                {
1928 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1929 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1930
                                }
1931
                            }
1932
                            break;
1933
1934
                        case ControlType.ArcArrow:
1935
                            {
1936 40b3ce25 ljiyeon
                                var control = currentControl as ArrowArcControl;
1937 d71ee575 djkim
                                if (control != null)
1938 787a4489 KangIngu
                                {
1939 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1940 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1941
                                }
1942
                            }
1943
                            break;
1944
1945
                        case ControlType.ArrowMultiLine:
1946
                            {
1947 d71ee575 djkim
                                var control = currentControl as ArrowControl_Multi;
1948
                                if (control != null)
1949 787a4489 KangIngu
                                {
1950 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1951 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1952
                                }
1953
                            }
1954
                            break;
1955
1956
                        case ControlType.Circle:
1957
                            {
1958 168f8027 taeseongkim
                                var control = currentControl as CircleControl;
1959
1960
                                if (control != null)
1961 787a4489 KangIngu
                                {
1962 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1963
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1964
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1965 787a4489 KangIngu
                                }
1966
                            }
1967
                            break;
1968
1969
                        case ControlType.PolygonCloud:
1970
                            {
1971
                                var control = currentControl as CloudControl;
1972
                                if (control != null)
1973
                                {
1974 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1975 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1976
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1977
                                }
1978
                            }
1979
                            break;
1980
1981
                        case ControlType.Triangle:
1982
                            {
1983
                                var control = currentControl as TriControl;
1984
                                if (control != null)
1985
                                {
1986 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1987 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1988
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1989
                                }
1990
                            }
1991
                            break;
1992
1993
                        case ControlType.ImgControl:
1994
                            {
1995
                                var control = currentControl as ImgControl;
1996
                                if (control != null)
1997
                                {
1998 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1999 787a4489 KangIngu
                                }
2000
                            }
2001
                            break;
2002
2003
                        case ControlType.Date:
2004
                            {
2005
                                var control = currentControl as DateControl;
2006
                                if (control != null)
2007
                                {
2008 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2009 787a4489 KangIngu
                                }
2010
                            }
2011
                            break;
2012
2013
                        case ControlType.ArrowTextControl:
2014
                        case ControlType.ArrowTransTextControl:
2015
                        case ControlType.ArrowTextBorderControl:
2016
                        case ControlType.ArrowTransTextBorderControl:
2017
                        case ControlType.ArrowTextCloudControl:
2018
                        case ControlType.ArrowTransTextCloudControl:
2019
                            {
2020
                                var control = currentControl as ArrowTextControl;
2021
                                if (control != null)
2022
                                {
2023 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2024 787a4489 KangIngu
                                }
2025
                            }
2026
                            break;
2027 233ef333 taeseongkim
2028 787a4489 KangIngu
                        case ControlType.PolygonControl:
2029 e6a9ddaf humkyung
                        case ControlType.ChainLine:
2030 787a4489 KangIngu
                            {
2031
                                var control = currentControl as PolygonControl;
2032
                                if (control != null)
2033
                                {
2034 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2035 787a4489 KangIngu
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2036
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2037
                                }
2038
                            }
2039
                            break;
2040 233ef333 taeseongkim
2041 787a4489 KangIngu
                        case ControlType.Sign:
2042
                            {
2043
                                var control = currentControl as SignControl;
2044
                                if (control != null)
2045
                                {
2046 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2047 787a4489 KangIngu
                                }
2048
                            }
2049
                            break;
2050 233ef333 taeseongkim
2051 787a4489 KangIngu
                        case ControlType.Symbol:
2052
                            {
2053
                                var control = currentControl as SymControl;
2054
                                if (control != null)
2055
                                {
2056 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2057 787a4489 KangIngu
                                }
2058
                            }
2059
                            break;
2060 233ef333 taeseongkim
2061 787a4489 KangIngu
                        case ControlType.Stamp:
2062
                            {
2063 cd988cd8 djkim
                                var control = currentControl as SymControlN;
2064
                                if (control != null)
2065 787a4489 KangIngu
                                {
2066 cd988cd8 djkim
                                    if (control.STAMP != null)
2067 cbaa3c91 ljiyeon
                                    {
2068 168f8027 taeseongkim
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2069 cbaa3c91 ljiyeon
                                    }
2070 cd988cd8 djkim
                                    else
2071
                                    {
2072
                                        currentControl = null;
2073 902faaea taeseongkim
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2074 cd988cd8 djkim
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2075
                                    }
2076 168f8027 taeseongkim
                                }
2077 787a4489 KangIngu
                            }
2078
                            break;
2079 233ef333 taeseongkim
2080 a6272c57 humkyung
                        case ControlType.Rectangle:
2081 787a4489 KangIngu
                        case ControlType.Mark:
2082
                            {
2083
                                var control = currentControl as RectangleControl;
2084
                                if (control != null)
2085
                                {
2086 168f8027 taeseongkim
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2087
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2088 7a5210f1 humkyung
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2089 787a4489 KangIngu
                                }
2090
                            }
2091
                            break;
2092 233ef333 taeseongkim
2093 787a4489 KangIngu
                        case ControlType.PenControl:
2094
                            {
2095
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2096
                                //inkBoard.Strokes.Add(stroke);
2097
                            }
2098
                            break;
2099 233ef333 taeseongkim
2100 787a4489 KangIngu
                        default:
2101
                            break;
2102
                    }
2103 168f8027 taeseongkim
2104 233ef333 taeseongkim
                    #endregion // 각 컨트롤의 특별한 기능을 제어한다.
2105
2106 4f017ed3 taeseongkim
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2107 168f8027 taeseongkim
                    {
2108 4f017ed3 taeseongkim
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2109 168f8027 taeseongkim
                    }
2110 787a4489 KangIngu
                }
2111
            }
2112 233ef333 taeseongkim
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2113 29cf2c0c humkyung
            {
2114
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2115
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2116
                SetCursor();
2117
                if (currentControl == null)
2118
                {
2119
                    switch (controlType)
2120
                    {
2121
                        case ControlType.PenControl:
2122
                            {
2123
                                if (inkBoard.Tag.ToString() == "Ink")
2124
                                {
2125
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2126
                                }
2127
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2128
                                {
2129
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2130
                                }
2131
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2132
                                {
2133
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2134
                                }
2135
2136
                                //inkBoard.Strokes.Add(stroke);
2137
                            }
2138
                            break;
2139
                    }
2140
                    return;
2141
                }
2142
            }
2143 233ef333 taeseongkim
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2144
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2145 e6a9ddaf humkyung
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2146 787a4489 KangIngu
            {
2147
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2148
2149
                if (isDraggingSelectionRect)
2150
                {
2151 c7fde400 taeseongkim
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2152 787a4489 KangIngu
                    e.Handled = true;
2153
                }
2154
                else if (isLeftMouseButtonDownOnWindow)
2155
                {
2156 c7fde400 taeseongkim
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2157 787a4489 KangIngu
                    double dragDistance = Math.Abs(dragDelta.Length);
2158
2159
                    if (dragDistance > DragThreshold)
2160
                    {
2161
                        isDraggingSelectionRect = true;
2162 c7fde400 taeseongkim
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2163 787a4489 KangIngu
                    }
2164
2165
                    e.Handled = true;
2166
                }
2167
2168 c7fde400 taeseongkim
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2169 787a4489 KangIngu
                {
2170
                }
2171
                else
2172
                {
2173
                    e.Handled = true;
2174
                }
2175
            }
2176 7211e0c2 ljiyeon
            /*
2177 e6a9ddaf humkyung
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2178 233ef333 taeseongkim
            { //symbol
2179 53880c83 ljiyeon
                if(_dragdropWindow != null)
2180
                {
2181
                    Win32Point w32Mouse = new Win32Point();
2182
                    GetCursorPos(ref w32Mouse);
2183
2184
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2185
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2186 233ef333 taeseongkim
                }
2187 53880c83 ljiyeon
            }
2188 7211e0c2 ljiyeon
            */
2189 233ef333 taeseongkim
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2190 e6a9ddaf humkyung
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2191 787a4489 KangIngu
            {
2192 dbddfdd0 taeseongkim
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2193
2194
2195
                //if (comment != null)
2196
                //{
2197
                //    comment.IsMouseEnter = true;
2198
2199
                //    if (enterMouse != comment)
2200
                //    {
2201
                //        if (enterMouse != null)
2202
                //            enterMouse.IsSelected = false;
2203
2204
                //        enterMouse = comment;
2205
                //    }
2206
                //}
2207
                //else
2208
                //{
2209
                //    if(enterMouse != null)
2210
                //        enterMouse.IsSelected = false;
2211
                //}
2212
2213 9380813b swate0609
2214 a342d378 taeseongkim
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2215 233ef333 taeseongkim
                if (control != null)
2216 787a4489 KangIngu
                {
2217
                    this.cursor = Cursors.Hand;
2218
                    SetCursor();
2219
                }
2220
                else
2221
                {
2222 902faaea taeseongkim
                    if (this.Cursor != Cursors.None)
2223
                    {
2224
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2225
                        SetCursor();
2226
                    }
2227 787a4489 KangIngu
                }
2228
            }
2229
            else
2230
            {
2231 9380813b swate0609
                
2232 787a4489 KangIngu
            }
2233
        }
2234
2235 dbddfdd0 taeseongkim
        private CommentUserInfo enterMouse = null;
2236
2237
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2238
        {
2239
            object result = null;
2240
2241
            // 검색할 정사각형의 크기 및 반경 설정
2242
            double squareSize = 1;
2243
            Rect searchRect = new Rect(
2244
                mousePosition.X - squareSize,
2245
                mousePosition.Y - squareSize,
2246
                squareSize * 2,
2247
                squareSize * 2
2248
            );
2249
2250
            foreach (CommentUserInfo child in drawingRotateCanvas.ChildrenOfType<CommentUserInfo>())
2251
            {
2252
                if (child is CommentUserInfo comment)
2253
                {
2254
                    // 검색 영역과 Rectangle의 경계가 겹치는지 확인합니다.
2255
                    if (searchRect.IntersectsWith(child.ItemRect))
2256
                    {
2257
                        child.IsMouseEnter = true;
2258
                        result = (object)child;
2259
                        // Geometry를 적용하거나 원하는 작업을 수행합니다.
2260
                        // 예: rectangle.Fill = new SolidColorBrush(Colors.Red);
2261
                    }
2262
                    else
2263
                    {
2264
                        child.IsMouseEnter = false;
2265
                    }
2266
                }
2267
            }
2268
2269
            return result;
2270
        }
2271
2272 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2273
        {
2274 e6a9ddaf humkyung
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2275 a1716fa5 KangIngu
            {
2276
                SetCursor();
2277
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2278
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2279
2280
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2281
2282
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2283
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2284
2285
                if (Sync.IsChecked)
2286
                {
2287
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2288
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2289
                }
2290
            }
2291
        }
2292
2293 787a4489 KangIngu
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2294
2295
        private EllipseGeometry hitArea = new EllipseGeometry();
2296
2297
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2298
        {
2299
            IsDrawing = false;
2300 233ef333 taeseongkim
2301 787a4489 KangIngu
            if (mouseHandlingMode != MouseHandlingMode.None)
2302
            {
2303
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2304
                {
2305 902faaea taeseongkim
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2306 787a4489 KangIngu
2307
                    SetCursor();
2308
2309
                    switch (controlType)
2310
                    {
2311
                        case ControlType.None:
2312
                            break;
2313 233ef333 taeseongkim
2314 787a4489 KangIngu
                        case ControlType.Rectangle:
2315
                            {
2316
                            }
2317
                            break;
2318 233ef333 taeseongkim
2319 787a4489 KangIngu
                        case ControlType.PenControl:
2320
                            {
2321
                            }
2322
                            break;
2323 233ef333 taeseongkim
2324 787a4489 KangIngu
                        default:
2325
                            break;
2326 233ef333 taeseongkim
                    }
2327 787a4489 KangIngu
                }
2328 9f473fb7 KangIngu
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2329 787a4489 KangIngu
                {
2330
                    if (isLeftMouseButtonDownOnWindow)
2331
                    {
2332
                        bool wasDragSelectionApplied = false;
2333
2334
                        if (isDraggingSelectionRect)
2335
                        {
2336 53880c83 ljiyeon
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2337
                            {
2338
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2339
                                mouseHandlingMode = MouseHandlingMode.None;
2340
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2341 0d97ab05 humkyung
                                Point endPoint = e.GetPosition(zoomAndPanControl);
2342
                                CaptureSymbolImage(endPoint);
2343 53880c83 ljiyeon
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2344 233ef333 taeseongkim
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2345 53880c83 ljiyeon
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2346
                            }
2347
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2348 787a4489 KangIngu
                            {
2349
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2350
                                mouseHandlingMode = MouseHandlingMode.None;
2351
                                Set_Capture();
2352
2353
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2354
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2355
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2356
                            }
2357 9f473fb7 KangIngu
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2358 787a4489 KangIngu
                            {
2359
                                ApplyDragSelectionRect();
2360
                            }
2361 9f473fb7 KangIngu
                            else
2362
                            {
2363
                                double x = Canvas.GetLeft(dragZoomBorder);
2364
                                double y = Canvas.GetTop(dragZoomBorder);
2365
                                double width = dragZoomBorder.Width;
2366
                                double height = dragZoomBorder.Height;
2367
                                Rect dragRect = new Rect(x, y, width, height);
2368
2369
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2370
2371
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2372
                            }
2373 787a4489 KangIngu
2374 9f473fb7 KangIngu
                            isDraggingSelectionRect = false;
2375 787a4489 KangIngu
                            e.Handled = true;
2376
                            wasDragSelectionApplied = true;
2377
                        }
2378
2379
                        if (isLeftMouseButtonDownOnWindow)
2380
                        {
2381
                            isLeftMouseButtonDownOnWindow = false;
2382
                            this.ReleaseMouseCapture();
2383
                            e.Handled = true;
2384
                        }
2385
2386
                        if (!wasDragSelectionApplied)
2387
                        {
2388
                            init();
2389
                        }
2390
                    }
2391
                }
2392 e6a9ddaf humkyung
                else if (e.RightButton == MouseButtonState.Pressed)
2393 787a4489 KangIngu
                {
2394 902faaea taeseongkim
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2395 787a4489 KangIngu
                    SetCursor();
2396
                }
2397
2398
                zoomAndPanControl.ReleaseMouseCapture();
2399
2400
                e.Handled = true;
2401
            }
2402
            else
2403
            {
2404 902faaea taeseongkim
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2405 787a4489 KangIngu
                SetCursor();
2406
            }
2407
2408 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
2409 787a4489 KangIngu
            //controlType = ControlType.SingleLine;
2410
        }
2411
2412 0d97ab05 humkyung
        /// <summary>
2413
        /// 주어진 좌표의 영역으로 심볼을 생성한다.
2414
        /// </summary>
2415
        /// <param name="endPoint"></param>
2416
        public void CaptureSymbolImage(Point endPoint)
2417 233ef333 taeseongkim
        {
2418 0d97ab05 humkyung
            double x = Math.Min(zoomAndPanControlMouseDownPoint.X, endPoint.X);
2419
            double y = Math.Min(zoomAndPanControlMouseDownPoint.Y, endPoint.Y);
2420
            double width = Math.Abs(zoomAndPanControlMouseDownPoint.X - endPoint.X);
2421
            double height = Math.Abs(zoomAndPanControlMouseDownPoint.Y - endPoint.Y);
2422 53880c83 ljiyeon
2423 0d97ab05 humkyung
            if (width > 0 && height > 0)
2424 53880c83 ljiyeon
            {
2425 0d97ab05 humkyung
                var SymbolRect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2426 53880c83 ljiyeon
2427 0d97ab05 humkyung
                canvasImage = ConverterBitmapImage(zoomAndPanControl);
2428
                BitmapSource crop = new CroppedBitmap(canvasImage, SymbolRect);
2429
#if DEBUG
2430
                BitmapEncoder pngEncoder = new PngBitmapEncoder();
2431
                pngEncoder.Frames.Add(BitmapFrame.Create(crop));
2432
                using (var fs = System.IO.File.OpenWrite(System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName())))
2433 53880c83 ljiyeon
                {
2434 0d97ab05 humkyung
                    pngEncoder.Save(fs);
2435
                }
2436
#endif
2437
2438
                double scale = dragCaptureBorder.Width / width;
2439
                SaveCapturedSymbol(crop, (int)x, (int)y, (int)width, (int)height, scale, scale);
2440 53880c83 ljiyeon
            }
2441
        }
2442
2443 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2444
        {
2445 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
2446 a1716fa5 KangIngu
        }
2447
2448 787a4489 KangIngu
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2449
        {
2450 e6a9ddaf humkyung
            ///mouseButtonDown = MouseButton.Left;
2451 902faaea taeseongkim
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2452 787a4489 KangIngu
        }
2453
2454
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2455
        {
2456
        }
2457
2458 4804a4fb humkyung
        /// <summary>
2459
        /// select items by dragging
2460
        /// </summary>
2461 787a4489 KangIngu
        private void ApplyDragSelectionRect()
2462
        {
2463
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2464
2465
            double x = Canvas.GetLeft(dragSelectionBorder);
2466
            double y = Canvas.GetTop(dragSelectionBorder);
2467
            double width = dragSelectionBorder.Width;
2468
            double height = dragSelectionBorder.Height;
2469 e6a9ddaf humkyung
            Rect dragRect = new Rect(x, y, width, height);
2470 e1b36bc0 humkyung
            SelectionSet.Instance.SelectItemByRect(dragRect, this);
2471 787a4489 KangIngu
        }
2472
2473
        private void InitDragSelectionRect(Point pt1, Point pt2)
2474
        {
2475 9f473fb7 KangIngu
            //캡쳐 중
2476
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2477
            {
2478
                dragCaptureBorder.Visibility = Visibility.Visible;
2479
            }
2480 787a4489 KangIngu
            //선택 중
2481 9f473fb7 KangIngu
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2482 787a4489 KangIngu
            {
2483
                dragSelectionBorder.Visibility = Visibility.Visible;
2484
            }
2485
            else
2486
            {
2487 9f473fb7 KangIngu
                dragZoomBorder.Visibility = Visibility.Visible;
2488 787a4489 KangIngu
            }
2489
            UpdateDragSelectionRect(pt1, pt2);
2490
        }
2491
2492
        /// <summary>
2493
        /// Update the position and size of the rectangle used for drag selection.
2494
        /// </summary>
2495
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2496
        {
2497
            double x, y, width, height;
2498
2499
            //
2500
            // Determine x,y,width and height of the rect inverting the points if necessary.
2501 233ef333 taeseongkim
            //
2502 787a4489 KangIngu
2503
            if (pt2.X < pt1.X)
2504
            {
2505
                x = pt2.X;
2506
                width = pt1.X - pt2.X;
2507
            }
2508
            else
2509
            {
2510
                x = pt1.X;
2511
                width = pt2.X - pt1.X;
2512
            }
2513
2514
            if (pt2.Y < pt1.Y)
2515
            {
2516
                y = pt2.Y;
2517
                height = pt1.Y - pt2.Y;
2518
            }
2519
            else
2520
            {
2521
                y = pt1.Y;
2522
                height = pt2.Y - pt1.Y;
2523
            }
2524
2525
            //
2526
            // Update the coordinates of the rectangle used for drag selection.
2527
            //
2528 9f473fb7 KangIngu
            //캡쳐 중
2529
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2530
            {
2531
                Canvas.SetLeft(dragCaptureBorder, x);
2532
                Canvas.SetTop(dragCaptureBorder, y);
2533
                dragCaptureBorder.Width = width;
2534
                dragCaptureBorder.Height = height;
2535
            }
2536 787a4489 KangIngu
            //선택 중
2537 a1716fa5 KangIngu
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2538 787a4489 KangIngu
            {
2539
                Canvas.SetLeft(dragSelectionBorder, x);
2540
                Canvas.SetTop(dragSelectionBorder, y);
2541
                dragSelectionBorder.Width = width;
2542
                dragSelectionBorder.Height = height;
2543
            }
2544
            else
2545
            {
2546 9f473fb7 KangIngu
                Canvas.SetLeft(dragZoomBorder, x);
2547
                Canvas.SetTop(dragZoomBorder, y);
2548
                dragZoomBorder.Width = width;
2549
                dragZoomBorder.Height = height;
2550 787a4489 KangIngu
            }
2551
        }
2552
2553
        private void drawingPannelRotate(double angle)
2554
        {
2555 548c696e ljiyeon
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2556 787a4489 KangIngu
            rotate.Angle = angle;
2557
            var rotationNum = Math.Abs((rotate.Angle / 90));
2558
2559
            if (angle == 90 || angle == 270)
2560
            {
2561
                double emptySize = zoomAndPanCanvas.Width;
2562
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2563
                zoomAndPanCanvas.Height = emptySize;
2564
            }
2565
            if (angle == 0)
2566
            {
2567
                translate.X = 0;
2568
                translate.Y = 0;
2569
            }
2570
            else if (angle == 90)
2571
            {
2572
                translate.X = zoomAndPanCanvas.Width;
2573
                translate.Y = 0;
2574
            }
2575
            else if (angle == 180)
2576
            {
2577
                translate.X = zoomAndPanCanvas.Width;
2578
                translate.Y = zoomAndPanCanvas.Height;
2579
            }
2580
            else
2581
            {
2582
                translate.X = 0;
2583
                translate.Y = zoomAndPanCanvas.Height;
2584
            }
2585
2586
            zoomAndPanControl.RotationAngle = rotate.Angle;
2587
2588
            if (!testPanel2.IsHidden)
2589
            {
2590
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2591
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2592
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2593
            }
2594
2595
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2596
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2597
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2598
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2599 4f017ed3 taeseongkim
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2600 787a4489 KangIngu
        }
2601
2602 497bbe52 ljiyeon
        private void syncPannelRotate(double angle)
2603
        {
2604
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2605
            rotate.Angle = angle;
2606
            var rotationNum = Math.Abs((rotate.Angle / 90));
2607
2608
            if (angle == 90 || angle == 270)
2609
            {
2610
                double emptySize = zoomAndPanCanvas2.Width;
2611
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2612
                zoomAndPanCanvas2.Height = emptySize;
2613
            }
2614
            if (angle == 0)
2615
            {
2616
                translate2.X = 0;
2617
                translate2.Y = 0;
2618
            }
2619
            else if (angle == 90)
2620
            {
2621
                translate2.X = zoomAndPanCanvas2.Width;
2622
                translate2.Y = 0;
2623
            }
2624
            else if (angle == 180)
2625
            {
2626
                translate2.X = zoomAndPanCanvas2.Width;
2627
                translate2.Y = zoomAndPanCanvas2.Height;
2628
            }
2629
            else
2630
            {
2631
                translate2.X = 0;
2632
                translate2.Y = zoomAndPanCanvas2.Height;
2633
            }
2634
2635
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2636
        }
2637
2638 e1b36bc0 humkyung
        public void PlaceImageSymbol(string id, string groupID, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2639 787a4489 KangIngu
        {
2640 53880c83 ljiyeon
            string Data_ = "";
2641
2642
            try
2643
            {
2644 664ea2e1 taeseongkim
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2645 53880c83 ljiyeon
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2646
                if (Data_ != null || Data_ != "")
2647
                {
2648 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2649 53880c83 ljiyeon
                }
2650
                else
2651
                {
2652 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2653 53880c83 ljiyeon
                }
2654
2655 c0977e97 djkim
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2656
                //{
2657
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2658
                //    STATE = 0,
2659
                //};
2660 53880c83 ljiyeon
                if (Data_ != null)
2661
                {
2662
                    Image img = new Image();
2663
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2664
                    if (Data_.Contains(".svg"))
2665
                    {
2666 f1f822e9 taeseongkim
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2667
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2668 53880c83 ljiyeon
                    }
2669
                    else
2670
                    {
2671
                        img.Source = new BitmapImage(new Uri(Data_));
2672
                    }
2673
2674
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2675
                    {
2676
                        PointSet = new List<Point>(),
2677
                        FilePath = Data_,
2678
                        ImageData = img.Source,
2679
                        StartPoint = canvasZoomPanningMouseDownPoint,
2680 233ef333 taeseongkim
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2681 53880c83 ljiyeon
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2682 233ef333 taeseongkim
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2683 53880c83 ljiyeon
                        canvasZoomPanningMouseDownPoint.Y),
2684
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2685
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2686
                    };
2687
2688
                    currentControl.PointSet = new List<Point>
2689
                                        {
2690
                                            currentControl.StartPoint,
2691
                                            currentControl.LeftBottomPoint,
2692
                                            currentControl.EndPoint,
2693
                                            currentControl.TopRightPoint,
2694
                                        };
2695 b79d6e7f humkyung
                    UndoData multi_UndoData = new UndoData();
2696 873011c4 humkyung
                    UndoDataGroup = new UndoDataGroup()
2697 53880c83 ljiyeon
                    {
2698
                        IsUndo = false,
2699 873011c4 humkyung
                        Event = EventType.Create,
2700 53880c83 ljiyeon
                        EventTime = DateTime.Now,
2701 b79d6e7f humkyung
                        MarkupDataColl = new List<UndoData>()
2702 53880c83 ljiyeon
                    };
2703
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2704
                    {
2705
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2706
                    });
2707
2708 873011c4 humkyung
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2709
                    multi_UndoData = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2710
                    UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
2711
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
2712 53880c83 ljiyeon
2713
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2714 5a223b60 humkyung
                    currentControl.CommentID = Commons.ShortGuid();
2715 53880c83 ljiyeon
                    currentControl.SymbolID = id;
2716 e1b36bc0 humkyung
                    currentControl.GroupID = groupID;
2717 53880c83 ljiyeon
                    currentControl.ApplyTemplate();
2718
                    currentControl.SetImage();
2719
2720
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2721
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2722
                    SelectLayer.Children.Add(final);
2723
                }
2724
            }
2725
            catch (Exception ex)
2726
            {
2727
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2728
            }
2729
        }
2730
2731 6a19b48d taeseongkim
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2732
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2733 10de973b taeseongkim
        {
2734 992a98b4 KangIngu
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2735 be04d12c djkim
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2736 992a98b4 KangIngu
            {
2737
                set_option.Value = double.Parse(set_option.ContentText);
2738 5d55f6fb ljiyeon
                //set_option.Focusable = false;
2739 3c71b3a5 taeseongkim
                zoomAndPanControl.Focus();
2740 992a98b4 KangIngu
            }
2741
2742 f959ea6f humkyung
            ConvertInkControlToPolygon();
2743 787a4489 KangIngu
2744 1b2cf911 taeseongkim
            // 텍스트가 없으면 삭제됨
2745 787a4489 KangIngu
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2746
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2747
2748 a1716fa5 KangIngu
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2749 787a4489 KangIngu
            {
2750 34ac8db7 humkyung
                UndoCommand.Instance.Push(EventType.Delete, new[] { text_item });
2751 787a4489 KangIngu
            }
2752 1305c420 taeseongkim
2753 d62c0439 humkyung
            /// up to here
2754 787a4489 KangIngu
2755 b7813553 djkim
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2756 787a4489 KangIngu
            {
2757 5c3caba6 humkyung
                if (item is ArrowTextControl ArrTextCtrl)
2758 787a4489 KangIngu
                {
2759 5c3caba6 humkyung
                    ArrTextCtrl.Base_TextBox.IsHitTestVisible = false;
2760 787a4489 KangIngu
                }
2761 5c3caba6 humkyung
                else if (item is TextControl TextCtrl)
2762 76688e76 djkim
                {
2763 5c3caba6 humkyung
                    TextCtrl.Base_TextBox.IsHitTestVisible = false;
2764 76688e76 djkim
                }
2765 787a4489 KangIngu
            }
2766
2767 49b217ad humkyung
            //if (currentControl != null)
2768 787a4489 KangIngu
            {
2769 5c3caba6 humkyung
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as TextControl) != null && (data as TextControl).IsEditingMode);
2770 a6f7f9b6 djkim
                if (text_item_ != null)
2771 787a4489 KangIngu
                {
2772
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2773
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2774 233ef333 taeseongkim
                    (text_item_ as TextControl).IsEditingMode = false;
2775 49b217ad humkyung
                    currentControl = null;
2776 787a4489 KangIngu
                }
2777
2778 5c3caba6 humkyung
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode);
2779 49b217ad humkyung
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2780 787a4489 KangIngu
                {
2781
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2782
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2783 49b217ad humkyung
                    currentControl = null;
2784 787a4489 KangIngu
                }
2785
            }
2786
2787 233ef333 taeseongkim
            double Ang = 0;
2788 787a4489 KangIngu
            if (rotate.Angle != 0)
2789
            {
2790
                Ang = 360 - rotate.Angle;
2791
            }
2792
2793 5c3caba6 humkyung
            if (e.OriginalSource is System.Windows.Controls.Image imgctrl)
2794 787a4489 KangIngu
            {
2795 5c3caba6 humkyung
                imgctrl.Focus();
2796 787a4489 KangIngu
            }
2797 7211e0c2 ljiyeon
            /*
2798 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2799 233ef333 taeseongkim
            {
2800 53880c83 ljiyeon
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2801
                if(symbol_id != null)
2802
                {
2803
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2804 233ef333 taeseongkim
                }
2805 53880c83 ljiyeon
            }
2806
2807 e6a9ddaf humkyung
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2808 53880c83 ljiyeon
            {
2809
                if (this._dragdropWindow != null)
2810
                {
2811
                    this._dragdropWindow.Close();
2812
                    this._dragdropWindow = null;
2813
                    symbol_id = null;
2814
                }
2815
            }
2816 7211e0c2 ljiyeon
            */
2817 53880c83 ljiyeon
2818 e6a9ddaf humkyung
            if (e.LeftButton == MouseButtonState.Pressed)
2819 787a4489 KangIngu
            {
2820 c7fde400 taeseongkim
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2821 1a7a7e62 이지연
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2822 0d97ab05 humkyung
                zoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl);
2823 902faaea taeseongkim
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2824 787a4489 KangIngu
                SetCursor();
2825
2826 315ae55e taeseongkim
                if (!ViewerDataModel.Instance.IsPressCtrl)
2827
                {
2828
                    SelectionSet.Instance.UnSelect(this);
2829
                }
2830 787a4489 KangIngu
            }
2831 f513c215 humkyung
2832 e6a9ddaf humkyung
            if (e.MiddleButton == MouseButtonState.Pressed)
2833 787a4489 KangIngu
            {
2834
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2835
                cursor = Cursors.SizeAll;
2836
                SetCursor();
2837
            }
2838 e6a9ddaf humkyung
            if (e.RightButton == MouseButtonState.Pressed)
2839 787a4489 KangIngu
            {
2840 d1f35ad3 swate0609
                List<AdornerMember> AdonerList = GetAdornerItem();
2841
2842
                if (AdonerList.Count > 0)
2843
                {
2844
                    if (this.zoomAndPanControl.ContextMenu == null)
2845
                        this.zoomAndPanControl.ContextMenu = m_ContextMenu;
2846
                }
2847
                else
2848
                {
2849
                    if (this.zoomAndPanControl.ContextMenu != null)
2850
                        this.zoomAndPanControl.ContextMenu = null;
2851
2852
                    canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2853
                    cursor = Cursors.SizeAll;
2854
                    SetCursor();
2855
                }
2856
2857 787a4489 KangIngu
            }
2858 e6a9ddaf humkyung
            else if (e.XButton1 == MouseButtonState.Pressed)
2859 787a4489 KangIngu
            {
2860
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2861
                {
2862 3908a575 humkyung
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2863 787a4489 KangIngu
                }
2864
2865 3908a575 humkyung
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2866 787a4489 KangIngu
            }
2867 e6a9ddaf humkyung
            else if (e.XButton2 == MouseButtonState.Pressed)
2868 787a4489 KangIngu
            {
2869
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2870
                {
2871
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2872
                }
2873
            }
2874
2875 1305c420 taeseongkim
            bool isArrowTextEdit = false;
2876
2877
            if (currentControl is ArrowTextControl textControl)
2878
            {
2879
                if (textControl.IsEditingMode)
2880
                    isArrowTextEdit = true;
2881
            }
2882
2883 e6a9ddaf humkyung
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2884 787a4489 KangIngu
            {
2885
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2886
                {
2887
                    if (SelectLayer.Children.Count == 0)
2888
                    {
2889
                        isLeftMouseButtonDownOnWindow = true;
2890
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2891
                    }
2892
2893
                    if (controlType == ControlType.None)
2894
                    {
2895
                        isLeftMouseButtonDownOnWindow = true;
2896
                    }
2897
                }
2898
2899 f513c215 humkyung
                /// 캡쳐 모드 설정
2900 9f473fb7 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2901
                {
2902
                    dragCaptureBorder.Visibility = Visibility.Visible;
2903
                    isLeftMouseButtonDownOnWindow = true;
2904
                }
2905
2906 f513c215 humkyung
                /// 줌 모드 설정
2907 9f473fb7 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2908
                {
2909
                    isLeftMouseButtonDownOnWindow = true;
2910 1066bae3 ljiyeon
                }
2911 787a4489 KangIngu
2912 5c3caba6 humkyung
                var control = ViewerDataModel.Instance.MarkupControls_USER.FirstOrDefault(data => data.IsMouseEnter);
2913 233ef333 taeseongkim
                if (control == null)
2914 787a4489 KangIngu
                {
2915 b643fcca taeseongkim
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2916
                }
2917
                else
2918
                {
2919 233ef333 taeseongkim
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2920
                    {
2921
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2922
                    }
2923 b643fcca taeseongkim
2924 e1b36bc0 humkyung
                    AdornerFinal selection = null;
2925 787a4489 KangIngu
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2926
                    {
2927 e1b36bc0 humkyung
                        selection = SelectionSet.Instance.SelectItem(control, this);
2928
                        if (selection.Members.Count == 1)
2929 787a4489 KangIngu
                        {
2930 e1b36bc0 humkyung
                            control = selection.Members[0].DrawingData as CommentUserInfo;
2931
                            if ((control as IPath) != null)
2932 787a4489 KangIngu
                            {
2933 e1b36bc0 humkyung
                                if ((control as IPath).LineSize != 0)
2934
                                {
2935
                                    ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2936
                                }
2937 787a4489 KangIngu
                            }
2938 e1b36bc0 humkyung
                            if ((control as IShapeControl) != null)
2939 787a4489 KangIngu
                            {
2940 e1b36bc0 humkyung
                                if ((control as IShapeControl).Paint == PaintSet.Hatch)
2941
                                {
2942
                                    ViewerDataModel.Instance.checkHatchShape = true;
2943
                                }
2944
                                else if ((control as IShapeControl).Paint == PaintSet.Fill)
2945
                                {
2946
                                    ViewerDataModel.Instance.checkFillShape = true;
2947
                                }
2948
                                else
2949
                                {
2950
                                    ViewerDataModel.Instance.checkHatchShape = false;
2951
                                    ViewerDataModel.Instance.checkFillShape = false;
2952
                                }
2953
                                ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2954 787a4489 KangIngu
                            }
2955 d4b0c723 KangIngu
2956 e1b36bc0 humkyung
                            ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2957 c206d293 taeseongkim
2958 e1b36bc0 humkyung
                            if (control is TextControl TextCtrl)
2959 d4b0c723 KangIngu
                            {
2960 e1b36bc0 humkyung
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont(TextCtrl.TextFamily);
2961 24c5e56c taeseongkim
2962 e1b36bc0 humkyung
                                if (!(TextCtrl.EnableEditing))
2963
                                {
2964
                                    TextCtrl.EnableEditing = true;
2965
                                }
2966
                                if (TextCtrl.TextStyle == FontStyles.Italic)
2967
                                {
2968
                                    ViewerDataModel.Instance.checkTextStyle = true;
2969
                                }
2970
                                else
2971
                                {
2972
                                    ViewerDataModel.Instance.checkTextStyle = false;
2973
                                }
2974
                                if (TextCtrl.TextWeight == FontWeights.Bold)
2975
                                {
2976
                                    ViewerDataModel.Instance.checkTextWeight = true;
2977
                                }
2978
                                else
2979
                                {
2980
                                    ViewerDataModel.Instance.checkTextWeight = false;
2981
                                }
2982
                                if (TextCtrl.UnderLine == TextDecorations.Underline)
2983
                                {
2984
                                    ViewerDataModel.Instance.checkUnderLine = true;
2985
                                }
2986
                                else
2987
                                {
2988
                                    ViewerDataModel.Instance.checkUnderLine = false;
2989
                                }
2990
                                ViewerDataModel.Instance.TextSize = TextCtrl.TextSize;
2991
                                ViewerDataModel.Instance.checkHighlight = TextCtrl.IsHighLight;
2992
                                ViewerDataModel.Instance.ArcLength = TextCtrl.ArcLength;
2993 d4b0c723 KangIngu
                            }
2994 e1b36bc0 humkyung
                            else if (control is ArrowTextControl ArrowTextCtrl)
2995 d4b0c723 KangIngu
                            {
2996 e1b36bc0 humkyung
                                ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2997
2998
                                if (!((control as ArrowTextControl).EnableEditing))
2999
                                {
3000
                                    ArrowTextCtrl.EnableEditing = true;
3001
                                }
3002
                                if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3003
                                {
3004
                                    ViewerDataModel.Instance.checkTextStyle = true;
3005
                                }
3006
                                else
3007
                                {
3008
                                    ViewerDataModel.Instance.checkTextStyle = false;
3009
                                }
3010
                                if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3011
                                {
3012
                                    ViewerDataModel.Instance.checkTextWeight = true;
3013
                                }
3014
                                else
3015
                                {
3016
                                    ViewerDataModel.Instance.checkTextWeight = false;
3017
                                }
3018
                                if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3019
                                {
3020
                                    ViewerDataModel.Instance.checkUnderLine = true;
3021
                                }
3022
                                else
3023
                                {
3024
                                    ViewerDataModel.Instance.checkUnderLine = false;
3025
                                }
3026
                                ViewerDataModel.Instance.checkHighlight = ArrowTextCtrl.isHighLight;
3027
                                ViewerDataModel.Instance.TextSize = ArrowTextCtrl.TextSize;
3028
                                ViewerDataModel.Instance.ArcLength = ArrowTextCtrl.ArcLength;
3029 e17af42b KangIngu
                            }
3030 e1b36bc0 humkyung
                            else if (control is RectCloudControl RectCloudCtrl)
3031 e17af42b KangIngu
                            {
3032 e1b36bc0 humkyung
                                ViewerDataModel.Instance.ArcLength = RectCloudCtrl.ArcLength;
3033 e17af42b KangIngu
                            }
3034 e1b36bc0 humkyung
                            else if (control is CloudControl CloudCtrl)
3035 e17af42b KangIngu
                            {
3036 e1b36bc0 humkyung
                                ViewerDataModel.Instance.ArcLength = CloudCtrl.ArcLength;
3037 d4b0c723 KangIngu
                            }
3038 9f473fb7 KangIngu
                        }
3039 787a4489 KangIngu
                    }
3040
                    else
3041
                    {
3042 e1b36bc0 humkyung
                        selection = SelectionSet.Instance.SelectItem(control, this, false);
3043 787a4489 KangIngu
                    }
3044
3045 e1b36bc0 humkyung
                    if (selection != null)
3046 f513c215 humkyung
                    {
3047 e1b36bc0 humkyung
                        this.SelectLayer.Children.Add(selection);
3048 f513c215 humkyung
                    }
3049 b643fcca taeseongkim
                }
3050 787a4489 KangIngu
            }
3051
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3052 233ef333 taeseongkim
            {
3053 787a4489 KangIngu
                init();
3054
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3055
                if (cursor != Cursors.SizeAll)
3056
                {
3057
                    cursor = Cursors.Cross;
3058
                    SetCursor();
3059
                }
3060
                bool init_user = false;
3061
                foreach (var user in gridViewMarkup.Items)
3062
                {
3063
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3064
                    {
3065
                        init_user = true;
3066
                    }
3067
                }
3068 5c3caba6 humkyung
                if (init_user && gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) == null && e.LeftButton == MouseButtonState.Pressed)
3069 787a4489 KangIngu
                {
3070 d7e20d2d taeseongkim
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3071 787a4489 KangIngu
                    RadWindow.Alert(new DialogParameters
3072
                    {
3073 b9b01f8e ljiyeon
                        Owner = Application.Current.MainWindow,
3074 787a4489 KangIngu
                        Theme = new VisualStudio2013Theme(),
3075 d7e20d2d taeseongkim
                        Header = "Info",
3076 f458ee80 이지연
                        Content = "Select a layer and write a comment.",//"Existing comments already existed. Select from the user list first",
3077 787a4489 KangIngu
                    });
3078
                    return;
3079
                }
3080
                else
3081
                {
3082 e31e5b1b humkyung
                    var item = gridViewMarkup.SelectedItems.FirstOrDefault(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID) as MarkupInfoItem;
3083 787a4489 KangIngu
                    if (item != null)
3084
                    {
3085
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3086
                    }
3087
                }
3088 1305c420 taeseongkim
                
3089 75448f5e ljiyeon
                switch (controlType)
3090 787a4489 KangIngu
                {
3091 684ef11c ljiyeon
                    case ControlType.Coordinate:
3092
                        {
3093 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3094 684ef11c ljiyeon
                            {
3095 5c3caba6 humkyung
                                if (currentControl is CoordinateControl coord)
3096 684ef11c ljiyeon
                                {
3097 5c3caba6 humkyung
                                    if (IsGetoutpoint(coord.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3098 684ef11c ljiyeon
                                    {
3099
                                        return;
3100
                                    }
3101
3102 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3103 684ef11c ljiyeon
3104
                                    currentControl = null;
3105
                                    this.cursor = Cursors.Arrow;
3106
                                }
3107
                                else
3108
                                {
3109
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3110 d62c0439 humkyung
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3111 5c3caba6 humkyung
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Any())
3112 684ef11c ljiyeon
                                    {
3113
                                        currentControl = null;
3114
                                        this.cursor = Cursors.Arrow;
3115
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3116
                                        return;
3117
                                    }
3118
                                    else
3119
                                    {
3120
                                        currentControl = new CoordinateControl
3121
                                        {
3122
                                            Background = new SolidColorBrush(Colors.Black),
3123 c7fde400 taeseongkim
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3124 684ef11c ljiyeon
                                            ControlType = ControlType.Coordinate
3125
                                        };
3126
3127 5a223b60 humkyung
                                        currentControl.CommentID = Commons.ShortGuid();
3128 684ef11c ljiyeon
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3129
                                        currentControl.IsNew = true;
3130
3131
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3132 5c3caba6 humkyung
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3133 684ef11c ljiyeon
                                    }
3134
                                }
3135
                            }
3136
                        }
3137
                        break;
3138 233ef333 taeseongkim
3139 684ef11c ljiyeon
                    case ControlType.InsideWhite:
3140
                        {
3141 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3142 684ef11c ljiyeon
                            {
3143 5c3caba6 humkyung
                                if (currentControl is InsideWhiteControl whitectrl)
3144 684ef11c ljiyeon
                                {
3145 5c3caba6 humkyung
                                    if (IsGetoutpoint(whitectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3146 684ef11c ljiyeon
                                    {
3147
                                        return;
3148
                                    }
3149
3150 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3151 684ef11c ljiyeon
3152
                                    currentControl = null;
3153
                                    this.cursor = Cursors.Arrow;
3154
                                }
3155
                                else
3156
                                {
3157
                                    currentControl = new InsideWhiteControl
3158
                                    {
3159
                                        Background = new SolidColorBrush(Colors.Black),
3160 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3161 684ef11c ljiyeon
                                        ControlType = ControlType.InsideWhite
3162
                                    };
3163
3164 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3165 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3166
                                    currentControl.IsNew = true;
3167
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3168
3169 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3170 684ef11c ljiyeon
                                }
3171
                            }
3172
                        }
3173
                        break;
3174 233ef333 taeseongkim
3175 684ef11c ljiyeon
                    case ControlType.OverlapWhite:
3176
                        {
3177 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3178 684ef11c ljiyeon
                            {
3179
                                if (currentControl is OverlapWhiteControl)
3180
                                {
3181
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3182
                                    {
3183
                                        return;
3184
                                    }
3185
3186 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3187 684ef11c ljiyeon
3188
                                    currentControl = null;
3189
                                    this.cursor = Cursors.Arrow;
3190
                                }
3191
                                else
3192
                                {
3193
                                    currentControl = new OverlapWhiteControl
3194
                                    {
3195
                                        Background = new SolidColorBrush(Colors.Black),
3196 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3197 684ef11c ljiyeon
                                        ControlType = ControlType.OverlapWhite
3198
                                    };
3199
3200 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3201 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3202
                                    currentControl.IsNew = true;
3203
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3204
3205 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3206 684ef11c ljiyeon
                                }
3207
                            }
3208
                        }
3209
                        break;
3210 233ef333 taeseongkim
3211 684ef11c ljiyeon
                    case ControlType.ClipWhite:
3212
                        {
3213 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3214 684ef11c ljiyeon
                            {
3215
                                if (currentControl is ClipWhiteControl)
3216
                                {
3217
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3218
                                    {
3219
                                        return;
3220
                                    }
3221
3222 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3223 684ef11c ljiyeon
3224
                                    currentControl = null;
3225
                                    this.cursor = Cursors.Arrow;
3226
                                }
3227
                                else
3228
                                {
3229
                                    currentControl = new ClipWhiteControl
3230
                                    {
3231
                                        Background = new SolidColorBrush(Colors.Black),
3232 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3233 684ef11c ljiyeon
                                        ControlType = ControlType.ClipWhite
3234
                                    };
3235
3236 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3237 684ef11c ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3238
                                    currentControl.IsNew = true;
3239
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3240
3241 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3242 684ef11c ljiyeon
                                }
3243
                            }
3244
                        }
3245
                        break;
3246 233ef333 taeseongkim
3247 787a4489 KangIngu
                    case ControlType.Rectangle:
3248
                        {
3249 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3250 787a4489 KangIngu
                            {
3251 5c3caba6 humkyung
                                if (currentControl is RectangleControl rectctrl)
3252 f67f164e humkyung
                                {
3253
                                    //20180906 LJY TEST IsRotationDrawingEnable
3254 5c3caba6 humkyung
                                    if (IsGetoutpoint(rectctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3255 787a4489 KangIngu
                                    {
3256 f67f164e humkyung
                                        return;
3257
                                    }
3258 787a4489 KangIngu
3259 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3260
                                    currentControl = null;
3261 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3262 f67f164e humkyung
                                }
3263
                                else
3264
                                {
3265
                                    currentControl = new RectangleControl
3266 787a4489 KangIngu
                                    {
3267 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black),
3268 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3269 f67f164e humkyung
                                        ControlType = ControlType.Rectangle
3270
                                    };
3271 787a4489 KangIngu
3272 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3273 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3274
                                    currentControl.IsNew = true;
3275
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3276 787a4489 KangIngu
3277 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3278 f67f164e humkyung
                                }
3279 787a4489 KangIngu
                            }
3280
                        }
3281
                        break;
3282 233ef333 taeseongkim
3283 787a4489 KangIngu
                    case ControlType.RectCloud:
3284
                        {
3285 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3286 787a4489 KangIngu
                            {
3287 5c3caba6 humkyung
                                if (currentControl is RectCloudControl rectcloudctrl)
3288 f67f164e humkyung
                                {
3289
                                    //20180906 LJY TEST IsRotationDrawingEnable
3290 5c3caba6 humkyung
                                    if (IsGetoutpoint(rectcloudctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3291 787a4489 KangIngu
                                    {
3292 f67f164e humkyung
                                        return;
3293
                                    }
3294 e66f22eb KangIngu
3295 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3296 787a4489 KangIngu
3297 f67f164e humkyung
                                    currentControl = null;
3298 233ef333 taeseongkim
3299 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3300 f67f164e humkyung
                                }
3301
                                else
3302
                                {
3303
                                    currentControl = new RectCloudControl
3304 787a4489 KangIngu
                                    {
3305 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3306 f67f164e humkyung
                                        ControlType = ControlType.RectCloud,
3307
                                        Background = new SolidColorBrush(Colors.Black)
3308
                                    };
3309 787a4489 KangIngu
3310 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3311 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3312 f67f164e humkyung
                                    currentControl.IsNew = true;
3313
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3314 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3315 f67f164e humkyung
                                }
3316 787a4489 KangIngu
                            }
3317
                        }
3318
                        break;
3319 233ef333 taeseongkim
3320 787a4489 KangIngu
                    case ControlType.Circle:
3321
                        {
3322 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3323 787a4489 KangIngu
                            {
3324 5c3caba6 humkyung
                                if (currentControl is CircleControl circlectrl)
3325 f67f164e humkyung
                                {
3326
                                    //20180906 LJY TEST IsRotationDrawingEnable
3327 5c3caba6 humkyung
                                    if (IsGetoutpoint(circlectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3328 787a4489 KangIngu
                                    {
3329 f67f164e humkyung
                                        return;
3330
                                    }
3331 e66f22eb KangIngu
3332 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3333 787a4489 KangIngu
3334 f67f164e humkyung
                                    currentControl = null;
3335
                                }
3336
                                else
3337
                                {
3338
                                    currentControl = new CircleControl
3339 787a4489 KangIngu
                                    {
3340 c7fde400 taeseongkim
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3341
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3342 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black)
3343
                                    };
3344 787a4489 KangIngu
3345 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3346 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3347 f67f164e humkyung
                                    currentControl.IsNew = true;
3348
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3349 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3350 f67f164e humkyung
                                }
3351 787a4489 KangIngu
                            }
3352
                        }
3353
                        break;
3354 233ef333 taeseongkim
3355 787a4489 KangIngu
                    case ControlType.Triangle:
3356
                        {
3357 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3358 787a4489 KangIngu
                            {
3359 5c3caba6 humkyung
                                if (currentControl is TriControl trictrl)
3360 f67f164e humkyung
                                {
3361 5c3caba6 humkyung
                                    if (trictrl.MidPoint == new Point(0, 0))
3362 787a4489 KangIngu
                                    {
3363 5c3caba6 humkyung
                                        trictrl.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3364 787a4489 KangIngu
                                    }
3365
                                    else
3366
                                    {
3367 ca40e004 ljiyeon
                                        //20180906 LJY TEST IsRotationDrawingEnable
3368 5c3caba6 humkyung
                                        if (IsGetoutpoint(trictrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3369 e66f22eb KangIngu
                                        {
3370
                                            return;
3371
                                        }
3372
3373 f513c215 humkyung
                                        CreateCommand.Instance.Execute(currentControl);
3374 787a4489 KangIngu
3375
                                        currentControl = null;
3376
                                    }
3377 f67f164e humkyung
                                }
3378
                                else
3379
                                {
3380
                                    currentControl = new TriControl
3381 787a4489 KangIngu
                                    {
3382 1a7a7e62 이지연
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3383 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black),
3384
                                    };
3385 787a4489 KangIngu
3386 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3387 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3388 f67f164e humkyung
                                    currentControl.IsNew = true;
3389
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3390 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3391 f67f164e humkyung
                                }
3392 787a4489 KangIngu
                            }
3393
                        }
3394
                        break;
3395
                    case ControlType.CancelLine:
3396 f67f164e humkyung
                    case ControlType.SingleLine:
3397
                    case ControlType.ArrowLine:
3398
                    case ControlType.TwinLine:
3399
                    case ControlType.DimLine:
3400 787a4489 KangIngu
                        {
3401 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3402 787a4489 KangIngu
                            {
3403 5c3caba6 humkyung
                                if (currentControl is LineControl linectrl)
3404 f67f164e humkyung
                                {
3405
                                    //20180906 LJY TEST IsRotationDrawingEnable
3406 5c3caba6 humkyung
                                    if (IsGetoutpoint(linectrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3407 787a4489 KangIngu
                                    {
3408 f67f164e humkyung
                                        return;
3409 787a4489 KangIngu
                                    }
3410 f67f164e humkyung
3411
                                    CreateCommand.Instance.Execute(currentControl);
3412
                                    currentControl = null;
3413 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3414 f67f164e humkyung
                                }
3415
                                else
3416
                                {
3417
                                    currentControl = new LineControl
3418 787a4489 KangIngu
                                    {
3419 f67f164e humkyung
                                        ControlType = this.controlType,
3420 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3421 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black)
3422
                                    };
3423 787a4489 KangIngu
3424 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3425 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3426 f67f164e humkyung
                                    currentControl.IsNew = true;
3427
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3428 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3429 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3430 f67f164e humkyung
                                }
3431 787a4489 KangIngu
                            }
3432
                        }
3433
                        break;
3434 f67f164e humkyung
                    case ControlType.PolygonControl:
3435 787a4489 KangIngu
                        {
3436 5c3caba6 humkyung
                            if (currentControl is PolygonControl polygonctrl)
3437 787a4489 KangIngu
                            {
3438 f67f164e humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
3439
                                {
3440 5c3caba6 humkyung
                                    polygonctrl.IsCompleted = true;
3441 f67f164e humkyung
                                }
3442 787a4489 KangIngu
3443 5c3caba6 humkyung
                                if (!polygonctrl.IsCompleted)
3444 f67f164e humkyung
                                {
3445 5c3caba6 humkyung
                                    polygonctrl.PointSet.Add(polygonctrl.EndPoint);
3446 f67f164e humkyung
                                }
3447
                                else
3448
                                {
3449
                                    //20180906 LJY TEST IsRotationDrawingEnable
3450 5c3caba6 humkyung
                                    if (IsGetoutpoint(polygonctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3451 787a4489 KangIngu
                                    {
3452 f67f164e humkyung
                                        return;
3453 787a4489 KangIngu
                                    }
3454 e66f22eb KangIngu
3455 5c3caba6 humkyung
                                    var firstPoint = polygonctrl.PointSet.First();
3456
                                    polygonctrl.DashSize = ViewerDataModel.Instance.DashSize;
3457
                                    polygonctrl.LineSize = ViewerDataModel.Instance.LineSize;
3458
                                    polygonctrl.PointSet.Add(firstPoint);
3459 787a4489 KangIngu
3460 5c3caba6 humkyung
                                    polygonctrl.ApplyOverViewData();
3461 f67f164e humkyung
3462
                                    CreateCommand.Instance.Execute(currentControl);
3463 5c3caba6 humkyung
                                    polygonctrl.UpdateControl();
3464 f67f164e humkyung
                                    currentControl = null;
3465
                                }
3466 787a4489 KangIngu
                            }
3467 f67f164e humkyung
                            else
3468 787a4489 KangIngu
                            {
3469 f67f164e humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3470
                                {
3471
                                    currentControl = new PolygonControl
3472 787a4489 KangIngu
                                    {
3473 f67f164e humkyung
                                        PointSet = new List<Point>(),
3474
                                    };
3475 787a4489 KangIngu
3476 f67f164e humkyung
                                    var polygonControl = (currentControl as PolygonControl);
3477 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3478 f67f164e humkyung
                                    currentControl.IsNew = true;
3479
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3480 c7fde400 taeseongkim
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3481
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3482
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3483
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3484 f67f164e humkyung
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3485
                                    polygonControl.ApplyTemplate();
3486
                                    polygonControl.Visibility = Visibility.Visible;
3487 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3488 f67f164e humkyung
                                }
3489 787a4489 KangIngu
                            }
3490
                        }
3491
                        break;
3492
                    case ControlType.ChainLine:
3493
                        {
3494
                            if (currentControl is PolygonControl)
3495
                            {
3496
                                var control = currentControl as PolygonControl;
3497
3498 e6a9ddaf humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
3499 787a4489 KangIngu
                                {
3500 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3501
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3502 e66f22eb KangIngu
                                    {
3503
                                        return;
3504
                                    }
3505
3506 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3507 787a4489 KangIngu
3508
                                    currentControl = null;
3509 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3510 787a4489 KangIngu
                                    return;
3511
                                }
3512
3513
                                if (!control.IsCompleted)
3514
                                {
3515
                                    control.PointSet.Add(control.EndPoint);
3516 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3517 787a4489 KangIngu
                                }
3518
                            }
3519
                            else
3520
                            {
3521 e6a9ddaf humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3522 787a4489 KangIngu
                                {
3523 2eac4f76 KangIngu
                                    MainAngle.Visibility = Visibility.Visible;
3524 787a4489 KangIngu
                                    currentControl = new PolygonControl
3525
                                    {
3526
                                        PointSet = new List<Point>(),
3527
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3528
                                        ControlType = ControlType.ChainLine,
3529
                                        DashSize = ViewerDataModel.Instance.DashSize,
3530
                                        LineSize = ViewerDataModel.Instance.LineSize,
3531
                                        //PointC = new StylusPointSet()
3532
                                    };
3533
3534 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3535
                                    //{
3536 233ef333 taeseongkim
                                    var polygonControl = (currentControl as PolygonControl);
3537 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3538 233ef333 taeseongkim
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3539
                                    currentControl.IsNew = true;
3540
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3541
                                    //currentControl.OnApplyTemplate();
3542
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3543
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3544
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3545
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3546 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3547 e66f22eb KangIngu
                                    //}
3548 787a4489 KangIngu
                                }
3549
                            }
3550
                        }
3551
                        break;
3552
                    case ControlType.ArcLine:
3553
                        {
3554 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3555 787a4489 KangIngu
                            {
3556 5c3caba6 humkyung
                                if (currentControl is ArcControl arcctrl)
3557 f67f164e humkyung
                                {
3558
                                    //20180906 LJY TEST IsRotationDrawingEnable
3559 5c3caba6 humkyung
                                    if (IsGetoutpoint(arcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3560 787a4489 KangIngu
                                    {
3561 f67f164e humkyung
                                        return;
3562
                                    }
3563 e66f22eb KangIngu
3564 f67f164e humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3565 787a4489 KangIngu
3566 f67f164e humkyung
                                    currentControl = null;
3567 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3568 f67f164e humkyung
                                }
3569
                                else
3570
                                {
3571
                                    currentControl = new ArcControl
3572 787a4489 KangIngu
                                    {
3573 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3574 f67f164e humkyung
                                        Background = new SolidColorBrush(Colors.Black)
3575
                                    };
3576 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3577 f67f164e humkyung
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3578
                                    currentControl.IsNew = true;
3579
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3580 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3581 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3582 f67f164e humkyung
                                }
3583 787a4489 KangIngu
                            }
3584 e6a9ddaf humkyung
                            else if (e.RightButton == MouseButtonState.Pressed)
3585 787a4489 KangIngu
                            {
3586
                                if (currentControl != null)
3587
                                {
3588
                                    (currentControl as ArcControl).setClock();
3589 05f4d127 KangIngu
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3590 787a4489 KangIngu
                                }
3591
                            }
3592
                        }
3593
                        break;
3594
                    case ControlType.ArcArrow:
3595
                        {
3596 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3597 787a4489 KangIngu
                            {
3598 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3599
                                //{
3600 5c3caba6 humkyung
                                if (currentControl is ArrowArcControl arrowarcctrl)
3601 40b3ce25 ljiyeon
                                {
3602
                                    //20180906 LJY TEST IsRotationDrawingEnable
3603 5c3caba6 humkyung
                                    if (IsGetoutpoint(arrowarcctrl.PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3604 787a4489 KangIngu
                                    {
3605 40b3ce25 ljiyeon
                                        return;
3606
                                    }
3607 e66f22eb KangIngu
3608 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3609 787a4489 KangIngu
3610 40b3ce25 ljiyeon
                                    currentControl = null;
3611 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3612 40b3ce25 ljiyeon
                                }
3613
                                else
3614
                                {
3615
                                    currentControl = new ArrowArcControl
3616 787a4489 KangIngu
                                    {
3617 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3618 40b3ce25 ljiyeon
                                        Background = new SolidColorBrush(Colors.Black)
3619
                                    };
3620 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3621 40b3ce25 ljiyeon
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3622
                                    currentControl.IsNew = true;
3623
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3624 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3625 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3626 40b3ce25 ljiyeon
                                }
3627 e66f22eb KangIngu
                                //}
3628 787a4489 KangIngu
                            }
3629 e6a9ddaf humkyung
                            else if (e.RightButton == MouseButtonState.Pressed)
3630 787a4489 KangIngu
                            {
3631 40b3ce25 ljiyeon
                                if (currentControl != null)
3632
                                {
3633
                                    (currentControl as ArrowArcControl).setClock();
3634 24c5e56c taeseongkim
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3635 40b3ce25 ljiyeon
                                    //(currentControl as ArcControl).ApplyTemplate();
3636
                                }
3637 787a4489 KangIngu
                            }
3638
                        }
3639
                        break;
3640
                    case ControlType.ArrowMultiLine:
3641
                        {
3642 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3643 787a4489 KangIngu
                            {
3644 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3645
                                //{
3646 233ef333 taeseongkim
                                if (currentControl is ArrowControl_Multi)
3647
                                {
3648
                                    var content = currentControl as ArrowControl_Multi;
3649
                                    if (content.MiddlePoint == new Point(0, 0))
3650 787a4489 KangIngu
                                    {
3651 233ef333 taeseongkim
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3652 787a4489 KangIngu
                                        {
3653 233ef333 taeseongkim
                                            content.MiddlePoint = content.EndPoint;
3654 787a4489 KangIngu
                                        }
3655
                                        else
3656
                                        {
3657 233ef333 taeseongkim
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3658 787a4489 KangIngu
                                        }
3659
                                    }
3660
                                    else
3661
                                    {
3662 233ef333 taeseongkim
                                        //20180906 LJY TEST IsRotationDrawingEnable
3663
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3664 787a4489 KangIngu
                                        {
3665 233ef333 taeseongkim
                                            return;
3666
                                        }
3667
3668
                                        CreateCommand.Instance.Execute(currentControl);
3669
3670
                                        currentControl = null;
3671
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3672 787a4489 KangIngu
                                    }
3673 233ef333 taeseongkim
                                }
3674
                                else
3675
                                {
3676
                                    currentControl = new ArrowControl_Multi
3677
                                    {
3678
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3679
                                        Background = new SolidColorBrush(Colors.Black)
3680
                                    };
3681 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3682 233ef333 taeseongkim
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3683
                                    currentControl.IsNew = true;
3684
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3685
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3686 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3687 233ef333 taeseongkim
                                }
3688 e66f22eb KangIngu
                                //}
3689 787a4489 KangIngu
                            }
3690
                        }
3691
                        break;
3692
                    case ControlType.PolygonCloud:
3693
                        {
3694
                            if (currentControl is CloudControl)
3695
                            {
3696
                                var control = currentControl as CloudControl;
3697 e6a9ddaf humkyung
                                if (e.RightButton == MouseButtonState.Pressed)
3698 787a4489 KangIngu
                                {
3699
                                    control.IsCompleted = true;
3700
                                }
3701
3702
                                if (!control.IsCompleted)
3703
                                {
3704
                                    control.PointSet.Add(control.EndPoint);
3705
                                }
3706
                                else
3707
                                {
3708 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
3709 5c3caba6 humkyung
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.FirstOrDefault(data => IsRotationDrawingEnable(data) == true)))
3710 e66f22eb KangIngu
                                    {
3711
                                        return;
3712
                                    }
3713
3714 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3715 787a4489 KangIngu
3716
                                    control.isTransOn = true;
3717
                                    var firstPoint = control.PointSet.First();
3718
3719
                                    control.PointSet.Add(firstPoint);
3720
                                    control.DrawingCloud();
3721
                                    control.ApplyOverViewData();
3722
3723
                                    currentControl = null;
3724
                                }
3725
                            }
3726
                            else
3727
                            {
3728 e6a9ddaf humkyung
                                if (e.LeftButton == MouseButtonState.Pressed)
3729 787a4489 KangIngu
                                {
3730
                                    currentControl = new CloudControl
3731
                                    {
3732
                                        PointSet = new List<Point>(),
3733
                                        PointC = new StylusPointSet()
3734
                                    };
3735
3736 233ef333 taeseongkim
                                    var polygonControl = (currentControl as CloudControl);
3737 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3738 233ef333 taeseongkim
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3739
                                    currentControl.IsNew = true;
3740
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3741
3742
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3743
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3744 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3745 787a4489 KangIngu
                                }
3746
                            }
3747
                        }
3748
                        break;
3749 233ef333 taeseongkim
3750 787a4489 KangIngu
                    case ControlType.ImgControl:
3751
                        {
3752 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3753 787a4489 KangIngu
                            {
3754 233ef333 taeseongkim
                                if (currentControl is ImgControl)
3755
                                {
3756
                                    //20180906 LJY TEST IsRotationDrawingEnable
3757 e31e5b1b humkyung
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Find(data => IsRotationDrawingEnable(data))))
3758 787a4489 KangIngu
                                    {
3759 233ef333 taeseongkim
                                        return;
3760 787a4489 KangIngu
                                    }
3761 233ef333 taeseongkim
3762
                                    CreateCommand.Instance.Execute(currentControl);
3763
                                    controlType = ControlType.ImgControl;
3764
                                    currentControl = null;
3765
                                }
3766
                                else
3767
                                {
3768
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3769
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3770 787a4489 KangIngu
                                    {
3771 b42dd24d taeseongkim
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3772
                                        UriBuilder uri = new UriBuilder(filename);
3773
                                        uri.Host = downloadUri.Host;
3774
                                        uri.Port = downloadUri.Port;
3775
3776 233ef333 taeseongkim
                                        Image img = new Image();
3777
                                        if (filename.Contains(".svg"))
3778 787a4489 KangIngu
                                        {
3779 f1f822e9 taeseongkim
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3780
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3781 233ef333 taeseongkim
                                        }
3782
                                        else
3783
                                        {
3784 b42dd24d taeseongkim
                                            img.Source = new BitmapImage(uri.Uri);
3785 233ef333 taeseongkim
                                        }
3786 787a4489 KangIngu
3787 233ef333 taeseongkim
                                        currentControl = new ImgControl
3788
                                        {
3789
                                            Background = new SolidColorBrush(Colors.Black),
3790
                                            PointSet = new List<Point>(),
3791 b42dd24d taeseongkim
                                            FilePath = uri.Uri.ToString(),
3792 233ef333 taeseongkim
                                            ImageData = img.Source,
3793
                                            StartPoint = CanvasDrawingMouseDownPoint,
3794
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3795
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3796
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3797
                                            ControlType = ControlType.ImgControl
3798
                                        };
3799
3800 5a223b60 humkyung
                                        currentControl.CommentID = Commons.ShortGuid();
3801 233ef333 taeseongkim
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3802
                                        currentControl.IsNew = true;
3803
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3804
3805
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3806 fa48eb85 taeseongkim
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3807 5c3caba6 humkyung
                                        currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3808 fa48eb85 taeseongkim
                                    }
3809 233ef333 taeseongkim
                                }
3810 787a4489 KangIngu
                            }
3811
                        }
3812
                        break;
3813 233ef333 taeseongkim
3814 787a4489 KangIngu
                    case ControlType.Date:
3815
                        {
3816 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3817 787a4489 KangIngu
                            {
3818 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3819
                                //{
3820 6b6e937c taeseongkim
                                if (currentControl is DateControl)
3821
                                {
3822
                                    //20180906 LJY TEST IsRotationDrawingEnable
3823
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3824 787a4489 KangIngu
                                    {
3825 6b6e937c taeseongkim
                                        return;
3826
                                    }
3827 e66f22eb KangIngu
3828 6b6e937c taeseongkim
                                    CreateCommand.Instance.Execute(currentControl);
3829
                                    currentControl = null;
3830 787a4489 KangIngu
3831 6b6e937c taeseongkim
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3832 b74a9c91 taeseongkim
                                    { 
3833 6b6e937c taeseongkim
                                        controlType = ControlType.None;
3834
                                        IsSwingMode = false;
3835
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3836
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3837
                                        mouseHandlingMode = MouseHandlingMode.None;
3838
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3839
                                        txtBatch.Visibility = Visibility.Collapsed;
3840 787a4489 KangIngu
                                    }
3841 6b6e937c taeseongkim
                                }
3842
                                else
3843
                                {
3844
                                    currentControl = new DateControl
3845 787a4489 KangIngu
                                    {
3846 6b6e937c taeseongkim
                                        StartPoint = CanvasDrawingMouseDownPoint,
3847
                                        Background = new SolidColorBrush(Colors.Black)
3848
                                    };
3849 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3850 6b6e937c taeseongkim
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3851
                                    currentControl.IsNew = true;
3852
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3853 ca40e004 ljiyeon
3854 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3855 6b6e937c taeseongkim
                                    if (currentControl is ImgControl)
3856
                                    {
3857 fa48eb85 taeseongkim
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3858 6b6e937c taeseongkim
                                    }
3859 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3860 ca40e004 ljiyeon
                                }
3861 e66f22eb KangIngu
                                //}
3862 787a4489 KangIngu
                            }
3863
                        }
3864
                        break;
3865 233ef333 taeseongkim
3866 787a4489 KangIngu
                    case ControlType.TextControl:
3867
                        {
3868 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3869 787a4489 KangIngu
                            {
3870
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3871
                                {
3872
                                    currentControl = new TextControl
3873
                                    {
3874
                                        ControlType = controlType
3875
                                    };
3876 14963423 swate0609
                                    
3877 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3878 8742caa5 humkyung
                                    currentControl.IsNew = true;
3879
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3880
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3881 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3882 c7fde400 taeseongkim
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3883
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3884 233ef333 taeseongkim
3885 14963423 swate0609
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3886
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3887 8742caa5 humkyung
                                    (currentControl as TextControl).ControlType_No = 0;
3888 fa48eb85 taeseongkim
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3889 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3890
                                    (currentControl as TextControl).Base_TextBox.Focus();
3891 4fcb686a taeseongkim
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3892 9380813b swate0609
3893
                                    if(previousControl == null)
3894
                                    {
3895
                                        previousControl = currentControl as TextControl;
3896
                                    }
3897
                                    else
3898
                                    {
3899
                                        var vPreviousControl = previousControl as TextControl;
3900
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3901
                                        {
3902 34ac8db7 humkyung
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3903 9380813b swate0609
                                            previousControl = null;
3904
                                        }
3905
                                        else
3906
                                        {
3907
                                            previousControl = currentControl as TextControl;
3908
                                        }
3909
                                    }
3910 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3911 9380813b swate0609
                                    if (previousControl == null)
3912
                                        previousControl = currentControl;
3913 787a4489 KangIngu
                                }
3914
                            }
3915
                        }
3916
                        break;
3917 233ef333 taeseongkim
3918 787a4489 KangIngu
                    case ControlType.TextBorder:
3919
                        {
3920 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3921 787a4489 KangIngu
                            {
3922
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3923
                                {
3924
                                    currentControl = new TextControl
3925
                                    {
3926
                                        ControlType = controlType
3927
                                    };
3928
3929 610a4b86 KangIngu
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3930 787a4489 KangIngu
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3931 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3932 787a4489 KangIngu
                                    currentControl.IsNew = true;
3933
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3934 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3935 c7fde400 taeseongkim
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3936
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3937 233ef333 taeseongkim
3938 787a4489 KangIngu
                                    (currentControl as TextControl).ControlType_No = 1;
3939 fa48eb85 taeseongkim
                                    (currentControl as TextControl).CommentAngle = Ang;
3940 787a4489 KangIngu
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3941 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3942
                                    (currentControl as TextControl).Base_TextBox.Focus();
3943 4fcb686a taeseongkim
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3944 7b031678 swate0609
3945
                                    if (previousControl == null)
3946
                                    {
3947
                                        previousControl = currentControl as TextControl;
3948
                                    }
3949
                                    else
3950
                                    {
3951
                                        var vPreviousControl = previousControl as TextControl;
3952
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3953
                                        {
3954 34ac8db7 humkyung
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
3955 7b031678 swate0609
                                            previousControl = null;
3956
                                        }
3957
                                        else
3958
                                        {
3959
                                            previousControl = currentControl as TextControl;
3960
                                        }
3961
                                    }
3962 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
3963 7b031678 swate0609
                                    if (previousControl == null)
3964
                                        previousControl = currentControl;
3965 787a4489 KangIngu
                                }
3966
                            }
3967
                        }
3968
                        break;
3969 233ef333 taeseongkim
3970 787a4489 KangIngu
                    case ControlType.TextCloud:
3971
                        {
3972 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
3973 787a4489 KangIngu
                            {
3974
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3975
                                {
3976
                                    currentControl = new TextControl
3977
                                    {
3978
                                        ControlType = controlType
3979
                                    };
3980 610a4b86 KangIngu
3981
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3982 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
3983 787a4489 KangIngu
                                    currentControl.IsNew = true;
3984
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3985
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3986
3987 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
3988 c7fde400 taeseongkim
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3989
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3990 787a4489 KangIngu
3991 fa48eb85 taeseongkim
                                    (currentControl as TextControl).CommentAngle = Ang;
3992 787a4489 KangIngu
                                    (currentControl as TextControl).ControlType_No = 2;
3993
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3994 666bb823 이지연
                                    (currentControl as TextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
3995 6b5d33c6 djkim
                                    (currentControl as TextControl).ApplyTemplate();
3996 666bb823 이지연
                                    
3997 4fcb686a taeseongkim
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3998
3999 6b5d33c6 djkim
                                    (currentControl as TextControl).Base_TextBox.Focus();
4000 7b031678 swate0609
                                    if (previousControl == null)
4001
                                    {
4002
                                        previousControl = currentControl as TextControl;
4003
                                    }
4004
                                    else
4005
                                    {
4006
                                        var vPreviousControl = previousControl as TextControl;
4007
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
4008
                                        {
4009 34ac8db7 humkyung
                                            UndoCommand.Instance.Push(EventType.Delete, new[] { previousControl });
4010 7b031678 swate0609
                                            previousControl = null;
4011
                                        }
4012
                                        else
4013
                                        {
4014
                                            previousControl = currentControl as TextControl;
4015
                                        }
4016
                                    }
4017 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4018 7b031678 swate0609
                                    if (previousControl == null)
4019
                                        previousControl = currentControl;
4020
4021 49b217ad humkyung
                                    //currentControl = null;
4022 787a4489 KangIngu
                                }
4023
                            }
4024
                        }
4025
                        break;
4026 233ef333 taeseongkim
4027 787a4489 KangIngu
                    case ControlType.ArrowTextControl:
4028 233ef333 taeseongkim
                        {
4029 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4030 787a4489 KangIngu
                            {
4031
                                if (currentControl is ArrowTextControl)
4032
                                {
4033 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4034
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4035 e66f22eb KangIngu
                                    {
4036
                                        return;
4037 f513c215 humkyung
                                    }
4038 e66f22eb KangIngu
4039 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4040 1305c420 taeseongkim
4041 b74a9c91 taeseongkim
                                    try
4042
                                    {
4043 1305c420 taeseongkim
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
4044
                                        {
4045
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4046
                                        }
4047 b74a9c91 taeseongkim
                                    }
4048
                                    catch (Exception ex)
4049
                                    {
4050
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4051
                                    }
4052 7ad417d8 이지연
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4053 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4054
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4055 49b217ad humkyung
                                    (currentControl as ArrowTextControl).IsNew = false;
4056 787a4489 KangIngu
                                    currentControl = null;
4057
                                }
4058
                                else
4059
                                {
4060 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4061
                                    //{
4062 907a99b3 taeseongkim
                                    currentControl = new ArrowTextControl()
4063
                                    {
4064
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4065
                                    };
4066
4067 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4068 233ef333 taeseongkim
                                    currentControl.IsNew = true;
4069
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4070 1305c420 taeseongkim
4071
                                    try
4072
                                    {
4073
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4074
                                    }
4075
                                    catch (Exception ex)
4076
                                    {
4077
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4078
                                    }
4079 787a4489 KangIngu
4080 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4081 233ef333 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4082
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4083
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4084
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4085 787a4489 KangIngu
4086 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4087 fa48eb85 taeseongkim
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4088 787a4489 KangIngu
4089 fa48eb85 taeseongkim
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4090 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4091 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4092 233ef333 taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4093 ca40e004 ljiyeon
4094 e66f22eb KangIngu
                                    //}
4095 787a4489 KangIngu
                                }
4096
                            }
4097
                        }
4098
                        break;
4099 233ef333 taeseongkim
4100 787a4489 KangIngu
                    case ControlType.ArrowTransTextControl:
4101
                        {
4102 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4103 787a4489 KangIngu
                            {
4104
                                if (currentControl is ArrowTextControl)
4105
                                {
4106 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4107
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4108 e66f22eb KangIngu
                                    {
4109
                                        return;
4110 f513c215 humkyung
                                    }
4111 e66f22eb KangIngu
4112 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4113 55d4f382 송근호
4114 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4115 233ef333 taeseongkim
4116 49b217ad humkyung
                                    currentControl.IsNew = false;
4117 787a4489 KangIngu
                                    currentControl = null;
4118 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4119 787a4489 KangIngu
                                }
4120
                                else
4121
                                {
4122 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4123
                                    //{
4124 120b8b00 송근호
                                    currentControl = new ArrowTextControl()
4125
                                    {
4126 907a99b3 taeseongkim
                                        ControlType = ControlType.ArrowTransTextControl,
4127
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4128 120b8b00 송근호
                                    };
4129 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4130 120b8b00 송근호
                                    currentControl.IsNew = true;
4131
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4132
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4133 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4134 c7fde400 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4135 233ef333 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4136 120b8b00 송근호
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4137
                                    (currentControl as ArrowTextControl).isFixed = true;
4138
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4139 787a4489 KangIngu
4140 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4141 fa48eb85 taeseongkim
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4142 ca40e004 ljiyeon
4143 120b8b00 송근호
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4144
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4145
                                    (currentControl as ArrowTextControl).isTrans = true;
4146 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4147 787a4489 KangIngu
                                }
4148
                            }
4149
                        }
4150
                        break;
4151 233ef333 taeseongkim
4152 787a4489 KangIngu
                    case ControlType.ArrowTextBorderControl:
4153 233ef333 taeseongkim
                        {
4154 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4155 787a4489 KangIngu
                            {
4156
                                if (currentControl is ArrowTextControl)
4157
                                {
4158 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4159
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4160 e66f22eb KangIngu
                                    {
4161
                                        return;
4162
                                    }
4163
4164 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4165 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4166 49b217ad humkyung
                                    currentControl.IsNew = false;
4167 787a4489 KangIngu
                                    currentControl = null;
4168 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4169 787a4489 KangIngu
                                }
4170
                                else
4171
                                {
4172 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4173
                                    //{
4174 233ef333 taeseongkim
                                    currentControl = new ArrowTextControl()
4175
                                    {
4176 907a99b3 taeseongkim
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4177
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4178 233ef333 taeseongkim
                                    };
4179 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4180 233ef333 taeseongkim
                                    currentControl.IsNew = true;
4181
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4182
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4183 787a4489 KangIngu
4184 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4185 233ef333 taeseongkim
4186
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4187 787a4489 KangIngu
4188 233ef333 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4189
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4190
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4191 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4192 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4193
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4194
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4195
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4196
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4197 e66f22eb KangIngu
                                    //}
4198 787a4489 KangIngu
                                }
4199
                            }
4200
                        }
4201
                        break;
4202 233ef333 taeseongkim
4203 787a4489 KangIngu
                    case ControlType.ArrowTransTextBorderControl:
4204
                        {
4205 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4206 787a4489 KangIngu
                            {
4207
                                if (currentControl is ArrowTextControl)
4208
                                {
4209 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4210
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4211 e66f22eb KangIngu
                                    {
4212
                                        return;
4213
                                    }
4214 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4215 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4216 49b217ad humkyung
                                    currentControl.IsNew = false;
4217 787a4489 KangIngu
                                    currentControl = null;
4218 55d4f382 송근호
4219 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4220 787a4489 KangIngu
                                }
4221
                                else
4222
                                {
4223 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4224
                                    //{
4225 ca40e004 ljiyeon
                                    currentControl = new ArrowTextControl()
4226 120b8b00 송근호
                                    {
4227
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4228 4f017ed3 taeseongkim
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4229
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4230 120b8b00 송근호
                                    };
4231 4f017ed3 taeseongkim
                                    
4232 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4233 233ef333 taeseongkim
                                    currentControl.IsNew = true;
4234
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4235
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4236 787a4489 KangIngu
4237 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4238 233ef333 taeseongkim
4239
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4240
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4241
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4242
                                    (currentControl as ArrowTextControl).isFixed = true;
4243
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4244
4245
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4246
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4247
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4248 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4249 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4250
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4251 787a4489 KangIngu
4252 ca40e004 ljiyeon
                                    //20180911 LJY
4253 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).isTrans = true;
4254 ca40e004 ljiyeon
4255 e66f22eb KangIngu
                                    //}
4256 787a4489 KangIngu
                                }
4257
                            }
4258
                        }
4259
                        break;
4260 233ef333 taeseongkim
4261 787a4489 KangIngu
                    case ControlType.ArrowTextCloudControl:
4262
                        {
4263 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4264 787a4489 KangIngu
                            {
4265
                                if (currentControl is ArrowTextControl)
4266
                                {
4267 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4268
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4269 e66f22eb KangIngu
                                    {
4270
                                        return;
4271
                                    }
4272 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4273 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4274 49b217ad humkyung
                                    currentControl.IsNew = false;
4275 787a4489 KangIngu
                                    currentControl = null;
4276 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4277 787a4489 KangIngu
                                }
4278
                                else
4279
                                {
4280 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4281
                                    //{
4282 233ef333 taeseongkim
                                    currentControl = new ArrowTextControl()
4283
                                    {
4284 907a99b3 taeseongkim
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4285 4fcb686a taeseongkim
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4286
                                        ControlType = ControlType.ArrowTextCloudControl
4287 233ef333 taeseongkim
                                    };
4288 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4289 233ef333 taeseongkim
                                    currentControl.IsNew = true;
4290
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4291
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4292 787a4489 KangIngu
4293 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4294 233ef333 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4295
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4296
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4297
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4298 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4299 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4300
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4301 7ad417d8 이지연
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4302 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4303
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4304
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4305 e66f22eb KangIngu
                                    //}
4306 787a4489 KangIngu
                                }
4307
                            }
4308
                        }
4309
                        break;
4310 233ef333 taeseongkim
4311 787a4489 KangIngu
                    case ControlType.ArrowTransTextCloudControl:
4312
                        {
4313 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4314 787a4489 KangIngu
                            {
4315
                                if (currentControl is ArrowTextControl)
4316
                                {
4317 ca40e004 ljiyeon
                                    //20180906 LJY TEST IsRotationDrawingEnable
4318
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4319 e66f22eb KangIngu
                                    {
4320
                                        return;
4321
                                    }
4322 f513c215 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4323 787a4489 KangIngu
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4324 49b217ad humkyung
                                    currentControl.IsNew = false;
4325 787a4489 KangIngu
                                    currentControl = null;
4326 b643fcca taeseongkim
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4327 787a4489 KangIngu
                                }
4328
                                else
4329
                                {
4330 e66f22eb KangIngu
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4331
                                    //{
4332 233ef333 taeseongkim
                                    currentControl = new ArrowTextControl()
4333
                                    {
4334
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4335 907a99b3 taeseongkim
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4336
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4337 233ef333 taeseongkim
                                    };
4338 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4339 233ef333 taeseongkim
                                    currentControl.IsNew = true;
4340
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4341
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4342 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4343 120b8b00 송근호
4344 233ef333 taeseongkim
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4345
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4346
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4347
                                    (currentControl as ArrowTextControl).isFixed = true;
4348
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4349
4350
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4351
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4352 7ad417d8 이지연
                                    (currentControl as ArrowTextControl).ArcLength = ViewerDataModel.Instance.ArcLength;
4353 4fcb686a taeseongkim
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4354 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4355
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4356
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4357 787a4489 KangIngu
4358 ca40e004 ljiyeon
                                    //20180911 LJY
4359 233ef333 taeseongkim
                                    (currentControl as ArrowTextControl).isTrans = true;
4360 e66f22eb KangIngu
                                    //}
4361 787a4489 KangIngu
                                }
4362
                            }
4363
                        }
4364
                        break;
4365
                    //강인구 추가
4366
                    case ControlType.Sign:
4367
                        {
4368 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4369 787a4489 KangIngu
                            {
4370 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4371
                                //{
4372 d7e20d2d taeseongkim
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4373 992a98b4 KangIngu
4374 d7e20d2d taeseongkim
                                if (_sign == null)
4375 233ef333 taeseongkim
                                {
4376
                                    txtBatch.Visibility = Visibility.Collapsed;
4377
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4378
                                    controlType = ControlType.None;
4379
4380
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4381
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4382
                                    return;
4383
                                }
4384 74abcf6f taeseongkim
                                else
4385
                                {
4386
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4387
                                    {
4388
                                        Application.Current.Resources.Add("UserSign", _sign);
4389
                                    }
4390
                                    else
4391
                                    {
4392
                                        Application.Current.Resources["UserSign"] = _sign;
4393
                                    }
4394
                                }
4395 992a98b4 KangIngu
4396 233ef333 taeseongkim
                                if (currentControl is SignControl)
4397
                                {
4398
                                    //20180906 LJY TEST IsRotationDrawingEnable
4399
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4400
                                    {
4401 992a98b4 KangIngu
                                        return;
4402
                                    }
4403
4404 233ef333 taeseongkim
                                    CreateCommand.Instance.Execute(currentControl);
4405
                                    currentControl = null;
4406
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4407 787a4489 KangIngu
                                    {
4408 233ef333 taeseongkim
                                        txtBatch.Text = "Place Date";
4409
                                        controlType = ControlType.Date;
4410 787a4489 KangIngu
                                    }
4411 233ef333 taeseongkim
                                }
4412
                                else
4413
                                {
4414
                                    currentControl = new SignControl
4415 787a4489 KangIngu
                                    {
4416 233ef333 taeseongkim
                                        Background = new SolidColorBrush(Colors.Black),
4417
                                        UserNumber = App.ViewInfo.UserID,
4418
                                        ProjectNO = App.ViewInfo.ProjectNO,
4419
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4420
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4421
                                        ControlType = ControlType.Sign
4422
                                    };
4423 787a4489 KangIngu
4424 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4425 233ef333 taeseongkim
                                    currentControl.IsNew = true;
4426
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4427
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4428 ca40e004 ljiyeon
4429 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4430
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4431 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4432 ca40e004 ljiyeon
                                }
4433 e66f22eb KangIngu
                                //}
4434 787a4489 KangIngu
                            }
4435
                        }
4436
                        break;
4437 233ef333 taeseongkim
4438 787a4489 KangIngu
                    case ControlType.Mark:
4439
                        {
4440 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4441 787a4489 KangIngu
                            {
4442 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4443
                                //{
4444 233ef333 taeseongkim
                                if (currentControl is RectangleControl)
4445
                                {
4446
                                    //20180906 LJY TEST IsRotationDrawingEnable
4447
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4448 787a4489 KangIngu
                                    {
4449 233ef333 taeseongkim
                                        return;
4450
                                    }
4451 e66f22eb KangIngu
4452 233ef333 taeseongkim
                                    CreateCommand.Instance.Execute(currentControl);
4453
                                    (currentControl as RectangleControl).ApplyOverViewData();
4454
                                    currentControl = null;
4455 787a4489 KangIngu
4456 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4457 233ef333 taeseongkim
4458
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4459
                                    {
4460
                                        txtBatch.Text = "Place Signature";
4461
                                        controlType = ControlType.Sign;
4462 787a4489 KangIngu
                                    }
4463 233ef333 taeseongkim
                                }
4464
                                else
4465
                                {
4466
                                    currentControl = new RectangleControl
4467 787a4489 KangIngu
                                    {
4468 233ef333 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4469
                                        Background = new SolidColorBrush(Colors.Black),
4470
                                        ControlType = ControlType.Mark,
4471
                                        Paint = PaintSet.Fill
4472
                                    };
4473 787a4489 KangIngu
4474 233ef333 taeseongkim
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4475 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4476 233ef333 taeseongkim
                                    currentControl.IsNew = true;
4477
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4478
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4479 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4480 233ef333 taeseongkim
                                }
4481 e66f22eb KangIngu
                                //}
4482 787a4489 KangIngu
                            }
4483
                        }
4484
                        break;
4485 233ef333 taeseongkim
4486 787a4489 KangIngu
                    case ControlType.Symbol:
4487
                        {
4488 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4489 787a4489 KangIngu
                            {
4490 a6272c57 humkyung
                                if (currentControl is SymControl)
4491
                                {
4492
                                    //20180906 LJY TEST IsRotationDrawingEnable
4493
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4494 787a4489 KangIngu
                                    {
4495 a6272c57 humkyung
                                        return;
4496 787a4489 KangIngu
                                    }
4497 a6272c57 humkyung
                                    CreateCommand.Instance.Execute(currentControl);
4498
                                    currentControl = null;
4499 233ef333 taeseongkim
4500 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4501 a6272c57 humkyung
                                }
4502
                                else
4503
                                {
4504
                                    currentControl = new SymControl
4505 787a4489 KangIngu
                                    {
4506 c7fde400 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4507 a6272c57 humkyung
                                        Background = new SolidColorBrush(Colors.Black),
4508
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4509
                                        ControlType = ControlType.Symbol
4510
                                    };
4511 787a4489 KangIngu
4512 a6272c57 humkyung
                                    currentControl.IsNew = true;
4513
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4514 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4515 a6272c57 humkyung
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4516 ca40e004 ljiyeon
4517 233ef333 taeseongkim
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4518 fa48eb85 taeseongkim
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4519 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4520 ca40e004 ljiyeon
                                }
4521 e66f22eb KangIngu
                                //}
4522 787a4489 KangIngu
                            }
4523
                        }
4524
                        break;
4525 233ef333 taeseongkim
4526 787a4489 KangIngu
                    case ControlType.Stamp:
4527
                        {
4528 e6a9ddaf humkyung
                            if (e.LeftButton == MouseButtonState.Pressed)
4529 787a4489 KangIngu
                            {
4530 e66f22eb KangIngu
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4531
                                //{
4532 233ef333 taeseongkim
                                if (currentControl is SymControlN)
4533
                                {
4534
                                    //20180906 LJY TEST IsRotationDrawingEnable
4535
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4536 787a4489 KangIngu
                                    {
4537 233ef333 taeseongkim
                                        return;
4538
                                    }
4539 e66f22eb KangIngu
4540 233ef333 taeseongkim
                                    CreateCommand.Instance.Execute(currentControl);
4541
                                    currentControl = null;
4542 510cbd2a ljiyeon
4543 902faaea taeseongkim
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4544 233ef333 taeseongkim
                                }
4545
                                else
4546
                                {
4547
                                    currentControl = new SymControlN
4548 787a4489 KangIngu
                                    {
4549 233ef333 taeseongkim
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4550
                                        Background = new SolidColorBrush(Colors.Black),
4551
                                        STAMP = App.SystemInfo.STAMP,
4552 43e1d368 taeseongkim
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4553 233ef333 taeseongkim
                                        ControlType = ControlType.Stamp
4554
                                    };
4555 787a4489 KangIngu
4556 233ef333 taeseongkim
                                    currentControl.IsNew = true;
4557
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4558 5a223b60 humkyung
                                    currentControl.CommentID = Commons.ShortGuid();
4559 233ef333 taeseongkim
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4560
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4561
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4562 5c3caba6 humkyung
                                    currentControl.SetValue(Canvas.ZIndexProperty, currentControl.ZIndex);
4563 233ef333 taeseongkim
                                }
4564 e66f22eb KangIngu
                                //}
4565 787a4489 KangIngu
                            }
4566
                        }
4567
                        break;
4568 233ef333 taeseongkim
4569 787a4489 KangIngu
                    case ControlType.PenControl:
4570
                        {
4571
                            if (inkBoard.Tag.ToString() == "Ink")
4572
                            {
4573
                                inkBoard.IsEnabled = true;
4574 c7fde400 taeseongkim
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4575 787a4489 KangIngu
                            }
4576
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4577
                            {
4578 c7fde400 taeseongkim
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4579 787a4489 KangIngu
                            }
4580
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4581
                            {
4582 c7fde400 taeseongkim
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4583 787a4489 KangIngu
                            }
4584
                            IsDrawing = true;
4585
                            return;
4586
                        }
4587
                    default:
4588
                        if (currentControl != null)
4589
                        {
4590
                            currentControl.CommentID = null;
4591
                            currentControl.IsNew = false;
4592
                        }
4593
                        break;
4594
                }
4595 fa48eb85 taeseongkim
4596 4fcb686a taeseongkim
                try
4597
                {
4598
                    if (currentControl is ITextControl)
4599
                    {
4600
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4601
4602
                        if(textBox.Count() > 0)
4603
                        {
4604
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4605
                            specialcharRemove.Attach(textBox.First());
4606
                        }
4607
                        else
4608
                        {
4609
4610
                        }
4611
4612
                    }
4613
                }
4614
                catch (Exception ex)
4615
                {
4616
                    System.Diagnostics.Debug.WriteLine(ex);
4617
4618
                }
4619
4620 1b2cf911 taeseongkim
                if (currentControl is ArrowTextControl)
4621
                {
4622
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4623
                    {
4624
                        var control = snd as ArrowTextControl;
4625
4626
                        if (string.IsNullOrEmpty(control.ArrowText))
4627
                        {
4628 34ac8db7 humkyung
                            UndoCommand.Instance.Push(EventType.Delete, new [] { control });
4629 1b2cf911 taeseongkim
                        }
4630
                    };
4631
4632
                }
4633 b74a9c91 taeseongkim
4634
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4635
                {
4636
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4637
                    {
4638
                        MacroHelper.MacroAction();
4639
                    }
4640
                    //if (currentControl.ControlType)
4641
                    //txtBatch.Text = "Draw a TextBox";
4642
                    //controlType = ControlType.ArrowTextBorderControl;
4643
                }
4644
4645 4f017ed3 taeseongkim
                //if (currentControl != null)
4646
                //{
4647
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4648
                //}
4649 787a4489 KangIngu
            }
4650 e6a9ddaf humkyung
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4651 787a4489 KangIngu
            {
4652 b74a9c91 taeseongkim
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4653
             
4654
4655 787a4489 KangIngu
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4656
                {
4657
                    bool mouseOff = false;
4658
                    foreach (var item in SelectLayer.Children)
4659
                    {
4660
                        if (item is AdornerFinal)
4661
                        {
4662 4913851c humkyung
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4663 787a4489 KangIngu
                            if (over != null)
4664
                            {
4665
                                mouseOff = true;
4666
                            }
4667 8295a079 이지연
4668 787a4489 KangIngu
                        }
4669
                    }
4670
4671
                    if (!mouseOff)
4672
                    {
4673 077896be humkyung
                        SelectionSet.Instance.UnSelect(this);
4674 787a4489 KangIngu
                    }
4675
                }
4676
                zoomAndPanControl.CaptureMouse();
4677
                e.Handled = true;
4678
            }
4679 9380813b swate0609
4680 787a4489 KangIngu
        }
4681 e54660e8 KangIngu
4682 d1f35ad3 swate0609
        
4683
4684
        
4685
4686
        private void MenuSendBackward_Click(object sender, RoutedEventArgs e)
4687
        {
4688
            foreach (var item in SelectionSet.Instance.SelectedItems)
4689
            {
4690
                if (item.ZIndex > 0)
4691
                {
4692
                    item.ZIndex--;
4693
                    Canvas.SetZIndex(item, item.ZIndex);
4694
                }
4695
            }
4696
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4697
        }
4698
4699
        private void MenuSendToBackward_Click(object sender, RoutedEventArgs e)
4700
        {
4701
            foreach (var item in SelectionSet.Instance.SelectedItems)
4702
            {
4703
                item.ZIndex = 0;
4704
                Canvas.SetZIndex(item, item.ZIndex);
4705
            }
4706
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4707
        }
4708
4709
        private void MenuBringForward_Click(object sender, RoutedEventArgs e)
4710
        {
4711
            foreach (var item in SelectionSet.Instance.SelectedItems)
4712
            {
4713
                if (item.ZIndex < 100)
4714
                {
4715
                    item.ZIndex++;
4716
                    Canvas.SetZIndex(item, item.ZIndex);
4717
                }
4718
            }
4719
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4720
        }
4721
        private void MenuBringToForward_Click(object sender, RoutedEventArgs e)
4722
        {
4723
            foreach (var item in SelectionSet.Instance.SelectedItems)
4724
            {
4725
                item.ZIndex = 99;
4726
                Canvas.SetZIndex(item, item.ZIndex);
4727
            }
4728
            ViewerDataModel.Instance.IsMarkupUpdate = true;
4729
        }
4730
4731
        private List<AdornerMember> GetAdornerItem()
4732
        {
4733
            List<AdornerMember> AdonerList = new List<AdornerMember>();
4734
4735
            if (this.ParentOfType<MainWindow>() != null)
4736
            {
4737
                if (this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Count > 0)
4738
                {
4739
                    foreach (var item in this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children)
4740
                    {
4741
                        if (item.GetType().Name == "AdornerFinal")
4742
                        {
4743
                            foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4744
                            {
4745
                                AdonerList.Add(InnerItem);
4746
                            }
4747
                        }
4748
                    }
4749
                }
4750
            }
4751
4752
            return AdonerList;
4753
        }
4754
4755 a1716fa5 KangIngu
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4756
        {
4757 e6a9ddaf humkyung
            ///mouseButtonDown = e.ChangedButton;
4758 a1716fa5 KangIngu
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4759
        }
4760
4761 787a4489 KangIngu
        private void RemoveLineStroke(Point P)
4762
        {
4763 a342d378 taeseongkim
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4764 787a4489 KangIngu
            if (control != null)
4765
            {
4766 34ac8db7 humkyung
                UndoCommand.Instance.Push(EventType.Delete, new List<CommentUserInfo>() { control });
4767 787a4489 KangIngu
            }
4768
        }
4769
4770
        private void RemovePointStroke(Point P)
4771
        {
4772
            foreach (Stroke hits in inkBoard.Strokes)
4773
            {
4774
                foreach (StylusPoint sty in hits.StylusPoints)
4775
                {
4776
                }
4777
                if (hits.HitTest(P))
4778
                {
4779
                    inkBoard.Strokes.Remove(hits);
4780
                    return;
4781
                }
4782
            }
4783
        }
4784
4785
        private void StartNewStroke(Point P)
4786
        {
4787
            strokePoints = new StylusPointCollection();
4788
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4789
            strokePoints.Add(segment1Start);
4790
            stroke = new Stroke(strokePoints);
4791
4792
            stroke.DrawingAttributes.Color = Colors.Red;
4793
            stroke.DrawingAttributes.Width = 4;
4794
            stroke.DrawingAttributes.Height = 4;
4795
4796
            inkBoard.Strokes.Add(stroke);
4797
        }
4798
4799 77cdac33 taeseongkim
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4800 787a4489 KangIngu
        {
4801 b42dd24d taeseongkim
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4802
            //// update mylist and gridview
4803
            //this.UpdateMyMarkupList();
4804
4805
            //bool result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4806
4807
            //if (result)
4808
            //{
4809 6a19b48d taeseongkim
            btnFinalPDF.IsEnabled = false;
4810
            btnConsolidate.IsEnabled = false;
4811 ef7ba61f humkyung
            var result = await ConsolidationMethod();
4812 dbddfdd0 taeseongkim
4813
            if(result)
4814
            {
4815
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4816
4817
                if(consolidateItem?.Count() > 0)
4818
                {
4819
                    gridViewMarkup.Select(consolidateItem);
4820
                }
4821
            }
4822 38d69491 taeseongkim
            else
4823
            {
4824
                btnFinalPDF.IsEnabled = true;
4825
                btnConsolidate.IsEnabled = true;
4826
            }
4827 787a4489 KangIngu
        }
4828
4829 102476f6 humkyung
        /// <summary>
4830
        /// execute TeamConsolidationCommand
4831
        /// </summary>
4832 77cdac33 taeseongkim
        public async void TeamConsolidationMethod()
4833 787a4489 KangIngu
        {
4834
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4835
            {
4836
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4837
            }
4838
            else
4839 90e7968d ljiyeon
            {
4840 77cdac33 taeseongkim
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4841 35a96e24 humkyung
                {
4842 77cdac33 taeseongkim
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4843
                    {
4844
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4845
                    }
4846 35a96e24 humkyung
                }
4847 233ef333 taeseongkim
4848 77cdac33 taeseongkim
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4849
                if (isSave)
4850
                {
4851 f5f788c2 taeseongkim
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4852 77cdac33 taeseongkim
4853
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4854 e31e5b1b humkyung
4855
                    #region 로그인 사용자가 같은 부서의 마크업을 취합하여 Team Consolidate을 수행한다.
4856 77cdac33 taeseongkim
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4857
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4858
                    {
4859 e31e5b1b humkyung
                        if((item as IKCOM.MarkupInfoItem).Depatment.Equals(this.userData.DEPARTMENT))
4860
                            MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4861 77cdac33 taeseongkim
                    }
4862
4863
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4864 e31e5b1b humkyung
                    #endregion
4865 77cdac33 taeseongkim
                }
4866
            }
4867
        }
4868
4869 e31e5b1b humkyung
        /// <summary>
4870
        /// Consolidate를 수행한다.
4871
        /// </summary>
4872
        /// <returns></returns>
4873 77cdac33 taeseongkim
        public async Task<bool> ConsolidationMethod()
4874
        {
4875
            bool result = false;
4876
4877
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4878
            {
4879
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4880
            }
4881
            else
4882
            {
4883 1d79913e taeseongkim
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4884 77cdac33 taeseongkim
4885
                if (isSave)
4886
                {
4887 f5f788c2 taeseongkim
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4888 77cdac33 taeseongkim
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4889
4890
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4891
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4892
                    {
4893
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4894
                    }
4895
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4896
4897 1d79913e taeseongkim
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4898 77cdac33 taeseongkim
                }
4899 787a4489 KangIngu
            }
4900 b42dd24d taeseongkim
4901
            return result;
4902 787a4489 KangIngu
        }
4903
4904 e31e5b1b humkyung
        /// <summary>
4905
        /// 조건에 맞게 Consolidate 버튼을 비활성화 시킨다.
4906
        /// </summary>
4907
        /// <param name="sender"></param>
4908
        /// <param name="e"></param>
4909 787a4489 KangIngu
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4910
        {
4911
            if (App.ViewInfo != null)
4912
            {
4913
                btnConsolidate = (sender as RadRibbonButton);
4914
                if (!App.ViewInfo.NewCommentPermission)
4915
                {
4916
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4917
                }
4918
            }
4919
        }
4920
4921
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4922
        {
4923 04a7385a djkim
            TeamConsolidationMethod();
4924 787a4489 KangIngu
        }
4925
4926 e31e5b1b humkyung
        /// <summary>
4927
        /// 조건에 따라 Team Consoidate 버튼을 비활성화 시킨다.
4928
        /// </summary>
4929
        /// <param name="sender"></param>
4930
        /// <param name="e"></param>
4931 787a4489 KangIngu
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4932
        {
4933
            btnTeamConsolidate = sender as RadRibbonButton;
4934
            if (App.ViewInfo != null)
4935
            {
4936
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4937
                {
4938
                    if (btnConsolidate != null)
4939
                    {
4940
                        btnConsolidate.Visibility = Visibility.Collapsed;
4941
                    }
4942
4943
                    if (!App.ViewInfo.NewCommentPermission)
4944
                    {
4945
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4946
                    }
4947
                }
4948
                else
4949
                {
4950
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4951
                }
4952
            }
4953
        }
4954
4955 b2d0f316 humkyung
        /// <summary>
4956
        /// Final PDF를 실행한다.
4957
        /// </summary>
4958
        /// <param name="sender"></param>
4959
        /// <param name="e"></param>
4960 bae83c92 taeseongkim
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4961 787a4489 KangIngu
        {
4962 b42dd24d taeseongkim
            // update mylist and gridview
4963
            this.UpdateMyMarkupList();
4964 a1e2ba68 taeseongkim
4965 43e1d368 taeseongkim
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4966 b42dd24d taeseongkim
4967 bae83c92 taeseongkim
            if(!result)
4968
            {
4969 a1e2ba68 taeseongkim
4970 bae83c92 taeseongkim
            }
4971
            else
4972 787a4489 KangIngu
            {
4973 b2d0f316 humkyung
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().FirstOrDefault(d => d.Consolidate == 1 && d.AvoidConsolidate == 0);
4974 bae83c92 taeseongkim
                if (item != null)
4975 81e3c9f6 ljiyeon
                {
4976 bae83c92 taeseongkim
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4977
                    {
4978
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4979 a1e2ba68 taeseongkim
4980 bae83c92 taeseongkim
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4981
4982
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4983
                    }
4984
                    else
4985
                    {
4986
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4987
                    }
4988 81e3c9f6 ljiyeon
                }
4989
                else
4990
                {
4991 bae83c92 taeseongkim
                    //Consolidate 가 없는 경우
4992
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4993 81e3c9f6 ljiyeon
                }
4994 233ef333 taeseongkim
            }
4995 787a4489 KangIngu
        }
4996
4997
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4998
        {
4999
            btnFinalPDF = sender as RadRibbonButton;
5000
            if (App.ViewInfo != null)
5001
            {
5002 b42dd24d taeseongkim
                //btnFinalPDF.IsEnabled = false;
5003
5004 787a4489 KangIngu
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5005
                {
5006
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5007
                    if (btnConsolidate != null)
5008
                    {
5009
                        btnConsolidate.Visibility = Visibility.Collapsed;
5010
                    }
5011
                }
5012
            }
5013
        }
5014
5015 b42dd24d taeseongkim
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5016 80458c15 ljiyeon
        {
5017 b42dd24d taeseongkim
            //UpdateMyMarkupList();
5018 80458c15 ljiyeon
5019
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5020
            {
5021
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5022
            }
5023
            else
5024
            {
5025 b42dd24d taeseongkim
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
5026
                //{
5027
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
5028
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
5029
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
5030 80458c15 ljiyeon
5031 b42dd24d taeseongkim
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
5032
                //// update mylist and gridview
5033
                //this.UpdateMyMarkupList();
5034
5035
                //var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
5036 324fcf3e taeseongkim
5037 1305c420 taeseongkim
                Mouse.SetCursor(Cursors.Wait);
5038 324fcf3e taeseongkim
5039 77cdac33 taeseongkim
                bool result = await ConsolidationMethod();
5040 80458c15 ljiyeon
5041 5c64268e taeseongkim
                //System.Threading.Thread.Sleep(500);
5042 1305c420 taeseongkim
5043
                if (result)
5044 80458c15 ljiyeon
                {
5045 1305c420 taeseongkim
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5046
5047
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5048
                    if (item2 != null)
5049 bae83c92 taeseongkim
                    {
5050 1305c420 taeseongkim
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
5051
                        {
5052
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5053 80458c15 ljiyeon
5054 1305c420 taeseongkim
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5055
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5056 bae83c92 taeseongkim
5057 1305c420 taeseongkim
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5058
5059
                            Mouse.SetCursor(Cursors.Arrow);
5060
                        }
5061
                        else
5062
                        {
5063
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
5064
                        }
5065 bae83c92 taeseongkim
                    }
5066
                    else
5067
                    {
5068 1305c420 taeseongkim
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5069 bae83c92 taeseongkim
                    }
5070 80458c15 ljiyeon
                }
5071
                else
5072
                {
5073 1305c420 taeseongkim
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5074 80458c15 ljiyeon
                }
5075 1305c420 taeseongkim
5076
                Mouse.SetCursor(Cursors.Arrow);
5077 90e7968d ljiyeon
            }
5078 80458c15 ljiyeon
        }
5079
5080
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5081 90e7968d ljiyeon
        {
5082 80458c15 ljiyeon
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5083 84605c0c taeseongkim
#if Hyosung
5084
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5085
#else
5086 b42dd24d taeseongkim
5087
            //btnConsolidateFinalPDF.IsEnabled = false;
5088
5089 80458c15 ljiyeon
            if (App.ViewInfo != null)
5090
            {
5091
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5092
                {
5093 90e7968d ljiyeon
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5094 80458c15 ljiyeon
                }
5095 90e7968d ljiyeon
            }
5096 84605c0c taeseongkim
#endif
5097 80458c15 ljiyeon
        }
5098
5099 3abe8d4e taeseongkim
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5100
        {
5101
5102
        }
5103
5104 787a4489 KangIngu
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5105
        {
5106 adce8360 humkyung
            SetCompareRect();
5107 787a4489 KangIngu
        }
5108
5109 9cd2865b KangIngu
        private void Sync_Click(object sender, RoutedEventArgs e)
5110
        {
5111 a1716fa5 KangIngu
            if (Sync.IsChecked)
5112 9cd2865b KangIngu
            {
5113
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5114
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5115
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5116
            }
5117
        }
5118
5119 787a4489 KangIngu
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5120
        {
5121
            if (UserList.IsChecked)
5122
            {
5123
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5124
            }
5125
            else
5126
            {
5127
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5128
            }
5129
        }
5130
5131
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5132
        {
5133
            if (BalanceMode.IsChecked)
5134
            {
5135
                ViewerDataModel.Instance.PageBalanceMode = true;
5136
            }
5137
            else
5138
            {
5139
                ViewerDataModel.Instance.PageBalanceMode = false;
5140
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5141
            }
5142
        }
5143
5144
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5145
        {
5146
            //초기화
5147
            testPanel2.IsHidden = true;
5148
            ViewerDataModel.Instance.PageBalanceMode = false;
5149
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5150 752b18ef taeseongkim
            ViewerDataModel.Instance.SyncPageNumber = 0;
5151 787a4489 KangIngu
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5152
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5153
            UserList.IsChecked = false;
5154
            BalanceMode.IsChecked = false;
5155
        }
5156
5157 ac4f1e13 taeseongkim
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5158 787a4489 KangIngu
        {
5159
            if ((sender as System.Windows.Controls.Control).Tag != null)
5160
            {
5161
                //Compare 초기화
5162
                CompareMode.IsChecked = false;
5163
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5164 752b18ef taeseongkim
                
5165
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5166 787a4489 KangIngu
                {
5167 752b18ef taeseongkim
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5168 787a4489 KangIngu
                }
5169
5170
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5171
                {
5172
                }
5173
                else
5174
                {
5175
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5176
                }
5177
5178 752b18ef taeseongkim
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5179 787a4489 KangIngu
                {
5180
                }
5181 752b18ef taeseongkim
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5182 787a4489 KangIngu
                {
5183 752b18ef taeseongkim
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5184 787a4489 KangIngu
                }
5185
5186 d04e8ee9 taeseongkim
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5187 6b6e937c taeseongkim
5188 787a4489 KangIngu
                if (!testPanel2.IsHidden)
5189
                {
5190
                    if (IsSyncPDFMode)
5191
                    {
5192
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5193 752b18ef taeseongkim
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5194 787a4489 KangIngu
5195
                        if (pdfpath.IsDownloading)
5196
                        {
5197
                            pdfpath.DownloadCompleted += (ex, arg) =>
5198
                            {
5199
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5200
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5201
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5202
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5203
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5204
                            };
5205
                        }
5206
                        else
5207
                        {
5208
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5209
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5210
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5211
5212
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5213
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5214
                        }
5215
                    }
5216
                    else
5217
                    {
5218 752b18ef taeseongkim
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5219 787a4489 KangIngu
5220 752b18ef taeseongkim
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5221
                        ComparePageLoad(uri, isOriginalSize);
5222 787a4489 KangIngu
                    }
5223 4f017ed3 taeseongkim
                   
5224 787a4489 KangIngu
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5225
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5226
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5227
5228
                    foreach (var item in gridSelectionRevItem)
5229
                    {
5230 752b18ef taeseongkim
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5231 ac4f1e13 taeseongkim
                        foreach (var markupitem in markupitems)
5232 787a4489 KangIngu
                        {
5233 58dd9e89 humkyung
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID,
5234
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5235 ac4f1e13 taeseongkim
                        }
5236 787a4489 KangIngu
                    }
5237 e54660e8 KangIngu
5238 752b18ef taeseongkim
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5239 787a4489 KangIngu
                }
5240
            }
5241
        }
5242
5243 43d2041c taeseongkim
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5244
        {
5245
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5246
5247
            double translateX = 0;
5248
            double translateY = 0;
5249
            double angle = rotate2.Angle;
5250
5251
            if (direction == 1)
5252
            {
5253
                if (angle < 270)
5254
                {
5255
                    angle += 90;
5256
                }
5257
                else
5258
                {
5259
                    angle = 0;
5260
                }
5261
            }
5262
            else
5263
            {
5264
                if (angle > 0)
5265
                {
5266
                    angle -= 90;
5267
                }
5268
                else
5269
                {
5270
                    angle = 270;
5271
                }
5272
            }
5273
            zoomAndPanControl2.RotationAngle = angle;
5274
            zoomAndPanControl2.ScaleToFit();
5275
5276
            //if (angle == 90 || angle == 270)
5277
            //{
5278
                double emptySize = zoomAndPanCanvas2.Width;
5279
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5280
                zoomAndPanCanvas2.Height = emptySize;
5281
            //}
5282
5283
            if (angle == 90)
5284
            {
5285
                translateX = zoomAndPanCanvas2.Width;
5286
                translateY = 0;
5287
            }
5288
            else if (angle == 180)
5289
            {
5290
                translateX = zoomAndPanCanvas2.Width;
5291
                translateY = zoomAndPanCanvas2.Height;
5292
            }
5293
            else if (angle == 270)
5294
            {
5295
                translateX = 0;
5296
                translateY = zoomAndPanCanvas2.Height;
5297
            }
5298
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5299
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5300
            translate2.X = translateX;
5301
            translate2.Y = translateY;
5302
            rotate2.Angle = angle;
5303
            //translate2CompareBorder.X = translateX;
5304
            //translate2CompareBorder.Y = translateY;
5305
            //rotate2CompareBorder.Angle = angle;
5306
5307
        }
5308
5309 787a4489 KangIngu
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5310
        {
5311
            if (MarkupMode.IsChecked)
5312
            {
5313
                IsSyncPDFMode = true;
5314
5315
                var uri = CurrentRev.TO_VENDOR;
5316 ae56d52d KangIngu
5317 752b18ef taeseongkim
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5318 787a4489 KangIngu
                {
5319 752b18ef taeseongkim
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5320 787a4489 KangIngu
                }
5321
5322
                //PDF모드 잠시 대기(강인구)
5323
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5324 752b18ef taeseongkim
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5325 787a4489 KangIngu
5326
                if (pdfpath.IsDownloading)
5327
                {
5328
                    pdfpath.DownloadCompleted += (ex, arg) =>
5329
                    {
5330
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5331
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5332
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5333
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5334
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5335
                    };
5336
                }
5337
                else
5338
                {
5339
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5340
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5341
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5342
5343
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5344
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5345
                }
5346
            }
5347
            else
5348
            {
5349
                IsSyncPDFMode = false;
5350 69f41aab humkyung
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5351 787a4489 KangIngu
5352 752b18ef taeseongkim
                ComparePageLoad(uri,false);
5353 787a4489 KangIngu
5354
                zoomAndPanControl2.ApplyTemplate();
5355
                zoomAndPanControl2.UpdateLayout();
5356
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5357
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5358
            }
5359
        }
5360
5361 adce8360 humkyung
        /// <summary>
5362
        /// Compare된 영역을 초기화
5363
        /// </summary>
5364
        private void ClearCompareRect()
5365
        {
5366
            da.From = 1;
5367
            da.To = 1;
5368
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5369
            da.AutoReverse = false;
5370
            canvas_compareBorder.Children.Clear();
5371
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5372
        }
5373
5374
        /// <summary>
5375 233ef333 taeseongkim
        /// 문서 Comprare
5376 adce8360 humkyung
        /// </summary>
5377
        private void SetCompareRect()
5378
        {
5379 43d2041c taeseongkim
            canvas_compareBorder.Children.Clear();
5380
5381 adce8360 humkyung
            if (CompareMode.IsChecked)
5382
            {
5383
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5384
                {
5385
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5386
                }
5387 752b18ef taeseongkim
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5388 adce8360 humkyung
                {
5389 752b18ef taeseongkim
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5390 adce8360 humkyung
                }
5391
5392 664ea2e1 taeseongkim
                //Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +"," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," + userData.COMPANY != "EXT" ? "true" : "false", 1);
5393 adce8360 humkyung
5394 41c4405e taeseongkim
                /// 비교대상원본, 비교할 대상
5395 752b18ef taeseongkim
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5396 adce8360 humkyung
            }
5397
            else
5398
            {
5399 43d2041c taeseongkim
                canvas_compareBorder.Visibility = Visibility.Hidden;
5400 adce8360 humkyung
                ClearCompareRect();
5401
            }
5402
        }
5403
5404 3212270d taeseongkim
        private void btnSync_Click(object sender, RoutedEventArgs e)
5405 787a4489 KangIngu
        {
5406
            gridViewHistory_Busy.IsBusy = true;
5407
5408
            RadButton instance = sender as RadButton;
5409
            if (instance.CommandParameter != null)
5410
            {
5411
                CurrentRev = instance.CommandParameter as VPRevision;
5412 adce8360 humkyung
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5413
5414
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5415 787a4489 KangIngu
                {
5416
                    if (ea.Error == null && ea.Result != null)
5417
                    {
5418
                        testPanel2.IsHidden = false;
5419
5420 d128ceb2 humkyung
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5421 233ef333 taeseongkim
                        foreach (var info in ea.Result)
5422 d128ceb2 humkyung
                        {
5423 233ef333 taeseongkim
                            if (info.UserID == App.ViewInfo.UserID)
5424 d128ceb2 humkyung
                            {
5425
                                info.userDelete = true;
5426 8f7f8073 taeseongkim
                                info.DisplayColor = "#FFFF0000";
5427 d128ceb2 humkyung
                            }
5428
                            else
5429
                            {
5430
                                info.userDelete = false;
5431
                            }
5432
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5433
                        }
5434 787a4489 KangIngu
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5435
5436 69f41aab humkyung
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5437 752b18ef taeseongkim
                        ComparePageLoad(uri,false);
5438 787a4489 KangIngu
5439
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5440
5441
                        zoomAndPanControl2.ApplyTemplate();
5442
                        zoomAndPanControl2.UpdateLayout();
5443 43d2041c taeseongkim
5444 787a4489 KangIngu
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5445
                        {
5446
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5447
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5448
                        }
5449
5450 9cd2865b KangIngu
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5451
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5452
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5453
5454 787a4489 KangIngu
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5455
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5456 43d2041c taeseongkim
5457
                        zoomAndPanControl.ScaleToFit();
5458
                        zoomAndPanControl2.ScaleToFit();
5459
5460 787a4489 KangIngu
                        gridViewHistory_Busy.IsBusy = false;
5461
                    }
5462 0f065e57 ljiyeon
5463 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5464 adce8360 humkyung
5465
                    if (GetSyncMarkupInfoItemshandler != null)
5466
                    {
5467
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5468
                    }
5469
5470 43d2041c taeseongkim
                    //ClearCompareRect();
5471 adce8360 humkyung
                    SetCompareRect();
5472 90e7968d ljiyeon
                };
5473 adce8360 humkyung
5474
                /// 중복 실행이 발생하여 수정함.
5475
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5476 787a4489 KangIngu
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5477 adce8360 humkyung
5478 664ea2e1 taeseongkim
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5479 787a4489 KangIngu
            }
5480
        }
5481 4eb052e4 ljiyeon
5482 752b18ef taeseongkim
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5483
        {
5484
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5485
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5486
5487 ffa5dbc7 taeseongkim
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5488 752b18ef taeseongkim
        }
5489
5490 94b7c12c djkim
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5491
        {
5492
            try
5493
            {
5494
                if (sender is RadButton)
5495
                {
5496
                    if ((sender as RadButton).Tag != null)
5497
                    {
5498
                        var url = (sender as RadButton).Tag.ToString();
5499
                        System.Diagnostics.Process.Start(url);
5500
                    }
5501
                    else
5502
                    {
5503
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5504
                    }
5505
                }
5506
            }
5507
            catch (Exception ex)
5508
            {
5509 664ea2e1 taeseongkim
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5510 94b7c12c djkim
            }
5511
        }
5512 787a4489 KangIngu
5513
        public void Sync_Event(VPRevision Currnet_Rev)
5514
        {
5515
            CurrentRev = Currnet_Rev;
5516
5517
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5518
            {
5519
                if (ea.Error == null && ea.Result != null)
5520
                {
5521
                    testPanel2.IsHidden = false;
5522
5523 d128ceb2 humkyung
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5524 233ef333 taeseongkim
                    foreach (var info in ea.Result)
5525 d128ceb2 humkyung
                    {
5526 233ef333 taeseongkim
                        if (info.UserID == App.ViewInfo.UserID)
5527 d128ceb2 humkyung
                        {
5528
                            info.userDelete = true;
5529 cf1cc862 taeseongkim
                            info.DisplayColor = "#FFFF0000";
5530 d128ceb2 humkyung
                        }
5531
                        else
5532
                        {
5533
                            info.userDelete = false;
5534
                        }
5535
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5536
                    }
5537 787a4489 KangIngu
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5538
5539 69f41aab humkyung
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5540 787a4489 KangIngu
5541
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5542
5543 752b18ef taeseongkim
                    ComparePageLoad(uri,false);
5544 90e7968d ljiyeon
5545 787a4489 KangIngu
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5546
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5547
                    zoomAndPanControl2.ApplyTemplate();
5548
                    zoomAndPanControl2.UpdateLayout();
5549
5550
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5551
                    {
5552
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5553
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5554
                    }
5555
                    //}
5556 30878507 taeseongkim
                    
5557 787a4489 KangIngu
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5558
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5559 90e7968d ljiyeon
                    gridViewHistory_Busy.IsBusy = false;
5560 787a4489 KangIngu
                }
5561 664ea2e1 taeseongkim
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5562 787a4489 KangIngu
            };
5563 664ea2e1 taeseongkim
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5564 90e7968d ljiyeon
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5565 787a4489 KangIngu
        }
5566
5567
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5568
        {
5569
            if (sender is Image)
5570
            {
5571
                if ((sender as Image).Tag != null)
5572
                {
5573
                    var pdfUrl = (sender as Image).Tag.ToString();
5574
                    System.Diagnostics.Process.Start(pdfUrl);
5575
                }
5576
                else
5577
                {
5578
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5579
                }
5580
            }
5581
        }
5582
5583 0d97ab05 humkyung
        private int symbolselectindex { get; set; } = 0;
5584 787a4489 KangIngu
5585 7fa95b67 humkyung
        /// <summary>
5586
        /// 심볼을 저장한다.
5587
        /// </summary>
5588
        /// <param name="Img_byte"></param>
5589
        /// <param name="data"></param>
5590
        /// <param name="args"></param>
5591
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5592
        {
5593
            try
5594 787a4489 KangIngu
            {
5595 7fa95b67 humkyung
                string svgfilename = null;
5596
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5597 787a4489 KangIngu
5598 7fa95b67 humkyung
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5599
                string guid = Commons.ShortGuid();
5600
5601
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5602
                fileUploader.RunCompleted += (ex, arg) =>
5603 787a4489 KangIngu
                {
5604 7fa95b67 humkyung
                    filename = arg.Result;
5605
                    if (prompt.IsPng)
5606 787a4489 KangIngu
                    {
5607 7fa95b67 humkyung
                        if (!string.IsNullOrEmpty(filename))
5608 787a4489 KangIngu
                        {
5609 7fa95b67 humkyung
                            if (symbolselectindex == 0)
5610 787a4489 KangIngu
                            {
5611 7fa95b67 humkyung
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5612
                            }
5613
                            else
5614
                            {
5615
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5616 787a4489 KangIngu
                            }
5617
                        }
5618
                    }
5619 7fa95b67 humkyung
                    else if (prompt.IsSvg)
5620 53880c83 ljiyeon
                    {
5621 7fa95b67 humkyung
                        try
5622 53880c83 ljiyeon
                        {
5623 0d97ab05 humkyung
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Img_byte))
5624 53880c83 ljiyeon
                            {
5625 0d97ab05 humkyung
                                string BmpFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5626
                                var bitmap = new System.Drawing.Bitmap(ms);
5627
                                bitmap.Save(BmpFilePath, System.Drawing.Imaging.ImageFormat.Bmp);
5628
5629
                                try
5630 53880c83 ljiyeon
                                {
5631 0d97ab05 humkyung
                                    var TempPath = System.IO.Path.GetTempPath();
5632 7fa95b67 humkyung
                                    Process potrace = new Process
5633
                                    {
5634
                                        StartInfo = new ProcessStartInfo
5635
                                        {
5636
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5637 0d97ab05 humkyung
                                            Arguments = "-b svg " + BmpFilePath,
5638 7fa95b67 humkyung
                                            RedirectStandardInput = true,
5639
                                            RedirectStandardOutput = true,
5640
                                            RedirectStandardError = true,
5641
                                            UseShellExecute = false,
5642
                                            CreateNoWindow = true,
5643
                                            WindowStyle = ProcessWindowStyle.Hidden
5644
                                        },
5645
                                    };
5646 53880c83 ljiyeon
5647 7fa95b67 humkyung
                                    StringBuilder svgBuilder = new StringBuilder();
5648
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5649
                                    {
5650
                                        svgBuilder.AppendLine(e2.Data);
5651
                                    };
5652 53880c83 ljiyeon
5653 7fa95b67 humkyung
                                    potrace.EnableRaisingEvents = true;
5654
                                    potrace.Start();
5655
                                    potrace.Exited += (sender, e) =>
5656 c73426a9 ljiyeon
                                    {
5657 0d97ab05 humkyung
                                        byte[] bytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(TempPath, System.IO.Path.GetFileNameWithoutExtension(BmpFilePath) + ".svg"));
5658 7fa95b67 humkyung
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5659
                                        Check_Uri.UriCheck(svgfilename);
5660
                                        if (symbolselectindex == 0)
5661 53880c83 ljiyeon
                                        {
5662 7fa95b67 humkyung
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5663
                                        }
5664
                                        else
5665
                                        {
5666
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5667
                                        }
5668
                                    };
5669
                                    potrace.WaitForExit();
5670 0d97ab05 humkyung
                                }
5671
                                catch (Exception e)
5672
                                {
5673
                                    DialogMessage_Alert(e.Message, "Error");
5674
                                }
5675 7fa95b67 humkyung
                            }
5676
                        }
5677
                        catch (Exception ee)
5678
                        {
5679
                            DialogMessage_Alert("" + ee, "Alert");
5680
                        }
5681 53880c83 ljiyeon
                    }
5682 7fa95b67 humkyung
                };
5683 53880c83 ljiyeon
            }
5684
            catch (Exception e)
5685
            {
5686 7fa95b67 humkyung
                throw new InvalidOperationException(e.Message);
5687 233ef333 taeseongkim
            }
5688 53880c83 ljiyeon
        }
5689
5690 0d97ab05 humkyung
        private void DefaultBitmapImage_DownloadFailed(object sender, ExceptionEventArgs e)
5691
        {
5692
            DialogMessage_Alert("Fail to download image : " + e.ErrorException.Message, "Error");
5693
        }
5694
5695 ef9ddca4 humkyung
        /// <summary>
5696
        /// 개인 심볼을 저장한다.
5697
        /// </summary>
5698
        /// <param name="Name"></param>
5699
        /// <param name="Url"></param>
5700
        /// <param name="Data"></param>
5701 7fa95b67 humkyung
        public void SavePrivateSymbol(string Name, string Url, string Data)
5702 53880c83 ljiyeon
        {
5703
            try
5704
            {
5705
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5706
                {
5707 5a223b60 humkyung
                    ID = Commons.ShortGuid(),
5708 53880c83 ljiyeon
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5709
                    NAME = Name,
5710
                    IMAGE_URL = Url,
5711
                    DATA = Data
5712
                };
5713
5714
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5715
            }
5716 ef9ddca4 humkyung
            catch (Exception ex)
5717 53880c83 ljiyeon
            {
5718 ef9ddca4 humkyung
                throw new InvalidOperationException(ex.Message);
5719 53880c83 ljiyeon
            }
5720
        }
5721
5722 0d97ab05 humkyung
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5723
        {
5724
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate 
5725
            { 
5726
                BindSymbolData(); 
5727
            }));
5728
        }
5729
5730 ef9ddca4 humkyung
        /// <summary>
5731
        /// 공용 심볼을 저장한다.
5732
        /// </summary>
5733
        /// <param name="Name"></param>
5734
        /// <param name="Url"></param>
5735
        /// <param name="Data"></param>
5736
        /// <param name="Department"></param>
5737 7fa95b67 humkyung
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5738 53880c83 ljiyeon
        {
5739
            try
5740
            {
5741
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5742
                {
5743 5a223b60 humkyung
                    ID = Commons.ShortGuid(),
5744 53880c83 ljiyeon
                    DEPARTMENT = Department,
5745
                    NAME = Name,
5746
                    IMAGE_URL = Url,
5747
                    DATA = Data
5748
                };
5749
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5750
            }
5751 ef9ddca4 humkyung
            catch (Exception ex)
5752 53880c83 ljiyeon
            {
5753 ef9ddca4 humkyung
                throw new InvalidOperationException(ex.Message);
5754 53880c83 ljiyeon
            }
5755
        }
5756
5757
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5758 233ef333 taeseongkim
        {
5759 0d97ab05 humkyung
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
5760
            {
5761
                BindSymbolData();
5762
            }));
5763 53880c83 ljiyeon
        }
5764 0d97ab05 humkyung
        
5765 233ef333 taeseongkim
5766 7fa95b67 humkyung
        /// <summary>
5767
        /// Symbol 데이터를 화면에 표시한다.
5768
        /// </summary>
5769
        private void BindSymbolData()
5770 53880c83 ljiyeon
        {
5771
            try
5772
            {
5773 0d97ab05 humkyung
                #region Private Symbol을 표시한다.
5774
                List<Symbol_Custom> PrivateSymbolList = new List<Symbol_Custom>();
5775
                var PrivateSymbols = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5776
                foreach (var symbol in PrivateSymbols)
5777 53880c83 ljiyeon
                {
5778 0d97ab05 humkyung
                    var Custom = new Symbol_Custom();
5779
                    Custom.Name = symbol.NAME;
5780
                    Custom.ImageUri = symbol.IMAGE_URL;
5781
                    Custom.ID = symbol.ID;
5782
                    PrivateSymbolList.Add(Custom);
5783 53880c83 ljiyeon
                }
5784 0d97ab05 humkyung
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = PrivateSymbolList;
5785
                #endregion
5786 53880c83 ljiyeon
5787 bb3a236d ljiyeon
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5788 53880c83 ljiyeon
5789 0d97ab05 humkyung
                #region Public Symbol을 표시한다.
5790
                List<SYMBOL_PUBLIC> PublicSymbols;
5791 53880c83 ljiyeon
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5792
                {
5793 0d97ab05 humkyung
                    PublicSymbols = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5794 53880c83 ljiyeon
                }
5795
                else
5796
                {
5797 0d97ab05 humkyung
                    PublicSymbols = BaseClient.GetPublicSymbolList(null);
5798 53880c83 ljiyeon
                }
5799 0d97ab05 humkyung
5800
                var PublicSymbolList = new List<Symbol_Custom>();
5801
                foreach (var symbol in PublicSymbols)
5802 53880c83 ljiyeon
                {
5803 0d97ab05 humkyung
                    var Custom = new Symbol_Custom();
5804
                    Custom.Name = symbol.NAME;
5805
                    Custom.ImageUri = symbol.IMAGE_URL;
5806
                    Custom.ID = symbol.ID;
5807
                    PublicSymbolList.Add(Custom);
5808 53880c83 ljiyeon
                }
5809 0d97ab05 humkyung
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = PublicSymbolList;
5810
                #endregion
5811 53880c83 ljiyeon
            }
5812 ef9ddca4 humkyung
            catch (Exception ex)
5813 53880c83 ljiyeon
            {
5814 ef9ddca4 humkyung
                DialogMessage_Alert(ex.Message, "Error");
5815 53880c83 ljiyeon
            }
5816
        }
5817 233ef333 taeseongkim
5818 ac4f1e13 taeseongkim
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5819 787a4489 KangIngu
        {
5820
            Canvas _canvas = new Canvas();
5821
            _canvas.Background = Brushes.White;
5822
            _canvas.Width = adorner_.BorderSize.Width;
5823
            _canvas.Height = adorner_.BorderSize.Height;
5824 58dd9e89 humkyung
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(),
5825
                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
5826 787a4489 KangIngu
5827
            BitmapEncoder encoder = new PngBitmapEncoder();
5828
5829
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
5830
5831
            DrawingVisual dv = new DrawingVisual();
5832
5833
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
5834
            _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)));
5835
5836
            using (DrawingContext ctx = dv.RenderOpen())
5837
            {
5838
                VisualBrush vb = new VisualBrush(_canvas);
5839
                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)));
5840
            }
5841
5842
            try
5843
            {
5844
                renderBitmap.Render(dv);
5845
5846 2007ecaa taeseongkim
                GC.Collect(2);
5847 787a4489 KangIngu
                GC.WaitForPendingFinalizers();
5848 90e7968d ljiyeon
                //GC.Collect();
5849 787a4489 KangIngu
                // encode png data
5850
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5851
                // puch rendered bitmap into it
5852
                pngEncoder.Interlace = PngInterlaceOption.Off;
5853
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5854
                return pngEncoder;
5855
            }
5856 53880c83 ljiyeon
            catch //(Exception ex)
5857 787a4489 KangIngu
            {
5858
                return null;
5859
            }
5860
        }
5861
5862
        public void DialogMessage_Alert(string content, string header)
5863
        {
5864 68e3cd94 taeseongkim
            App.splashScreen.Close();
5865 cf1cc862 taeseongkim
            App.FileLogger.Error(content + " " + header);
5866 68e3cd94 taeseongkim
5867 787a4489 KangIngu
            DialogParameters parameters = new DialogParameters()
5868
            {
5869 4279e717 djkim
                Owner = this.ParentOfType<MainWindow>(),
5870 0d32593b ljiyeon
                Content = new TextBlock()
5871 233ef333 taeseongkim
                {
5872 0d32593b ljiyeon
                    MinWidth = 400,
5873
                    FontSize = 11,
5874
                    Text = content,
5875
                    TextWrapping = System.Windows.TextWrapping.Wrap
5876
                },
5877 b79f786f 송근호
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5878 787a4489 KangIngu
                Header = header,
5879
                Theme = new VisualStudio2013Theme(),
5880
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5881 233ef333 taeseongkim
            };
5882 787a4489 KangIngu
            RadWindow.Alert(parameters);
5883
        }
5884
5885 233ef333 taeseongkim
        #region 캡쳐 기능
5886 787a4489 KangIngu
5887
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5888
        {
5889
            if (x < 0)
5890
            {
5891
                width += x;
5892
                x = 0;
5893
            }
5894
            if (y < 0)
5895
            {
5896
                height += y;
5897
                y = 0;
5898
5899
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5900
            }
5901
            if (x + width > zoomAndPanCanvas.ActualWidth)
5902
            {
5903
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5904
            }
5905
            if (y + height > zoomAndPanCanvas.ActualHeight)
5906
            {
5907
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5908
            }
5909
5910
            byte[] pixels = CopyPixels(x, y, width, height);
5911
5912
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5913
5914
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5915
        }
5916
5917
        public byte[] CopyPixels(int x, int y, int width, int height)
5918
        {
5919
            byte[] pixels = new byte[width * height * 4];
5920
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5921
5922
            // Canvas 이미지에서 객체 역역만큼 픽셀로 복사
5923
            canvasImage.CopyPixels(new Int32Rect(x, y, width, height), pixels, stride, 0);
5924
5925
            return pixels;
5926
        }
5927
5928
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5929
        {
5930
            DrawingVisual drawingVisual = new DrawingVisual();
5931
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5932
5933
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5934
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5935
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5936
            drawingContext.Close();
5937
5938
            // 비트맵으로 변환합니다.
5939
            RenderTargetBitmap target =
5940
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5941
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5942
5943
            target.Render(drawingVisual);
5944
            return target;
5945
        }
5946
5947 233ef333 taeseongkim
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5948 53880c83 ljiyeon
        {
5949
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5950
            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);
5951
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5952
            bmp.UnlockBits(data);
5953
            return bmp;
5954
        }
5955 233ef333 taeseongkim
5956 0d97ab05 humkyung
        /// <summary>
5957
        /// 캡쳐한 심볼을 저장한다.
5958
        /// </summary>
5959
        /// <param name="source"></param>
5960
        /// <param name="x"></param>
5961
        /// <param name="y"></param>
5962
        /// <param name="width"></param>
5963
        /// <param name="height"></param>
5964
        public void SaveCapturedSymbol(BitmapSource source, int x, int y, int width, int height, double XScale = 1, double YScale = 1)
5965 53880c83 ljiyeon
        {
5966 0d97ab05 humkyung
            var resized = new TransformedBitmap(source, new ScaleTransform(XScale, YScale));
5967
            System.Drawing.Bitmap image = GetBitmap(resized);
5968 53880c83 ljiyeon
5969
            byte[] imageBytes = null;
5970 0d97ab05 humkyung
            using (var imageStream = new System.IO.MemoryStream())
5971 53880c83 ljiyeon
            {
5972 0d97ab05 humkyung
#if DEBUG
5973
                string TempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempFileName());
5974
                image.Save(TempFilePath);
5975
#endif
5976 53880c83 ljiyeon
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5977
                imageStream.Position = 0;
5978
                imageBytes = imageStream.ToArray();
5979
            }
5980
5981
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5982
5983
            RadWindow CheckPop = new RadWindow();
5984
            //Alert check = new Alert(Msg);
5985
5986
            CheckPop = new RadWindow
5987
            {
5988
                MinWidth = 400,
5989
                MinHeight = 100,
5990 233ef333 taeseongkim
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5991 41e3c8ac swate0609
                //Header = "Alert",
5992
                Header = "Symbol",
5993 53880c83 ljiyeon
                Content = symbolPrompt,
5994 233ef333 taeseongkim
                //DialogResult =
5995 53880c83 ljiyeon
                ResizeMode = System.Windows.ResizeMode.NoResize,
5996
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5997
                IsTopmost = true,
5998
            };
5999 7fa95b67 humkyung
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
6000 53880c83 ljiyeon
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6001
            CheckPop.ShowDialog();
6002
6003
            /*
6004
            DialogParameters parameters = new DialogParameters()
6005
            {
6006
                Owner = Application.Current.MainWindow,
6007
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6008
                DefaultPromptResultValue = "Custom State",
6009
                Content = "Name :",
6010
                Header = "Insert Custom Symbol Name",
6011
                Theme = new VisualStudio2013Theme(),
6012
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6013 233ef333 taeseongkim
            };
6014 53880c83 ljiyeon
            RadWindow.Prompt(parameters);
6015
            */
6016
        }
6017
6018 787a4489 KangIngu
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6019
        {
6020
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6021
            KCOMDataModel.DataModel.CHECK_LIST check_;
6022
            string Result = streamToBase64.ImageToBase64(source);
6023
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6024 6c781c0c djkim
            string projectno = App.ViewInfo.ProjectNO;
6025
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6026 0f065e57 ljiyeon
6027 664ea2e1 taeseongkim
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6028 6c781c0c djkim
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6029 90e7968d ljiyeon
            if (Item != null)
6030 0f065e57 ljiyeon
            {
6031 664ea2e1 taeseongkim
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6032 0f065e57 ljiyeon
            }
6033
            else
6034
            {
6035 664ea2e1 taeseongkim
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6036 0f065e57 ljiyeon
            }
6037 90e7968d ljiyeon
6038 6c781c0c djkim
            if (Item == null)
6039 787a4489 KangIngu
            {
6040 6c781c0c djkim
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6041 787a4489 KangIngu
                {
6042 5a223b60 humkyung
                    ID = Commons.ShortGuid(),
6043 6c781c0c djkim
                    USER_ID = App.ViewInfo.UserID,
6044
                    IMAGE_URL = Result,
6045
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6046
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6047
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6048
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6049
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6050
                    STATUS = "False",
6051
                    CREATE_TIME = DateTime.Now,
6052
                    UPDATE_TIME = DateTime.Now,
6053
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6054
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6055
                };
6056 274cde11 taeseongkim
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6057 664ea2e1 taeseongkim
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6058 274cde11 taeseongkim
                this.BaseClient.AddCheckList(projectno, check_);
6059 787a4489 KangIngu
            }
6060 6c781c0c djkim
            else
6061
            {
6062
                Item.IMAGE_URL = Result;
6063
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6064 90e7968d ljiyeon
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6065 274cde11 taeseongkim
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6066 664ea2e1 taeseongkim
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6067 274cde11 taeseongkim
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6068 6c781c0c djkim
            }
6069 787a4489 KangIngu
        }
6070
6071
        public void Set_Capture()
6072 90e7968d ljiyeon
        {
6073 c7fde400 taeseongkim
            double x = CanvasDrawingMouseDownPoint.X;
6074
            double y = CanvasDrawingMouseDownPoint.Y;
6075 787a4489 KangIngu
            double width = dragCaptureBorder.Width;
6076
            double height = dragCaptureBorder.Height;
6077
6078
            if (width > 5 || height > 5)
6079
            {
6080
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6081
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6082
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6083
            }
6084
        }
6085 233ef333 taeseongkim
6086
        #endregion 캡쳐 기능
6087 787a4489 KangIngu
6088 b79d6e7f humkyung
        public UndoData Control_Style(CommentUserInfo control)
6089 787a4489 KangIngu
        {
6090 b79d6e7f humkyung
            multi_UndoData = new UndoData();
6091 787a4489 KangIngu
6092 873011c4 humkyung
            multi_UndoData.Markup = control;
6093 787a4489 KangIngu
6094 ab7fe8c0 humkyung
            if (control is IShapeControl)
6095 787a4489 KangIngu
            {
6096 873011c4 humkyung
                multi_UndoData.paint = (control as IShapeControl).Paint;
6097 787a4489 KangIngu
            }
6098 ab7fe8c0 humkyung
            if (control is IDashControl)
6099 787a4489 KangIngu
            {
6100 873011c4 humkyung
                multi_UndoData.DashSize = (control as IDashControl).DashSize;
6101 787a4489 KangIngu
            }
6102 ab7fe8c0 humkyung
            if (control is IPath)
6103 787a4489 KangIngu
            {
6104 873011c4 humkyung
                multi_UndoData.LineSize = (control as IPath).LineSize;
6105 787a4489 KangIngu
            }
6106
            if ((control as UIElement) != null)
6107
            {
6108 873011c4 humkyung
                multi_UndoData.Opacity = (control as UIElement).Opacity;
6109 787a4489 KangIngu
            }
6110
6111 873011c4 humkyung
            return multi_UndoData;
6112 787a4489 KangIngu
        }
6113
6114 ac4f1e13 taeseongkim
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6115 787a4489 KangIngu
        {
6116 d2279f18 taeseongkim
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6117 787a4489 KangIngu
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6118
            {
6119 4f017ed3 taeseongkim
                if (items.MarkupInfoID == Select_ID)
6120 787a4489 KangIngu
                {
6121
                    foreach (var item in items.MarkupList)
6122
                    {
6123
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6124
                        {
6125 f5f788c2 taeseongkim
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6126 5a223b60 humkyung
                                 items.MarkupInfoID, Commons.ShortGuid(), STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
6127 787a4489 KangIngu
                        }
6128
                    }
6129
                }
6130
            }
6131
        }
6132 d62c0439 humkyung
6133 f959ea6f humkyung
        /// <summary>
6134
        /// convert inkcontrol to polygoncontrol
6135
        /// </summary>
6136
        public void ConvertInkControlToPolygon()
6137 787a4489 KangIngu
        {
6138
            if (inkBoard.Strokes.Count > 0)
6139
            {
6140
                inkBoard.Strokes.ToList().ForEach(stroke =>
6141
                {
6142
                    InkToPath ip = new InkToPath();
6143 f959ea6f humkyung
6144 787a4489 KangIngu
                    List<Point> inkPointSet = new List<Point>();
6145 f959ea6f humkyung
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6146
6147
                    PolygonControl pc = new PolygonControl()
6148 787a4489 KangIngu
                    {
6149 fa48eb85 taeseongkim
                        CommentAngle = 0,
6150 f959ea6f humkyung
                        PointSet = inkPointSet,
6151 787a4489 KangIngu
                        ControlType = ControlType.Ink
6152
                    };
6153 f959ea6f humkyung
                    pc.StartPoint = inkPointSet[0];
6154
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6155
                    pc.LineSize = 3;
6156 5a223b60 humkyung
                    pc.CommentID = Commons.ShortGuid();
6157 f959ea6f humkyung
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6158 787a4489 KangIngu
6159 f959ea6f humkyung
                    if (pc.PointSet.Count > 0)
6160
                    {
6161
                        CreateCommand.Instance.Execute(pc);
6162 787a4489 KangIngu
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6163
                    }
6164
                });
6165 f959ea6f humkyung
                inkBoard.Strokes.Clear();
6166 787a4489 KangIngu
            }
6167
        }
6168 17a22987 KangIngu
6169 4318fdeb KangIngu
        /// <summary>
6170 e66f22eb KangIngu
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6171
        /// </summary>
6172
        /// <author>ingu</author>
6173
        /// <date>2018.06.05</date>
6174
        /// <param name="getPoint"></param>
6175
        /// <returns></returns>
6176
        private bool IsGetoutpoint(Point getPoint)
6177 670a4be2 humkyung
        {
6178 e66f22eb KangIngu
            if (getPoint == new Point())
6179 670a4be2 humkyung
            {
6180 e66f22eb KangIngu
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6181
                currentControl = null;
6182
                return true;
6183 670a4be2 humkyung
            }
6184
6185 e66f22eb KangIngu
            return false;
6186 670a4be2 humkyung
        }
6187 e66f22eb KangIngu
6188 5b46312f djkim
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6189
        {
6190
            e.Effects = DragDropEffects.Copy;
6191
        }
6192
6193
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6194
        {
6195
            e.Effects = DragDropEffects.Copy;
6196
        }
6197
6198
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6199
        {
6200
            e.Effects = DragDropEffects.None;
6201
        }
6202
6203 92442e4a taeseongkim
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6204 cdfb57ff taeseongkim
        {
6205
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6206
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6207
6208 92442e4a taeseongkim
            ScaleImage(pageWidth, pageHeight);
6209
        }
6210
6211
        /// <summary>
6212
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6213
        /// </summary>
6214
        /// <param name="pageWidth">원본 사이즈</param>
6215
        /// <param name="pageHeight">원본 사이즈</param>
6216
        /// <returns></returns>
6217 233ef333 taeseongkim
        private void ScaleImage(double pageWidth, double pageHeight)
6218 92442e4a taeseongkim
        {
6219 7e2d682c taeseongkim
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6220 cdfb57ff taeseongkim
        }
6221
6222 d0eda156 ljiyeon
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6223
        {
6224
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6225
        }
6226
6227 f38ed998 humkyung
        /// <summary>
6228
        /// 헤더의 CheckBox를 클릭했을때 Consolidate되지 않고 부서가 동일한 MarkupInfo를 선택한다.(선택하면 자동으로 체크됨)
6229
        /// </summary>
6230
        /// <param name="sender"></param>
6231
        /// <param name="e"></param>
6232 53deabaf taeseongkim
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6233
        {
6234
            var checkbox = (sender as CheckBox);
6235
6236
            if (checkbox != null)
6237
            {
6238
                if (checkbox.IsChecked.GetValueOrDefault())
6239
                {
6240 92c9cab8 taeseongkim
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6241
                    {
6242
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6243
6244 f38ed998 humkyung
                        if (currentItem.Any())
6245 92c9cab8 taeseongkim
                        {
6246
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6247
                            {
6248
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6249
                                {
6250
                                    gridViewMarkup.SelectedItems.Add(item);
6251
                                }
6252
                            }
6253
                        }
6254
                    }
6255
                    else
6256
                    {
6257
                        gridViewMarkup.SelectAll();
6258
                    }
6259 53deabaf taeseongkim
                }
6260
                else
6261
                {
6262
                    gridViewMarkup.UnselectAll();
6263
                }
6264
            }
6265
        }
6266 3abe8d4e taeseongkim
6267
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6268
        {
6269
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6270
6271
            if (dataSet?.Count() == 1)
6272
            {
6273
                PopupWindow popup = new PopupWindow();
6274
                
6275
            }
6276
        }
6277 552af7c7 swate0609
6278
        private void gridViewMarkup_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
6279
        {
6280
            foreach(var vCol in e.OwnerGridViewItemsControl.Columns)
6281
            {
6282
                vCol.IsReadOnly = false;
6283
            }
6284
        }
6285
6286
        private void gridViewMarkup_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
6287
        {
6288
            var vEditItem = e.EditedItem;
6289
            ((MarkupInfoItem)vEditItem).UserID = App.ViewInfo.UserID;
6290
            ((MarkupInfoItem)vEditItem).UpdateTime = DateTime.Now;
6291
            //((GridViewRow)e.Row).MarkupInfoItem).UserID == App.ViewInfo.UserID
6292
6293
            foreach (var vCol in ((RadGridView)e.OriginalSource).Columns)
6294
            {
6295
                vCol.IsReadOnly = true;
6296
            }
6297
        }
6298
6299
6300 3abe8d4e taeseongkim
6301 e6a9ddaf humkyung
        /*
6302 5b46312f djkim
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6303
        {
6304 90e7968d ljiyeon
            try
6305 5b46312f djkim
            {
6306 90e7968d ljiyeon
                if (e.Data.GetDataPresent(typeof(string)))
6307
                {
6308
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6309
                    string dragData = e.Data.GetData(typeof(string)) as string;
6310
                    Move_Symbol(sender, dragData);
6311
                }
6312 5b46312f djkim
            }
6313 90e7968d ljiyeon
            catch (Exception ex)
6314
            {
6315 664ea2e1 taeseongkim
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6316 233ef333 taeseongkim
            }
6317 5b46312f djkim
        }
6318 e6a9ddaf humkyung
        */
6319 787a4489 KangIngu
    }
6320 f65e6c02 taeseongkim
6321
    public class testItem
6322
    {
6323
        public string Title { get; set; }
6324
    }
6325 26ec6226 taeseongkim
6326
6327 233ef333 taeseongkim
}
클립보드 이미지 추가 (최대 크기: 500 MB)