프로젝트

일반

사용자정보

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

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

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

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

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

    
34

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

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

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

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

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

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

    
70

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

    
76

    
77
            }            
78
        }
79

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

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

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

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

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

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

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

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

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

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

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

    
136
        private ObservableCollection<UsersCommentPagesMember> _UsersCommentPagesList;
137

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

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

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

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

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

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

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

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

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

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

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

    
199
            DownloadProcess.ThumbnailDownloader(endpoint,ViewerDataModel.Instance.IsAdmin, this._DefaultUri, tempStoragePath, "jpg", this.PageCount);
200
            DownloadProcess.ProcessMonitor(ViewerDataModel.Instance.IsAdmin, tempStoragePath, App.PageStorage.LocalStorage,Common.ViewerDataModel.Instance.OriginalTempFile);
201

    
202
            App.splashScreen.Close();
203

    
204
        }
205

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

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

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

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

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

    
231
                //});
232
            }
233
        }
234

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

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

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

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

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

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

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

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

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

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

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

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

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

    
328
        public bool GotoPageFlag = false;
329

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

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

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

    
350
                                ImgListbox.SelectedItem = thumbnailitem;
351

    
352

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
651

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

    
656
        }
657

    
658
        List<int> FilterPages = null;
659

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

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

    
668
                var pageList = ViewerDataModel.Instance.Document_Info;
669

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

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

    
684
                FilteredThumbnail.Source = _thumbnailItems;
685

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

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

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

    
705
            }
706

    
707
            FilterPages.Clear();
708

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

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

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

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

    
751
                FilteredThumbnail.View.Refresh();
752

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

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

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

    
775

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

    
782
                GotoPage(selectItem.PageNumber);
783

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1018
        //        #endregion
1019

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

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

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

    
1036
        //            pageNavigator.PageChanged += handler;
1037

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

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

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

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

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

    
1064
        //            try
1065
        //            {
1066
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
1067
        //                {
1068
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
1069
        //                    {
1070
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
1071
        //                    } 
1072
                            
1073
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
1074
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
1075
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
1076
        //                }
1077

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1135

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

    
1147
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1148
        {
1149
            if (MarkupInfoSmallList.Count == 0)
1150
            {
1151
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1152
                {
1153
                    if (d.MarkupList != null)
1154
                    {
1155
                        d.MarkupList.ForEach(b =>
1156
                        {
1157
                            bool isConsolidate = false;
1158

    
1159
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1160
                            {
1161
                                isConsolidate = true;
1162
                            }
1163

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

    
1166
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1167
                            {
1168
                                Id = b.ID,
1169
                                Data = b.Data,
1170
                                Data_Type = b.Data_Type,
1171
                                PageNumber = b.PageNumber,
1172
                                UserID = d.UserID,
1173
                                UserName = d.UserName,
1174
                                IsConsolidate = isConsolidate
1175

    
1176
                            });
1177
                        });
1178
                    }
1179
                });
1180
                MarkupList.ItemsSource = null;
1181
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1182

    
1183
                FilterUpdate();
1184
            }
1185
        }
1186

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

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

    
1255
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1256

    
1257
            bool IsConsolidation = false;
1258
            string UserId = null;
1259

    
1260
            if (commentUser.SelectedValue != null)
1261
            {
1262
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1263
                {
1264
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1265
                }
1266
                else
1267
                {
1268
                    IsConsolidation = true;
1269
                }
1270
            }
1271

    
1272
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1273
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1274
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1275

    
1276
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1277

    
1278
            FilterUpdate();
1279
        }
1280

    
1281
        private void FilterUpdate(string selectUser = null)
1282
        {
1283
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1284

    
1285
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1286
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1287

    
1288

    
1289
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1290
 
1291
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1292
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1293

    
1294
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1295
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1296

    
1297
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1298
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1299

    
1300
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1301
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1302
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1303
        }
1304

    
1305
        
1306

    
1307
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1308
        {
1309
            MarkupList.ItemsSource = null;
1310
            txtSearch.Text = string.Empty;
1311

    
1312
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1313

    
1314
            bool IsConsolidation = false;
1315
            string userName = null;
1316

    
1317
            if (commentUser.SelectedValue != null)
1318
            {
1319
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1320
                {
1321
                    userName = commentUser.SelectedValue.ToString();
1322
                }
1323
                else
1324
                {
1325
                    IsConsolidation = true;
1326
                }
1327
            }
1328

    
1329
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1330
                                   .WhereIf(userName != null, d => d.UserName == userName)
1331
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1332
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1333

    
1334
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1335

    
1336
            FilterUpdate();
1337
        }
1338

    
1339
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1340
        {
1341
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1342
        }
1343

    
1344
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1345
        {
1346
            string search_str = txtSearch.Text;
1347

    
1348
            if(string.IsNullOrWhiteSpace(search_str))
1349
            {
1350
                return;
1351
            }
1352

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

    
1374
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1375
                {
1376
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1377
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1378
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1379
                        {
1380
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1381

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

    
1400
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1401
                            {
1402
                                if (instance.ArrowText.Contains(search_str))
1403
                                {
1404
                                    small_list.Add(item);
1405
                                }
1406
                            }
1407
                        }
1408
                        break;
1409
                }
1410
            }
1411

    
1412
            MarkupList.ItemsSource = null;
1413
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1414
        }
1415

    
1416
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1417
        {
1418
            if(e.Key == Key.Enter || e.Key == Key.Return)
1419
            {
1420
                btnSearch_Click(sender, new RoutedEventArgs());
1421
            }
1422
        }
1423

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