프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 83a98e96

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

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

    
17
namespace KCOM.Controls
18
{
19
    /// <summary>
20
    /// Interaction logic for PageNavigator.xaml
21
    /// </summary>
22
    public partial class Sample : UserControl, INotifyPropertyChanged
23
    {
24
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
25
        public event PropertyChangedEventHandler PropertyChanged;
26
        public Sample()
27
        {
28
            //InitializeComponent();            
29
            this.Loaded += Sample_Loaded;
30
            //_Initialize = true;
31

    
32
            //lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
33
            //ImgListbox.MouseDoubleClick += ImgListbox_MouseDoubleClick;
34
        }
35

    
36
        private void Sample_Loaded(object sender, RoutedEventArgs e)
37
        {
38
            //측정
39
            //Stopwatch sw = new Stopwatch();
40
            //sw.Start();
41
            InitializeComponent();
42
            //System.Diagnostics.Debug.WriteLine("Sample() : " + sw.ElapsedMilliseconds.ToString() + "ms");
43

    
44
            _Initialize = true;
45
            lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
46

    
47
        }
48

    
49
        //private void ImgListbox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
50
        //{
51

    
52
        //    if (ImgListbox.SelectedItem !=null && (ImgListbox.SelectedItem as ThumbnailItem).PageNumber == CurrentPage.PageNumber)
53
        //    {
54
        //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ScaleToFit();
55
        //    }
56
        //}
57

    
58
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
59
        private List<DOCPAGE> _PageList = null;
60
        private string _DefaultUri = null;
61
        public ThumbnailItem CurrentPage = null;
62
        public ThumbnailItem _NextPage = null;
63
        public int PageCount = 0;
64

    
65
        private bool _Initialize;
66
        public event EventHandler<PageChangeEventArgs> PageChanged;
67
        public event EventHandler<PageChangeEventArgs> PageChanging;
68
        List<UsersCommentPagesMember> _UsersCommentPagesList = new List<UsersCommentPagesMember>();
69
        public class PageChangeEventArgs : EventArgs
70
        {
71
            public DOCPAGE CurrentPage { get; set; }
72
            public string PageUri { get; set; }
73
            public int PageNumber { get; set; }
74
        }
75

    
76
        private bool _IsFitOn { get; set; }
77
        public bool IsFitOn
78
        {
79
            get
80
            {
81
                return _IsFitOn;
82
            }
83
            set
84
            {
85
                _IsFitOn = value;
86
                RaisePropertyChanged("IsFitOn");
87
            }
88
        }
89

    
90
        public void RaisePropertyChanged(string propName)
91
        {
92
            if (PropertyChanged != null)
93
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
94
        }
95

    
96
        public void SetPageNavi(List<DOCPAGE> PageList, string DefaultUri)
97
        {
98
            Logger.sendCheckLog("SetPageNavi", 1);
99
            this._PageList = PageList;
100
            this._DefaultUri = DefaultUri;
101
            ThumbnailSet();
102
            this.PageCount = PageList.Count();
103
            //ThumbNmailSet();
104
            rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
105
            rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
106
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
107
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
108
        }
109
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
110
        {
111
            Logger.sendCheckLog("rdoCommented_Checked", 1);
112
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
113
            SetCommentPages();
114
        }
115

    
116
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
117
        {
118
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
119
            if (rdoFavoritePages.IsChecked == true)
120
                expCommentPages.IsExpanded = false;
121

    
122
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
123
            if (_FavoriteSet.Count > 0)
124
            {
125
                SetCommentPages_Favorite(); //수정    
126
            }
127
            else
128
            {
129
                rdoAllPages.IsChecked = true;
130
                rdoFavoritePages.IsChecked = false;
131
            }
132
        }
133

    
134
        private void SetCommentPages_Favorite()
135
        {
136
            ThumbnailSet();            
137
            SetCommentPages();
138
        }
139

    
140
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
141
        {
142
            //txtThumbCount.Visibility = Visibility.Collapsed;            
143
        }
144

    
145
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
146
        {
147
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
148
            rdoAllPages.IsChecked = false;
149
            rdoFavoritePages.IsChecked = false;
150
            //txtThumbCount.Visibility = Visibility.Visible;
151
            SetCommentPages();
152
        }
153

    
154
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
155
        {
156
            Logger.sendCheckLog("ImgListbox_SelectionChanged", 1);
157
            if (ImgListbox.SelectedItem != null)
158
            {
159
                int _PageNo = -1;
160

    
161
                if (this.CurrentPage != null)
162
                {
163
                    _PageNo = this.CurrentPage.PageNumber;
164
                };
165

    
166
                if (_PageNo != ((ImgListbox.SelectedItem as ThumbnailItem).PageNumber))
167
                {
168
                    var _page = this._thumbnailItems.Where(item => item.PageNumber == (ImgListbox.SelectedItem as ThumbnailItem).PageNumber);
169
                    if (_page.Count() > 0)
170
                    {
171
                        ThumbnailItem _item = _page.First();
172
                        setPageChange(_item);
173
                    }
174
                }
175
            }
176
            var border = VisualTreeHelper.GetChild(ImgListbox, 0);
177
            if(border!= null)
178
            {
179
                IEnumerable<ScrollViewer> scrollViewer = border.ChildrenOfType<ScrollViewer>();
180

    
181
            }
182
            //ScrollViewer scrollViewer = (sender as RadListBox) as ScrollViewer;
183
            //ImgListbox.ScrollIntoView(ImgListbox.SelectedItem);
184
        }
185

    
186
        public bool GotoPageFlag = false;
187

    
188
        /// <summary>
189
        /// 해당 썸네일로 이동
190
        /// </summary>
191
        /// <param name="_pageNumber"></param>
192
        public void GotoPage(int _pageNumber)
193
        {
194
            try
195
            {
196
                int _PageNo = -1;
197
                if (int.TryParse(_pageNumber.ToString(), out _PageNo))
198
                {
199
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
200
                    if (_page.Count() > 0)
201
                    {
202
                        ThumbnailItem _item = _page.First();
203
                        setPageChange(_item);
204
                        this.ImgListbox.SelectedIndex = _pageNumber - 1;
205
                        this.ImgListbox.ScrollIntoView(_pageNumber - 1);
206
                    }
207
                }
208
            }
209
            catch(Exception ex)
210
            {
211
                Logger.sendResLog("GotoPage", ex.Message, 0);
212
            }
213
            
214
        }
215

    
216
        public void setPageChange(ThumbnailItem thumbnailItem)
217
        {
218
            Logger.sendCheckLog("setPageChange", 1);
219
            if (thumbnailItem != null)
220
            {
221
                if (PageChanging != null)
222
                {
223
                    //강인구 수정(페이지가 같을 경우 이동 안함)
224
                    if (CurrentPage != null && CurrentPage == thumbnailItem)
225
                    {
226
                        return;
227
                    }
228

    
229
                    this.CurrentPage = _NextPage;
230
                    _NextPage = thumbnailItem;
231
                    PageChanging(this, new PageChangeEventArgs
232
                    {
233
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
234
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
235
                        PageUri = null
236
                    });
237
                }
238
            }
239
        }
240

    
241
        public void GotoPageTALK(int _pageNumber, int _angle)
242
        {
243
            int _PageNo = -1;
244

    
245
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
246
            {
247
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
248
                if (_page.Count() > 0)
249
                {
250
                    ThumbnailItem _item = _page.First();
251
                    setPageChangeTALK(_item, _angle);
252
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
253
                    this.ImgListbox.ScrollIntoView(_pageNumber - 1);
254
                }
255
            }
256
        }
257

    
258
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
259
        {
260
            if (thumbnailItem != null)
261
            {
262
                if (PageChanging != null)
263
                {
264
                   this.CurrentPage = _NextPage;
265
                    _NextPage = thumbnailItem;
266
                    PageChanging(this, new PageChangeEventArgs
267
                    {
268
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
269
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
270
                        PageUri = null
271
                    });
272

    
273
                    var instanceMain = this.ParentOfType<MainWindow>();
274

    
275
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
276

    
277
                    if (rotationNum > 0) // 1, 2, 3
278
                    {
279
                        for (int i = 0; i < rotationNum; i++)
280
                        {
281
                            drawingPannelRotate(true);
282
                        }
283
                    }
284
                    else if (rotationNum < 0)// -1, -2, -3
285
                    {
286
                        for (int i = 0; i < -rotationNum; i++)
287
                        {
288
                            drawingPannelRotate(false);
289
                        }
290
                    }
291
                }
292
            }
293
        }
294

    
295
        public void drawingPannelRotate(bool Flag)
296
        {
297
            var instanceMain = this.ParentOfType<MainWindow>();
298

    
299
            if (Flag)
300
            {
301
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
302
                {
303
                    instanceMain.dzMainMenu.rotate.Angle = 0;
304
                }
305
                else
306
                {
307
                    instanceMain.dzMainMenu.rotate.Angle += 90;
308
                }
309
            }
310
            else
311
            {
312
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
313
                {
314
                    instanceMain.dzMainMenu.rotate.Angle = 270;
315
                }
316
                else
317
                {
318
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
319
                }
320
            }
321

    
322
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
323
            {
324
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
325
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
326
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
327
            }
328

    
329
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
330
            {
331
                instanceMain.dzMainMenu.translate.X = 0;
332
                instanceMain.dzMainMenu.translate.Y = 0;
333
            }
334
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
335
            {
336
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
337
                instanceMain.dzMainMenu.translate.Y = 0;
338
            }
339
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
340
            {
341
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
342
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
343
            }
344
            else
345
            {
346
                instanceMain.dzMainMenu.translate.X = 0;
347
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
348
            }
349

    
350
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
351
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
352
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
353
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
354
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
355
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
356

    
357
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
358
            {
359
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
360

    
361
                instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
362
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
363
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
364

    
365
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
366
                if (rotationdoc != null)
367
                {
368
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
369
                }
370
                else
371
                {
372
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
373
                }
374
                instanceMain.dzMainMenu.pageNavigator.setPageChange(data);
375
            });
376
        }
377

    
378
        public void SetNextPage()
379
        {
380
            Logger.sendCheckLog("pageNavigator_PageChanging_SetNextPage", 1);
381
            CurrentPage = _NextPage;
382
            PageChange(_NextPage);
383
        }
384

    
385
        private void PageChange(ThumbnailItem thumbitem)
386
        {
387
            Logger.sendCheckLog("pageNavigator_PageChanging_PageChange", 1);
388
            if (PageChanged != null)
389
            {
390
                var uri = _DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
391
                //var _thumbitem = _thumbnailItems.Where(item => item.PageNumber == DocPage.PageNumber).First();
392
                var _itemIndex = _thumbnailItems.IndexOf(thumbitem);
393
                //ImgListbox.SelectedItem(_thumbitem, true);
394
                ImgListbox.SelectedItem = thumbitem;
395

    
396
                if (_itemIndex < _thumbnailItems.Count() - 1)
397
                    ImgListbox.ScrollIntoView(_itemIndex);
398
                else
399
                    ImgListbox.ScrollIntoView(_thumbnailItems.Count() - 1);
400

    
401
                //txtCurentPageNo.Text = (_itemIndex + 1).ToString();
402

    
403
                //txtCurentPageNo.Text = this.CurrentPage.PageNumber.ToString();
404

    
405
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber);
406

    
407
                if (_DocPages.Count() > 0)
408
                {
409
                    var _page = _DocPages.First();
410

    
411
                    PageChanged(this, new PageChangeEventArgs
412
                    {
413
                        CurrentPage = _page,
414
                        PageUri = uri,
415
                        PageNumber = thumbitem.PageNumber
416
                    });
417
                    ImgListbox.SelectedItem = thumbitem;
418

    
419
                }
420
                else
421
                {
422
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
423
                }
424
            }
425
        }
