프로젝트

일반

사용자정보

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

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

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

1 787a4489 KangIngu
using IKCOM;
2
using KCOM.Common;
3
using KCOMDataModel.DataModel;
4
using System;
5
using System.Collections.Generic;
6
using System.Collections.ObjectModel;
7
using System.ComponentModel;
8 0c997b99 ljiyeon
using System.Diagnostics;
9 787a4489 KangIngu
using System.Linq;
10
using System.Windows;
11
using System.Windows.Controls;
12
using System.Windows.Input;
13
using Telerik.Windows.Controls;
14
15
namespace KCOM.Controls
16
{
17
    /// <summary>
18
    /// Interaction logic for PageNavigator.xaml
19
    /// </summary>
20
    public partial class Sample : UserControl, INotifyPropertyChanged
21
    {
22 992a98b4 KangIngu
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
23 787a4489 KangIngu
        public event PropertyChangedEventHandler PropertyChanged;
24
        public Sample()
25
        {
26 0c997b99 ljiyeon
            //InitializeComponent();            
27
            this.Loaded += Sample_Loaded;
28
            //_Initialize = true;
29
            
30
            //lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
31
            //ImgListbox.MouseDoubleClick += ImgListbox_MouseDoubleClick;
32
        }
33
34
        private void Sample_Loaded(object sender, RoutedEventArgs e)
35
        {
36
            //측정
37
            //Stopwatch sw = new Stopwatch();
38
            //sw.Start();
39 787a4489 KangIngu
            InitializeComponent();
40 0c997b99 ljiyeon
            //System.Diagnostics.Debug.WriteLine("Sample() : " + sw.ElapsedMilliseconds.ToString() + "ms");
41
42 787a4489 KangIngu
            _Initialize = true;
43
            lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
44 0c997b99 ljiyeon
            
45 787a4489 KangIngu
        }
46
47
        //private void ImgListbox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
48
        //{
49
50
        //    if (ImgListbox.SelectedItem !=null && (ImgListbox.SelectedItem as ThumbnailItem).PageNumber == CurrentPage.PageNumber)
51
        //    {
52
        //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ScaleToFit();
53
        //    }
54
        //}
55
56
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
57
        private List<DOCPAGE> _PageList = null;
58
        private string _DefaultUri = null;
59
        public ThumbnailItem CurrentPage = null;
60
        public ThumbnailItem _NextPage = null;
61
        public int PageCount = 0;
62
63
        private bool _Initialize;
64
        public event EventHandler<PageChangeEventArgs> PageChanged;
65
        public event EventHandler<PageChangeEventArgs> PageChanging;
66
        List<UsersCommentPagesMember> _UsersCommentPagesList = new List<UsersCommentPagesMember>();
67
        public class PageChangeEventArgs : EventArgs
68
        {
69
            public DOCPAGE CurrentPage { get; set; }
70
            public string PageUri { get; set; }
71
            public int PageNumber { get; set; }
72
        }
73
74
        private bool _IsFitOn { get; set; }
75
        public bool IsFitOn
76
        {
77
            get
78
            {
79
                return _IsFitOn;
80
            }
81
            set
82
            {
83
                _IsFitOn = value;
84
                RaisePropertyChanged("IsFitOn");
85
            }
86
        }
87
88
        public void RaisePropertyChanged(string propName)
89
        {
90
            if (PropertyChanged != null)
91
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
92
        }
93
94
        public void SetPageNavi(List<DOCPAGE> PageList, string DefaultUri)
95
        {
96
            this._PageList = PageList;
97
            this._DefaultUri = DefaultUri;
98
            ThumbnailSet();
99
            this.PageCount = PageList.Count();
100
            //ThumbNmailSet();
101
            rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
102
            rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
103
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
104
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
105
        }
106
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
107
        {
108
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
109
            SetCommentPages();
110
        }
111
112
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
113
        {
114 992a98b4 KangIngu
            if (rdoFavoritePages.IsChecked == true)
115
                expCommentPages.IsExpanded = false;
116
117
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet; 
118
            if (_FavoriteSet.Count > 0)
119
            {
120
                SetCommentPages_Favorite(); //수정    
121
            }
122
            else
123
            {
124
                rdoAllPages.IsChecked = true;
125
                rdoFavoritePages.IsChecked = false;
126
            }
127
        }
128
129
        private void SetCommentPages_Favorite()
130
        {
131
            ThumbnailSet();
132
            //_UsersCommentPagesList
133
            //var result = (from A in _UsersCommentPagesList
134
            //              from B in _FavoriteSet
135
            //              where A.PageNumber.Contains(B.PageNo)
136
            //              select A).ToList();
137
            //_UsersCommentPagesList = result;
138
139
            SetCommentPages();
140
141 787a4489 KangIngu
        }
142 992a98b4 KangIngu
143 787a4489 KangIngu
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
144
        {
145
            //txtThumbCount.Visibility = Visibility.Collapsed;            
146
        }
147
148
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
149
        {
150
            rdoAllPages.IsChecked = false;
151
            rdoFavoritePages.IsChecked = false;
152
            //txtThumbCount.Visibility = Visibility.Visible;
153
            SetCommentPages();
154
        }
155
156
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
157
        {
158
            if (ImgListbox.SelectedItem != null)
159
            {
160
                int _PageNo = -1;
161
162
                if (this.CurrentPage != null)
163
                {
164
                    _PageNo = this.CurrentPage.PageNumber;
165
                };
166
167
                if (_PageNo != ((ImgListbox.SelectedItem as ThumbnailItem).PageNumber))
168
                {
169 64f6713a humkyung
                    var _page = this._thumbnailItems.Where(item => item.PageNumber == (ImgListbox.SelectedItem as ThumbnailItem).PageNumber);
170
                    if (_page.Count() > 0)
171
                    {
172
                        ThumbnailItem _item = _page.First();
173
                        setPageChange(_item);
174
                    }
175 787a4489 KangIngu
                }
176
            }
177
        }
178
179
        public bool GotoPageFlag = false;
180
181 b2a6b24a humkyung
        /// <summary>
182
        /// 해당 썸네일로 이동
183
        /// </summary>
184
        /// <param name="_pageNumber"></param>
185 787a4489 KangIngu
        public void GotoPage(int _pageNumber)
186
        {
187
            int _PageNo = -1;
188
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
189
            {
190
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
191
                if (_page.Count() > 0)
192
                {
193
                    ThumbnailItem _item = _page.First();
194
                    setPageChange(_item);
195 64f6713a humkyung
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
196
                    this.ImgListbox.ScrollIntoView(_pageNumber - 1);
197 787a4489 KangIngu
                }
198
            }
199 d974f3f8 ljiyeon
        }      
200 787a4489 KangIngu
201
        public void setPageChange(ThumbnailItem thumbnailItem)
202
        {
203
            if (thumbnailItem != null)
204
            {
205
                if (PageChanging != null)
206
                {
207
                    //강인구 수정(페이지가 같을 경우 이동 안함)
208
                    if (CurrentPage != null && CurrentPage == thumbnailItem)
209
                    {
210
                        return;
211
                    }
212 64f6713a humkyung
213
                    this.CurrentPage = _NextPage;
214 787a4489 KangIngu
                    _NextPage = thumbnailItem;
215
                    PageChanging(this, new PageChangeEventArgs
216
                    {
217
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
218
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
219
                        PageUri = null
220
                    });
221
                }
222
            }
223
        }
224 64f6713a humkyung
225 d974f3f8 ljiyeon
        public void GotoPageTALK(int _pageNumber, int _angle)
226
        {
227
            int _PageNo = -1;
228
229
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
230
            {
231
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
232
                if (_page.Count() > 0)
233
                {
234
                    ThumbnailItem _item = _page.First();
235
                    setPageChangeTALK(_item, _angle);
236
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
237
                    this.ImgListbox.ScrollIntoView(_pageNumber - 1);
238
                }
239
            }
240
        }
241
242
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
243
        {
244
            if (thumbnailItem != null)
245
            {
246
                if (PageChanging != null)
247
                {   
248
                    this.CurrentPage = _NextPage;
249
                    _NextPage = thumbnailItem;
250
                    PageChanging(this, new PageChangeEventArgs
251
                    {
252
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
253
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
254
                        PageUri = null
255
                    });
256
257
                    var instanceMain = this.ParentOfType<MainWindow>();
258
259
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
260
261
                    if (rotationNum > 0) // 1, 2, 3
262
                    {
263
                        for(int i = 0; i < rotationNum; i++)
264
                        {
265
                            drawingPannelRotate(true);
266
                        }
267
                    }
268
                    else if(rotationNum < 0)// -1, -2, -3
269
                    {
270
                        for (int i = 0; i < -rotationNum; i++)
271
                        {
272
                            drawingPannelRotate(false);
273
                        }
274
                    }                    
275
                }
276
            }
277
        }
278
     
279
        public void drawingPannelRotate(bool Flag)
280
        {
281
            var instanceMain = this.ParentOfType<MainWindow>();
282
283
            if (Flag)
284
            {
285
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
286
                {
287
                    instanceMain.dzMainMenu.rotate.Angle = 0;
288
                }
289
                else
290
                {
291
                    instanceMain.dzMainMenu.rotate.Angle += 90;
292
                }
293
            }
294
            else
295
            {
296
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
297
                {
298
                    instanceMain.dzMainMenu.rotate.Angle = 270;
299
                }
300
                else
301
                {
302
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
303
                }
304
            }
305
306
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
307
            {
308
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
309
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
310
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
311
            }
312
        
313
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
314
            {
315
                instanceMain.dzMainMenu.translate.X = 0;
316
                instanceMain.dzMainMenu.translate.Y = 0;
317
            }
318
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
319
            {
320
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
321
                instanceMain.dzMainMenu.translate.Y = 0;
322
            }
323
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
324
            {
325
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
326
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
327
            }
328
            else
329
            {
330
                instanceMain.dzMainMenu.translate.X = 0;
331
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
332
            }
333
334
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
335
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
336
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
337
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
338
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
339
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
340
341
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
342
            {
343
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
344
345
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
346
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
347
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
348
349
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
350
                if (rotationdoc != null)
351
                {
352
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
353
                }
354
                else
355
                {
356
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
357
                }
358
                instanceMain.dzMainMenu.pageNavigator.setPageChange(data);
359
            });
360
        }
361
362 787a4489 KangIngu
        public void SetNextPage()
363
        {  
364
            CurrentPage = _NextPage;
365
            PageChange(_NextPage);
366
        }
367 64f6713a humkyung
368 787a4489 KangIngu
        private void PageChange(ThumbnailItem thumbitem)
369
        {
370
            if (PageChanged != null)
371
            {
372
                var uri = _DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
373
                //var _thumbitem = _thumbnailItems.Where(item => item.PageNumber == DocPage.PageNumber).First();
374
                var _itemIndex = _thumbnailItems.IndexOf(thumbitem);
375
                //ImgListbox.SelectedItem(_thumbitem, true);
376
                ImgListbox.SelectedItem = thumbitem;
377
378
                if (_itemIndex < _thumbnailItems.Count() - 1)
379
                    ImgListbox.ScrollIntoView(_itemIndex);
380
                else
381
                    ImgListbox.ScrollIntoView(_thumbnailItems.Count() - 1);
382
383
                //txtCurentPageNo.Text = (_itemIndex + 1).ToString();
384
385
                //txtCurentPageNo.Text = this.CurrentPage.PageNumber.ToString();
386
387
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber);
388
389
                if (_DocPages.Count() > 0)
390
                {   
391
                    var _page = _DocPages.First();
392
393
                    PageChanged(this, new PageChangeEventArgs
394
                    {
395
                        CurrentPage = _page,
396
                        PageUri = uri,
397
                        PageNumber = thumbitem.PageNumber
398
                    });
399
                    ImgListbox.SelectedItem = thumbitem;
400
401
                }
402
                else
403
                {
404 6c781c0c djkim
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
405 787a4489 KangIngu
                }
406
            }
407
        }
