프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 664ea2e1

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

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

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

    
34

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

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

    
44
            App.splashString(ISplashMessage.SAMPLE);
45
            this.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
            App.splashString(ISplashMessage.SAMPLE);
158
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
159
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
160

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

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

    
166
            
167
            //ThumbnailSetAsync();
168
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
169

    
170
            this.PageCount = PageList.Count();
171

    
172
            string endpoint = Common.Commons.shortGuid() + "Thumbnail";
173

    
174
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
175
            wcfServer.IpcThumbnailReceived += WcfServer_IpcThumbnailReceived;
176
            wcfServer.Start();
177

    
178
            DownloadProcess.ThumbnailDownloader(endpoint,ViewerDataModel.Instance.IsAdmin, this._DefaultUri, tempStoragePath, "jpg", this.PageCount);
179
            DownloadProcess.ProcessMonitor(ViewerDataModel.Instance.IsAdmin, tempStoragePath);
180

    
181
            App.splashScreen.Close();
182
        }
183

    
184
        private void WcfServer_IpcThumbnailReceived(object sender, IpcThumbnailEventArgs e)
185
        {
186
            var items = _thumbnailItems.Where(x => x.PageNumber == e.PageNo);
187

    
188
            if (items.Count() > 0)
189
            {
190
                //Dispatcher.BeginInvoke((Action)delegate ()
191
                //{
192
                    items.First().ImageUri = new Uri(e.Path, UriKind.Absolute);
193
                //});
194
            }
195
        }
196

    
197
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
198
        {
199
            Logger.sendCheckLog("rdoCommented_Checked", 1);
200
            SetCommentPages();
201
        }
202

    
203
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
204
        {
205
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
206
            //if (rdoFavoritePages.IsChecked == true)
207
            //    expCommentPages.IsExpanded = false;
208

    
209
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
210
            //if (_FavoriteSet.Count > 0)
211
            //{
212
            //    SetCommentPages(); //수정    
213
            //}
214
            //else
215
            //{
216
            //    rdoAllPages.IsChecked = true;
217
            //    rdoFavoritePages.IsChecked = false;
218
            //}
219
        }
220

    
221
        private async void ShowPageChange(object sender, RoutedEventArgs e)
222
        {
223
            //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
224
            if (IsInitialized)
225
            {
226
                //ThumbnailSetAsync();
227
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
228
            }
229
        }
230

    
231
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
232
        {
233
            //txtThumbCount.Visibility = Visibility.Collapsed;            
234
        }
235

    
236
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
237
        {
238
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
239
            rdoAllPages.IsChecked = false;
240
            rdoFavoritePages.IsChecked = false;
241
            //txtThumbCount.Visibility = Visibility.Visible;
242
            SetCommentPages();
243
        }
244

    
245
        private void ImgListbox_PreviewKeyUp(object sender, KeyEventArgs e)
246
        {
247
            if (ImgListbox.SelectedItem != null && (e.Key == Key.Up || e.Key == Key.Down))
248
            {
249
                System.Diagnostics.Debug.WriteLine("ImgListbox_PreviewKeyUp");
250

    
251
                PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
252
            }
253
        }
254

    
255
        /// <summary>
256
        /// called when image list box's selection is changed
257
        /// </summary>
258
        /// <param name="sender"></param>
259
        /// <param name="e"></param>
260
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
261
        {
262
            if (!Keyboard.IsKeyDown(Key.Down) && !Keyboard.IsKeyDown(Key.Up))
263
            {
264
                if (ImgListbox.SelectedItem != null)
265
                {
266
                    PageChange(ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem);
267
                }
268
            }
269
        }
270

    
271
        private void PageChange(KCOM.Common.ThumbnailItem selectItem)
272
        { 
273
                var number = selectItem.PageNumber;
274

    
275
                if (ViewerDataModel.Instance.PageNumber != number)
276
                {
277
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
278

    
279
                    this.CurrentPage = ImgListbox.SelectedItem as KCOM.Common.ThumbnailItem;
280

    
281
                    PageChanging(this, new PageChangeEventArgs
282
                    {
283
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
284
                        PageNumber = number,
285
                        PageUri = null
286
                    });
287
                }
288
        }
