프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 24c5e56c

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

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

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

    
33
        //PageManager.PageStorage samplePageStorage;
34

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

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

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

    
49
        private void Sample_Unloaded(object sender, RoutedEventArgs e)
50
        {
51
          
52
        }
53

    
54
        private void Sample_Loaded(object sender, RoutedEventArgs e)
55
        {
56
            if(!_Initialize)
57
            {
58
                _Initialize = true;
59
                SelectCommentCommand = new DelegateCommand(SetCommentPages);
60

    
61

    
62
                this.SizeChanged += Sample_SizeChanged;
63
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
64
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);
65
                this.ImgListbox.PreviewKeyUp += ImgListbox_PreviewKeyUp;
66

    
67

    
68
            }            
69
        }
70

    
71
        private void Sample_SizeChanged(object sender, SizeChangedEventArgs e)
72
        {
73
            if (e.WidthChanged)
74
            {
75
                ImgListbox.UpdateLayout();
76
            }
77
        }
78

    
79
        public static readonly DependencyProperty FilteredThumbnailProperty =  DependencyProperty.Register("FilteredThumbnail", typeof(CollectionViewSource),typeof(Sample));
80
        public CollectionViewSource FilteredThumbnail
81
        {
82
            get { return (CollectionViewSource)GetValue(FilteredThumbnailProperty); }
83
            set { SetValue(FilteredThumbnailProperty, value); }
84
        }
85

    
86
        public static readonly DependencyProperty CurrentPageProperty 
87
            = DependencyProperty.Register("CurrentPage", typeof(ThumbnailItem), typeof(Sample),new PropertyMetadata(null,CurrentPageChnaged));
88

    
89
        private static void CurrentPageChnaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
90
        {
91
            //var owner = d as Sample;
92

    
93
            //if (owner?.UsersCommentPagesList != null)
94
            //{
95
            //    owner.SetCommentPages();
96
            //}
97
        }
98

    
99
        public ThumbnailItem CurrentPage
100
        {
101
            get { return (ThumbnailItem)GetValue(CurrentPageProperty); }
102
            set { SetValue(CurrentPageProperty, value); }
103
        }
104

    
105
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
106
        private List<DOCPAGE> _PageList = null;
107
        private string _DefaultUri = null;
108
        public int PageCount = 0;
109
        private bool _Initialize;
110

    
111
        public event EventHandler<EventArgs> ThumbInitialized;
112
        public event EventHandler<PageChangeEventArgs> PageChanged;
113
        public event EventHandler<PageChangeEventArgs> PageChanging;
114

    
115
        private ObservableCollection<UsersCommentPagesMember> _UsersCommentPagesList;
116

    
117
        public ObservableCollection<UsersCommentPagesMember> UsersCommentPagesList
118
        {
119
            get {
120
                if(_UsersCommentPagesList == null)
121
                {
122
                    _UsersCommentPagesList = new ObservableCollection<UsersCommentPagesMember>();
123
                }
124

    
125
                return _UsersCommentPagesList; }
126
            set { _UsersCommentPagesList = value; }
127
        }
128

    
129
        public class PageChangeEventArgs : EventArgs
130
        {
131
            public DOCPAGE CurrentPage { get; set; }
132
            public string PageUri { get; set; }
133
            public int PageNumber { get; set; }
134
        }
135
        private bool _IsFitOn { get; set; }
136
        public bool IsFitOn
137
        {
138
            get
139
            {
140
                return _IsFitOn;
141
            }
142
            set
143
            {
144
                _IsFitOn = value;
145
                RaisePropertyChanged("IsFitOn");
146
            }
147
        }
148

    
149
        public void RaisePropertyChanged(string propName)
150
        {
151
            if (PropertyChanged != null)
152
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
153
        }