408
409
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
410
        {
411
            SetCommentPages();
412
        }
413
414
415
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
416
        {
417
            SetCommentPages();
418 6c781c0c djkim
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
419 787a4489 KangIngu
        }
420
        public void SetCommentPages()
421
        {
422
            ThumbnailSet();
423
            SetCommentList(_UsersCommentPagesList.ToList());
424
        }
425
426
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
427
        {
428
            #region 기존 색상 제거 작업
429
            foreach (var item in this._thumbnailItems)
430
            {
431
                item.DisplayColorItems.Clear();
432
            } 
433
            #endregion
434
435
436
437
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
438
439
            _UsersCommentPagesList.ToList().ForEach(item =>
440
            {
441
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
442
443
                if (_comm.Count() == 0)
444
                {
445
                    _delItem.Add(item);
446
                }
447
            });
448
449
            _delItem.ForEach(f => _UsersCommentPagesList.Remove(f));
450
451
            UsersCommentPagesList.ForEach(user =>
452
            {
453
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
454
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
455
456
                var _commLst = _UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
457
458
                if (_commLst.Count() == 0)
459
                {
460
                    _UsersCommentPagesList.Add(user);
461
                }
462
                else
463
                {
464
                    if (_commLst.First().PageNumber != user.PageNumber)
465
                        _commLst.First().PageNumber = user.PageNumber;
466
                }
467
468
                user.PageNumber.ForEach(page =>
469
                {
470
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
471
472
                    if (_items.Count() > 0)
473
                        _items.First().DisplayColorItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor });
474
                });
475
            });
