프로젝트

일반

사용자정보

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

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

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

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

    
19
namespace KCOM.Controls
20
{
21
    /// <summary>
22
    /// Interaction logic for PageNavigator.xaml
23
    /// </summary>
24
    public partial class Sample : UserControl, INotifyPropertyChanged
25
    {
26
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
27
        public event PropertyChangedEventHandler PropertyChanged;
28
        public Sample()
29
        {   
30
            if(App.IsDesignMode)
31
            {
32
                return;
33
            }
34

    
35
            App.splashString(ISplashMessage.SAMPLE);
36
            this.Loaded += Sample_Loaded;
37
        }
38

    
39
        private void Sample_Loaded(object sender, RoutedEventArgs e)
40
        {
41
            if(!_Initialize)
42
            {
43
                InitializeComponent();
44
                _Initialize = true;
45
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
46
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);                
47
            }            
48
        }
49

    
50
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
51
        private List<DOCPAGE> _PageList = null;
52
        private string _DefaultUri = null;
53
        public ThumbnailItem CurrentPage = null;
54
        public int PageCount = 0;
55
        private bool _Initialize;
56
        public event EventHandler<PageChangeEventArgs> PageChanged;
57
        public event EventHandler<PageChangeEventArgs> PageChanging;
58
        List<UsersCommentPagesMember> _UsersCommentPagesList = new List<UsersCommentPagesMember>();
59
        public class PageChangeEventArgs : EventArgs
60
        {
61
            public DOCPAGE CurrentPage { get; set; }
62
            public string PageUri { get; set; }
63
            public int PageNumber { get; set; }
64
        }
65
        private bool _IsFitOn { get; set; }
66
        public bool IsFitOn
67
        {
68
            get
69
            {
70
                return _IsFitOn;
71
            }
72
            set
73
            {
74
                _IsFitOn = value;
75
                RaisePropertyChanged("IsFitOn");
76
            }
77
        }
78

    
79
        public void RaisePropertyChanged(string propName)
80
        {
81
            if (PropertyChanged != null)
82
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
83
        }
84

    
85
        public void SetPageNavi(List<DOCPAGE> PageList, string DefaultUri)
86
        {
87
            this._PageList = PageList;
88
            this._DefaultUri = DefaultUri;
89
            ThumbnailSet();
90
            this.PageCount = PageList.Count();
91
            //ThumbNmailSet();
92
            rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
93
            rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
94
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
95
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
96
        }
97

    
98
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
99
        {
100
            Logger.sendCheckLog("rdoCommented_Checked", 1);
101
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
102
            SetCommentPages();
103
        }
104

    
105
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
106
        {
107
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
108
            if (rdoFavoritePages.IsChecked == true)
109
                expCommentPages.IsExpanded = false;
110

    
111
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
112
            if (_FavoriteSet.Count > 0)
113
            {
114
                SetCommentPages_Favorite(); //수정    
115
            }
116
            else
117
            {
118
                rdoAllPages.IsChecked = true;
119
                rdoFavoritePages.IsChecked = false;
120
            }
121
        }
122

    
123
        private void SetCommentPages_Favorite()
124
        {
125
            ThumbnailSet();            
126
            SetCommentPages();
127
        }
128

    
129
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
130
        {
131
            //txtThumbCount.Visibility = Visibility.Collapsed;            
132
        }
133

    
134
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
135
        {
136
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
137
            rdoAllPages.IsChecked = false;
138
            rdoFavoritePages.IsChecked = false;
139
            //txtThumbCount.Visibility = Visibility.Visible;
140
            SetCommentPages();
141
        }
142

    
143
        /// <summary>
144
        /// called when image list box's selection is changed
145
        /// </summary>
146
        /// <param name="sender"></param>
147
        /// <param name="e"></param>
148
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
149
        {            
150
            if (ImgListbox.SelectedItem != null)
151
            {
152
                int _CurrentPageNo = -1;
153
                if (this.CurrentPage != null)
154
                {
155
                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);   /// save controls
156
                    _CurrentPageNo = this.CurrentPage.PageNumber;
157
                }
158

    
159
                this.CurrentPage = ImgListbox.SelectedItem as ThumbnailItem;
160
                int iPageNo = this.CurrentPage.PageNumber;
161
                if(_CurrentPageNo != iPageNo)
162
                {
163
                    PageChanging(this, new PageChangeEventArgs
164
                    {
165
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == iPageNo).First(),
166
                        PageNumber = iPageNo,
167
                        PageUri = null
168
                    });
169
                }
170
            }