154

    
155
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
156
        {
157
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
158
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
159

    
160
            this._PageList = PageList;
161
            this._DefaultUri = DefaultUri;
162

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

    
165
            //samplePageStorage = new PageManager.PageStorage(_DefaultUri, tempStoragePath,"jpg", _PageList.Count(), _PageList.Count());
166

    
167
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
168
            
169
            this.PageCount = PageList.Count();
170

    
171
            //ThumbNmailSet();
172
            
173
        }
174

    
175
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
176
        {
177
            Logger.sendCheckLog("rdoCommented_Checked", 1);
178
            SetCommentPages();
179
        }
180

    
181
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
182
        {
183
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
184
            //if (rdoFavoritePages.IsChecked == true)
185
            //    expCommentPages.IsExpanded = false;
186

    
187
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
188
            //if (_FavoriteSet.Count > 0)
189
            //{
190
            //    SetCommentPages(); //수정    
191
            //}
192
            //else
193
            //{
194
            //    rdoAllPages.IsChecked = true;
195
            //    rdoFavoritePages.IsChecked = false;
196
            //}
197
        }
198

    
199
        private async void ShowPageChange(object sender, RoutedEventArgs e)
200
        {
201
            //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
202
            if (IsInitialized)
203
            {
204
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
205
            }
206
        }
207

    
208
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
209
        {
210
            //txtThumbCount.Visibility = Visibility.Collapsed;            
211
        }
212

    
213
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
214
        {
215
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
216
            rdoAllPages.IsChecked = false;
217
            rdoFavoritePages.IsChecked = false;
218
            //txtThumbCount.Visibility = Visibility.Visible;
219
            SetCommentPages();
220
        }
221

    
222
        private void ImgListbox_PreviewKeyUp(object sender, KeyEventArgs e)
223
        {
224
            if (ImgListbox.SelectedItem != null && (e.Key == Key.Up || e.Key == Key.Down))
225
            {
226
                System.Diagnostics.Debug.WriteLine("ImgListbox_PreviewKeyUp");
227

    
228
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
229
            }
230
        }
231

    
232
        /// <summary>
233
        /// called when image list box's selection is changed
234
        /// </summary>
235
        /// <param name="sender"></param>
236
        /// <param name="e"></param>
237
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
238
        {
239
            if (!Keyboard.IsKeyDown(Key.Down) && !Keyboard.IsKeyDown(Key.Up))
240
            {
241
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
242
            }
243
        }
244

    
245
        private void PageChange(KCOM.Common.ThumbnailItem selectItem)
246
        { 
247
                var number = selectItem.PageNumber;
248

    
249
                if (ViewerDataModel.Instance.PageNumber != number)
250
                {
251
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
252

    
253
                    this.CurrentPage = ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem;
254

    
255
                    PageChanging(this, new PageChangeEventArgs
256
                    {
257
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
258
                        PageNumber = number,
259
                        PageUri = null
260
                    });
261
                }
262
        }
263

    
264
        public bool GotoPageFlag = false;
265

    
266
        /// <summary>
267
        /// 해당 썸네일로 이동
268
        /// </summary>
269
        /// <param name="_pageNumber">이동할 페이지 번호</param>
270
        public void GotoPage(int _pageNumber)
271
        {
272
            try
273
            {
274
                System.Threading.Tasks.Task.Factory.StartNew(() => { 
275

    
276
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
277
                    if (_page.Count() > 0)
278
                    {
279
                        ThumbnailItem thumbnailitem = _page.First();
280
                        if (PageChanging != null)
281
                        {
282

    
283
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
284
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
285
                                ImgListbox.SelectedItem = thumbnailitem;
286
                            });
287
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
288
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
289
                            //    ImgListbox.ScrollIntoView(_itemIndex);
290
                            //else
291
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
292
                        }
293
                    }
294

    
295
                }).ConfigureAwait(true);
296
            }
297
            catch(Exception ex)
298
            {
299
                Logger.sendResLog("GotoPage", ex.Message, 0);
300
            }
301
        }
302

    
303
        /// <summary>