476
477
478
479
            var data = _UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
480
            if (data.Count() != 0)
481
            {
482
                if (Convert.ToBoolean(data.First().isConSolidation))
483
                {
484
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
485
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
486
                    this.lstSelectComment.ItemsSource = data;
487
                }
488
                else
489
                {
490
                    this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
491
                }
492
            }
493
            else
494
            {
495
                this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
496
            }
497
            //this.ImgListbox.ItemsSource = null;
498
            this.ImgListbox.ItemsSource = this._thumbnailItems;
499
            var template = this.ImgListbox.ItemTemplate;
500
            this.ImgListbox.ItemTemplate = null;
501
            this.ImgListbox.ItemTemplate = template;
502
            this.ImgListbox.UpdateLayout();
503
        }
504
505
        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
506
        {
507
508
        }
509
        private void ThumbnailSet()
510
        {
511
            if (!_Initialize) return;
512
513
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
514
            List<int> _selectComment = new List<int>();
515
            if (this.lstSelectComment.ItemsSource != null)
516
            {
517
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
518
                             where commentPage.IsSelected == true
519
                             select commentPage.PageNumber;
520
521
                foreach (var item in _pages)
522
                {
523
                    item.ForEach(pp => _selectComment.Add(pp));
524
                }
525
526
                _selectComment.Distinct();
527
            }
528
529
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
530
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
531
            //this._PageList.ForEach(page =>
532
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
533
            {
534
                var _pageNo = page.PAGE_NUMBER;
535
                bool _addFlag = false;
536
537 276fdd9b KangIngu
                if (rdoFavoritePages.IsChecked == false)
538 787a4489 KangIngu
                {
539 276fdd9b KangIngu
                    if (_selectComment.Count() > 0)
540 787a4489 KangIngu
                    {
541 276fdd9b KangIngu
                        if ((rdoAllPages.IsChecked == true)
542
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
543
                        {
544
                            _addFlag = true;
545
                        }
546 787a4489 KangIngu
                    }
547 276fdd9b KangIngu
                    else
548
                    {
549
                        //if (App.ViewInfo.IsCustomPage)
550
                        //{
551
                        //    //_addFlag = false;
552
553
                        //    //App.ViewInfo.IsCustomPage = false;
554
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
555
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
556
                        //    this.rdoAllPages.IsChecked = false;
557
                        //    this.rdoFavoritePages.IsChecked = true;
558
                        //    //SetCommentPages();                        
559
                        //}
560
                        //else
561
                        //{
562 787a4489 KangIngu
                        _addFlag = true;
563 276fdd9b KangIngu
                        //}
564
                    }
565 787a4489 KangIngu
                }
566
567
568
                if(_addFlag)
569
                {
570
                    this._thumbnailItems.Add(new ThumbnailItem
571
                    {
572
                        ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
573
                        PageNumber = _pageNo,
574
                        Angle = page.PAGE_ANGLE,
575
                    });
576
                }
577
                else
578
                {
579 992a98b4 KangIngu
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
580
                    {
581
                        this._thumbnailItems.Add(new ThumbnailItem
582
                        {
583
                            ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
584
                            PageNumber = _pageNo,
585
                            Angle = page.PAGE_ANGLE,
586
                        });
587
                    }
588 787a4489 KangIngu
                }
589
590
591
592
                //this._thumbnailItems.Add(new ThumbnailItem
593
                //{
594
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
595
596
                //    //ImageUri = new Uri(@"http://www.honeyhead.net/Pages/000000/111111/11111111/1.cmp"),
597
598
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
599
                //    //DisplayColorItems = pageColor,
600
                //    PageNumber = Convert.ToInt32(_pageNo),
601
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
602
                //});
603
            });
604
605
            //txtTotPageNo.Text = this._PageList.Count().ToString();
606
607
            //txtThumbCount.Text = String.Format("Count : {0}", (this._thumbnailItems.Count).ToString());
608
609
            if (ImgListbox.ItemsSource == null)
610
            {
611
                ImgListbox.ItemsSource = this._thumbnailItems;
612
613
                this._thumbnailItems.ToList().ForEach(data =>
614
                {
615
                    data.Width = ImgListbox.ActualWidth;
616
                });
617
618
                if (ImgListbox.Items.Count > 0)
619
                {
620
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
621
                    int StartPageIdx = 1;
622
                    //if (App.ViewInfo.IsCustomPage)
623
                    //{
624
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
625
                    //}
626
                    //else
627
                    //{
628
629
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
630
                    {
631
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
632
                    }
633
                    else
634
                    {
635
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
636
                    }
637
                    //}
638
                }
639
            }
640
            else
641
            {
642
                ImgListbox.UpdateLayout();
643
                ImgListbox.ItemsSource = this._thumbnailItems;
644
            }
645
        }