426

    
427
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
428
        {
429
            SetCommentPages();
430
        }
431

    
432

    
433
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
434
        {
435
            SetCommentPages();
436
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
437
        }
438
        public void SetCommentPages()
439
        {
440
            ThumbnailSet();
441
            SetCommentList(_UsersCommentPagesList.ToList());
442
        }
443

    
444
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
445
        {
446
            Logger.sendCheckLog("SetCommentList", 1);
447
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
448
            #region 기존 색상 제거 작업
449
            foreach (var item in this._thumbnailItems)
450
            {
451
                item.DisplayColorItems.Clear();
452
            }
453
            #endregion
454

    
455
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
456
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
457

    
458
            _UsersCommentPagesList.ToList().ForEach(item =>
459
            {
460
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
461

    
462
                if (_comm.Count() == 0)
463
                {
464
                    _delItem.Add(item);
465
                }
466
            });
467

    
468
            _delItem.ForEach(f => _UsersCommentPagesList.Remove(f));
469

    
470
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
471
            UsersCommentPagesList.ForEach(user =>
472
            {
473
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
474
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
475

    
476
                var _commLst = _UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
477

    
478
                if (_commLst.Count() == 0)
479
                {
480
                    _UsersCommentPagesList.Add(user);
481
                }
482
                else
483
                {
484
                    if (_commLst.First().PageNumber != user.PageNumber)
485
                        _commLst.First().PageNumber = user.PageNumber;
486
                }
487

    
488
                user.PageNumber.ForEach(page =>
489
                {
490
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
491

    
492
                    if (_items.Count() > 0)
493
                        _items.First().DisplayColorItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor });
494
                });
495
            });
