프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 6c687be8

이력 | 보기 | 이력해설 | 다운로드 (56.5 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.Input;
17
using System.Windows.Media;
18
using Telerik.Windows.Controls;
19
using static MarkupToPDF.Controls.Parsing.MarkupParser;
20

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

    
31
        //PageManager.PageStorage samplePageStorage;
32

    
33
        public Sample()
34
        {
35
            InitializeComponent();
36

    
37
            if (App.IsDesignMode)
38
            {
39
                return;
40
            }
41

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

    
47
        private void Sample_Unloaded(object sender, RoutedEventArgs e)
48
        {
49
          
50
        }
51

    
52
        private void Sample_Loaded(object sender, RoutedEventArgs e)
53
        {
54
            if(!_Initialize)
55
            {
56
                _Initialize = true;
57

    
58
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
59
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);                
60
            }            
61
        }
62

    
63
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
64
        private List<DOCPAGE> _PageList = null;
65
        private string _DefaultUri = null;
66
        public ThumbnailItem CurrentPage = null;
67
        public int PageCount = 0;
68
        private bool _Initialize;
69

    
70
        public event EventHandler<EventArgs> ThumbInitialized;
71
        public event EventHandler<PageChangeEventArgs> PageChanged;
72
        public event EventHandler<PageChangeEventArgs> PageChanging;
73

    
74
        private List<UsersCommentPagesMember> _UsersCommentPagesList;
75

    
76
        public List<UsersCommentPagesMember> UsersCommentPagesList
77
        {
78
            get {
79
                if(_UsersCommentPagesList == null)
80
                {
81
                    _UsersCommentPagesList = new List<UsersCommentPagesMember>();
82
                }
83

    
84
                return _UsersCommentPagesList; }
85
            set { _UsersCommentPagesList = value; }
86
        }
87

    
88
        public class PageChangeEventArgs : EventArgs
89
        {
90
            public DOCPAGE CurrentPage { get; set; }
91
            public string PageUri { get; set; }
92
            public int PageNumber { get; set; }
93
        }
94
        private bool _IsFitOn { get; set; }
95
        public bool IsFitOn
96
        {
97
            get
98
            {
99
                return _IsFitOn;
100
            }
101
            set
102
            {
103
                _IsFitOn = value;
104
                RaisePropertyChanged("IsFitOn");
105
            }
106
        }
107

    
108
        public void RaisePropertyChanged(string propName)
109
        {
110
            if (PropertyChanged != null)
111
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
112
        }
113

    
114
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
115
        {
116
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
117
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
118
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
119
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
120

    
121
            this._PageList = PageList;
122
            this._DefaultUri = DefaultUri;
123

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

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

    
128
            if (cts != null)
129
            {
130
                cts.CancelAfter(100);
131
            }
132

    
133
            cts = new CancellationTokenSource();
134

    
135
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync(cts.Token));
136
            
137
            this.PageCount = PageList.Count();
138

    
139
            //ThumbNmailSet();
140
            
141
        }
142

    
143
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
144
        {
145
            Logger.sendCheckLog("rdoCommented_Checked", 1);
146
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
147
            SetCommentPages();
148
        }
149

    
150
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
151
        {
152
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
153
            if (rdoFavoritePages.IsChecked == true)
154
                expCommentPages.IsExpanded = false;
155

    
156
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
157
            if (_FavoriteSet.Count > 0)
158
            {
159
                SetCommentPages(); //수정    
160
            }
161
            else
162
            {
163
                rdoAllPages.IsChecked = true;
164
                rdoFavoritePages.IsChecked = false;
165
            }
166
        }
167

    
168
        private async void ShowPageChange(object sender, RoutedEventArgs e)
169
        {
170
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
171

    
172
            if (cts != null)
173
            {
174
                cts.CancelAfter(100);
175
            }
176

    
177
            cts = new CancellationTokenSource();
178

    
179
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync(cts.Token));
180
        }
181

    
182
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
183
        {
184
            //txtThumbCount.Visibility = Visibility.Collapsed;            
185
        }