646
647
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
648
        {
649
            if (e.ClickCount >= 2)
650
            {
651
                var selectItem = gogogo.SelectedItem as IKCOM.MarkupItem;
652
                GotoPage(selectItem.PageNumber);
653
                MarkupToPDF.Controls.Parsing.LayerControl control = new MarkupToPDF.Controls.Parsing.LayerControl();
654
                var result = control.markupParse_GetBaseControl(selectItem.Data);
655
                Rect rect = new Rect(new Point(result.StartPoint.X-100, result.StartPoint.Y-100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));             
656
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
657
                //bool isGO = false;
658
659
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
660
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
661
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
662
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
663
                //{
664
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
665
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
666
                //    {
667
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
668
                //    }
669
670
                //};
671
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
672
673
                //GotoPage(gogogo.SelectedItem as MarkupList)
674
            }
675
        }
676
677
        private void commentUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
678
        {
679 79f3f21a djkim
            tbSearch.Text = string.Empty;
680 787a4489 KangIngu
            if (e.AddedItems.Count > 0)
681
            {
682
                if (commentUser.Items.Count > 0)
683
                {
684
                    MarkupInfoSmallList.Clear();
685
                    //var d = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First();
686
                    //d.PageNumber
687
688
                    //e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First().
689
                    //gogo.DataContext = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
690
691
                    //gogogo.ItemsSource = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
692
                    //gogogo.ItemsSource = ViewerDataModel.Instance._markupInfoList.Where(d=>d.UserName ==  sender as RadCombo
693
694
                    var temp = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault();
695 4836261b djkim
                    var markuplist = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.MarkupInfoID == temp.MarkupInfoID).ToList();
696
                    markuplist.ForEach(d =>
697 787a4489 KangIngu
                    {
698
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
699
                        {
700
                            Data = d.Data,
701
                            Data_Type = d.Data_Type,
702
                            PageNumber = d.PageNumber,
703
                            UserID = temp.UserID,
704
                            UserName = temp.UserName,
705
                        });
706
                    });
707
                    gogogo.ItemsSource = null;
708
                    gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
709 4836261b djkim
                    
710 787a4489 KangIngu
                }                
