프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 992a98b4

이력 | 보기 | 이력해설 | 다운로드 (33.4 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.Linq;
9
using System.Windows;
10
using System.Windows.Controls;
11
using System.Windows.Input;
12
using Telerik.Windows.Controls;
13

    
14
namespace KCOM.Controls
15
{
16
    /// <summary>
17
    /// Interaction logic for PageNavigator.xaml
18
    /// </summary>
19
    public partial class Sample : UserControl, INotifyPropertyChanged
20
    {
21
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
22
        public event PropertyChangedEventHandler PropertyChanged;
23
        public Sample()
24
        {
25
            InitializeComponent();
26
            _Initialize = true;
27
            
28
            lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
29
            //ImgListbox.MouseDoubleClick += ImgListbox_MouseDoubleClick;
30
        }
31

    
32
        //private void ImgListbox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
33
        //{
34

    
35
        //    if (ImgListbox.SelectedItem !=null && (ImgListbox.SelectedItem as ThumbnailItem).PageNumber == CurrentPage.PageNumber)
36
        //    {
37
        //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ScaleToFit();
38
        //    }
39
        //}
40

    
41
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
42
        private List<DOCPAGE> _PageList = null;
43
        private string _DefaultUri = null;
44
        public ThumbnailItem CurrentPage = null;
45
        public ThumbnailItem _NextPage = null;
46
        public int PageCount = 0;
47

    
48
        private bool _Initialize;
49
        public event EventHandler<PageChangeEventArgs> PageChanged;
50
        public event EventHandler<PageChangeEventArgs> PageChanging;
51
        List<UsersCommentPagesMember> _UsersCommentPagesList = new List<UsersCommentPagesMember>();
52
        public class PageChangeEventArgs : EventArgs
53
        {
54
            public DOCPAGE CurrentPage { get; set; }
55
            public string PageUri { get; set; }
56
            public int PageNumber { get; set; }
57
        }
58

    
59
        private bool _IsFitOn { get; set; }
60
        public bool IsFitOn
61
        {
62
            get
63
            {
64
                return _IsFitOn;
65
            }
66
            set
67
            {
68
                _IsFitOn = value;
69
                RaisePropertyChanged("IsFitOn");
70
            }
71
        }
72

    
73
        public void RaisePropertyChanged(string propName)
74
        {
75
            if (PropertyChanged != null)
76
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
77
        }
78

    
79
        public void SetPageNavi(List<DOCPAGE> PageList, string DefaultUri)
80
        {
81
            this._PageList = PageList;
82
            this._DefaultUri = DefaultUri;
83
            ThumbnailSet();
84
            this.PageCount = PageList.Count();
85
            //ThumbNmailSet();
86
            rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
87
            rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
88
            expCommentPages.PreviewCollapsed += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewCollapsed);
89
            expCommentPages.PreviewExpanded += new Telerik.Windows.RadRoutedEventHandler(expCommentPages_PreviewExpanded);
90
        }
91
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
92
        {
93
            if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
94
            SetCommentPages();
95
        }
96

    
97
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
98
        {
99
            if (rdoFavoritePages.IsChecked == true)
100
                expCommentPages.IsExpanded = false;
101

    
102
            _FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet; 
103
            if (_FavoriteSet.Count > 0)
104
            {
105
                SetCommentPages_Favorite(); //수정    
106
            }
107
            else
108
            {
109
                rdoAllPages.IsChecked = true;
110
                rdoFavoritePages.IsChecked = false;
111
            }
112
        }
113

    
114
        private void SetCommentPages_Favorite()
115
        {
116
            ThumbnailSet();
117
            //_UsersCommentPagesList
118
            //var result = (from A in _UsersCommentPagesList
119
            //              from B in _FavoriteSet
120
            //              where A.PageNumber.Contains(B.PageNo)
121
            //              select A).ToList();
122
            //_UsersCommentPagesList = result;
123

    
124
            SetCommentPages();
125

    
126
        }
127

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

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

    
141
        private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
142
        {
143
            //tmStart = false;
144
            //tm.Stop();
145
            //tm.Tick -= new EventHandler(tm_Tick);
146

    
147

    
148
            if (ImgListbox.SelectedItem != null)
149
            {
150
                int _PageNo = -1;
151

    
152
                if (this.CurrentPage != null)
153
                {
154
                    _PageNo = this.CurrentPage.PageNumber;
155
                };
156

    
157
                if (_PageNo != ((ImgListbox.SelectedItem as ThumbnailItem).PageNumber))
158
                {
159

    
160
                    GotoPage((ImgListbox.SelectedItem as ThumbnailItem).PageNumber);
161
                }
162
            }
163
        }
164

    
165
        public bool GotoPageFlag = false;
166

    
167
        public void GotoPage(int _pageNumber)
168
        {
169
            int _PageNo = -1;
170
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
171
            {
172
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
173
                if (_page.Count() > 0)
174
                {
175
                    ThumbnailItem _item = _page.First();
176
                    setPageChange(_item);
177
                    if (ImgListbox.SelectedIndex  != _PageNo-1)
178
                    {  
179
                        ImgListbox.SelectedIndex = _PageNo-1;
180
                    }
181
                    else if(this.CurrentPage.PageNumber == this.PageCount)
182
                    {
183
                        ImgListbox.SelectedIndex = _pageNumber;
184
                    }
185
                }
186
            }
187
        }
188

    
189
        public void setPageChange(ThumbnailItem thumbnailItem)
190
        {
191
            if (thumbnailItem != null)
192
            {
193
                if (PageChanging != null)
194
                {
195
                    //강인구 수정(페이지가 같을 경우 이동 안함)
196
                    if (CurrentPage != null && CurrentPage == thumbnailItem)
197
                    {
198
                        return;
199
                    }
200
                    CurrentPage = _NextPage;
201
                    _NextPage = thumbnailItem;
202
                    PageChanging(this, new PageChangeEventArgs
203
                    {
204
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
205
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
206
                        PageUri = null
207
                    });
208
                }
209
            }
210
        }
211
        public void SetNextPage()
212
        {  
213
            //if (CurrentPage != null)
214
            //    System.Diagnostics.Debug.WriteLine("다음페이지 이동 : " + _NextPage.PageNumber + " 이전페이지 : " + CurrentPage.PageNumber);
215

    
216
            CurrentPage = _NextPage;
217

    
218
            PageChange(_NextPage);
219
        }
220
        private void PageChange(ThumbnailItem thumbitem)
221
        {
222
            if (PageChanged != null)
223
            {
224
                var uri = _DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
225
                //var _thumbitem = _thumbnailItems.Where(item => item.PageNumber == DocPage.PageNumber).First();
226
                var _itemIndex = _thumbnailItems.IndexOf(thumbitem);
227
                //ImgListbox.SelectedItem(_thumbitem, true);
228
                ImgListbox.SelectedItem = thumbitem;
229

    
230
                if (_itemIndex < _thumbnailItems.Count() - 1)
231
                    ImgListbox.ScrollIntoView(_itemIndex);
232
                else
233
                    ImgListbox.ScrollIntoView(_thumbnailItems.Count() - 1);
234

    
235
                //txtCurentPageNo.Text = (_itemIndex + 1).ToString();
236

    
237
                //txtCurentPageNo.Text = this.CurrentPage.PageNumber.ToString();
238

    
239
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber);
240

    
241
                if (_DocPages.Count() > 0)
242
                {   
243
                    var _page = _DocPages.First();
244

    
245
                    PageChanged(this, new PageChangeEventArgs
246
                    {
247
                        CurrentPage = _page,
248
                        PageUri = uri,
249
                        PageNumber = thumbitem.PageNumber
250
                    });
251
                    ImgListbox.SelectedItem = thumbitem;
252

    
253
                }
254
                else
255
                {
256
                    System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
257
                }
258
            }
259
        }
260

    
261
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
262
        {
263
            SetCommentPages();
264
        }
265

    
266

    
267
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
268
        {
269
            SetCommentPages();
270
            System.Diagnostics.Debug.WriteLine(e.PropertyName);
271
        }
272
        public void SetCommentPages()
273
        {
274
            ThumbnailSet();
275
            SetCommentList(_UsersCommentPagesList.ToList());
276
        }
277

    
278
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
279
        {
280
            #region 기존 색상 제거 작업
281
            foreach (var item in this._thumbnailItems)
282
            {
283
                item.DisplayColorItems.Clear();
284
            } 
285
            #endregion
286

    
287

    
288

    
289
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
290

    
291
            _UsersCommentPagesList.ToList().ForEach(item =>
292
            {
293
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
294

    
295
                if (_comm.Count() == 0)
296
                {
297
                    _delItem.Add(item);
298
                }
299
            });
300

    
301
            _delItem.ForEach(f => _UsersCommentPagesList.Remove(f));
302

    
303
            UsersCommentPagesList.ForEach(user =>
304
            {
305
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
306
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
307

    
308
                var _commLst = _UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
309

    
310
                if (_commLst.Count() == 0)
311
                {
312
                    _UsersCommentPagesList.Add(user);
313
                }
314
                else
315
                {
316
                    if (_commLst.First().PageNumber != user.PageNumber)
317
                        _commLst.First().PageNumber = user.PageNumber;
318
                }
319

    
320
                user.PageNumber.ForEach(page =>
321
                {
322
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
323

    
324
                    if (_items.Count() > 0)
325
                        _items.First().DisplayColorItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor });
326
                });
327
            });
