프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (40.2 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
            if (e.AddedItems.Count > 0)
680
            {
681
                if (commentUser.Items.Count > 0)
682
                {
683
                    MarkupInfoSmallList.Clear();
684
                    //var d = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First();
685
                    //d.PageNumber
686

    
687
                    //e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First().
688
                    //gogo.DataContext = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
689

    
690
                    //gogogo.ItemsSource = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
691
                    //gogogo.ItemsSource = ViewerDataModel.Instance._markupInfoList.Where(d=>d.UserName ==  sender as RadCombo
692

    
693
                    var temp = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault();
694
                    temp.MarkupList.ForEach(d =>
695
                    {
696
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
697
                        {
698
                            Data = d.Data,
699
                            Data_Type = d.Data_Type,
700
                            PageNumber = d.PageNumber,
701
                            UserID = temp.UserID,
702
                            UserName = temp.UserName,
703
                        });
704
                    });
705
                    gogogo.ItemsSource = null;
706
                    gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
707
                }                
708
            }
709
            else
710
            {
711
                MarkupInfoSmallList.Clear();
712
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
713
                {
714
                    d.MarkupList.ForEach(b =>
715
                    {
716
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
717
                        {
718

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
950
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
951
        {
952
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
953
        }
954
    }
955
}
클립보드 이미지 추가 (최대 크기: 500 MB)