프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ b627aa5a

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

1
using IIpc;
2
using IKCOM;
3
using KCOM.Common;
4
using KCOMDataModel.DataModel;
5
using MarkupToPDF.Common;
6
using MarkupToPDF.Controls.Parsing;
7
using System;
8
using System.Collections.Generic;
9
using System.Collections.ObjectModel;
10
using System.ComponentModel;
11
using System.Diagnostics;
12
using System.Linq;
13
using System.Threading;
14
using System.Threading.Tasks;
15
using System.Windows;
16
using System.Windows.Controls;
17
using System.Windows.Data;
18
using System.Windows.Input;
19
using System.Windows.Media;
20
using Telerik.Windows.Controls;
21
using static MarkupToPDF.Controls.Parsing.MarkupParser;
22

    
23
namespace KCOM.Controls
24
{
25
    /// <summary>
26
    /// Interaction logic for PageNavigator.xaml
27
    /// </summary>
28
    public partial class Sample : UserControl, INotifyPropertyChanged
29
    {
30
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
31
        public event PropertyChangedEventHandler PropertyChanged;
32
        public DelegateCommand SelectCommentCommand { get; private set; }
33

    
34

    
35
        public Sample()
36
        {
37
            InitializeComponent();
38

    
39
            if (App.IsDesignMode)
40
            {
41
                return;
42
            }
43

    
44
            App.splashString(ISplashMessage.SAMPLE);
45
            this.SizeChanged += Sample_SizeChanged1;
46
            this.Loaded += Sample_Loaded;
47
            this.Unloaded += Sample_Unloaded;
48
        }
49

    
50
        private void Sample_SizeChanged1(object sender, SizeChangedEventArgs e)
51
        {
52
            if(e.PreviousSize.Width != e.NewSize.Width)
53
            {
54
                ImgListbox.ApplyTemplate();
55
            }
56
        }
57

    
58
        private void Sample_Unloaded(object sender, RoutedEventArgs e)
59
        {
60
          
61
        }
62

    
63
        private void Sample_Loaded(object sender, RoutedEventArgs e)
64
        {
65
            if(!_Initialize)
66
            {
67
                _Initialize = true;
68
                SelectCommentCommand = new DelegateCommand(SetCommentPages);
69

    
70

    
71
                this.SizeChanged += Sample_SizeChanged;
72
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
73
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);
74
                this.ImgListbox.PreviewKeyUp += ImgListbox_PreviewKeyUp;
75

    
76

    
77
            }            
78
        }
79

    
80
        private void Sample_SizeChanged(object sender, SizeChangedEventArgs e)
81
        {
82
            if (e.WidthChanged)
83
            {
84
                ImgListbox.ApplyTemplate();
85
            }
86
        }
87

    
88
        public static readonly DependencyProperty FilteredThumbnailProperty =  DependencyProperty.Register("FilteredThumbnail", typeof(CollectionViewSource),typeof(Sample)
89
                                                                            ,new PropertyMetadata(null,new PropertyChangedCallback(FilteredThumbnailPropertyChanged)));
90

    
91
        private static void FilteredThumbnailPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
92
        {
93
            var owner = d as Sample;
94

    
95
            if(owner != null)
96
            {
97
                owner.ImgListbox.ApplyTemplate();
98
            }
99
        }
100

    
101
        public CollectionViewSource FilteredThumbnail
102
        {
103
            get { return (CollectionViewSource)GetValue(FilteredThumbnailProperty); }
104
            set { SetValue(FilteredThumbnailProperty, value); }
105
        }
106

    
107
        public static readonly DependencyProperty CurrentPageProperty 
108
            = DependencyProperty.Register("CurrentPage", typeof(ThumbnailItem), typeof(Sample),new PropertyMetadata(null,CurrentPageChnaged));
109

    
110
        private static void CurrentPageChnaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
111
        {
112
            //var owner = d as Sample;
113

    
114
            //if (owner?.UsersCommentPagesList != null)
115
            //{
116
            //    owner.SetCommentPages();
117
            //}
118
        }
119

    
120
        public ThumbnailItem CurrentPage
121
        {
122
            get { return (ThumbnailItem)GetValue(CurrentPageProperty); }
123
            set { SetValue(CurrentPageProperty, value); }
124
        }
125

    
126
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
127
        private List<DOCPAGE> _PageList = null;
128
        private string _DefaultUri = null;
129
        public int PageCount = 0;
130
        private bool _Initialize;
131

    
132
        public event EventHandler<EventArgs> ThumbInitialized;
133
        public event EventHandler<PageChangeEventArgs> PageChanged;
134
        public event EventHandler<PageChangeEventArgs> PageChanging;
135

    
136
        private ObservableCollection<UsersCommentPagesMember> _UsersCommentPagesList;
137

    
138
        public ObservableCollection<UsersCommentPagesMember> UsersCommentPagesList
139
        {
140
            get {
141
                if(_UsersCommentPagesList == null)
142
                {
143
                    _UsersCommentPagesList = new ObservableCollection<UsersCommentPagesMember>();
144
                }
145

    
146
                return _UsersCommentPagesList; }
147
            set { _UsersCommentPagesList = value; }
148
        }
149

    
150
        public class PageChangeEventArgs : EventArgs
151
        {
152
            public DOCPAGE CurrentPage { get; set; }
153
            public string PageUri { get; set; }
154
            public int PageNumber { get; set; }
155
        }
156
        private bool _IsFitOn { get; set; }
157
        public bool IsFitOn
158
        {
159
            get
160
            {
161
                return _IsFitOn;
162
            }
163
            set
164
            {
165
                _IsFitOn = value;
166
                RaisePropertyChanged("IsFitOn");
167
            }
168
        }
169

    
170
        public void RaisePropertyChanged(string propName)
171
        {
172
            if (PropertyChanged != null)
173
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
174
        }
175

    
176
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
177
        {
178
            App.splashString(ISplashMessage.SAMPLE);
179
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
180
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
181

    
182
            this._PageList = PageList;
183
            this._DefaultUri = DefaultUri;
184

    
185
            string tempStoragePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName());
186

    
187
            
188
            //ThumbnailSetAsync();
189
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
190

    
191
            this.PageCount = PageList.Count();
192

    
193
            string endpoint = Common.Commons.shortGuid() + "Thumbnail";
194

    
195
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
196
            wcfServer.IpcThumbnailReceived += WcfServer_IpcThumbnailReceived;
197
            wcfServer.Start();
198

    
199
            DownloadProcess.ThumbnailDownloader(endpoint,ViewerDataModel.Instance.IsAdmin, this._DefaultUri, tempStoragePath, "jpg", this.PageCount);
200

    
201
            DownloadProcess.ProcessMonitor(ViewerDataModel.Instance.IsAdmin, tempStoragePath, App.PageStorage.LocalStorage,Common.ViewerDataModel.Instance.OriginalTempFile);
202

    
203
            App.splashScreen.Close();
204

    
205
        }