186

    
187
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
188
        {
189
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
190
            rdoAllPages.IsChecked = false;
191
            rdoFavoritePages.IsChecked = false;
192
            //txtThumbCount.Visibility = Visibility.Visible;
193
            SetCommentPages();
194
        }
195

    
196
        /// <summary>
197
        /// called when image list box's selection is changed
198
        /// </summary>
199
        /// <param name="sender"></param>
200
        /// <param name="e"></param>
201
        private async void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
202
        {
203
            if(e.AddedItems.Count > 0)
204
            {
205
                await ImgListbox.Dispatcher.InvokeAsync(() =>
206
                {
207
                    var number = (e.AddedItems[0] as KCOM.Common.ThumbnailItem).PageNumber;
208

    
209
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
210

    
211
                    this.CurrentPage = e.AddedItems[0] as KCOM.Common.ThumbnailItem;
212

    
213
                    PageChanging(this, new PageChangeEventArgs
214
                    {
215
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
216
                        PageNumber = number,
217
                        PageUri = null
218
                    });
219

    
220
                });
221
            }
222
            
223

    
224
            //if (ImgListbox.SelectedItem != null)
225
            //{
226
            //    int _CurrentPageNo = -1;
227
            //    if (this.CurrentPage != null)
228
            //    {
229
            //        ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
230

    
231
            //        _CurrentPageNo = this.CurrentPage.PageNumber;
232
            //    }
233

    
234
            //    this.CurrentPage = ImgListbox.SelectedItem as ThumbnailItem;
235
            //    int iPageNo = this.CurrentPage.PageNumber;
236
            //    if(_CurrentPageNo != iPageNo)
237
            //    {
238
            //        PageChanging(this, new PageChangeEventArgs
239
            //        {
240
            //            CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == iPageNo).First(),
241
            //            PageNumber = iPageNo,
242
            //            PageUri = null
243
            //        });
244
            //    }
245
            //}
246

    
247
            //var border = VisualTreeHelper.GetChild(ImgListbox, 0);
248
            //if (border != null)
249
            //{
250
            //    IEnumerable<ScrollViewer> scrollViewer = border.ChildrenOfType<ScrollViewer>();
251

    
252
            //}
253
            //ScrollViewer scrollViewer = (sender as RadListBox) as ScrollViewer;
254

    
255
            
256
            //System.Diagnostics.Debug.WriteLine("page:"+ImgListbox.SelectedIndex);
257
        }
258

    
259
        public bool GotoPageFlag = false;
260

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

    
271
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
272
                    if (_page.Count() > 0)
273
                    {
274
                        ThumbnailItem thumbnailitem = _page.First();
275
                        if (PageChanging != null)
276
                        {
277

    
278
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
279
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
280
                                ImgListbox.SelectedItem = thumbnailitem;
281
                            });
282
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
283
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
284
                            //    ImgListbox.ScrollIntoView(_itemIndex);
285
                            //else
286
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
287
                        }
288
                    }
289

    
290
                }).ConfigureAwait(true);
291
            }
292
            catch(Exception ex)
293
            {
294
                Logger.sendResLog("GotoPage", ex.Message, 0);
295
            }
296
        }
297

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

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

    
331
        public void GotoPageTALK(int _pageNumber, int _angle)
332
        {
333
            int _PageNo = -1;
334

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

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

    
363
                    var instanceMain = this.ParentOfType<MainWindow>();
364

    
365
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
366

    
367
                    if (rotationNum > 0) // 1, 2, 3
368
                    {
369
                        for (int i = 0; i < rotationNum; i++)
370
                        {
371
                            drawingPannelRotate(true);
372
                        }
373
                    }
374
                    else if (rotationNum < 0)// -1, -2, -3
375
                    {
376
                        for (int i = 0; i < -rotationNum; i++)
377
                        {
378
                            drawingPannelRotate(false);
379
                        }
380
                    }
381
                }
382
            }
383
        }
384

    
385
        public void drawingPannelRotate(bool Flag)