289

    
290
        public bool GotoPageFlag = false;
291

    
292
        /// <summary>
293
        /// 해당 썸네일로 이동
294
        /// </summary>
295
        /// <param name="_pageNumber">이동할 페이지 번호</param>
296
        public void GotoPage(int _pageNumber)
297
        {
298
            try
299
            {
300
                System.Threading.Tasks.Task.Factory.StartNew(() => { 
301

    
302
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
303
                    if (_page.Count() > 0)
304
                    {
305
                        ThumbnailItem thumbnailitem = _page.First();
306
                        if (PageChanging != null)
307
                        {
308

    
309
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
310
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
311
                                ImgListbox.SelectedItem = thumbnailitem;
312
                            });
313
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
314
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
315
                            //    ImgListbox.ScrollIntoView(_itemIndex);
316
                            //else
317
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
318
                        }
319
                    }
320

    
321
                }).ConfigureAwait(true);
322
            }
323
            catch(Exception ex)
324
            {
325
                //Logger.sendResLog("GotoPage", ex.Message, 0);
326
            }
327
        }
328

    
329
        /// <summary>
330
        /// 주어진 페이지로 변경한다
331
        /// </summary>
332
        /// <param name="iPageNo">변경할 페이지 번호</param>
333
        public void ChangePage(int iPageNo)
334
        {
335
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
336
            if ((PageChanged != null) && (thumbitem != null))
337
            {
338
                var uri = thumbitem.PageUri.ToString();
339
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
340

    
341
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
342
                if (_DocPages != null)
343
                {
344
                    PageChanged(this, new PageChangeEventArgs
345
                    {
346
                        CurrentPage = _DocPages,
347
                        PageUri = uri,
348
                        PageNumber = thumbitem.PageNumber
349
                    });
350
                    //ImgListbox.SelectedItem = thumbitem;                    
351
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
352
                    
353
                    this.CurrentPage = thumbitem;
354
                }
355
                else
356
                {
357
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
358
                }
359
            }
360
        }
361

    
362
        public void GotoPageTALK(int _pageNumber, int _angle)
363
        {
364
            int _PageNo = -1;
365

    
366
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
367
            {
368
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
369
                if (_page.Count() > 0)
370
                {
371
                    ThumbnailItem _item = _page.First();
372
                    setPageChangeTALK(_item, _angle);
373
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
374
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
375
                }
376
            }
377
        }
378

    
379
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
380
        {
381
            if (thumbnailItem != null)
382
            {
383
                if (PageChanging != null)
384
                {
385
                    ///this.CurrentPage = _NextPage;
386
                    ///_NextPage = thumbnailItem;
387
                    PageChanging(this, new PageChangeEventArgs
388
                    {
389
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
390
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
391
                        PageUri = null
392
                    });
393

    
394
                    var instanceMain = this.ParentOfType<MainWindow>();
395

    
396
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
397

    
398
                    if (rotationNum > 0) // 1, 2, 3
399
                    {
400
                        for (int i = 0; i < rotationNum; i++)
401
                        {
402
                            drawingPannelRotate(true);
403
                        }
404
                    }
405
                    else if (rotationNum < 0)// -1, -2, -3
406
                    {
407
                        for (int i = 0; i < -rotationNum; i++)
408
                        {
409
                            drawingPannelRotate(false);
410
                        }
411
                    }
412
                }
413
            }
414
        }
415

    
416
        public void drawingPannelRotate(bool Flag)
417
        {
418
            var instanceMain = this.ParentOfType<MainWindow>();
419

    
420
            if (Flag)
421
            {
422
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
423
                {
424
                    instanceMain.dzMainMenu.rotate.Angle = 0;
425
                }
426
                else
427
                {
428
                    instanceMain.dzMainMenu.rotate.Angle += 90;
429
                }
430
            }
431
            else
432
            {
433
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
434
                {
435
                    instanceMain.dzMainMenu.rotate.Angle = 270;
436
                }
437
                else
438
                {
439
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
440
                }
441
            }
442

    
443
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
444
            {
445
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
446
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
447
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
448
            }
449

    
450
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
451
            {
452
                instanceMain.dzMainMenu.translate.X = 0;
453
                instanceMain.dzMainMenu.translate.Y = 0;
454
            }
455
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
456
            {
457
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
458
                instanceMain.dzMainMenu.translate.Y = 0;
459
            }
460
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
461
            {
462
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
463
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
464
            }
465
            else
466
            {
467
                instanceMain.dzMainMenu.translate.X = 0;
468
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
469
            }
470

    
471
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
472
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
473
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
474
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
475
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
476
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
477

    
478
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
479
            {
480
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
481

    
482
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
483
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
484
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
485

    
486
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
487
                if (rotationdoc != null)
488
                {
489
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
490
                }
491
                else
492
                {
493
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
494
                }
495
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
496
            });