171

    
172
            //var border = VisualTreeHelper.GetChild(ImgListbox, 0);
173
            //if (border != null)
174
            //{
175
            //    IEnumerable<ScrollViewer> scrollViewer = border.ChildrenOfType<ScrollViewer>();
176

    
177
            //}
178
            //ScrollViewer scrollViewer = (sender as RadListBox) as ScrollViewer;
179

    
180
            
181
            //System.Diagnostics.Debug.WriteLine("page:"+ImgListbox.SelectedIndex);
182
        }
183

    
184
        public bool GotoPageFlag = false;
185

    
186
        /// <summary>
187
        /// 해당 썸네일로 이동
188
        /// </summary>
189
        /// <param name="_pageNumber">이동할 페이지 번호</param>
190
        public void GotoPage(int _pageNumber)
191
        {
192
            try
193
            {
194
                System.Threading.Tasks.Task.Factory.StartNew(() => { 
195

    
196
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
197
                    if (_page.Count() > 0)
198
                    {
199
                        ThumbnailItem thumbnailitem = _page.First();
200
                        if (PageChanging != null)
201
                        {
202

    
203
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
204
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
205
                                ImgListbox.SelectedItem = thumbnailitem;
206
                            });
207
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
208
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
209
                            //    ImgListbox.ScrollIntoView(_itemIndex);
210
                            //else
211
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
212
                        }
213
                    }
214

    
215
                }).ConfigureAwait(true);
216
            }
217
            catch(Exception ex)
218
            {
219
                Logger.sendResLog("GotoPage", ex.Message, 0);
220
            }
221
        }
222

    
223
        /// <summary>
224
        /// 주어진 페이지로 변경한다
225
        /// </summary>
226
        /// <param name="iPageNo">변경할 페이지 번호</param>
227
        public void ChangePage(int iPageNo)
228
        {
229
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
230
            if ((PageChanged != null) && (thumbitem != null))
231
            {
232
                var uri = thumbitem.PageUri.ToString();
233
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
234

    
235
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
236
                if (_DocPages != null)
237
                {
238
                    PageChanged(this, new PageChangeEventArgs
239
                    {
240
                        CurrentPage = _DocPages,
241
                        PageUri = uri,
242
                        PageNumber = thumbitem.PageNumber
243
                    });
244
                    //ImgListbox.SelectedItem = thumbitem;                    
245
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
246
                    
247
                    this.CurrentPage = thumbitem;
248
                }
249
                else
250
                {
251
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
252
                }
253
            }
254
        }
255

    
256
        public void GotoPageTALK(int _pageNumber, int _angle)
257
        {
258
            int _PageNo = -1;
259

    
260
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
261
            {
262
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
263
                if (_page.Count() > 0)
264
                {
265
                    ThumbnailItem _item = _page.First();
266
                    setPageChangeTALK(_item, _angle);
267
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
268
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
269
                }
270
            }
271
        }
272

    
273
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
274
        {
275
            if (thumbnailItem != null)
276
            {
277
                if (PageChanging != null)
278
                {
279
                    ///this.CurrentPage = _NextPage;
280
                    ///_NextPage = thumbnailItem;
281
                    PageChanging(this, new PageChangeEventArgs
282
                    {
283
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
284
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
285
                        PageUri = null
286
                    });
287

    
288
                    var instanceMain = this.ParentOfType<MainWindow>();
289

    
290
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
291

    
292
                    if (rotationNum > 0) // 1, 2, 3
293
                    {
294
                        for (int i = 0; i < rotationNum; i++)
295
                        {
296
                            drawingPannelRotate(true);
297
                        }
298
                    }
299
                    else if (rotationNum < 0)// -1, -2, -3
300
                    {
301
                        for (int i = 0; i < -rotationNum; i++)
302
                        {
303
                            drawingPannelRotate(false);
304
                        }
305
                    }
306
                }
307
            }
308
        }
309

    
310
        public void drawingPannelRotate(bool Flag)