328

    
329

    
330

    
331
            var data = _UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
332
            if (data.Count() != 0)
333
            {
334
                if (Convert.ToBoolean(data.First().isConSolidation))
335
                {
336
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
337
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
338
                    this.lstSelectComment.ItemsSource = data;
339
                }
340
                else
341
                {
342
                    this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
343
                }
344
            }
345
            else
346
            {
347
                this.lstSelectComment.ItemsSource = _UsersCommentPagesList;  //섬네일   
348
            }
349
            //this.ImgListbox.ItemsSource = null;
350
            this.ImgListbox.ItemsSource = this._thumbnailItems;
351
            var template = this.ImgListbox.ItemTemplate;
352
            this.ImgListbox.ItemTemplate = null;
353
            this.ImgListbox.ItemTemplate = template;
354
            this.ImgListbox.UpdateLayout();
355
        }
356

    
357
        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
358
        {
359

    
360
        }
361
        private void ThumbnailSet()
362
        {
363
            if (!_Initialize) return;
364

    
365
            this._thumbnailItems = new ObservableCollection<ThumbnailItem>();
366
            List<int> _selectComment = new List<int>();
367
            if (this.lstSelectComment.ItemsSource != null)
368
            {
369
                var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>()
370
                             where commentPage.IsSelected == true
371
                             select commentPage.PageNumber;
372

    
373
                foreach (var item in _pages)
374
                {
375
                    item.ForEach(pp => _selectComment.Add(pp));
376
                }
377

    
378
                _selectComment.Distinct();
379
            }
380

    
381
            var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
382
            this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList();
383
            //this._PageList.ForEach(page =>
384
            ViewerDataModel.Instance.Document_Info.OrderBy(data => data.PAGE_NUMBER).ToList().ForEach(page =>
385
            {
386
                var _pageNo = page.PAGE_NUMBER;
387
                bool _addFlag = false;
388

    
389

    
390
                if (_selectComment.Count() > 0)
391
                {
392
                    if ((rdoAllPages.IsChecked == true)
393
                        || (expCommentPages.IsExpanded == true && _selectComment.Where(s => s == _pageNo).Count() > 0))
394
                    {
395
                        _addFlag = true;
396
                    }
397
                }
398
                else
399
                {
400
                    //if (App.ViewInfo.IsCustomPage)
401
                    //{
402
                    //    //_addFlag = false;
403

    
404
                    //    //App.ViewInfo.IsCustomPage = false;
405
                    //    //this.rdoAllPages.Visibility = System.Windows.Visibility.Collapsed;
406
                    //    //this.lstSelectComment.Visibility = System.Windows.Visibility.Collapsed;
407
                    //    this.rdoAllPages.IsChecked = false;
408
                    //    this.rdoFavoritePages.IsChecked = true;
409
                    //    //SetCommentPages();                        
410
                    //}
411
                    //else
412
                    //{
413
                        _addFlag = true;
414
                    //}
415
                }
416

    
417

    
418
                if(_addFlag)
419
                {
420
                    this._thumbnailItems.Add(new ThumbnailItem
421
                    {
422
                        ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
423
                        PageNumber = _pageNo,
424
                        Angle = page.PAGE_ANGLE,
425
                    });
426
                }
427
                else
428
                {
429
                    if ((rdoFavoritePages.IsChecked == true) && _FavoriteSet.Where(data => data.PAGE_NO == _pageNo).FirstOrDefault() != null)
430
                    {
431
                        this._thumbnailItems.Add(new ThumbnailItem
432
                        {
433
                            ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
434
                            PageNumber = _pageNo,
435
                            Angle = page.PAGE_ANGLE,
436
                        });
437
                    }
438
                }
439

    
440

    
441

    
442
                //this._thumbnailItems.Add(new ThumbnailItem
443
                //{
444
                //    ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())),
445

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

    
448
                //    //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"),
449
                //    //DisplayColorItems = pageColor,
450
                //    PageNumber = Convert.ToInt32(_pageNo),
451
                //    Angle = Convert.ToInt32(page.PAGE_ANGLE),
452
                //});
453
            });
454

    
455
            //txtTotPageNo.Text = this._PageList.Count().ToString();
456

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

    
459
            if (ImgListbox.ItemsSource == null)
460
            {
461
                ImgListbox.ItemsSource = this._thumbnailItems;
462

    
463
                this._thumbnailItems.ToList().ForEach(data =>
464
                {
465
                    data.Width = ImgListbox.ActualWidth;
466
                });
467

    
468
                if (ImgListbox.Items.Count > 0)
469
                {
470
                    //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1;
471
                    int StartPageIdx = 1;
472
                    //if (App.ViewInfo.IsCustomPage)
473
                    //{
474
                    //    ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault();
475
                    //}
476
                    //else
477
                    //{
478

    
479
                    if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1)
480
                    {
481
                        ImgListbox.SelectedItem = ImgListbox.Items[0];
482
                    }
483
                    else
484
                    {
485
                        ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx];
486
                    }
487
                    //}
488
                }