496

    
497

    
498
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
499
            var data = _UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
500
            if (data.Count() != 0)
501
            {
502
                if (Convert.ToBoolean(data.First().isConSolidation))
503
                {
504
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
505
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
506
                    this.lstSelectComment.ItemsSource = data;
507
                }
508
                else
509
                {
510
                    this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
511
                }
512
            }
513
            else
514
            {
515
                this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
516
            }
517
            //this.ImgListbox.ItemsSource = null;
518
            Logger.sendCheckLog("SetCommentList_ImgListbox 설정", 1);
519

    
520
       
521
                this.ImgListbox.ItemsSource = this._thumbnailItems;
522
                var template = this.ImgListbox.ItemTemplate;
523
                this.ImgListbox.ItemTemplate = null;
524
                this.ImgListbox.ItemTemplate = template;
525
               //Logger.sendCheckLog("SetCommentList_ImgListbox UpdateLayout_Start", 1);
526
                //this.ImgListbox.UpdateLayout();
527
                //Logger.sendCheckLog("SetCommentList_ImgListbox UpdateLayout_End", 1);
528
           
529
        }
530

    
531
        private void ThumbnailSet()
532
        {
533
            Logger.sendCheckLog("ThumbnailSet", 1);
534
            if (!_Initialize) return;
535

    
536
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
537
            List<int> _selectComment = new List<int>();
538
            if (this.lstSelectComment.ItemsSource != null)
539
            {
540
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
541
                             where commentPage.IsSelected == true
542
                             select commentPage.PageNumber;
543

    
544
                foreach (var item in _pages)
545
                {
546
                    item.ForEach(pp => _selectComment.Add(pp));
547
                }
548

    
549
                _selectComment.Distinct();
550
            }
551

    
552
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
553
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
554
            //this._PageList.ForEach(page =>
555
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
556
            {
557
                var _pageNo = page.PAGE_NUMBER;
558
                bool _addFlag = false;
559

    
560
                if (rdoFavoritePages.IsChecked == false)
561
                {
562
                    if (_selectComment.Count() > 0)
563
                    {
564
                        if ((rdoAllPages.IsChecked == true)
565
                            || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
566
                        {
567
                            _addFlag = true;
568
                        }
569
                    }
570
                    else
571
                    {
572
                        //if (App.ViewInfo.IsCustomPage)
573
                        //{
574
                        //    //_addFlag = false;
575

    
576
                        //    //App.ViewInfo.IsCustomPage = false;
577
                        //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
578
                        //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
579
                        //    this.rdoAllPages.IsChecked = false;
580
                        //    this.rdoFavoritePages.IsChecked = true;
581
                        //    //SetCommentPages();                        
582
                        //}
583
                        //else
584
                        //{
585
                        _addFlag = true;
586
                        //}
587
                    }
588
                }
589

    
590

    
591
                if (_addFlag)
592
                {
593
                    this._thumbnailItems.Add(new ThumbnailItem
594
                    {
595
                        ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
596
                        PageNumber = _pageNo,
597
                        Angle = page.PAGE_ANGLE,
598
                    });
599
                }
600
                else
601
                {
602
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
603
                    {
604
                        this._thumbnailItems.Add(new ThumbnailItem
605
                        {
606
                            ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
607
                            PageNumber = _pageNo,
608
                            Angle = page.PAGE_ANGLE,
609
                        });
610
                    }
611
                }
612

    
613

    
614

    
615
                //this._thumbnailItems.Add(new ThumbnailItem
616
                //{
617
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
618

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

    
621
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
622
                //    //DisplayColorItems = pageColor,
623
                //    PageNumber = Convert.ToInt32(_pageNo),
624
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
625
                //});
626
            });
627

    
628
            //txtTotPageNo.Text = this._PageList.Count().ToString();
629

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

    
632
            if (ImgListbox.ItemsSource == null)
633
            {
634
                ImgListbox.ItemsSource = this._thumbnailItems;
635

    
636
                this._thumbnailItems.ToList().ForEach(data =>
637
                {
638
                    data.Width = ImgListbox.ActualWidth;
639
                });
640

    
641
                if (ImgListbox.Items.Count > 0)
642
                {
643
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
644
                    int StartPageIdx = 1;
645
                    //if (App.ViewInfo.IsCustomPage)
646
                    //{
647
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
648
                    //}
649
                    //else
650
                    //{
651

    
652
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
653
                    {
654
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
655
                    }
656
                    else
657
                    {
658
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
659
                    }
660
                    //}
661
                }
662
            }
663
            else
664
            {
665
                ImgListbox.UpdateLayout();
666
                ImgListbox.ItemsSource = this._thumbnailItems;
667
            }
668
        }