311
        {
312
            var instanceMain = this.ParentOfType<MainWindow>();
313

    
314
            if (Flag)
315
            {
316
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
317
                {
318
                    instanceMain.dzMainMenu.rotate.Angle = 0;
319
                }
320
                else
321
                {
322
                    instanceMain.dzMainMenu.rotate.Angle += 90;
323
                }
324
            }
325
            else
326
            {
327
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
328
                {
329
                    instanceMain.dzMainMenu.rotate.Angle = 270;
330
                }
331
                else
332
                {
333
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
334
                }
335
            }
336

    
337
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
338
            {
339
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
340
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
341
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
342
            }
343

    
344
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
345
            {
346
                instanceMain.dzMainMenu.translate.X = 0;
347
                instanceMain.dzMainMenu.translate.Y = 0;
348
            }
349
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
350
            {
351
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
352
                instanceMain.dzMainMenu.translate.Y = 0;
353
            }
354
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
355
            {
356
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
357
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
358
            }
359
            else
360
            {
361
                instanceMain.dzMainMenu.translate.X = 0;
362
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
363
            }
364

    
365
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
366
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
367
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
368
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
369
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
370
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
371

    
372
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
373
            {
374
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
375

    
376
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
377
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
378
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
379

    
380
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
381
                if (rotationdoc != null)
382
                {
383
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
384
                }
385
                else
386
                {
387
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
388
                }
389
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
390
            });
391
        }
392

    
393
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
394
        {
395
            SetCommentPages();
396
        }
397
        
398
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
399
        {
400
            SetCommentPages();
401
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
402
        }
403

    
404
        public void SetCommentPages()
405
        {
406
            ThumbnailSet();
407
            SetCommentList(_UsersCommentPagesList.ToList());
408
        }
409

    
410
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
411
        {
412
            Logger.sendCheckLog("SetCommentList", 1);
413
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
414
            #region 기존 색상 제거 작업
415
            foreach (var item in this._thumbnailItems)
416
            {
417
                item.DisplayColorItems.Clear();
418
            }
419
            #endregion
420

    
421
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
422
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
423

    
424
            _UsersCommentPagesList.ToList().ForEach(item =>
425
            {
426
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
427

    
428
                if (_comm.Count() == 0)
429
                {
430
                    _delItem.Add(item);
431
                }
432
            });
433

    
434
            _delItem.ForEach(f => _UsersCommentPagesList.Remove(f));
435

    
436
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
437
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
438

    
439
            UsersCommentPagesList.ForEach(user =>
440
            {
441
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
442
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
443

    
444
                var _commLst = _UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
445

    
446
                if (_commLst.Count() == 0)
447
                {
448
                    _UsersCommentPagesList.Add(user);
449
                }
450
                else
451
                {
452
                    if (_commLst.First().PageNumber != user.PageNumber)
453
                        _commLst.First().PageNumber = user.PageNumber;
454
                }
455

    
456
                user.PageNumber.ForEach(page =>
457
                {
458
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
459

    
460
                    if (_items.Count() > 0)
461
                    {
462
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
463
                        
464
                    }
465
                        
466
                });
467
            });
468

    
469
            foreach (var item in this._thumbnailItems)
470
            {
471
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
472
            }
473
            
474
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
475
            var data = _UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
476
            if (data.Count() != 0)
477
            {
478
                if (Convert.ToBoolean(data.First().isConSolidation))
479
                {
480
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
481
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
482
                    this.lstSelectComment.ItemsSource = data;
483
                }
484
                else
485
                {
486
                    this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
487
                }
488
            }
489
            else
490
            {
491
                this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
492
            }
493
            
494
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
495

    
496

    
497
            //var template = this.ImgListbox.ItemTemplate;
498
            //this.ImgListbox.ItemTemplate = null;
499
            //this.ImgListbox.ItemTemplate = template;
500

    
501
        }
502

    
503
        private void ThumbnailSet()