497
        }
498

    
499
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
500
        {
501
            SetCommentPages();
502
        }
503

    
504
        public async void SetCommentPages(object obj = null)
505
        {
506
            //ThumbnailSetAsync();
507
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
508
        }
509

    
510
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList,CancellationToken? cts)
511
        {
512
            Logger.sendCheckLog("SetCommentList", 1);
513
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
514
            #region 기존 색상 제거 작업
515

    
516
            foreach (var item in this._thumbnailItems)
517
            {
518
                if (item.DisplayColorItems != null)
519
                {
520
                    item.DisplayColorItems.Clear();
521
                }
522
            }
523
            #endregion
524

    
525
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
526
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
527

    
528
            this.UsersCommentPagesList.ToList().ForEach(item =>
529
            {
530
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
531

    
532
                if (_comm.Count() == 0)
533
                {
534
                    _delItem.Add(item);
535
                }
536

    
537
                if (cts != null)
538
                {
539
                    if (cts.Value.IsCancellationRequested)
540
                        return;
541
                }
542
            });
543

    
544
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
545

    
546
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
547
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
548

    
549
            UsersCommentPagesList.ForEach(user =>
550
            {
551
                //user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
552
                //user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
553

    
554
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
555

    
556
                if (_commLst.Count() == 0)
557
                {
558
                    this.UsersCommentPagesList.Add(user);
559
                }
560
                else
561
                {
562
                    if (_commLst.First().PageNumber != user.PageNumber)
563
                        _commLst.First().PageNumber = user.PageNumber;
564
                }
565

    
566
                user.PageNumber.ForEach(page =>
567
                {
568
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
569

    
570
                    if (_items.Count() > 0)
571
                    {
572
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
573
                        
574
                    }
575

    
576
                    if (cts != null)
577
                    {
578
                        if (cts.Value.IsCancellationRequested)
579
                            return;
580
                    }
581
                });
582
            });
583

    
584
            foreach (var item in this._thumbnailItems)
585
            {
586
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
587
            }
588

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

    
592
            if (data.Count() != 0)
593
            {
594
                if (Convert.ToBoolean(data.First().isConSolidation))
595
                {
596
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
597
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
598
                    this.lstSelectComment.ItemsSource = data;
599
                }
600
            }
601

    
602
            this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
603

    
604
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
605

    
606

    
607
            //var template = this.ImgListbox.ItemTemplate;
608
            //this.ImgListbox.ItemTemplate = null;
609
            //this.ImgListbox.ItemTemplate = template;
610

    
611
        }
612

    
613
        List<int> FilterPages = null;
614

    
615
        private void ThumbnailSetAsync()