669

    
670
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
671
        {
672
            if (e.ClickCount >= 2)
673
            {
674
                var selectItem = gogogo.SelectedItem as IKCOM.MarkupItem;
675
                GotoPage(selectItem.PageNumber);
676
                var result = MarkupParser.GetBaseControl(selectItem.Data);
677
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
678
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
679
                //bool isGO = false;
680

    
681
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
682
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
683
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
684
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
685
                //{
686
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
687
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
688
                //    {
689
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
690
                //    }
691

    
692
                //};
693
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
694

    
695
                //GotoPage(gogogo.SelectedItem as MarkupList)
696
            }
697
        }
698

    
699
        private void commentUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
700
        {
701
            tbSearch.Text = string.Empty;
702
            if (e.AddedItems.Count > 0)
703
            {
704
                if (commentUser.Items.Count > 0)
705
                {
706
                    MarkupInfoSmallList.Clear();
707
                    //var d = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First();
708
                    //d.PageNumber
709

    
710
                    //e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First().
711
                    //gogo.DataContext = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
712

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

    
716
                    var temp = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault();
717
                    var markuplist = ViewerDataModel.Instance.MyMarkupList.Where(d => d.MarkupInfoID == temp.MarkupInfoID).ToList();
718
                    markuplist.ForEach(d =>
719
                    {
720
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
721
                        {
722
                            Data = d.Data,
723
                            Data_Type = d.Data_Type,
724
                            PageNumber = d.PageNumber,
725
                            UserID = temp.UserID,
726
                            UserName = temp.UserName,
727
                        });
728
                    });
729
                    gogogo.ItemsSource = null;
730
                    gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
731

    
732
                }
733
            }