504
        {
505
            Logger.sendCheckLog("ThumbnailSet", 1);
506
            if (!_Initialize) return;
507

    
508
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
509
            List<int> _selectComment = new List<int>();
510
            if (this.lstSelectComment.ItemsSource != null)
511
            {
512
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
513
                             where commentPage.IsSelected == true
514
                             select commentPage.PageNumber;
515

    
516
                foreach (var item in _pages)
517
                {
518
                    item.ForEach(pp => _selectComment.Add(pp));
519
                }
520

    
521
                _selectComment.Distinct();
522
            }
523

    
524
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
525
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
526
            //this._PageList.ForEach(page =>
527
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
528
            {
529
                var _pageNo = page.PAGE_NUMBER;
530
                bool _addFlag = false;
531

    
532
                if (rdoFavoritePages.IsChecked == false)
533
                {
534
                    if (_selectComment.Count() > 0)
535
                    {
536
                        if ((rdoAllPages.IsChecked == true)
537
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
538
                        {
539
                            _addFlag = true;
540
                        }
541
                    }
542
                    else
543
                    {
544
                        //if (App.ViewInfo.IsCustomPage)
545
                        //{
546
                        //    //_addFlag = false;
547

    
548
                        //    //App.ViewInfo.IsCustomPage = false;
549
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
550
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
551
                        //    this.rdoAllPages.IsChecked = false;
552
                        //    this.rdoFavoritePages.IsChecked = true;
553
                        //    //SetCommentPages();                        
554
                        //}
555
                        //else
556
                        //{
557
                        _addFlag = true;
558
                        //}
559
                    }
560
                }
561

    
562

    
563
                if (_addFlag)
564
                {
565
                    this._thumbnailItems.Add(new ThumbnailItem
566
                    {
567
                        ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
568
                        PageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString()).Replace("jpg","png")),
569
                        PageNumber = _pageNo,
570
                        Angle = page.PAGE_ANGLE,
571
                    });
572
                }
573
                else
574
                {
575
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
576
                    {
577
                        this._thumbnailItems.Add(new ThumbnailItem
578
                        {
579
                            ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
580
                            PageNumber = _pageNo,
581
                            Angle = page.PAGE_ANGLE,
582
                        });
583
                    }
584
                }
585

    
586

    
587

    
588
                //this._thumbnailItems.Add(new ThumbnailItem
589
                //{
590
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
591

    
592
                //    //ImageUri = new Uri(@"http://www.honeyhead.net/Pages/000000/111111/11111111/1.cmp"),
593

    
594
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
595
                //    //DisplayColorItems = pageColor,
596
                //    PageNumber = Convert.ToInt32(_pageNo),
597
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
598
                //});
599
            });
600

    
601
            //txtTotPageNo.Text = this._PageList.Count().ToString();
602

    
603
            //txtThumbCount.Text = String.Format("Count : {0}", (this._thumbnailItems.Count).ToString());
604

    
605
            if (ImgListbox.ItemsSource == null)
606
            {
607
                ImgListbox.ItemsSource = this._thumbnailItems;
608

    
609
                this._thumbnailItems.ToList().ForEach(data =>
610
                {
611
                    data.Width = ImgListbox.ActualWidth;
612
                    data.Height = ImgListbox.ActualHeight;
613
                });
614

    
615
                if (ImgListbox.Items.Count > 0)
616
                {
617
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
618
                    int StartPageIdx = 1;
619
                    //if (App.ViewInfo.IsCustomPage)
620
                    //{
621
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
622
                    //}
623
                    //else
624
                    //{
625

    
626
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
627
                    {
628
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
629
                    }
630
                    else
631
                    {
632
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
633
                    }
634
                    //}
635
                }
636
            }
637
            else
638
            {
639
                ImgListbox.UpdateLayout();
640
                ImgListbox.ItemsSource = this._thumbnailItems;
641
            }
642
        }
643

    
644
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
645
        {
646
            if (e.ClickCount >= 2)
647
            {
648
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
649
                GotoPage(selectItem.PageNumber);
650
                var result = MarkupParser.GetBaseControl(selectItem.Data);
651
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
652
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
653
                //bool isGO = false;
654

    
655
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
656
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
657
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
658
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
659
                //{
660
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
661
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
662
                //    {
663
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
664
                //    }
665

    
666
                //};
667
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
668

    
669
                //GotoPage(MarkupList.SelectedItem as MarkupList)
670
            }
671
        }
672

    
673
        private void commentUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
674
        {
675
            MarkupList.ItemsSource = null;
676
            txtSearch.Text = string.Empty;
677

    
678
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
679

    
680
            if (commentType.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue)).ToList(); }
681

    
682
            if (commentUser.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.UserName == ((MarkupUserInfo)commentUser.SelectedValue).UserName).ToList(); }
683

    
684
            if (commentPage.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue)).ToList(); }
685

    
686
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
687
        }
688

    
689
        public class MarkupInfoItemSmall
690
        {
691
            public string Id { get; set; }
692
            public string UserName { get; set; }
693
            public string UserID { get; set; }
694
            public int PageNumber { get; set; }
695
            public string Data { get; set; }
696
            public int Data_Type { get; set; }
697
        }