386
        {
387
            var instanceMain = this.ParentOfType<MainWindow>();
388

    
389
            if (Flag)
390
            {
391
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
392
                {
393
                    instanceMain.dzMainMenu.rotate.Angle = 0;
394
                }
395
                else
396
                {
397
                    instanceMain.dzMainMenu.rotate.Angle += 90;
398
                }
399
            }
400
            else
401
            {
402
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
403
                {
404
                    instanceMain.dzMainMenu.rotate.Angle = 270;
405
                }
406
                else
407
                {
408
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
409
                }
410
            }
411

    
412
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
413
            {
414
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
415
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
416
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
417
            }
418

    
419
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
420
            {
421
                instanceMain.dzMainMenu.translate.X = 0;
422
                instanceMain.dzMainMenu.translate.Y = 0;
423
            }
424
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
425
            {
426
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
427
                instanceMain.dzMainMenu.translate.Y = 0;
428
            }
429
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
430
            {
431
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
432
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
433
            }
434
            else
435
            {
436
                instanceMain.dzMainMenu.translate.X = 0;
437
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
438
            }
439

    
440
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
441
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
442
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
443
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
444
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
445
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
446

    
447
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
448
            {
449
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
450

    
451
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
452
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
453
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
454

    
455
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
456
                if (rotationdoc != null)
457
                {
458
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
459
                }
460
                else
461
                {
462
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
463
                }
464
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
465
            });
466
        }
467

    
468
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
469
        {
470
            SetCommentPages();
471
        }
472
        
473
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
474
        {
475
            SetCommentPages();
476
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
477
        }
478

    
479
        public async void SetCommentPages()
480
        {
481
            if (cts != null)
482
            {
483
                cts.CancelAfter(100);
484
            }
485

    
486
            cts = new CancellationTokenSource();
487

    
488
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync(cts.Token));
489
            //SetCommentList(UsersCommentPagesList.ToList());
490
        }
491

    
492
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
493
        {
494
            Logger.sendCheckLog("SetCommentList", 1);
495
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
496
            #region 기존 색상 제거 작업
497

    
498
            foreach (var item in this._thumbnailItems)
499
            {
500
                if (item.DisplayColorItems != null)
501
                {
502
                    item.DisplayColorItems.Clear();
503
                }
504
            }
505
            #endregion
506

    
507
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
508
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
509

    
510
            this.UsersCommentPagesList.ToList().ForEach(item =>
511
            {
512
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
513

    
514
                if (_comm.Count() == 0)
515
                {
516
                    _delItem.Add(item);
517
                }
518
            });
519

    
520
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
521

    
522
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
523
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
524

    
525
            UsersCommentPagesList.ForEach(user =>
526
            {
527
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
528
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
529

    
530
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
531

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

    
542
                user.PageNumber.ForEach(page =>
543
                {
544
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
545

    
546
                    if (_items.Count() > 0)
547
                    {
548
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
549
                        
550
                    }
551
                        
552
                });
553
            });
554

    
555
            foreach (var item in this._thumbnailItems)
556
            {
557
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
558
            }
559
            
560
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
561
            var data = UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
562
            if (data.Count() != 0)
563
            {
564
                if (Convert.ToBoolean(data.First().isConSolidation))
565
                {
566
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
567
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
568
                    this.lstSelectComment.ItemsSource = data;
569
                }
570
                else
571
                {
572
                    this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
573
                }
574
            }
575
            else
576
            {
577
                this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
578
            }
579

    
580
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
581

    
582

    
583
            //var template = this.ImgListbox.ItemTemplate;
584
            //this.ImgListbox.ItemTemplate = null;
585
            //this.ImgListbox.ItemTemplate = template;
586

    
587
        }
588

    
589
        CancellationTokenSource cts = null;
590

    
591
        private void ThumbnailSetAsync(CancellationToken ct)