206

    
207
        private void WcfServer_IpcThumbnailReceived(object sender, IpcThumbnailEventArgs e)
208
        {
209
            var items = _thumbnailItems.Where(x => x.PageNumber == e.PageNo);
210

    
211
            if (items.Count() > 0)
212
            {
213
                //Dispatcher.BeginInvoke((Action)delegate ()
214
                //{
215
                items.First().ImageUri = new Uri(e.Path, UriKind.Absolute);
216
                System.Diagnostics.Debug.WriteLine($"no:{e.PageNo} {e.Path}");
217

    
218
                if(e.IsLast)
219
                {
220
                    (sender as IIpc.IIpcServer).IpcThumbnailReceived -= WcfServer_IpcThumbnailReceived;
221
                    //(sender as IIpc.IIpcServer).Stop();
222
                }
223

    
224
                //if (e.PageNo > 2 && ImgListbox.Items.Count > 0)
225
                //{
226

    
227
                //    ImgListbox.IsScrollIntoViewEnabled = true;
228
                //    //ImgListbox.BringIntoView();
229
                //    ImgListbox.ScrollIntoView(0);
230
                //}
231

    
232
                //});
233
            }
234
        }
235

    
236
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
237
        {
238
            Logger.sendCheckLog("rdoCommented_Checked", 1);
239
            SetCommentPages();
240
        }
241

    
242
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
243
        {
244
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
245
            //if (rdoFavoritePages.IsChecked == true)
246
            //    expCommentPages.IsExpanded = false;
247

    
248
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
249
            //if (_FavoriteSet.Count > 0)
250
            //{
251
            //    SetCommentPages(); //수정    
252
            //}
253
            //else
254
            //{
255
            //    rdoAllPages.IsChecked = true;
256
            //    rdoFavoritePages.IsChecked = false;
257
            //}
258
        }
259

    
260
        private async void ShowPageChange(object sender, RoutedEventArgs e)
261
        {
262
            //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
263
            if (IsInitialized)
264
            {
265
                //ThumbnailSetAsync();
266
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
267
            }
268
        }
269

    
270
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
271
        {
272
            //txtThumbCount.Visibility = Visibility.Collapsed;            
273
        }