698

    
699
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
700
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
701
        {
702
            get
703
            {
704
                if (_MarkupInfoSmallList == null)
705
                {
706
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
707
                }
708
                return _MarkupInfoSmallList;
709
            }
710
            set
711
            {
712

    
713
                _MarkupInfoSmallList = value;
714
                RaisePropertyChanged("MarkupInfoSmallList");
715
            }
716
        }
717

    
718
        /// <summary>
719
        /// goto page and select item selected by user
720
        /// </summary>
721
        /// <param name="sender"></param>
722
        /// <param name="e"></param>
723
        private void RadButton_Click_OLD(object sender, RoutedEventArgs e)
724
        {
725
            var clickButtonItem = sender as RadButton;
726
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
727
            {
728
                try
729
                {
730
                    Rect rect = new Rect();
731
                    Point s_point = new Point();
732
                    Point e_point = new Point();
733

    
734
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
735
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
736

    
737
                    var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(gaza.Data.ToString()); //언패킹작업
738
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
739
                    {
740
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
741
                            {
742
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
743
                                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));
744
                            }
745
                            break;
746
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
747
                            {
748
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
749
                                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));
750
                            }
751
                            break;
752
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
753
                            {
754
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
755
                                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));
756
                            }
757
                            break;
758
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
759
                            {
760
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
761

    
762
                                foreach (Point A in instance.PointSet)
763
                                {
764
                                    if (s_point == new Point())
765
                                    {
766
                                        s_point = A;
767
                                        e_point = A;
768
                                    }
769
                                    s_point.X = Math.Min(s_point.X, A.X);
770
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
771
                                    e_point.X = Math.Max(e_point.X, A.X);
772
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
773
                                }
774
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
775
                            }
776
                            break;
777
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
778
                            {
779
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
780

    
781
                                foreach (Point A in instance.PointSet)
782
                                {
783
                                    if (s_point == new Point())
784
                                    {
785
                                        s_point = A;
786
                                        e_point = A;
787
                                    }
788
                                    s_point.X = Math.Min(s_point.X, A.X);
789
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
790
                                    e_point.X = Math.Max(e_point.X, A.X);
791
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
792
                                }
793
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
794
                            }
795
                            break;
796
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
797
                            {
798
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
799

    
800
                                foreach (Point A in instance.PointSet)
801
                                {
802
                                    if (s_point == new Point())
803
                                    {
804
                                        s_point = A;
805
                                        e_point = A;
806
                                    }
807
                                    s_point.X = Math.Min(s_point.X, A.X);
808
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
809
                                    e_point.X = Math.Max(e_point.X, A.X);
810
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
811
                                }
812
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
813
                            }
814
                            break;
815
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
816
                            {
817
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
818

    
819
                                foreach (Point A in instance.PointSet)
820
                                {
821
                                    if (s_point == new Point())
822
                                    {
823
                                        s_point = A;
824
                                        e_point = A;
825
                                    }
826
                                    s_point.X = Math.Min(s_point.X, A.X);
827
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
828
                                    e_point.X = Math.Max(e_point.X, A.X);
829
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
830
                                }
831
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
832
                            }
833
                            break;
834
                        default:
835
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
836
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
837
                            break;
838
                    }
839

    
840
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
841
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
842
                }
843
                catch (Exception ex)
844
                {
845
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
846
                }
847
            }
848
        }
849

    
850

    
851
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
852
        {
853
            var clickButtonItem = sender as RadButton;
854
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
855
            {
856
                try
857
                {
858
             
859

    
860
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
861
                    MarkupList.SelectedItem = gaza;
862

    
863
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
864
                }
865
                catch (Exception ex)
866
                {
867
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
868
                }
869
            }
870
        }
871

    
872
        ///// <summary>
873
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
874
        ///// </summary>
875
        ///// <param name="CommentIdList"></param>
876
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
877
        //{
878
        //    var instance = Common.ViewerDataModel.Instance;
879

    
880
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
881

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

    
884
        //    if (commentList.Count() > 0)
885
        //    {
886
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
887
        //        #region markup list grid select items
888

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

    
891
        //        if (infoItem.Count() > 0)
892
        //        {
893

    
894
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
895
        //            gridMarkup.SelectedItems.Clear();
896
        //            gridMarkup.SelectedItems.Add(infoItem.First());
897
        //        }
898

    
899
        //        #endregion
900

    
901
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
902

    
903
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
904
        //        {