304
        /// 주어진 페이지로 변경한다
305
        /// </summary>
306
        /// <param name="iPageNo">변경할 페이지 번호</param>
307
        public void ChangePage(int iPageNo)
308
        {
309
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
310
            if ((PageChanged != null) && (thumbitem != null))
311
            {
312
                var uri = thumbitem.PageUri.ToString();
313
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
314

    
315
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
316
                if (_DocPages != null)
317
                {
318
                    PageChanged(this, new PageChangeEventArgs
319
                    {
320
                        CurrentPage = _DocPages,
321
                        PageUri = uri,
322
                        PageNumber = thumbitem.PageNumber
323
                    });
324
                    //ImgListbox.SelectedItem = thumbitem;                    
325
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
326
                    
327
                    this.CurrentPage = thumbitem;
328
                }
329
                else
330
                {
331
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
332
                }
333
            }
334
        }
335

    
336
        public void GotoPageTALK(int _pageNumber, int _angle)
337
        {
338
            int _PageNo = -1;
339

    
340
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
341
            {
342
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
343
                if (_page.Count() > 0)
344
                {
345
                    ThumbnailItem _item = _page.First();
346
                    setPageChangeTALK(_item, _angle);
347
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
348
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
349
                }
350
            }
351
        }
352

    
353
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
354
        {
355
            if (thumbnailItem != null)
356
            {
357
                if (PageChanging != null)
358
                {
359
                    ///this.CurrentPage = _NextPage;
360
                    ///_NextPage = thumbnailItem;
361
                    PageChanging(this, new PageChangeEventArgs
362
                    {
363
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
364
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
365
                        PageUri = null
366
                    });
367

    
368
                    var instanceMain = this.ParentOfType<MainWindow>();
369

    
370
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
371

    
372
                    if (rotationNum > 0) // 1, 2, 3
373
                    {
374
                        for (int i = 0; i < rotationNum; i++)
375
                        {
376
                            drawingPannelRotate(true);
377
                        }
378
                    }
379
                    else if (rotationNum < 0)// -1, -2, -3
380
                    {
381
                        for (int i = 0; i < -rotationNum; i++)
382
                        {
383
                            drawingPannelRotate(false);
384
                        }
385
                    }
386
                }
387
            }
388
        }
389

    
390
        public void drawingPannelRotate(bool Flag)
391
        {
392
            var instanceMain = this.ParentOfType<MainWindow>();
393

    
394
            if (Flag)
395
            {
396
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
397
                {
398
                    instanceMain.dzMainMenu.rotate.Angle = 0;
399
                }
400
                else
401
                {
402
                    instanceMain.dzMainMenu.rotate.Angle += 90;
403
                }
404
            }
405
            else
406
            {
407
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
408
                {
409
                    instanceMain.dzMainMenu.rotate.Angle = 270;
410
                }
411
                else
412
                {
413
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
414
                }
415
            }
416

    
417
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
418
            {
419
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
420
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
421
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
422
            }
423

    
424
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
425
            {
426
                instanceMain.dzMainMenu.translate.X = 0;
427
                instanceMain.dzMainMenu.translate.Y = 0;
428
            }
429
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
430
            {
431
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
432
                instanceMain.dzMainMenu.translate.Y = 0;
433
            }
434
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
435
            {
436
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
437
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
438
            }
439
            else
440
            {
441
                instanceMain.dzMainMenu.translate.X = 0;
442
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
443
            }
444

    
445
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
446
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
447
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
448
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
449
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
450
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
451

    
452
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
453
            {
454
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
455

    
456
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
457
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
458
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
459

    
460
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
461
                if (rotationdoc != null)
462
                {
463
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
464
                }
465
                else
466
                {
467
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
468
                }
469
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
470
            });
471
        }
472

    
473
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
474
        {
475
            SetCommentPages();
476
        }
477

    
478
        public async void SetCommentPages(object obj = null)