274

    
275
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
276
        {
277
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
278
            rdoAllPages.IsChecked = false;
279
            rdoFavoritePages.IsChecked = false;
280
            //txtThumbCount.Visibility = Visibility.Visible;
281
            SetCommentPages();
282
        }
283

    
284
        private void ImgListbox_PreviewKeyUp(object sender, KeyEventArgs e)
285
        {
286
            if (ImgListbox.SelectedItem != null && (e.Key == Key.Up || e.Key == Key.Down))
287
            {
288
                System.Diagnostics.Debug.WriteLine("ImgListbox_PreviewKeyUp");
289

    
290
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
291
            }
292
        }
293

    
294
        /// <summary>
295
        /// called when image list box's selection is changed
296
        /// </summary>
297
        /// <param name="sender"></param>
298
        /// <param name="e"></param>
299
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
300
        {
301
            if (!Keyboard.IsKeyDown(Key.Down) && !Keyboard.IsKeyDown(Key.Up))
302
            {
303
                if (ImgListbox.SelectedItem != null)
304
                {
305
                    PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
306
                }
307
            }
308
        }
309

    
310
        private void PageChange(KCOM.Common.ThumbnailItem selectItem)
311
        { 
312
                var number = selectItem.PageNumber;
313

    
314
                if (ViewerDataModel.Instance.SyncPageNumber != number)
315
                {
316
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
317

    
318
                    this.CurrentPage = ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem;
319

    
320
                    PageChanging(this, new PageChangeEventArgs
321
                    {
322
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
323
                        PageNumber = number,
324
                        PageUri = null
325
                    });
326
                }
327
        }
328

    
329
        public bool GotoPageFlag = false;
330

    
331
        /// <summary>
332
        /// 해당 썸네일로 이동
333
        /// </summary>
334
        /// <param name="_pageNumber">이동할 페이지 번호</param>
335
        public void GotoPage(int _pageNumber)
336
        {
337
            try
338
            {
339
                //System.Threading.Tasks.Task.Factory.StartNew(() => { 
340

    
341
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
342
                    if (_page.Count() > 0)
343
                    {
344
                        ThumbnailItem thumbnailitem = _page.First();
345
                        if (PageChanging != null)
346
                        {
347

    
348
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
349
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
350

    
351
                                ImgListbox.SelectedItem = thumbnailitem;
352

    
353

    
354
                                if (navigationTab.SelectedIndex != 0)
355
                                {
356
                                    PageChange(thumbnailitem);
357
                                }
358

    
359
                            });
360
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
361
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
362
                            //    ImgListbox.ScrollIntoView(_itemIndex);
363
                            //else
364
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
365
                        }
366
                    }
367

    
368
                //}).ConfigureAwait(false);
369
            }
370
            catch(Exception ex)
371
            {
372
                //Logger.sendResLog("GotoPage", ex.Message, 0);
373
            }
374
        }
375

    
376
        /// <summary>
377
        /// 주어진 페이지로 변경한다
378
        /// </summary>
379
        /// <param name="iPageNo">변경할 페이지 번호</param>
380
        public void ChangePage(int iPageNo)
381
        {
382
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
383
            if ((PageChanged != null) && (thumbitem != null))
384
            {
385
                var uri = thumbitem.PageUri.ToString();
386
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
387

    
388
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
389
                if (_DocPages != null)
390
                {
391
                    PageChanged(this, new PageChangeEventArgs
392
                    {
393
                        CurrentPage = _DocPages,
394
                        PageUri = uri,
395
                        PageNumber = thumbitem.PageNumber
396
                    });
397
                    //ImgListbox.SelectedItem = thumbitem;                    
398
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
399
                    
400
                    this.CurrentPage = thumbitem;
401
                }
402
                else
403
                {
404
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
405
                }
406
            }
407
        }
408

    
409
        public void GotoPageTALK(int _pageNumber, int _angle)
410
        {
411
            int _PageNo = -1;
412

    
413
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
414
            {
415
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
416
                if (_page.Count() > 0)
417
                {
418
                    ThumbnailItem _item = _page.First();
419
                    setPageChangeTALK(_item, _angle);
420
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
421
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
422
                }
423
            }
424
        }
425

    
426
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
427
        {
428
            if (thumbnailItem != null)
429
            {
430
                if (PageChanging != null)
431
                {
432
                    ///this.CurrentPage = _NextPage;
433
                    ///_NextPage = thumbnailItem;
434
                    PageChanging(this, new PageChangeEventArgs
435
                    {
436
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
437
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
438
                        PageUri = null
439
                    });
440

    
441
                    var instanceMain = this.ParentOfType<MainWindow>();
442

    
443
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
444

    
445
                    if (rotationNum > 0) // 1, 2, 3
446
                    {
447
                        for (int i = 0; i < rotationNum; i++)
448
                        {
449
                            drawingPannelRotate(true);
450
                        }
451
                    }
452
                    else if (rotationNum < 0)// -1, -2, -3
453
                    {
454
                        for (int i = 0; i < -rotationNum; i++)
455
                        {
456
                            drawingPannelRotate(false);
457
                        }
458
                    }
459
                }
460
            }
461
        }