711
            }
712
            else
713
            {
714
                MarkupInfoSmallList.Clear();
715
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
716
                {
717 4836261b djkim
                    var markuplist = ViewerDataModel.Instance.MarkupList_USER.Where(u => u.MarkupInfoID == d.MarkupInfoID).ToList();
718
719
                    markuplist.ForEach(b =>
720 787a4489 KangIngu
                    {
721
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
722
                        {
723
724
                            Data = b.Data,
725
                            Data_Type = b.Data_Type,
726
                            PageNumber = b.PageNumber,
727
                            UserID = d.UserID,
728
                            UserName = d.UserName,
729
                        });
730
                    });
731 4836261b djkim
732 787a4489 KangIngu
                });
733
                gogogo.ItemsSource = null;
734
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList(); 
735
            }
736
        }
737
738
        public class MarkupInfoItemSmall
739
        {
740
            public string Id { get; set; }
741
            public string UserName { get; set; }
742
            public string UserID { get; set; }
743
            public int PageNumber { get; set; }
744
            public string Data { get; set; }
745
            public int Data_Type { get; set; }
746
        }
747
748
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
749
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
750
        {
751
            get
752
            {
753
                if (_MarkupInfoSmallList == null)
754
                {
755
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
756
                }
757
                return _MarkupInfoSmallList;
758
            }
759
            set
760
            {
761
               
762
                _MarkupInfoSmallList = value;
763
                RaisePropertyChanged("MarkupInfoSmallList");
764
            }
765
        }