905
        //            GotoSelectedMarkup(CommentIdList);
906
        //        }
907
        //        else
908
        //        {
909
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
910

    
911
        //            handler = (snd, evt) =>
912
        //            {
913
        //                GotoSelectedMarkup(CommentIdList);
914
        //                pageNavigator.PageChanged -= handler;
915
        //            };
916

    
917
        //            pageNavigator.PageChanged += handler;
918

    
919
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
920
        //        }
921
        //    }
922
        //}
923

    
924
        ///// <summary>
925
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
926
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
927
        ///// </summary>
928
        ///// <param name="CommentIdList"></param>
929
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
930
        //{
931
        //    var instance = Common.ViewerDataModel.Instance;
932

    
933
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
934
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
935

    
936
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
937
        //    {
938
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
939
        //        commentUserInfo.AddRange(selectOrderComments);
940

    
941
        //        if (commentUserInfo?.Count() > 0)
942
        //        {
943
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
944

    
945
        //            try
946
        //            {
947
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
948
        //                {
949
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
950
        //                    {
951
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
952
        //                    } 
953
                            
954
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
955
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
956
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
957
        //                }
958

    
959
        //                Rect rect = commentUserInfo.First().ItemRect;
960

    
961
        //                foreach (var UserInfo in commentUserInfo)
962
        //                {
963
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
964
        //                }
965

    
966
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
967

    
968
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
969
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
970
        //                //rect.Transform(matrix);
971

    
972
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
973
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
974
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
975
        //                double positionX = 0;
976
        //                double positionY = 0;
977

    
978
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
979
        //                {
980
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
981
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
982
        //                }
983

    
984
        //                main.zoomAndPanControl.ContentScale = newScale;
985
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
986
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
987

    
988
              
989
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
990

    
991
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
992

    
993
        //                if (pageAngle == 90)
994
        //                {
995
        //                    pageAngle = 270;
996
        //                }
997
        //                else
998
        //                {
999
        //                    pageAngle = 90;
1000
        //                }
1001

    
1002
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1003
        //                {
1004
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1005
        //                    rect.Transform(matrix);
1006

    
1007
        //                    main.zoomAndPanControl.ZoomTo(rect);
1008
        //                }
1009
        //                else
1010
        //                {
1011
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1012

    
1013
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1014
        //                    rect.Transform(matrix);
1015

    
1016

    
1017
        //                    main.zoomAndPanControl.ZoomTo(rect);
1018
        //                }
1019
        //            }
1020
        //            catch (Exception ex)
1021
        //            {
1022
        //                main.DialogMessage_Alert(ex.Message, "Error");
1023
        //            }
1024
        //        }
1025
        //    }
1026
        //}
1027

    
1028
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1029
        {
1030
            if (MarkupInfoSmallList.Count == 0)
1031
            {
1032
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1033
                {
1034
                    if (d.MarkupList != null)
1035
                    {
1036
                        d.MarkupList.ForEach(b =>
1037
                        {
1038
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1039
                            {
1040
                                Id = b.ID,
1041
                                Data = b.Data,
1042
                                Data_Type = b.Data_Type,
1043
                                PageNumber = b.PageNumber,
1044
                                UserID = d.UserID,
1045
                                UserName = d.UserName,
1046
                            });
1047
                        });
1048
                    }
1049
                });
1050
                MarkupList.ItemsSource = null;
1051
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1052

    
1053
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1054
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1055
            }
1056
        }
1057

    
1058
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1059
        {
1060
            if (MarkupInfoSmallList.Count == 0)
1061
            {
1062
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1063
                {
1064
                    if (d.MarkupList != null)
1065
                    {
1066
                        d.MarkupList.ForEach(b =>
1067
                        {
1068
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1069
                            {
1070
                                Id = b.ID,
1071
                                Data = b.Data,
1072
                                Data_Type = b.Data_Type,
1073
                                PageNumber = b.PageNumber,
1074
                                UserID = d.UserID,
1075
                                UserName = d.UserName,
1076
                            });
1077
                        });
1078
                    }
1079
                });
1080
                MarkupList.ItemsSource = null;
1081
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1082
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1083
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1084
            }
1085

    
1086
            switch (eventType)
1087
            {
1088
                case Event_Type.Create:
1089
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1090
                    {
1091
                        Id = res.CommentID,
1092
                        Data = res.ConvertData,
1093
                        Data_Type = res.DATA_TYPE,
1094
                        PageNumber = CurrentPage.PageNumber,
1095
                        UserID = App.ViewInfo.UserID,
1096
                        UserName = App.UserName,
1097
                    });