479
        {
480
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
481
        }
482

    
483
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList,CancellationToken? cts)
484
        {
485
            Logger.sendCheckLog("SetCommentList", 1);
486
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
487
            #region 기존 색상 제거 작업
488

    
489
            foreach (var item in this._thumbnailItems)
490
            {
491
                if (item.DisplayColorItems != null)
492
                {
493
                    item.DisplayColorItems.Clear();
494
                }
495
            }
496
            #endregion
497

    
498
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
499
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
500

    
501
            this.UsersCommentPagesList.ToList().ForEach(item =>
502
            {
503
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
504

    
505
                if (_comm.Count() == 0)
506
                {
507
                    _delItem.Add(item);
508
                }
509

    
510
                if (cts != null)
511
                {
512
                    if (cts.Value.IsCancellationRequested)
513
                        return;
514
                }
515
            });
516

    
517
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
518

    
519
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
520
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
521

    
522
            UsersCommentPagesList.ForEach(user =>
523
            {
524
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
525
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
526

    
527
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
528

    
529
                if (_commLst.Count() == 0)
530
                {
531
                    this.UsersCommentPagesList.Add(user);
532
                }
533
                else
534
                {
535
                    if (_commLst.First().PageNumber != user.PageNumber)
536
                        _commLst.First().PageNumber = user.PageNumber;
537
                }
538

    
539
                user.PageNumber.ForEach(page =>
540
                {
541
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
542

    
543
                    if (_items.Count() > 0)
544
                    {
545
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
546
                        
547
                    }
548

    
549
                    if (cts != null)
550
                    {
551
                        if (cts.Value.IsCancellationRequested)
552
                            return;
553
                    }
554
                });
555
            });
556

    
557
            foreach (var item in this._thumbnailItems)
558
            {
559
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
560
            }
561

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

    
565
            if (data.Count() != 0)
566
            {
567
                if (Convert.ToBoolean(data.First().isConSolidation))
568
                {
569
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
570
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
571
                    this.lstSelectComment.ItemsSource = data;
572
                }
573
            }
574

    
575
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
576

    
577
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
578

    
579

    
580
            //var template = this.ImgListbox.ItemTemplate;
581
            //this.ImgListbox.ItemTemplate = null;
582
            //this.ImgListbox.ItemTemplate = template;
583

    
584
        }
585

    
586
        List<int> FilterPages = null;
587

    
588
        private void ThumbnailSetAsync()