616
        {
617
            Logger.sendCheckLog("ThumbnailSet", 1);
618

    
619
            if (FilteredThumbnail == null)
620
            {
621
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
622

    
623
                var pageList = ViewerDataModel.Instance.Document_Info;
624

    
625
                var items = from page in pageList
626
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
627
                            select new ThumbnailItem
628
                            {
629
                                //ImageUri = new Uri(pageLink),
630
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
631
                                PageNumber = page.PAGE_NUMBER,
632
                                Angle = page.PAGE_ANGLE
633
                            };
634

    
635
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
636
                FilteredThumbnail = new CollectionViewSource();
637
                FilteredThumbnail.SortDescriptions.Add(new SortDescription { Direction = ListSortDirection.Ascending, PropertyName = "PageNumber" });
638

    
639
                FilteredThumbnail.Source = _thumbnailItems;
640

    
641
                FilteredThumbnail.View.CurrentChanging += (snd, evt) =>
642
                  {
643
                      System.Diagnostics.Debug.WriteLine("ect");
644
                  };
645

    
646
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
647

    
648
                FilteredThumbnail.Filter += (snd, evt) =>
649
                {
650
                    if (FilterPages?.Count() > 0 && evt.Item != null)
651
                    {
652
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
653
                    }
654
                    else
655
                    {
656
                        evt.Accepted = false;
657
                    }
658
                };
659

    
660
            }
661

    
662
            FilterPages.Clear();
663

    
664
            if (rdoAllPages.IsChecked == true)
665
            {
666
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
667
            }
668
            else if (rdoFavoritePages.IsChecked == true)
669
            {
670
                if (_FavoriteSet != null)
671
                {
672
                    FilterPages = (from thumb in _thumbnailItems
673
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
674
                                select thumb.PageNumber).ToList();
675
                }
676
            }
677
            else if (rdoCommentPages.IsChecked == true)
678
            {
679
                if (this.lstSelectComment.ItemsSource != null)
680
                {
681
                    var commentPages = (from commentPage in this.UsersCommentPagesList
682
                                        where commentPage.IsSelected == true
683
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
684

    
685
                    if (commentPages?.Count() > 0)
686
                    {
687
                        FilterPages = (from thumb in _thumbnailItems
688
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
689
                                       select thumb.PageNumber).ToList();
690
                    }
691
                }
692
            }
693

    
694
            if (FilterPages != null)
695
            {
696
                if(FilteredThumbnail == null)
697
                {
698
                    System.Diagnostics.Debug.WriteLine("filter null");
699
                }
700

    
701
                if (FilteredThumbnail.View == null)
702
                {
703
                    System.Diagnostics.Debug.WriteLine("filter null");
704
                }
705

    
706
                FilteredThumbnail.View.Refresh();
707

    
708
                if (FilterPages.Count() > 0)
709
                {
710
                    if (_thumbnailItems.Count() > 0)
711
                    {
712
                        ImgListbox.SelectedItem = _thumbnailItems[0];
713
                    }
714

    
715
                    //SetCommentList(UsersCommentPagesList.ToList());
716
                }
717
                else
718
                {
719
                    ImgListbox.SelectedItem = null;
720
                }
721

    
722
                if (ThumbInitialized != null)
723
                {
724
                    ThumbInitialized(this, new EventArgs());
725
                    ThumbInitialized = null;
726
                }
727
            }
728
        }
729

    
730

    
731
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
732
        {
733
            if (e.ClickCount >= 2)
734
            {
735
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
736

    
737
                GotoPage(selectItem.PageNumber);
738

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

    
741
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
742
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
743
                //bool isGO = false;
744

    
745
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
746
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
747
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
748
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
749
                //{
750
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
751
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
752
                //    {
753
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
754
                //    }
755

    
756
                //};
757
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
758

    
759
                //GotoPage(MarkupList.SelectedItem as MarkupList)
760
            }
761
        }
762

    
763
        public class MarkupInfoItemSmall
764
        {
765
            public string Id { get; set; }
766
            public string UserName { get; set; }
767
            public string UserID { get; set; }
768
            public int PageNumber { get; set; }
769
            public string Data { get; set; }
770
            public int Data_Type { get; set; }
771
            public bool IsConsolidate { get; set; }
772
        }
773

    
774
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
775
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
776
        {
777
            get
778
            {
779
                if (_MarkupInfoSmallList == null)
780
                {
781
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
782
                }
783
                return _MarkupInfoSmallList;
784
            }
785
            set
786
            {
787

    
788
                _MarkupInfoSmallList = value;
789
                RaisePropertyChanged("MarkupInfoSmallList");
790
            }
791
        }
792

    
793
        /// <summary>
794
        /// goto page and select item selected by user
795
        /// </summary>
796
        /// <param name="sender"></param>
797
        /// <param name="e"></param>
798
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
799
        {
800
            var clickButtonItem = sender as RadButton;
801
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
802
            {
803
                try
804
                {
805
                    Rect rect = new Rect();
806
                    Point s_point = new Point();
807
                    Point e_point = new Point();
808

    
809
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
810
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
811

    
812
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString(),ViewerDataModel.Instance.CancellationToken()); //언패킹작업
813
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
814
                    {
815
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
816
                            {
817
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
818
                                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));
819
                            }
820
                            break;
821
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
822
                            {
823
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
824
                                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));
825
                            }