489
            }
490
            else
491
            {
492
                ImgListbox.UpdateLayout();
493
                ImgListbox.ItemsSource = this._thumbnailItems;
494
            }
495
        }
496

    
497
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
498
        {
499
            if (e.ClickCount >= 2)
500
            {
501
                var selectItem = gogogo.SelectedItem as IKCOM.MarkupItem;
502
                GotoPage(selectItem.PageNumber);
503
                MarkupToPDF.Controls.Parsing.LayerControl control = new MarkupToPDF.Controls.Parsing.LayerControl();
504
                var result = control.markupParse_GetBaseControl(selectItem.Data);
505
                Rect rect = new Rect(new Point(result.StartPoint.X-100, result.StartPoint.Y-100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));             
506
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
507
                //bool isGO = false;
508

    
509
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
510
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
511
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
512
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
513
                //{
514
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
515
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
516
                //    {
517
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
518
                //    }
519

    
520
                //};
521
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
522

    
523
                //GotoPage(gogogo.SelectedItem as MarkupList)
524
            }
525
        }
526

    
527
        private void commentUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
528
        {
529
            if (e.AddedItems.Count > 0)
530
            {
531
                if (commentUser.Items.Count > 0)
532
                {
533
                    MarkupInfoSmallList.Clear();
534
                    //var d = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First();
535
                    //d.PageNumber
536

    
537
                    //e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList.First().
538
                    //gogo.DataContext = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault().MarkupList;
539

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

    
543
                    var temp = e.AddedItems.Cast<MarkupInfoItem>().FirstOrDefault();
544
                    temp.MarkupList.ForEach(d =>
545
                    {
546
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
547
                        {
548
                            Data = d.Data,
549
                            Data_Type = d.Data_Type,
550
                            PageNumber = d.PageNumber,
551
                            UserID = temp.UserID,
552
                            UserName = temp.UserName,
553
                        });
554
                    });
555
                    gogogo.ItemsSource = null;
556
                    gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
557
                }                
558
            }