589
        {
590
            Logger.sendCheckLog("ThumbnailSet", 1);
591

    
592
            if (FilteredThumbnail == null)
593
            {
594
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
595

    
596
                var pageList = ViewerDataModel.Instance.Document_Info;
597

    
598
                var items = from page in pageList
599
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
600
                            select new ThumbnailItem
601
                            {
602
                                ImageUri = new Uri(pageLink),
603
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
604
                                PageNumber = page.PAGE_NUMBER,
605
                                Angle = page.PAGE_ANGLE
606
                            };
607

    
608
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
609
                FilteredThumbnail = new CollectionViewSource();
610
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
611

    
612
                FilteredThumbnail.Source = _thumbnailItems;
613

    
614
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
615

    
616
                FilteredThumbnail.Filter += (snd,evt) =>
617
                {
618
                    if (FilterPages?.Count() > 0 && evt.Item != null)
619
                    {
620
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
621
                    }
622
                    else
623
                    {
624
                        evt.Accepted = false;
625
                    }
626
                };
627

    
628
            }
629

    
630
            FilterPages.Clear();
631

    
632

    
633
            if (rdoAllPages.IsChecked == true)
634
            {
635
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
636
            }
637
            else if (rdoFavoritePages.IsChecked == true)
638
            {
639
                if (_FavoriteSet != null)
640
                {
641
                    FilterPages = (from thumb in _thumbnailItems
642
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
643
                                select thumb.PageNumber).ToList();
644
                }
645
            }
646
            else if (rdoCommentPages.IsChecked == true)
647
            {
648
                if (this.lstSelectComment.ItemsSource != null)
649
                {
650
                    var commentPages = (from commentPage in this.UsersCommentPagesList
651
                                        where commentPage.IsSelected == true
652
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
653

    
654
                    if (commentPages?.Count() > 0)
655
                    {
656
                        FilterPages = (from thumb in _thumbnailItems
657
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
658
                                       select thumb.PageNumber).ToList();
659
                    }
660
                }
661
            }
662

    
663
            if (FilterPages != null)
664
            {
665
                FilteredThumbnail.View.Refresh();
666

    
667
                if (FilterPages.Count() > 0)
668
                {
669
                    ImgListbox.SelectedItem = _thumbnailItems.Where(x=>x.PageNumber == FilterPages.FirstOrDefault()).FirstOrDefault();
670
                    //SetCommentList(UsersCommentPagesList.ToList());
671
                }
672
                else
673
                {
674
                    ImgListbox.SelectedItem = null;
675
                }
676

    
677
                if (ThumbInitialized != null)
678
                {
679
                    ThumbInitialized(this, new EventArgs());
680
                    ThumbInitialized = null;
681
                }
682
            }
683
        }
684

    
685

    
686
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
687
        {
688
            if (e.ClickCount >= 2)
689
            {
690
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
691

    
692
                GotoPage(selectItem.PageNumber);
693

    
694
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data, ViewerDataModel.Instance.CancellationToken());
695

    
696
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
697
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
698
                //bool isGO = false;
699

    
700
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
701
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
702
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
703
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
704
                //{
705
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
706
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
707
                //    {
708
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
709
                //    }
710

    
711
                //};
712
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
713

    
714
                //GotoPage(MarkupList.SelectedItem as MarkupList)
715
            }
716
        }
717

    
718
        public class MarkupInfoItemSmall
719
        {
720
            public string Id { get; set; }
721
            public string UserName { get; set; }
722
            public string UserID { get; set; }
723
            public int PageNumber { get; set; }
724
            public string Data { get; set; }
725
            public int Data_Type { get; set; }
726
            public bool IsConsolidate { get; set; }
727
        }
728

    
729
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
730
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
731
        {
732
            get
733
            {
734
                if (_MarkupInfoSmallList == null)
735
                {
736
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
737
                }
738
                return _MarkupInfoSmallList;
739
            }
740
            set
741
            {
742

    
743
                _MarkupInfoSmallList = value;
744
                RaisePropertyChanged("MarkupInfoSmallList");
745
            }
746
        }
747

    
748
        /// <summary>
749
        /// goto page and select item selected by user
750
        /// </summary>
751
        /// <param name="sender"></param>
752
        /// <param name="e"></param>
753
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
754
        {
755
            var clickButtonItem = sender as RadButton;
756
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
757
            {
758
                try
759
                {
760
                    Rect rect = new Rect();
761
                    Point s_point = new Point();
762
                    Point e_point = new Point();
763

    
764
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
765
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
766

    
767
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString(),ViewerDataModel.Instance.CancellationToken()); //언패킹작업
768
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
769
                    {
770
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
771
                            {
772
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
773
                                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));
774
                            }
775
                            break;
776
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
777
                            {
778
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
779
                                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));
780
                            }
781
                            break;
782
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
783
                            {
784
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
785
                                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));
786
                            }
787
                            break;
788
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
789
                            {
790
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
791

    
792
                                foreach (Point A in instance.PointSet)
793
                                {
794
                                    if (s_point == new Point())
795
                                    {
796
                                        s_point = A;
797
                                        e_point = A;
798
                                    }
799
                                    s_point.X = Math.Min(s_point.X, A.X);
800
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
801
                                    e_point.X = Math.Max(e_point.X, A.X);
802
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
803
                                }
804
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
805
                            }
806
                            break;