734
            else
735
            {
736
                MarkupInfoSmallList.Clear();
737
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
738
                {
739
                    var markuplist = ViewerDataModel.Instance.MyMarkupList.Where(u => u.MarkupInfoID == d.MarkupInfoID).ToList();
740

    
741
                    markuplist.ForEach(b =>
742
                    {
743
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
744
                        {
745

    
746
                            Data = b.Data,
747
                            Data_Type = b.Data_Type,
748
                            PageNumber = b.PageNumber,
749
                            UserID = d.UserID,
750
                            UserName = d.UserName,
751
                        });
752
                    });
753

    
754
                });
755
                gogogo.ItemsSource = null;
756
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
757
            }
758
        }
759

    
760
        public class MarkupInfoItemSmall
761
        {
762
            public string Id { get; set; }
763
            public string UserName { get; set; }
764
            public string UserID { get; set; }
765
            public int PageNumber { get; set; }
766
            public string Data { get; set; }
767
            public int Data_Type { get; set; }
768
        }
769

    
770
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
771
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
772
        {
773
            get
774
            {
775
                if (_MarkupInfoSmallList == null)
776
                {
777
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
778
                }
779
                return _MarkupInfoSmallList;
780
            }
781
            set
782
            {
783

    
784
                _MarkupInfoSmallList = value;
785
                RaisePropertyChanged("MarkupInfoSmallList");
786
            }
787
        }