826
                            break;
827
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
828
                            {
829
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
830
                                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));
831
                            }
832
                            break;
833
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
834
                            {
835
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
836

    
837
                                foreach (Point A in instance.PointSet)
838
                                {
839
                                    if (s_point == new Point())
840
                                    {
841
                                        s_point = A;
842
                                        e_point = A;
843
                                    }
844
                                    s_point.X = Math.Min(s_point.X, A.X);
845
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
846
                                    e_point.X = Math.Max(e_point.X, A.X);
847
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
848
                                }
849
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
850
                            }
851
                            break;
852
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
853
                            {
854
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
855

    
856
                                foreach (Point A in instance.PointSet)
857
                                {
858
                                    if (s_point == new Point())
859
                                    {
860
                                        s_point = A;
861
                                        e_point = A;
862
                                    }
863
                                    s_point.X = Math.Min(s_point.X, A.X);
864
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
865
                                    e_point.X = Math.Max(e_point.X, A.X);
866
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
867
                                }
868
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
869
                            }
870
                            break;
871
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
872
                            {
873
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
874

    
875
                                foreach (Point A in instance.PointSet)
876
                                {
877
                                    if (s_point == new Point())
878
                                    {
879
                                        s_point = A;
880
                                        e_point = A;
881
                                    }
882
                                    s_point.X = Math.Min(s_point.X, A.X);
883
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
884
                                    e_point.X = Math.Max(e_point.X, A.X);
885
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
886
                                }
887
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
888
                            }
889
                            break;
890
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
891
                            {
892
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
893

    
894
                                foreach (Point A in instance.PointSet)
895
                                {
896
                                    if (s_point == new Point())
897
                                    {
898
                                        s_point = A;
899
                                        e_point = A;
900
                                    }
901
                                    s_point.X = Math.Min(s_point.X, A.X);
902
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
903
                                    e_point.X = Math.Max(e_point.X, A.X);
904
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
905
                                }
906
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
907
                            }
908
                            break;
909
                        default:
910
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
911
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
912
                            break;
913
                    }
914

    
915
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
916
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
917
                }
918
                catch (Exception ex)
919
                {
920
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
921
                }
922
            }
923
        }
924

    
925
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
926
        {
927
            var clickButtonItem = sender as RadButton;
928
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
929
            {
930
                try
931
                {
932
             
933

    
934
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
935
                    MarkupList.SelectedItem = gaza;
936

    
937
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
938
                }
939
                catch (Exception ex)
940
                {
941
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
942
                }
943
            }
944
        }
945

    
946
        ///// <summary>
947
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
948
        ///// </summary>
949
        ///// <param name="CommentIdList"></param>
950
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
951
        //{
952
        //    var instance = Common.ViewerDataModel.Instance;
953

    
954
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
955

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

    
958
        //    if (commentList.Count() > 0)
959
        //    {
960
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
961
        //        #region markup list grid select items
962

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

    
965
        //        if (infoItem.Count() > 0)
966
        //        {
967

    
968
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
969
        //            gridMarkup.SelectedItems.Clear();
970
        //            gridMarkup.SelectedItems.Add(infoItem.First());
971
        //        }
972

    
973
        //        #endregion
974

    
975
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
976

    
977
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
978
        //        {
979
        //            GotoSelectedMarkup(CommentIdList);
980
        //        }
981
        //        else
982
        //        {
983
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
984

    
985
        //            handler = (snd, evt) =>
986
        //            {
987
        //                GotoSelectedMarkup(CommentIdList);
988
        //                pageNavigator.PageChanged -= handler;
989
        //            };
990

    
991
        //            pageNavigator.PageChanged += handler;
992

    
993
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
994
        //        }
995
        //    }
996
        //}
997

    
998
        ///// <summary>
999
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
1000
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
1001
        ///// </summary>
1002
        ///// <param name="CommentIdList"></param>
1003
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
1004
        //{
1005
        //    var instance = Common.ViewerDataModel.Instance;