462

    
463
        public void drawingPannelRotate(bool Flag)
464
        {
465
            var instanceMain = this.ParentOfType<MainWindow>();
466

    
467
            if (Flag)
468
            {
469
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
470
                {
471
                    instanceMain.dzMainMenu.rotate.Angle = 0;
472
                }
473
                else
474
                {
475
                    instanceMain.dzMainMenu.rotate.Angle += 90;
476
                }
477
            }
478
            else
479
            {
480
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
481
                {
482
                    instanceMain.dzMainMenu.rotate.Angle = 270;
483
                }
484
                else
485
                {
486
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
487
                }
488
            }
489

    
490
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
491
            {
492
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
493
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
494
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
495
            }
496

    
497
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
498
            {
499
                instanceMain.dzMainMenu.translate.X = 0;
500
                instanceMain.dzMainMenu.translate.Y = 0;
501
            }
502
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
503
            {
504
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
505
                instanceMain.dzMainMenu.translate.Y = 0;
506
            }
507
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
508
            {
509
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
510
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
511
            }
512
            else
513
            {
514
                instanceMain.dzMainMenu.translate.X = 0;
515
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
516
            }
517

    
518
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
519
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
520
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
521
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
522
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
523
            ViewerDataModel.Instance.MarkupAngle = instanceMain.dzMainMenu.rotate.Angle;
524

    
525
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
526
            {
527
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
528

    
529
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
530
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
531
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
532

    
533
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
534
                if (rotationdoc != null)
535
                {
536
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
537
                }
538
                else
539
                {
540
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
541
                }
542
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
543
            });
544
        }
545

    
546
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
547
        {
548
            SetCommentPages();
549
        }
550

    
551
        public async void SetCommentPages(object obj = null)
552
        {
553
            //ThumbnailSetAsync();
554
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
555
        }
556

    
557
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList,CancellationToken? cts)
558
        {
559
            Logger.sendCheckLog("SetCommentList", 1);
560
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
561
            #region 기존 색상 제거 작업
562

    
563
            foreach (var item in this._thumbnailItems)
564
            {
565
                if (item.DisplayColorItems != null)
566
                {
567
                    item.DisplayColorItems.Clear();
568
                }
569
            }
570
            #endregion
571

    
572
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
573
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
574

    
575
            this.UsersCommentPagesList.ToList().ForEach(item =>
576
            {
577
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
578

    
579
                if (_comm.Count() == 0)
580
                {
581
                    _delItem.Add(item);
582
                }
583

    
584
                if (cts != null)
585
                {
586
                    if (cts.Value.IsCancellationRequested)
587
                        return;
588
                }
589
            });
590

    
591
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
592

    
593
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
594
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
595

    
596
            UsersCommentPagesList.ForEach(user =>
597
            {
598
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
599
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
600

    
601
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
602

    
603
                if (_commLst.Count() == 0)
604
                {
605
                    this.UsersCommentPagesList.Add(user);
606
                }
607
                else
608
                {
609
                    if (_commLst.First().PageNumber != user.PageNumber)
610
                        _commLst.First().PageNumber = user.PageNumber;
611
                }
612

    
613
                user.PageNumber.ForEach(page =>
614
                {
615
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
616

    
617
                    if (_items.Count() > 0)
618
                    {
619
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
620
                        
621
                    }
622

    
623
                    if (cts != null)
624
                    {
625
                        if (cts.Value.IsCancellationRequested)
626
                            return;
627
                    }
628
                });
629
            });
630

    
631
            foreach (var item in this._thumbnailItems)
632
            {
633
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
634
            }
635

    
636
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
637
            var data = UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
638

    
639
            if (data.Count() != 0)
640
            {
641
                if (Convert.ToBoolean(data.First().isConSolidation))
642
                {
643
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
644
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
645
                    this.lstSelectComment.ItemsSource = data;
646
                }
647
            }
648

    
649
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
650
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
651

    
652

    
653
            //var template = this.ImgListbox.ItemTemplate;
654
            //this.ImgListbox.ItemTemplate = null;
655
            //this.ImgListbox.ItemTemplate = template;
656

    
657
        }
658

    
659
        List<int> FilterPages = null;
660

    
661
        private void ThumbnailSetAsync()