788

    
789
        /// <summary>
790
        /// goto page and select item selected by user
791
        /// </summary>
792
        /// <param name="sender"></param>
793
        /// <param name="e"></param>
794
        private void RadButton_Click(object sender, RoutedEventArgs e)
795
        {
796
            var clickButtonItem = sender as RadButton;
797
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
798
            {
799
                try
800
                {
801
                    Rect rect = new Rect();
802
                    Point s_point = new Point();
803
                    Point e_point = new Point();
804

    
805
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
806
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
807

    
808
                    var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(gaza.Data.ToString()); //언패킹작업
809
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
810
                    {
811
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
812
                            {
813
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
814
                                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));
815
                            }
816
                            break;
817
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
818
                            {
819
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
820
                                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));
821
                            }
822
                            break;
823
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
824
                            {
825
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
826
                                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));
827
                            }
828
                            break;
829
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
830
                            {
831
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
832

    
833
                                foreach (Point A in instance.PointSet)
834
                                {
835
                                    if (s_point == new Point())
836
                                    {
837
                                        s_point = A;
838
                                        e_point = A;
839
                                    }
840
                                    s_point.X = Math.Min(s_point.X, A.X);
841
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
842
                                    e_point.X = Math.Max(e_point.X, A.X);
843
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
844
                                }
845
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
846
                            }
847
                            break;
848
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
849
                            {
850
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
851

    
852
                                foreach (Point A in instance.PointSet)
853
                                {
854
                                    if (s_point == new Point())
855
                                    {
856
                                        s_point = A;
857
                                        e_point = A;
858
                                    }
859
                                    s_point.X = Math.Min(s_point.X, A.X);
860
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
861
                                    e_point.X = Math.Max(e_point.X, A.X);
862
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
863
                                }
864
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
865
                            }
866
                            break;
