프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 79f3f21a

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

1
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
using System.Diagnostics;
9
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
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
23
        public event PropertyChangedEventHandler PropertyChanged;
24
        public Sample()
25
        {
26
            //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
            InitializeComponent();
40
            //System.Diagnostics.Debug.WriteLine("Sample() : " + sw.ElapsedMilliseconds.ToString() + "ms");
41

    
42
            _Initialize = true;
43
            lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
44
            
45
        }
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
            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
        }
142

    
143
        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
                    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
                }
176
            }
177
        }
178

    
179
        public bool GotoPageFlag = false;
180

    
181
        /// <summary>
182
        /// 해당 썸네일로 이동
183
        /// </summary>
184
        /// <param name="_pageNumber"></param>
185
        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
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
196
                    this.ImgListbox.ScrollIntoView(_pageNumber - 1);
197
                }
198
            }
199
        }      
200

    
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

    
213
                    this.CurrentPage = _NextPage;
214
                    _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

    
225
        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
        public void SetNextPage()
363
        {  
364
            CurrentPage = _NextPage;
365
            PageChange(_NextPage);
366
        }
367

    
368
        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
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
405
                }
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
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
419
        }
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
                if (rdoFavoritePages.IsChecked == false)
538
                {
539
                    if (_selectComment.Count() > 0)
540
                    {
541
                        if ((rdoAllPages.IsChecked == true)
542
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
543
                        {
544
                            _addFlag = true;
545
                        }
546
                    }
547
                    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
                        _addFlag = true;
563
                        //}
564
                    }
565
                }
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
                    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
                }
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
            tbSearch.Text = string.Empty;
680
            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
                    temp.MarkupList.ForEach(d =>
696
                    {
697
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
698
                        {
699
                            Data = d.Data,
700
                            Data_Type = d.Data_Type,
701
                            PageNumber = d.PageNumber,
702
                            UserID = temp.UserID,
703
                            UserName = temp.UserName,
704
                        });
705
                    });
706
                    gogogo.ItemsSource = null;
707
                    gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
708
                }                
709
            }
710
            else
711
            {
712
                MarkupInfoSmallList.Clear();
713
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
714
                {
715
                    d.MarkupList.ForEach(b =>
716
                    {
717
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
718
                        {
719

    
720
                            Data = b.Data,
721
                            Data_Type = b.Data_Type,
722
                            PageNumber = b.PageNumber,
723
                            UserID = d.UserID,
724
                            UserName = d.UserName,
725
                        });
726
                    });
727
                });
728
                gogogo.ItemsSource = null;
729
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList(); 
730
            }
731
        }
732

    
733
        public class MarkupInfoItemSmall
734
        {
735
            public string Id { get; set; }
736
            public string UserName { get; set; }
737
            public string UserID { get; set; }
738
            public int PageNumber { get; set; }
739
            public string Data { get; set; }
740
            public int Data_Type { get; set; }
741
        }
742

    
743
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
744
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
745
        {
746
            get
747
            {
748
                if (_MarkupInfoSmallList == null)
749
                {
750
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
751
                }
752
                return _MarkupInfoSmallList;
753
            }
754
            set
755
            {
756
               
757
                _MarkupInfoSmallList = value;
758
                RaisePropertyChanged("MarkupInfoSmallList");
759
            }
760
        }
761

    
762
        /// <summary>
763
        /// goto page and select item selected by user
764
        /// </summary>
765
        /// <param name="sender"></param>
766
        /// <param name="e"></param>
767
        private void RadButton_Click(object sender, RoutedEventArgs e)
768
        {
769
            var clickButtonItem = sender as RadButton;
770
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
771
            {
772
                try
773
                {
774
                    Rect rect = new Rect();
775
                    Point s_point = new Point();
776
                    Point e_point = new Point();
777

    
778
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
779
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
780

    
781
                    var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(gaza.Data.ToString()); //언패킹작업
782
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
783
                    {
784
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
785
                            {
786
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
787
                                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));
788
                            }
789
                            break;
790
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
791
                            {
792
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
793
                                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));
794
                            }
795
                            break;
796
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
797
                            {
798
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
799
                                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));
800
                            }
801
                            break;