662
        {
663
            Logger.sendCheckLog("ThumbnailSet", 1);
664

    
665
            if (FilteredThumbnail == null)
666
            {
667
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
668

    
669
                var pageList = ViewerDataModel.Instance.Document_Info;
670

    
671
                var items = from page in pageList
672
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
673
                            select new ThumbnailItem
674
                            {
675
                                //ImageUri = new Uri(pageLink),
676
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
677
                                PageNumber = page.PAGE_NUMBER,
678
                                Angle = page.PAGE_ANGLE
679
                            };
680

    
681
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
682
                FilteredThumbnail = new CollectionViewSource();
683
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
684

    
685
                FilteredThumbnail.Source = _thumbnailItems;
686

    
687
                FilteredThumbnail.View.CurrentChanging += (snd, evt) =>
688
                  {
689
                      System.Diagnostics.Debug.WriteLine("ect");
690
                  };
691

    
692
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
693

    
694
                FilteredThumbnail.Filter += (snd, evt) =>
695
                {
696
                    if (FilterPages?.Count() > 0 && evt.Item != null)
697
                    {
698
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
699
                    }
700
                    else
701
                    {
702
                        evt.Accepted = false;
703
                    }
704
                };
705

    
706
            }
707

    
708
            FilterPages.Clear();
709

    
710
            if (rdoAllPages.IsChecked == true)
711
            {
712
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
713
            }
714
            else if (rdoFavoritePages.IsChecked == true)
715
            {
716
                if (_FavoriteSet != null)
717
                {
718
                    FilterPages = (from thumb in _thumbnailItems
719
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
720
                                select thumb.PageNumber).ToList();
721
                }
722
            }
723
            else if (rdoCommentPages.IsChecked == true)
724
            {
725
                if (this.lstSelectComment.ItemsSource != null)
726
                {
727
                    var commentPages = (from commentPage in this.UsersCommentPagesList
728
                                        where commentPage.IsSelected == true
729
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
730

    
731
                    if (commentPages?.Count() > 0)
732
                    {
733
                        FilterPages = (from thumb in _thumbnailItems
734
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
735
                                       select thumb.PageNumber).ToList();
736
                    }
737
                }
738
            }
739

    
740
            if (FilterPages != null)
741
            {
742
                if(FilteredThumbnail == null)
743
                {
744
                    System.Diagnostics.Debug.WriteLine("filter null");
745
                }
746

    
747
                if (FilteredThumbnail.View == null)
748
                {
749
                    System.Diagnostics.Debug.WriteLine("filter null");
750
                }
751

    
752
                FilteredThumbnail.View.Refresh();
753

    
754
                if (FilterPages.Count() > 0)
755
                {
756
                    if (_thumbnailItems.Count() > 0)
757
                    {
758
                        ImgListbox.SelectedItem = _thumbnailItems[0];
759
                    }
760

    
761
                    //SetCommentList(UsersCommentPagesList.ToList());
762
                }
763
                else
764
                {
765
                    ImgListbox.SelectedItem = null;
766
                }
767

    
768
                if (ThumbInitialized != null)
769
                {
770
                    ThumbInitialized(this, new EventArgs());
771
                    ThumbInitialized = null;
772
                }
773
            }
774
        }
775

    
776

    
777
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
778
        {
779
            if (e.ClickCount >= 2)
780
            {
781
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
782

    
783
                GotoPage(selectItem.PageNumber);
784

    
785
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data, ViewerDataModel.Instance.NewMarkupCancelToken());
786

    
787
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
788
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
789
                //bool isGO = false;
790

    
791
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
792
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
793
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
794
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
795
                //{
796
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
797
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
798
                //    {
799
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
800
                //    }
801

    
802
                //};
803
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
804

    
805
                //GotoPage(MarkupList.SelectedItem as MarkupList)
806
            }
807
        }
808

    
809
        public class MarkupInfoItemSmall
810
        {
811
            public string Id { get; set; }
812
            public string UserName { get; set; }
813
            public string UserID { get; set; }
814
            public int PageNumber { get; set; }
815
            public string Data { get; set; }
816
            public int Data_Type { get; set; }
817
            public bool IsConsolidate { get; set; }
818
        }
819

    
820
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
821
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
822
        {
823
            get
824
            {
825
                if (_MarkupInfoSmallList == null)
826
                {
827
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
828
                }
829
                return _MarkupInfoSmallList;
830
            }
831
            set
832
            {
833

    
834
                _MarkupInfoSmallList = value;
835
                RaisePropertyChanged("MarkupInfoSmallList");
836
            }
837
        }
838

    
839
        /// <summary>
840
        /// goto page and select item selected by user
841
        /// </summary>