867
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
868
                            {
869
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
870

    
871
                                foreach (Point A in instance.PointSet)
872
                                {
873
                                    if (s_point == new Point())
874
                                    {
875
                                        s_point = A;
876
                                        e_point = A;
877
                                    }
878
                                    s_point.X = Math.Min(s_point.X, A.X);
879
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
880
                                    e_point.X = Math.Max(e_point.X, A.X);
881
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
882
                                }
883
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
884
                            }
885
                            break;
886
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
887
                            {
888
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
889

    
890
                                foreach (Point A in instance.PointSet)
891
                                {
892
                                    if (s_point == new Point())
893
                                    {
894
                                        s_point = A;
895
                                        e_point = A;
896
                                    }
897
                                    s_point.X = Math.Min(s_point.X, A.X);
898
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
899
                                    e_point.X = Math.Max(e_point.X, A.X);
900
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
901
                                }
902
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
903
                            }
904
                            break;
905
                        default:
906
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
907
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
908
                            break;
909
                    }
910

    
911
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
912
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
913
                }
914
                catch (Exception ex)
915
                {
916
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
917
                }
918
            }
919
        }
920

    
921
        private void gogogo_Loaded(object sender, RoutedEventArgs e)
922
        {
923
            if (MarkupInfoSmallList.Count == 0)
924
            {
925
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
926
                {
927
                    if (d.MarkupList != null)
928
                    {
929
                        d.MarkupList.ForEach(b =>
930
                        {
931
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
932
                            {
933
                                Id = b.ID,
934
                                Data = b.Data,
935
                                Data_Type = b.Data_Type,
936
                                PageNumber = b.PageNumber,
937
                                UserID = d.UserID,
938
                                UserName = d.UserName,
939
                            });
940
                        });
941
                    }
942
                });
943
                gogogo.ItemsSource = null;
944
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
945

    
946
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
947
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
948
            }
949
        }
950

    
951
        private void commentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
952
        {
953
            gogogo.ItemsSource = null;
954
            tbSearch.Text = string.Empty;
955
            if (e.AddedItems.Count > 0)
956
            {
957

    
958
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(e.AddedItems[0])).ToList();
959
            }
960
            else
961
            {
962
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
963
            }
964
        }
965

    
966
        private void commentPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
967
        {
968
            gogogo.ItemsSource = null;
969
            tbSearch.Text = string.Empty;
970
            if (e.AddedItems.Count > 0)
971
            {
972
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(e.AddedItems[0])).ToList();
973
            }
974
            else
975
            {
976
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
977
            }
978
        }
979

    
980
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
981
        {
982
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
983
        }
984

    
985
        private void btnSearch_Click(object sender, RoutedEventArgs e)
986
        {
987
            string search_str = tbSearch.Text;
988
            var sel_type = commentType.SelectedItem;
989
            var sel_user = commentUser.SelectedItem;
990
            var sel_page = commentPage.SelectedItem;
991
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
992
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
993
            if (sel_page != null)
994
            {
995
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
996
            }
997
            if (sel_type != null)
998
            {
999
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1000
            }
1001
            if (sel_user != null)
1002
            {
1003
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1004
            }
1005
            foreach (var item in list)
1006
            {
1007
                var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(item.Data.ToString());
1008

    
1009
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1010
                {
1011
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1012
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1013
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1014
                        {
1015
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1016
                            if (instance.Text.Contains(search_str))
1017
                            {
1018
                                small_list.Add(item);
1019
                            }
1020
                        }
1021
                        break;
1022
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1023
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1024
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1025
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1026
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1027
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1028
                        {
1029
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1030
                            if (instance.ArrowText.Contains(search_str))
1031
                            {
1032
                                small_list.Add(item);
1033
                            }
1034
                        }
1035
                        break;
1036

    
1037
                }
1038

    
1039
            }
1040

    
1041
            gogogo.ItemsSource = null;
1042
            gogogo.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1043
            tbSearch.Text = string.Empty;
1044
        }
1045
    }
1046
}
클립보드 이미지 추가 (최대 크기: 500 MB)