프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 41e3c8ac

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