1006

    
1007
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1008
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
1009

    
1010
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
1011
        //    {
1012
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
1013
        //        commentUserInfo.AddRange(selectOrderComments);
1014

    
1015
        //        if (commentUserInfo?.Count() > 0)
1016
        //        {
1017
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
1018

    
1019
        //            try
1020
        //            {
1021
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
1022
        //                {
1023
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
1024
        //                    {
1025
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
1026
        //                    } 
1027
                            
1028
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
1029
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
1030
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
1031
        //                }
1032

    
1033
        //                Rect rect = commentUserInfo.First().ItemRect;
1034

    
1035
        //                foreach (var UserInfo in commentUserInfo)
1036
        //                {
1037
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1038
        //                }
1039

    
1040
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1041

    
1042
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1043
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1044
        //                //rect.Transform(matrix);
1045

    
1046
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1047
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1048
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1049
        //                double positionX = 0;
1050
        //                double positionY = 0;
1051

    
1052
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1053
        //                {
1054
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1055
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1056
        //                }
1057

    
1058
        //                main.zoomAndPanControl.ContentScale = newScale;
1059
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1060
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1061

    
1062
              
1063
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1064

    
1065
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1066

    
1067
        //                if (pageAngle == 90)
1068
        //                {
1069
        //                    pageAngle = 270;
1070
        //                }
1071
        //                else
1072
        //                {
1073
        //                    pageAngle = 90;
1074
        //                }
1075

    
1076
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1077
        //                {
1078
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1079
        //                    rect.Transform(matrix);
1080

    
1081
        //                    main.zoomAndPanControl.ZoomTo(rect);
1082
        //                }
1083
        //                else
1084
        //                {
1085
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1086

    
1087
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1088
        //                    rect.Transform(matrix);
1089

    
1090

    
1091
        //                    main.zoomAndPanControl.ZoomTo(rect);
1092
        //                }
1093
        //            }
1094
        //            catch (Exception ex)
1095
        //            {
1096
        //                main.DialogMessage_Alert(ex.Message, "Error");
1097
        //            }
1098
        //        }
1099
        //    }
1100
        //}
1101

    
1102
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1103
        {
1104
            if (MarkupInfoSmallList.Count == 0)
1105
            {
1106
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1107
                {
1108
                    if (d.MarkupList != null)
1109
                    {
1110
                        d.MarkupList.ForEach(b =>
1111
                        {
1112
                            bool isConsolidate = false;
1113

    
1114
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1115
                            {
1116
                                isConsolidate = true;
1117
                            }
1118

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

    
1121
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1122
                            {
1123
                                Id = b.ID,
1124
                                Data = b.Data,
1125
                                Data_Type = b.Data_Type,
1126
                                PageNumber = b.PageNumber,
1127
                                UserID = d.UserID,
1128
                                UserName = d.UserName,
1129
                                IsConsolidate = isConsolidate
1130

    
1131
                            });
1132
                        });
1133
                    }
1134
                });
1135
                MarkupList.ItemsSource = null;
1136
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1137

    
1138
                FilterUpdate();
1139
            }
1140
        }
1141

    
1142
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1143
        {
1144
            if (MarkupInfoSmallList.Count == 0)
1145
            {
1146
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1147
                {
1148
                    if (d.MarkupList != null)
1149
                    {
1150
                        d.MarkupList.ForEach(b =>
1151
                        {
1152
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1153
                            {
1154
                                Id = b.ID,
1155
                                Data = b.Data,
1156
                                Data_Type = b.Data_Type,
1157
                                PageNumber = b.PageNumber,
1158
                                UserID = d.UserID,
1159
                                UserName = d.UserName,
1160
                            });
1161
                        });
1162
                    }
1163
                });
1164
                MarkupList.ItemsSource = null;
1165
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1166
            }
1167

    
1168
            switch (eventType)
1169
            {
1170
                case Event_Type.Create:
1171
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1172
                    {
1173
                        Id = res.CommentID,
1174
                        Data = res.ConvertData,
1175
                        Data_Type = res.DATA_TYPE,
1176
                        PageNumber = CurrentPage.PageNumber,
1177
                        UserID = App.ViewInfo.UserID,
1178
                        UserName = App.UserName,
1179
                    });