807
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
808
                            {
809
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
810

    
811
                                foreach (Point A in instance.PointSet)
812
                                {
813
                                    if (s_point == new Point())
814
                                    {
815
                                        s_point = A;
816
                                        e_point = A;
817
                                    }
818
                                    s_point.X = Math.Min(s_point.X, A.X);
819
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
820
                                    e_point.X = Math.Max(e_point.X, A.X);
821
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
822
                                }
823
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
824
                            }
825
                            break;
826
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
827
                            {
828
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
829

    
830
                                foreach (Point A in instance.PointSet)
831
                                {
832
                                    if (s_point == new Point())
833
                                    {
834
                                        s_point = A;
835
                                        e_point = A;
836
                                    }
837
                                    s_point.X = Math.Min(s_point.X, A.X);
838
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
839
                                    e_point.X = Math.Max(e_point.X, A.X);
840
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
841
                                }
842
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
843
                            }
844
                            break;
845
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
846
                            {
847
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
848

    
849
                                foreach (Point A in instance.PointSet)
850
                                {
851
                                    if (s_point == new Point())
852
                                    {
853
                                        s_point = A;
854
                                        e_point = A;
855
                                    }
856
                                    s_point.X = Math.Min(s_point.X, A.X);
857
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
858
                                    e_point.X = Math.Max(e_point.X, A.X);
859
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
860
                                }
861
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
862
                            }
863
                            break;
864
                        default:
865
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
866
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
867
                            break;
868
                    }
869

    
870
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
871
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
872
                }
873
                catch (Exception ex)
874
                {
875
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
876
                }
877
            }
878
        }
879

    
880
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
881
        {
882
            var clickButtonItem = sender as RadButton;
883
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
884
            {
885
                try
886
                {
887
             
888

    
889
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
890
                    MarkupList.SelectedItem = gaza;
891

    
892
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
893
                }
894
                catch (Exception ex)
895
                {
896
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
897
                }
898
            }
899
        }
900

    
901
        ///// <summary>
902
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
903
        ///// </summary>
904
        ///// <param name="CommentIdList"></param>
905
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
906
        //{
907
        //    var instance = Common.ViewerDataModel.Instance;
908

    
909
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
910

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

    
913
        //    if (commentList.Count() > 0)
914
        //    {
915
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
916
        //        #region markup list grid select items
917

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

    
920
        //        if (infoItem.Count() > 0)
921
        //        {
922

    
923
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
924
        //            gridMarkup.SelectedItems.Clear();
925
        //            gridMarkup.SelectedItems.Add(infoItem.First());
926
        //        }
927

    
928
        //        #endregion
929

    
930
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
931

    
932
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
933
        //        {
934
        //            GotoSelectedMarkup(CommentIdList);
935
        //        }
936
        //        else
937
        //        {
938
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
939

    
940
        //            handler = (snd, evt) =>
941
        //            {
942
        //                GotoSelectedMarkup(CommentIdList);
943
        //                pageNavigator.PageChanged -= handler;
944
        //            };
945

    
946
        //            pageNavigator.PageChanged += handler;
947

    
948
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
949
        //        }
950
        //    }
951
        //}
952

    
953
        ///// <summary>
954
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
955
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
956
        ///// </summary>
957
        ///// <param name="CommentIdList"></param>
958
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
959
        //{
960
        //    var instance = Common.ViewerDataModel.Instance;
961

    
962
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
963
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
964

    
965
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
966
        //    {
967
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
968
        //        commentUserInfo.AddRange(selectOrderComments);
969

    
970
        //        if (commentUserInfo?.Count() > 0)
971
        //        {
972
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
973

    
974
        //            try
975
        //            {
976
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
977
        //                {
978
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
979
        //                    {
980
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
981
        //                    } 
982
                            
983
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
984
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
985
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
986
        //                }
987

    
988
        //                Rect rect = commentUserInfo.First().ItemRect;