842
        /// <param name="sender"></param>
843
        /// <param name="e"></param>
844
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
845
        {
846
            var clickButtonItem = sender as RadButton;
847
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
848
            {
849
                try
850
                {
851
                    Rect rect = new Rect();
852
                    Point s_point = new Point();
853
                    Point e_point = new Point();
854

    
855
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
856
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
857

    
858
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString(),ViewerDataModel.Instance.NewMarkupCancelToken()); //언패킹작업
859
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
860
                    {
861
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
862
                            {
863
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
864
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
865
                            }
866
                            break;
867
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
868
                            {
869
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
870
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
871
                            }
872
                            break;
873
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
874
                            {
875
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
876
                                rect = new Rect(new Point(instance.StartPoint.X - 100, instance.StartPoint.Y - 100), new Point(instance.StartPoint.X + instance.BoxW + 100, instance.StartPoint.Y + instance.BoxW + 100));
877
                            }
878
                            break;
879
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
880
                            {
881
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
882

    
883
                                foreach (Point A in instance.PointSet)
884
                                {
885
                                    if (s_point == new Point())
886
                                    {
887
                                        s_point = A;
888
                                        e_point = A;
889
                                    }
890
                                    s_point.X = Math.Min(s_point.X, A.X);
891
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
892
                                    e_point.X = Math.Max(e_point.X, A.X);
893
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
894
                                }
895
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
896
                            }
897
                            break;
898
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
899
                            {
900
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
901

    
902
                                foreach (Point A in instance.PointSet)
903
                                {
904
                                    if (s_point == new Point())
905
                                    {
906
                                        s_point = A;
907
                                        e_point = A;
908
                                    }
909
                                    s_point.X = Math.Min(s_point.X, A.X);
910
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
911
                                    e_point.X = Math.Max(e_point.X, A.X);
912
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
913
                                }
914
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
915
                            }
916
                            break;
917
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
918
                            {
919
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
920

    
921
                                foreach (Point A in instance.PointSet)
922
                                {
923
                                    if (s_point == new Point())
924
                                    {
925
                                        s_point = A;
926
                                        e_point = A;
927
                                    }
928
                                    s_point.X = Math.Min(s_point.X, A.X);
929
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
930
                                    e_point.X = Math.Max(e_point.X, A.X);
931
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
932
                                }
933
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
934
                            }
935
                            break;
936
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
937
                            {
938
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
939

    
940
                                foreach (Point A in instance.PointSet)
941
                                {
942
                                    if (s_point == new Point())
943
                                    {
944
                                        s_point = A;
945
                                        e_point = A;
946
                                    }
947
                                    s_point.X = Math.Min(s_point.X, A.X);
948
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
949
                                    e_point.X = Math.Max(e_point.X, A.X);
950
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
951
                                }
952
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
953
                            }
954
                            break;
955
                        default:
956
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
957
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
958
                            break;
959
                    }
960

    
961
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
962
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
963
                }
964
                catch (Exception ex)
965
                {
966
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
967
                }
968
            }
969
        }
970

    
971
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
972
        {
973
            var clickButtonItem = sender as RadButton;
974
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
975
            {
976
                try
977
                {
978
             
979

    
980
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
981
                    MarkupList.SelectedItem = gaza;
982

    
983
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
984
                }
985
                catch (Exception ex)
986
                {
987
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
988
                }
989
            }
990
        }
991

    
992
        ///// <summary>
993
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
994
        ///// </summary>
995
        ///// <param name="CommentIdList"></param>
996
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
997
        //{
998
        //    var instance = Common.ViewerDataModel.Instance;
999

    
1000
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
1001

    
1002
        //    var commentList = instance._markupInfoList.Where(x => x.MarkupList != null).SelectMany(x => x.MarkupList).Where(f => f.ID == CommentIdList.First());
1003

    
1004
        //    if (commentList.Count() > 0)
1005
        //    {
1006
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
1007
        //        #region markup list grid select items
1008

    
1009
        //        var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0);
1010

    
1011
        //        if (infoItem.Count() > 0)
1012
        //        {
1013

    
1014
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
1015
        //            gridMarkup.SelectedItems.Clear();
1016
        //            gridMarkup.SelectedItems.Add(infoItem.First());
1017
        //        }
1018

    
1019
        //        #endregion
1020

    
1021
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
1022

    
1023
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
1024
        //        {
1025
        //            GotoSelectedMarkup(CommentIdList);
1026
        //        }
1027
        //        else
1028
        //        {
1029
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
1030

    
1031
        //            handler = (snd, evt) =>
1032
        //            {
1033
        //                GotoSelectedMarkup(CommentIdList);