559
            else
560
            {
561
                MarkupInfoSmallList.Clear();
562
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
563
                {
564
                    d.MarkupList.ForEach(b =>
565
                    {
566
                        MarkupInfoSmallList.Add(new MarkupInfoItemSmall
567
                        {
568

    
569
                            Data = b.Data,
570
                            Data_Type = b.Data_Type,
571
                            PageNumber = b.PageNumber,
572
                            UserID = d.UserID,
573
                            UserName = d.UserName,
574
                        });
575
                    });
576
                });
577
                gogogo.ItemsSource = null;
578
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList(); 
579
            }
580
        }
581

    
582
        public class MarkupInfoItemSmall
583
        {
584
            public string Id { get; set; }
585
            public string UserName { get; set; }
586
            public string UserID { get; set; }
587
            public int PageNumber { get; set; }
588
            public string Data { get; set; }
589
            public int Data_Type { get; set; }
590
        }
591

    
592
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
593
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
594
        {
595
            get
596
            {
597
                if (_MarkupInfoSmallList == null)
598
                {
599
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
600
                }
601
                return _MarkupInfoSmallList;
602
            }
603
            set
604
            {
605
               
606
                _MarkupInfoSmallList = value;
607
                RaisePropertyChanged("MarkupInfoSmallList");
608
            }
609
        }
610

    
611

    
612

    
613
        private void RadButton_Click(object sender, RoutedEventArgs e)