989

    
990
        //                foreach (var UserInfo in commentUserInfo)
991
        //                {
992
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
993
        //                }
994

    
995
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
996

    
997
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
998
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
999
        //                //rect.Transform(matrix);
1000

    
1001
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1002
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1003
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1004
        //                double positionX = 0;
1005
        //                double positionY = 0;
1006

    
1007
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1008
        //                {
1009
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1010
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1011
        //                }
1012

    
1013
        //                main.zoomAndPanControl.ContentScale = newScale;
1014
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1015
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1016

    
1017
              
1018
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1019

    
1020
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1021

    
1022
        //                if (pageAngle == 90)
1023
        //                {
1024
        //                    pageAngle = 270;
1025
        //                }
1026
        //                else
1027
        //                {
1028
        //                    pageAngle = 90;
1029
        //                }
1030

    
1031
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1032
        //                {
1033
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1034
        //                    rect.Transform(matrix);
1035

    
1036
        //                    main.zoomAndPanControl.ZoomTo(rect);
1037
        //                }
1038
        //                else
1039
        //                {
1040
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1041

    
1042
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1043
        //                    rect.Transform(matrix);
1044

    
1045

    
1046
        //                    main.zoomAndPanControl.ZoomTo(rect);
1047
        //                }
1048
        //            }
1049
        //            catch (Exception ex)
1050
        //            {
1051
        //                main.DialogMessage_Alert(ex.Message, "Error");
1052
        //            }
1053
        //        }
1054
        //    }
1055
        //}
1056

    
1057
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1058
        {
1059
            if (MarkupInfoSmallList.Count == 0)
1060
            {
1061
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1062
                {
1063
                    if (d.MarkupList != null)
1064
                    {
1065
                        d.MarkupList.ForEach(b =>
1066
                        {
1067
                            bool isConsolidate = false;
1068

    
1069
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1070
                            {
1071
                                isConsolidate = true;
1072
                            }
1073

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

    
1076
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1077
                            {
1078
                                Id = b.ID,
1079
                                Data = b.Data,
1080
                                Data_Type = b.Data_Type,
1081
                                PageNumber = b.PageNumber,
1082
                                UserID = d.UserID,
1083
                                UserName = d.UserName,
1084
                                IsConsolidate = isConsolidate
1085

    
1086
                            });
1087
                        });
1088
                    }
1089
                });
1090
                MarkupList.ItemsSource = null;
1091
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1092

    
1093
                FilterUpdate();
1094
            }
1095
        }
1096

    
1097
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1098
        {
1099
            if (MarkupInfoSmallList.Count == 0)
1100
            {
1101
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1102
                {
1103
                    if (d.MarkupList != null)
1104
                    {
1105
                        d.MarkupList.ForEach(b =>
1106
                        {
1107
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1108
                            {
1109
                                Id = b.ID,
1110
                                Data = b.Data,
1111
                                Data_Type = b.Data_Type,
1112
                                PageNumber = b.PageNumber,
1113
                                UserID = d.UserID,
1114
                                UserName = d.UserName,
1115
                            });
1116
                        });
1117
                    }
1118
                });
1119
                MarkupList.ItemsSource = null;
1120
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1121
            }
1122

    
1123
            switch (eventType)
1124
            {
1125
                case Event_Type.Create:
1126
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1127
                    {
1128
                        Id = res.CommentID,
1129
                        Data = res.ConvertData,
1130
                        Data_Type = res.DATA_TYPE,
1131
                        PageNumber = CurrentPage.PageNumber,
1132
                        UserID = App.ViewInfo.UserID,
1133
                        UserName = App.UserName,
1134
                    });
1135
                    break;
1136
                case Event_Type.Delete:
1137
                    if(CommentID == null) //user information list delete btn
1138
                    {
1139
                        foreach (var delItem in item.MarkupList)
1140
                        {
1141
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1142
                        }
1143
                    }
1144
                    else //delete, cut, 
