프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 666bb823

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