592
        {
593
            Logger.sendCheckLog("ThumbnailSet", 1);
594

    
595
            _thumbnailItems = new ObservableCollection<ThumbnailItem>();
596
            ImgListbox.ItemsSource = null;
597

    
598
            IEnumerable<int> selectComment = null;
599
            IEnumerable<DOCPAGE> pageList = null;
600

    
601
            if (this.lstSelectComment.ItemsSource != null)
602
            {
603
                selectComment = (from commentPage in this.UsersCommentPagesList
604
                                 where commentPage.IsSelected == true
605
                                 select commentPage.PageNumber).SelectMany(x => x).Distinct();
606
            }
607

    
608
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
609

    
610
            if (rdoAllPages.IsChecked == true)
611
            {
612
                pageList = ViewerDataModel.Instance.Document_Info;
613
            }
614
            else if (expCommentPages.IsExpanded == true)
615
            {
616
                if (selectComment != null)
617
                {
618
                    pageList = ViewerDataModel.Instance.Document_Info
619
                                .Where(p => selectComment.Where(s => s == p.PAGE_NUMBER).Count() > 0);
620
                }
621
            }
622
            else if (rdoFavoritePages.IsChecked == true)
623
            {
624
                if (_FavoriteSet != null)
625
                {
626
                    pageList = ViewerDataModel.Instance.Document_Info
627
                                .Where(p => _FavoriteSet.Where(data => data.PAGE_NO == p.PAGE_NUMBER).FirstOrDefault() != null);
628
                }
629
            }
630

    
631
            if (pageList?.Count() > 0)
632
            {
633
                var items = from page in pageList
634
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
635
                            orderby page.PAGE_NUMBER
636
                            select new ThumbnailItem
637
                            {
638
                                ImageUri = new Uri(pageLink),
639
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
640
                                PageNumber = page.PAGE_NUMBER,
641
                                Angle = page.PAGE_ANGLE
642
                            };
643

    
644

    
645
                if (items.Count() > 0)
646
                {
647
                    try
648
                    {
649
                        //await this.Dispatcher.InvokeAsync(() =>
650
                        //{
651
                            foreach (var item in items.ToList())
652
                            {
653
                                if (!ct.IsCancellationRequested)
654
                                {
655
                                    _thumbnailItems.Add(item);
656
                                    System.Diagnostics.Debug.WriteLine("Page Set : " + item.PageNumber);
657
                                }
658
                            }
659
                        //}, System.Windows.Threading.DispatcherPriority.Background, ct);
660
                    }
661
                    catch (OperationCanceledException ex)
662
                    {
663

    
664
                    }
665
                    
666
                    SetCommentList(UsersCommentPagesList.ToList());
667

    
668
                    ImgListbox.ItemsSource = _thumbnailItems;
669

    
670
                    if (_thumbnailItems.Count() > 0)
671
                    {
672
                        ImgListbox.SelectedItem = _thumbnailItems[0];
673

    
674
                        if (ThumbInitialized != null)
675
                        {
676
                            ThumbInitialized(this, new EventArgs());
677
                        }
678
                    }
679
                    //ImgListbox.UpdateLayout();
680
                }
681
            }
682
        }
683

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

    
690
                GotoPage(selectItem.PageNumber);
691

    
692
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data);
693

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

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

    
709
                //};
710
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
711

    
712
                //GotoPage(MarkupList.SelectedItem as MarkupList)
713
            }
714
        }
715

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

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

    
741
                _MarkupInfoSmallList = value;
742
                RaisePropertyChanged("MarkupInfoSmallList");
743
            }
744
        }
745

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

    
762
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
763
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
764

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

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

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

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

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

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

    
878

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

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

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

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

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

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

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

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

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

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

    
927
        //        #endregion
928

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

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

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

    
945
        //            pageNavigator.PageChanged += handler;
946

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1044

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

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

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

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

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

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

    
1092
                FilterUpdate();
1093
            }
1094
        }
1095

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

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

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

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

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

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

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

    
1187
            FilterUpdate();
1188
        }
1189

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

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

    
1197

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

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

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

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

    
1214
        
1215

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

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

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

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

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

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

    
1245
            FilterUpdate();
1246
        }
1247

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

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

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

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

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

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

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

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

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

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