1180
                    break;
1181
                case Event_Type.Delete:
1182
                    if(CommentID == null) //user information list delete btn
1183
                    {
1184
                        foreach (var delItem in item.MarkupList)
1185
                        {
1186
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1187
                        }
1188
                    }
1189
                    else //delete, cut, 
1190
                    {
1191
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1192
                    }                    
1193
                    break;
1194
                case Event_Type.Thumb://이동 회전
1195
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1196
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1197
                    {
1198
                        Id = res.CommentID,
1199
                        Data = res.ConvertData,
1200
                        Data_Type = res.DATA_TYPE,
1201
                        PageNumber = CurrentPage.PageNumber,
1202
                        UserID = App.ViewInfo.UserID,
1203
                        UserName = App.UserName,
1204
                    });
1205
                    break;
1206
                default:
1207
                    break;
1208
            }
1209

    
1210
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1211

    
1212
            bool IsConsolidation = false;
1213
            string UserId = null;
1214

    
1215
            if (commentUser.SelectedValue != null)
1216
            {
1217
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1218
                {
1219
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1220
                }
1221
                else
1222
                {
1223
                    IsConsolidation = true;
1224
                }
1225
            }
1226

    
1227
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1228
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1229
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1230

    
1231
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1232

    
1233
            FilterUpdate();
1234
        }
1235

    
1236
        private void FilterUpdate(string selectUser = null)
1237
        {
1238
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1239

    
1240
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1241
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1242

    
1243

    
1244
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1245
 
1246
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1247
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1248

    
1249
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1250
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1251

    
1252
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1253
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1254

    
1255
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1256
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1257
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1258
        }
1259

    
1260
        
1261

    
1262
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1263
        {
1264
            MarkupList.ItemsSource = null;
1265
            txtSearch.Text = string.Empty;
1266

    
1267
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1268

    
1269
            bool IsConsolidation = false;
1270
            string userName = null;
1271

    
1272
            if (commentUser.SelectedValue != null)
1273
            {
1274
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1275
                {
1276
                    userName = commentUser.SelectedValue.ToString();
1277
                }
1278
                else
1279
                {
1280
                    IsConsolidation = true;
1281
                }
1282
            }
1283

    
1284
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1285
                                   .WhereIf(userName != null, d => d.UserName == userName)
1286
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1287
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1288

    
1289
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1290

    
1291
            FilterUpdate();
1292
        }
1293

    
1294
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1295
        {
1296
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1297
        }
1298

    
1299
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1300
        {
1301
            string search_str = txtSearch.Text;
1302

    
1303
            if(string.IsNullOrWhiteSpace(search_str))
1304
            {
1305
                return;
1306
            }
1307

    
1308
            var sel_type = commentType.SelectedItem;
1309
            var sel_user = commentUser.SelectedItem;
1310
            var sel_page = commentPage.SelectedItem;
1311
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1312
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1313
            if (sel_page != null)
1314
            {
1315
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1316
            }
1317
            if (sel_type != null)
1318
            {
1319
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1320
            }
1321
            if (sel_user != null)
1322
            {
1323
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1324
            }
1325
            foreach (var item in list)
1326
            {
1327
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString(), ViewerDataModel.Instance.CancellationToken());
1328

    
1329
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1330
                {
1331
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1332
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1333
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1334
                        {
1335
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1336

    
1337
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1338
                            {
1339
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1340
                                {
1341
                                    small_list.Add(item);
1342
                                }
1343
                            }
1344
                        }
1345
                        break;
1346
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1347
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1348
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1349
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1350
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1351
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1352
                        {
1353
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1354

    
1355
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1356
                            {
1357
                                if (instance.ArrowText.Contains(search_str))
1358
                                {
1359
                                    small_list.Add(item);
1360
                                }
1361
                            }
1362
                        }
1363
                        break;
1364
                }
1365
            }
1366

    
1367
            MarkupList.ItemsSource = null;
1368
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1369
        }
1370

    
1371
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1372
        {
1373
            if(e.Key == Key.Enter || e.Key == Key.Return)
1374
            {
1375
                btnSearch_Click(sender, new RoutedEventArgs());
1376
            }
1377
        }
1378

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