766
767 2aaf9645 humkyung
        /// <summary>
768
        /// goto page and select item selected by user
769
        /// </summary>
770
        /// <param name="sender"></param>
771
        /// <param name="e"></param>
772 787a4489 KangIngu
        private void RadButton_Click(object sender, RoutedEventArgs e)
773
        {
774
            var clickButtonItem = sender as RadButton;
775
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
776
            {
777
                try
778
                {
779
                    Rect rect = new Rect();
780
                    Point s_point = new Point();
781
                    Point e_point = new Point();
782
783
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
784
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
785 2aaf9645 humkyung
786 787a4489 KangIngu
                    var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(gaza.Data.ToString()); //언패킹작업
787
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
788
                    {
789
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
790
                            {
791
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
792
                                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));
793
                            }
794
                            break;
795
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
796
                            {
797
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
798
                                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));
799
                            }
800
                            break;
801
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
802
                            {
803
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
804
                                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));
805
                            }
806
                            break;
807
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
808
                            {
809
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
810
811
                                foreach (Point A in instance.PointSet)
812
                                {
813
                                    if (s_point == new Point())
814
                                    {
815
                                        s_point = A;
816
                                        e_point = A;
817
                                    }
818
                                    s_point.X = Math.Min(s_point.X, A.X);
819
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
820
                                    e_point.X = Math.Max(e_point.X, A.X);
821
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
822
                                }
823
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
824
                            }
825
                            break;
826
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
827
                            {
828
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
829
830
                                foreach (Point A in instance.PointSet)
831
                                {
832
                                    if (s_point == new Point())
833
                                    {
834
                                        s_point = A;
835
                                        e_point = A;
836
                                    }
837
                                    s_point.X = Math.Min(s_point.X, A.X);
838
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
839
                                    e_point.X = Math.Max(e_point.X, A.X);
840
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
841
                                }
842
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
843
                            }
844
                            break;
845
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
846
                            {
847
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
848
849
                                foreach (Point A in instance.PointSet)
850
                                {
851
                                    if (s_point == new Point())
852
                                    {
853
                                        s_point = A;
854
                                        e_point = A;
855
                                    }
856
                                    s_point.X = Math.Min(s_point.X, A.X);
857
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
858
                                    e_point.X = Math.Max(e_point.X, A.X);
859
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
860
                                }
861
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
862
                            }
863
                            break;
864
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
865
                            {
866
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
867
868
                                foreach (Point A in instance.PointSet)
869
                                {
870
                                    if (s_point == new Point())
871
                                    {
872
                                        s_point = A;
873
                                        e_point = A;
874
                                    }
875
                                    s_point.X = Math.Min(s_point.X, A.X);
876
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
877
                                    e_point.X = Math.Max(e_point.X, A.X);
878
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
879
                                }
880
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
881
                            }
882
                            break;
883
                        default:
884
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
885
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
886
                            break;
887
                    }