614
        {
615
            var clickButtonItem = sender as RadButton;
616
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
617
            {
618
                try
619
                {
620
                    Rect rect = new Rect();
621
                    Point s_point = new Point();
622
                    Point e_point = new Point();
623

    
624
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
625
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
626
                    var data = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString(gaza.Data.ToString()); //언패킹작업
627
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
628
                    {
629
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
630
                            {
631
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
632
                                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));
633
                            }
634
                            break;
635
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
636
                            {
637
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
638
                                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));
639
                            }
640
                            break;
641
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
642
                            {
643
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
644
                                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));
645
                            }
646
                            break;
647
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
648
                            {
649
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
650

    
651
                                foreach (Point A in instance.PointSet)
652
                                {
653
                                    if (s_point == new Point())
654
                                    {
655
                                        s_point = A;
656
                                        e_point = A;
657
                                    }
658
                                    s_point.X = Math.Min(s_point.X, A.X);
659
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
660
                                    e_point.X = Math.Max(e_point.X, A.X);
661
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
662
                                }
663
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
664
                            }
665
                            break;
666
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
667
                            {
668
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
669

    
670
                                foreach (Point A in instance.PointSet)
671
                                {
672
                                    if (s_point == new Point())
673
                                    {
674
                                        s_point = A;
675
                                        e_point = A;
676
                                    }
677
                                    s_point.X = Math.Min(s_point.X, A.X);
678
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
679
                                    e_point.X = Math.Max(e_point.X, A.X);
680
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
681
                                }
682
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
683
                            }
684
                            break;
685
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
686
                            {
687
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
688

    
689
                                foreach (Point A in instance.PointSet)
690
                                {
691
                                    if (s_point == new Point())
692
                                    {
693
                                        s_point = A;
694
                                        e_point = A;
695
                                    }
696
                                    s_point.X = Math.Min(s_point.X, A.X);
697
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
698
                                    e_point.X = Math.Max(e_point.X, A.X);
699
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
700
                                }
701
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
702
                            }
703
                            break;
704
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
705
                            {
706
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
707

    
708
                                foreach (Point A in instance.PointSet)
709
                                {
710
                                    if (s_point == new Point())
711
                                    {
712
                                        s_point = A;
713
                                        e_point = A;
714
                                    }
715
                                    s_point.X = Math.Min(s_point.X, A.X);
716
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
717
                                    e_point.X = Math.Max(e_point.X, A.X);
718
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
719
                                }
720
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
721
                            }
722
                            break;
723
                        default:
724
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
725
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
726
                            break;
727
                    }
728

    
729
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
730
                }
731
                catch (Exception ex)
732
                {
733
                    throw;
734
                }
735
                
736
                
737
            }
738
        }
739

    
740
        private void gogogo_Loaded(object sender, RoutedEventArgs e)
741
        {
742
            if (MarkupInfoSmallList.Count == 0)
743
            {
744
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
745
                {
746
                    if (d.MarkupList != null)
747
                    {
748
                        d.MarkupList.ForEach(b =>
749
                        {
750
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
751
                            {
752
                                Id = b.ID,
753
                                Data = b.Data,
754
                                Data_Type = b.Data_Type,
755
                                PageNumber = b.PageNumber,
756
                                UserID = d.UserID,
757
                                UserName = d.UserName,
758
                            });
759
                        });
760
                    }
761
                });
762
                gogogo.ItemsSource = null;
763
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList(); ;
764

    
765
                commentPage.ItemsSource = MarkupInfoSmallList.Select(d => d.PageNumber).Distinct().OrderBy(d=>d).ToList();
766
                commentType.ItemsSource = MarkupInfoSmallList.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
767
            }
768
        }
769

    
770
        private void commentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
771
        {
772
            gogogo.ItemsSource = null;
773
            if (e.AddedItems.Count >0)
774
            {
775
                
776
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.Data_Type == Convert.ToInt32(e.AddedItems[0])).ToList();
777
            }
778
            else
779
            {
780
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
781
            }
782
        }
783

    
784
        private void commentPage_SelectionChanged(object sender, SelectionChangedEventArgs e)
785
        {
786
            gogogo.ItemsSource = null;
787
            if (e.AddedItems.Count > 0)
788
            {
789
                gogogo.ItemsSource = MarkupInfoSmallList.Where(d => d.PageNumber == Convert.ToInt32(e.AddedItems[0])).ToList();
790
            }
791
            else
792
            {
793
                gogogo.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
794
            }
795
        }
796

    
797
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
798
        {
799
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
800
        }
801
    }
802
}
클립보드 이미지 추가 (최대 크기: 500 MB)