1098
                    break;
1099
                case Event_Type.Delete:
1100
                    if(CommentID == null) //user information list delete btn
1101
                    {
1102
                        foreach (var delItem in item.MarkupList)
1103
                        {
1104
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1105
                        }
1106
                    }
1107
                    else //delete, cut, 
1108
                    {
1109
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1110
                    }                    
1111
                    break;
1112
                case Event_Type.Thumb://이동 회전
1113
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1114
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1115
                    {
1116
                        Id = res.CommentID,
1117
                        Data = res.ConvertData,
1118
                        Data_Type = res.DATA_TYPE,
1119
                        PageNumber = CurrentPage.PageNumber,
1120
                        UserID = App.ViewInfo.UserID,
1121
                        UserName = App.UserName,
1122
                    });
1123
                    break;
1124
                default:
1125
                    break;
1126
            }
1127

    
1128
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1129
            if (commentType.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue)).ToList(); }
1130

    
1131
            if (commentUser.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.UserName == ((IKCOM.MarkupInfoItem)commentUser.SelectedValue).UserName).ToList();                 }            
1132

    
1133
            if (commentPage.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue)).ToList(); }
1134

    
1135
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();            
1136
           
1137
            commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1138
            commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();            
1139
        }
1140

    
1141
        private void commentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
1142
        {
1143
            MarkupList.ItemsSource = null;
1144
            txtSearch.Text = string.Empty;
1145
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1146
            if (commentType.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue)).ToList(); }
1147

    
1148
            if (commentUser.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.UserName == ((IKCOM.MarkupInfoItem)commentUser.SelectedValue).UserName).ToList(); }
1149

    
1150
            if (commentPage.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue)).ToList(); }
1151

    
1152
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1153
        }
1154

    
1155
        private void commentPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
1156
        {
1157
            MarkupList.ItemsSource = null;
1158
            txtSearch.Text = string.Empty;
1159

    
1160
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1161
            if (commentType.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue)).ToList(); }
1162

    
1163
            if (commentUser.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.UserName == ((IKCOM.MarkupInfoItem)commentUser.SelectedValue).UserName).ToList(); }
1164

    
1165
            if (commentPage.SelectedValue != null) { TempMarkupInfoSmallList = TempMarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue)).ToList(); }
1166

    
1167
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1168
        }
1169

    
1170
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1171
        {
1172
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1173
        }
1174

    
1175
        private void btnSearch_Click(object sender, RoutedEventArgs e)
1176
        {
1177
            string search_str = txtSearch.Text;
1178

    
1179
            if(string.IsNullOrWhiteSpace(search_str))
1180
            {
1181
                return;
1182
            }
1183

    
1184
            var sel_type = commentType.SelectedItem;
1185
            var sel_user = commentUser.SelectedItem;
1186
            var sel_page = commentPage.SelectedItem;
1187
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1188
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1189
            if (sel_page != null)
1190
            {
1191
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1192
            }
1193
            if (sel_type != null)
1194
            {
1195
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1196
            }
1197
            if (sel_user != null)
1198
            {
1199
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1200
            }
1201
            foreach (var item in list)
1202
            {
1203
                var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(item.Data.ToString());
1204

    
1205
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1206
                {
1207
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1208
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1209
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1210
                        {
1211
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1212

    
1213
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1214
                            {
1215
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1216
                                {
1217
                                    small_list.Add(item);
1218
                                }
1219
                            }
1220
                        }
1221
                        break;
1222
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1223
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1224
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1225
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1226
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1227
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1228
                        {
1229
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1230

    
1231
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1232
                            {
1233
                                if (instance.ArrowText.Contains(search_str))
1234
                                {
1235
                                    small_list.Add(item);
1236
                                }
1237
                            }
1238
                        }
1239
                        break;
1240
                }
1241
            }
1242

    
1243
            MarkupList.ItemsSource = null;
1244
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1245
        }
1246

    
1247
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1248
        {
1249
            if(e.Key == Key.Enter || e.Key == Key.Return)
1250
            {
1251
                btnSearch_Click(sender, new RoutedEventArgs());
1252
            }
1253
        }
1254
    }
1255
}
클립보드 이미지 추가 (최대 크기: 500 MB)