888
889 2aaf9645 humkyung
                    this.ParentOfType<KCOM.Views.MainMenu>().SelecteItemByRect(rect);
890 787a4489 KangIngu
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
891
                }
892
                catch (Exception ex)
893
                {
894 2aaf9645 humkyung
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
895 787a4489 KangIngu
                }
896
            }
897
        }
898 4836261b djkim
        public void MarkupListReload()
899
        {
900
            ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
901
            {
902
                if (d.MarkupList != null)
903
                {
904
                    d.MarkupList.ForEach(b =>
905
                    {
906
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
907
                        {
908
                            Id = b.ID,
909
                            Data = b.Data,
910
                            Data_Type = b.Data_Type,
911
                            PageNumber = b.PageNumber,
912
                            UserID = d.UserID,
913
                            UserName = d.UserName,
914
                        });
915
                    });
916
                }
917
            });
918
            gogogo.ItemsSource = null;
919
            gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
920 787a4489 KangIngu
921 4836261b djkim
            commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
922
            commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
923
        }
924 787a4489 KangIngu
        private void gogogo_Loaded(object sender, RoutedEventArgs e)
925
        {
926
            if (MarkupInfoSmallList.Count == 0)
927
            {
928
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
929
                {
930
                    if (d.MarkupList != null)
931
                    {
932
                        d.MarkupList.ForEach(b =>
933
                        {
934
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
935
                            {
936
                                Id = b.ID,
937
                                Data = b.Data,
938
                                Data_Type = b.Data_Type,
939
                                PageNumber = b.PageNumber,
940
                                UserID = d.UserID,
941
                                UserName = d.UserName,
942
                            });
943
                        });
944
                    }
945
                });
946
                gogogo.ItemsSource = null;
947 4836261b djkim
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
948 787a4489 KangIngu
949
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d=>d).ToList();
950
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
951
            }
952
        }
953
954
        private void commentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
955
        {
956
            gogogo.ItemsSource = null;
957 79f3f21a djkim
            tbSearch.Text = string.Empty;
958 787a4489 KangIngu
            if (e.AddedItems.Count >0)
959
            {
960
                
961
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(e.AddedItems[0])).ToList();
962
            }
963
            else
964
            {
965
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
966
            }
967
        }
968
969
        private void commentPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
970
        {
971
            gogogo.ItemsSource = null;
972 79f3f21a djkim
            tbSearch.Text = string.Empty;
973 787a4489 KangIngu
            if (e.AddedItems.Count > 0)
974
            {
975
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(e.AddedItems[0])).ToList();
976
            }
977
            else
978
            {
979
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
980
            }
981
        }
982
983
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
984
        {
985
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
986
        }
987 79f3f21a djkim
988
        private void btnSearch_Click(object sender, RoutedEventArgs e)
989
        {
990
            string search_str = tbSearch.Text;
991
            var sel_type = commentType.SelectedItem;
992
            var sel_user = commentUser.SelectedItem;
993
            var sel_page = commentPage.SelectedItem;
994
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
995
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
996
            if(sel_page !=null)
997
            {
998
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
999
            }
1000
            if(sel_type !=null)
1001
            {
1002
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1003
            }
1004
            if (sel_user != null)
1005
            {
1006
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1007
            }
1008
            foreach (var item in list)
1009
            {
1010
                var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(item.Data.ToString());
1011
                
1012
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1013
                {                    
1014
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1015
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1016
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1017
                        {
1018
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1019
                            if (instance.Text.Contains(search_str))
1020
                            {                                
1021
                                small_list.Add(item);
1022
                            }
1023
                        }
1024
                        break;
1025
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1026
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1027
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1028
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1029
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1030
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1031
                        {
1032
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1033
                            if (instance.ArrowText.Contains(search_str))
1034
                            {
1035
                                small_list.Add(item);
1036
                            }
1037
                        }
1038
                        break;
1039
                    
1040
                }
1041
                
1042
            }
1043
            
1044
            gogogo.ItemsSource = null;
1045
            gogogo.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1046
            tbSearch.Text = string.Empty;
1047
        }
1048 4836261b djkim
        
1049 787a4489 KangIngu
    }
1050
}
클립보드 이미지 추가 (최대 크기: 500 MB)