1145
                    {
1146
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1147
                    }                    
1148
                    break;
1149
                case Event_Type.Thumb://이동 회전
1150
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1151
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1152
                    {
1153
                        Id = res.CommentID,
1154
                        Data = res.ConvertData,
1155
                        Data_Type = res.DATA_TYPE,
1156
                        PageNumber = CurrentPage.PageNumber,
1157
                        UserID = App.ViewInfo.UserID,
1158
                        UserName = App.UserName,
1159
                    });
1160
                    break;
1161
                default:
1162
                    break;
1163
            }
1164

    
1165
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1166

    
1167
            bool IsConsolidation = false;
1168
            string UserId = null;
1169

    
1170
            if (commentUser.SelectedValue != null)
1171
            {
1172
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1173
                {
1174
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1175
                }
1176
                else
1177
                {
1178
                    IsConsolidation = true;
1179
                }
1180
            }
1181

    
1182
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1183
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1184
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1185

    
1186
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1187

    
1188
            FilterUpdate();
1189
        }
1190

    
1191
        private void FilterUpdate(string selectUser = null)
1192
        {
1193
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1194

    
1195
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1196
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1197

    
1198

    
1199
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1200
 
1201
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1202
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1203

    
1204
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1205
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1206

    
1207
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1208
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1209

    
1210
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1211
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1212
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1213
        }
1214

    
1215
        
1216

    
1217
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1218
        {
1219
            MarkupList.ItemsSource = null;
1220
            txtSearch.Text = string.Empty;
1221

    
1222
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1223

    
1224
            bool IsConsolidation = false;
1225
            string userName = null;
1226

    
1227
            if (commentUser.SelectedValue != null)
1228
            {
1229
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1230
                {
1231
                    userName = commentUser.SelectedValue.ToString();
1232
                }
1233
                else
1234
                {
1235
                    IsConsolidation = true;
1236
                }
1237
            }
1238

    
1239
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1240
                                   .WhereIf(userName != null, d => d.UserName == userName)
1241
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1242
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1243

    
1244
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1245

    
1246
            FilterUpdate();
1247
        }
1248

    
1249
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1250
        {
1251
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1252
        }
1253

    
1254
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1255
        {
1256
            string search_str = txtSearch.Text;
1257

    
1258
            if(string.IsNullOrWhiteSpace(search_str))
1259
            {
1260
                return;
1261
            }
1262

    
1263
            var sel_type = commentType.SelectedItem;
1264
            var sel_user = commentUser.SelectedItem;
1265
            var sel_page = commentPage.SelectedItem;
1266
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1267
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1268
            if (sel_page != null)
1269
            {
1270
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1271
            }
1272
            if (sel_type != null)
1273
            {
1274
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1275
            }
1276
            if (sel_user != null)
1277
            {
1278
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1279
            }
1280
            foreach (var item in list)
1281
            {
1282
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString(), ViewerDataModel.Instance.CancellationToken());
1283

    
1284
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1285
                {
1286
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1287
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1288
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1289
                        {
1290
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1291

    
1292
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1293
                            {
1294
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1295
                                {
1296
                                    small_list.Add(item);
1297
                                }
1298
                            }
1299
                        }
1300
                        break;
1301
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1302
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1303
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1304
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1305
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1306
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1307
                        {
1308
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1309

    
1310
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1311
                            {
1312
                                if (instance.ArrowText.Contains(search_str))
1313
                                {
1314
                                    small_list.Add(item);
1315
                                }
1316
                            }
1317
                        }
1318
                        break;
1319
                }
1320
            }
1321

    
1322
            MarkupList.ItemsSource = null;
1323
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1324
        }
1325

    
1326
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1327
        {
1328
            if(e.Key == Key.Enter || e.Key == Key.Return)
1329
            {
1330
                btnSearch_Click(sender, new RoutedEventArgs());
1331
            }
1332
        }
1333

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