802
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
803
                            {
804
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
805

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

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

    
844
                                foreach (Point A in instance.PointSet)
845
                                {
846
                                    if (s_point == new Point())
847
                                    {
848
                                        s_point = A;
849
                                        e_point = A;
850
                                    }
851
                                    s_point.X = Math.Min(s_point.X, A.X);
852
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
853
                                    e_point.X = Math.Max(e_point.X, A.X);
854
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
855
                                }
856
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
857
                            }
858
                            break;
859
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
860
                            {
861
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
862

    
863
                                foreach (Point A in instance.PointSet)
864
                                {
865
                                    if (s_point == new Point())
866
                                    {
867
                                        s_point = A;
868
                                        e_point = A;
869
                                    }
870
                                    s_point.X = Math.Min(s_point.X, A.X);
871
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
872
                                    e_point.X = Math.Max(e_point.X, A.X);
873
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
874
                                }
875
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
876
                            }
877
                            break;
878
                        default:
879
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
880
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
881
                            break;
882
                    }
883

    
884
                    this.ParentOfType<KCOM.Views.MainMenu>().SelecteItemByRect(rect);
885
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
886
                }
887
                catch (Exception ex)
888
                {
889
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
890
                }
891
            }
892
        }
893

    
894
        private void gogogo_Loaded(object sender, RoutedEventArgs e)
895
        {
896
            if (MarkupInfoSmallList.Count == 0)
897
            {
898
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
899
                {
900
                    if (d.MarkupList != null)
901
                    {
902
                        d.MarkupList.ForEach(b =>
903
                        {
904
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
905
                            {
906
                                Id = b.ID,
907
                                Data = b.Data,
908
                                Data_Type = b.Data_Type,
909
                                PageNumber = b.PageNumber,
910
                                UserID = d.UserID,
911
                                UserName = d.UserName,
912
                            });
913
                        });
914
                    }
915
                });
916
                gogogo.ItemsSource = null;
917
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList(); ;
918

    
919
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d=>d).ToList();
920
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
921
            }
922
        }
923

    
924
        private void commentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
925
        {
926
            gogogo.ItemsSource = null;
927
            tbSearch.Text = string.Empty;
928
            if (e.AddedItems.Count >0)
929
            {
930
                
931
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(e.AddedItems[0])).ToList();
932
            }
933
            else
934
            {
935
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
936
            }
937
        }
938

    
939
        private void commentPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
940
        {
941
            gogogo.ItemsSource = null;
942
            tbSearch.Text = string.Empty;
943
            if (e.AddedItems.Count > 0)
944
            {
945
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(e.AddedItems[0])).ToList();
946
            }
947
            else
948
            {
949
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
950
            }
951
        }
952

    
953
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
954
        {
955
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
956
        }
957

    
958
        private void btnSearch_Click(object sender, RoutedEventArgs e)
959
        {
960
            string search_str = tbSearch.Text;
961
            var sel_type = commentType.SelectedItem;
962
            var sel_user = commentUser.SelectedItem;
963
            var sel_page = commentPage.SelectedItem;
964
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
965
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
966
            if(sel_page !=null)
967
            {
968
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
969
            }
970
            if(sel_type !=null)
971
            {
972
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
973
            }
974
            if (sel_user != null)
975
            {
976
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
977
            }
978
            foreach (var item in list)
979
            {
980
                var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(item.Data.ToString());
981
                
982
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
983
                {                    
984
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
985
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
986
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
987
                        {
988
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
989
                            if (instance.Text.Contains(search_str))
990
                            {                                
991
                                small_list.Add(item);
992
                            }
993
                        }
994
                        break;
995
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
996
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
997
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
998
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
999
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1000
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1001
                        {
1002
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1003
                            if (instance.ArrowText.Contains(search_str))
1004
                            {
1005
                                small_list.Add(item);
1006
                            }
1007
                        }
1008
                        break;
1009
                    
1010
                }
1011
                
1012
            }
1013
            
1014
            gogogo.ItemsSource = null;
1015
            gogogo.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1016
            tbSearch.Text = string.Empty;
1017
        }
1018
    }
1019
}
클립보드 이미지 추가 (최대 크기: 500 MB)