프로젝트

일반

사용자정보

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

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

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

1 787a4489 KangIngu

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