1034
        //                pageNavigator.PageChanged -= handler;
1035
        //            };
1036

    
1037
        //            pageNavigator.PageChanged += handler;
1038

    
1039
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
1040
        //        }
1041
        //    }
1042
        //}
1043

    
1044
        ///// <summary>
1045
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
1046
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
1047
        ///// </summary>
1048
        ///// <param name="CommentIdList"></param>
1049
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
1050
        //{
1051
        //    var instance = Common.ViewerDataModel.Instance;
1052

    
1053
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1054
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1055

    
1056
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
1057
        //    {
1058
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
1059
        //        commentUserInfo.AddRange(selectOrderComments);
1060

    
1061
        //        if (commentUserInfo?.Count() > 0)
1062
        //        {
1063
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
1064

    
1065
        //            try
1066
        //            {
1067
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
1068
        //                {
1069
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
1070
        //                    {
1071
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
1072
        //                    } 
1073

    
1074
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
1075
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
1076
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
1077
        //                }
1078

    
1079
        //                Rect rect = commentUserInfo.First().ItemRect;
1080

    
1081
        //                foreach (var UserInfo in commentUserInfo)
1082
        //                {
1083
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1084
        //                }
1085

    
1086
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1087

    
1088
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1089
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1090
        //                //rect.Transform(matrix);
1091

    
1092
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1093
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1094
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1095
        //                double positionX = 0;
1096
        //                double positionY = 0;
1097

    
1098
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1099
        //                {
1100
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1101
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1102
        //                }
1103

    
1104
        //                main.zoomAndPanControl.ContentScale = newScale;
1105
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1106
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1107

    
1108

    
1109
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1110

    
1111
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1112

    
1113
        //                if (pageAngle == 90)
1114
        //                {
1115
        //                    pageAngle = 270;
1116
        //                }
1117
        //                else
1118
        //                {
1119
        //                    pageAngle = 90;
1120
        //                }
1121

    
1122
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1123
        //                {
1124
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1125
        //                    rect.Transform(matrix);
1126

    
1127
        //                    main.zoomAndPanControl.ZoomTo(rect);
1128
        //                }
1129
        //                else
1130
        //                {
1131
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1132

    
1133
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1134
        //                    rect.Transform(matrix);
1135

    
1136

    
1137
        //                    main.zoomAndPanControl.ZoomTo(rect);
1138
        //                }
1139
        //            }
1140
        //            catch (Exception ex)
1141
        //            {
1142
        //                main.DialogMessage_Alert(ex.Message, "Error");
1143
        //            }
1144
        //        }
1145
        //    }
1146
        //}
1147

    
1148
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1149
        {
1150
            LoadMakupList();
1151
        }
1152

    
1153
        public void LoadMakupList()
1154
        { 
1155
            if (MarkupInfoSmallList.Count == 0)
1156
            {
1157
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1158
                {
1159
                    if (d.MarkupList != null)
1160
                    {
1161
                        d.MarkupList.ForEach(b =>
1162
                        {
1163
                            bool isConsolidate = false;
1164

    
1165
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1166
                            {
1167
                                isConsolidate = true;
1168
                            }
1169

    
1170
                            System.Diagnostics.Debug.WriteLine($"UserID : {d.UserID} Consolidate : {d.Consolidate}  AvoidConsolidate : {d.AvoidConsolidate}");
1171

    
1172
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1173
                            {
1174
                                Id = b.ID,
1175
                                Data = b.Data,
1176
                                Data_Type = b.Data_Type,
1177
                                PageNumber = b.PageNumber,
1178
                                UserID = d.UserID,
1179
                                UserName = d.UserName,
1180
                                IsConsolidate = isConsolidate
1181

    
1182
                            });
1183
                        });
1184
                    }
1185
                });
1186
                MarkupList.ItemsSource = null;
1187
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1188

    
1189
                FilterUpdate();
1190
            }
1191
        }
1192

    
1193
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1194
        {
1195
            if (MarkupInfoSmallList.Count == 0)
1196
            {
1197
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1198
                {
1199
                    if (d.MarkupList != null)
1200
                    {
1201
                        d.MarkupList.ForEach(b =>
1202
                        {
1203
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1204
                            {
1205
                                Id = b.ID,
1206
                                Data = b.Data,
1207
                                Data_Type = b.Data_Type,
1208
                                PageNumber = b.PageNumber,
1209
                                UserID = d.UserID,
1210
                                UserName = d.UserName,
1211
                            });
1212
                        });
1213
                    }
1214
                });
1215
                MarkupList.ItemsSource = null;
1216
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1217
            }
1218

    
1219
            switch (eventType)
1220
            {
1221
                case Event_Type.Create:
1222
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1223
                    {
1224
                        Id = res.CommentID,
1225
                        Data = res.ConvertData,
1226
                        Data_Type = res.DATA_TYPE,
1227
                        PageNumber = CurrentPage.PageNumber,
1228
                        UserID = App.ViewInfo.UserID,
1229
                        UserName = App.UserName,
1230
                    });
1231
                    break;
1232
                case Event_Type.Delete:
1233
                    if(CommentID == null) //user information list delete btn
1234
                    {
1235
                        foreach (var delItem in item.MarkupList)
1236
                        {
1237
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1238
                        }
1239
                    }
1240
                    else //delete, cut, 
1241
                    {
1242
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1243
                    }                    
1244
                    break;
1245
                case Event_Type.Thumb://이동 회전
1246
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1247
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1248
                    {
1249
                        Id = res.CommentID,
1250
                        Data = res.ConvertData,
1251
                        Data_Type = res.DATA_TYPE,
1252
                        PageNumber = CurrentPage.PageNumber,
1253
                        UserID = App.ViewInfo.UserID,
1254
                        UserName = App.UserName,
1255
                    });
1256
                    break;
1257
                default:
1258
                    break;
1259
            }
1260

    
1261
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1262

    
1263
            bool IsConsolidation = false;
1264
            string UserId = null;
1265

    
1266
            if (commentUser.SelectedValue != null)
1267
            {
1268
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1269
                {
1270
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1271
                }
1272
                else
1273
                {
1274
                    IsConsolidation = true;
1275
                }
1276
            }
1277

    
1278
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1279
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1280
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1281

    
1282
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1283

    
1284
            FilterUpdate();
1285
        }
1286

    
1287
        private void FilterUpdate(string selectUser = null)
1288
        {
1289
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1290

    
1291
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1292
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1293

    
1294

    
1295
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1296
 
1297
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1298
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1299

    
1300
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1301
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1302

    
1303
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1304
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1305

    
1306
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1307
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1308
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1309
        }
1310

    
1311
        
1312

    
1313
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1314
        {
1315
            MarkupList.ItemsSource = null;
1316
            txtSearch.Text = string.Empty;
1317

    
1318
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1319

    
1320
            bool IsConsolidation = false;
1321
            string userName = null;
1322

    
1323
            if (commentUser.SelectedValue != null)
1324
            {
1325
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1326
                {
1327
                    userName = commentUser.SelectedValue.ToString();
1328
                }
1329
                else
1330
                {
1331
                    IsConsolidation = true;
1332
                }
1333
            }
1334

    
1335
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1336
                                   .WhereIf(userName != null, d => d.UserName == userName)
1337
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1338
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1339

    
1340
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1341

    
1342
            FilterUpdate();
1343
        }
1344

    
1345
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1346
        {
1347
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1348
        }
1349

    
1350
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1351
        {
1352
            string search_str = txtSearch.Text;
1353

    
1354
            if(string.IsNullOrWhiteSpace(search_str))
1355
            {
1356
                return;
1357
            }
1358

    
1359
            var sel_type = commentType.SelectedItem;
1360
            var sel_user = commentUser.SelectedItem;
1361
            var sel_page = commentPage.SelectedItem;
1362
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1363
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1364
            if (sel_page != null)
1365
            {
1366
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1367
            }
1368
            if (sel_type != null)
1369
            {
1370
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1371
            }
1372
            if (sel_user != null)
1373
            {
1374
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1375
            }
1376
            foreach (var item in list)
1377
            {
1378
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString(), ViewerDataModel.Instance.NewMarkupCancelToken());
1379

    
1380
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1381
                {
1382
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1383
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1384
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1385
                        {
1386
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1387

    
1388
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1389
                            {
1390
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1391
                                {
1392
                                    small_list.Add(item);
1393
                                }
1394
                            }
1395
                        }
1396
                        break;
1397
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1398
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1399
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1400
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1401
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1402
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1403
                        {
1404
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1405

    
1406
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1407
                            {
1408
                                if (instance.ArrowText.Contains(search_str))
1409
                                {
1410
                                    small_list.Add(item);
1411
                                }
1412
                            }
1413
                        }
1414
                        break;
1415
                }
1416
            }
1417

    
1418
            MarkupList.ItemsSource = null;
1419
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1420
        }
1421

    
1422
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1423
        {
1424
            if(e.Key == Key.Enter || e.Key == Key.Return)
1425
            {
1426
                btnSearch_Click(sender, new RoutedEventArgs());
1427
            }
1428
        }
1429

    
1430
    }
1431
}
클립보드 이미지 추가 (최대 크기: 500 MB)