프로젝트

일반

사용자정보

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

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

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

1 787a4489 KangIngu
using IKCOM;
2
using KCOM.Common;
3
using KCOMDataModel.DataModel;
4 4eb052e4 ljiyeon
using MarkupToPDF.Common;
5 5529d2a2 humkyung
using MarkupToPDF.Controls.Parsing;
6 787a4489 KangIngu
using System;
7
using System.Collections.Generic;
8
using System.Collections.ObjectModel;
9
using System.ComponentModel;
10 0c997b99 ljiyeon
using System.Diagnostics;
11 787a4489 KangIngu
using System.Linq;
12 6c687be8 taeseongkim
using System.Threading;
13 54a28343 taeseongkim
using System.Threading.Tasks;
14 787a4489 KangIngu
using System.Windows;
15
using System.Windows.Controls;
16 d18ea2bd taeseongkim
using System.Windows.Data;
17 787a4489 KangIngu
using System.Windows.Input;
18 83a98e96 송근호
using System.Windows.Media;
19 787a4489 KangIngu
using Telerik.Windows.Controls;
20 4eb052e4 ljiyeon
using static MarkupToPDF.Controls.Parsing.MarkupParser;
21 787a4489 KangIngu
22
namespace KCOM.Controls
23
{
24
    /// <summary>
25
    /// Interaction logic for PageNavigator.xaml
26
    /// </summary>
27
    public partial class Sample : UserControl, INotifyPropertyChanged
28
    {
29 992a98b4 KangIngu
        public List<FAVORITE_DOC> _FavoriteSet { get; set; }
30 787a4489 KangIngu
        public event PropertyChangedEventHandler PropertyChanged;
31 54a28343 taeseongkim
32 6c687be8 taeseongkim
        //PageManager.PageStorage samplePageStorage;
33 54a28343 taeseongkim
34 787a4489 KangIngu
        public Sample()
35 f65e6c02 taeseongkim
        {
36
            InitializeComponent();
37
38
            if (App.IsDesignMode)
39 2089959a taeseongkim
            {
40
                return;
41
            }
42
43 f65e6c02 taeseongkim
            //App.splashString(ISplashMessage.SAMPLE);
44 0c997b99 ljiyeon
            this.Loaded += Sample_Loaded;
45 d97dbc7f taeseongkim
            this.Unloaded += Sample_Unloaded;
46
        }
47
48
        private void Sample_Unloaded(object sender, RoutedEventArgs e)
49
        {
50 6c687be8 taeseongkim
          
51 0c997b99 ljiyeon
        }
52
53
        private void Sample_Loaded(object sender, RoutedEventArgs e)
54
        {
55 afaa7c92 djkim
            if(!_Initialize)
56
            {
57
                _Initialize = true;
58 d18ea2bd taeseongkim
                this.SizeChanged += Sample_SizeChanged;
59 afaa7c92 djkim
                this.lstSelectComment.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(lstSelectComment_SelectionChanged);
60
                this.ImgListbox.SelectionChanged += new SelectionChangedEventHandler(ImgListbox_SelectionChanged);                
61
            }            
62 787a4489 KangIngu
        }
63
64 d18ea2bd taeseongkim
        private void Sample_SizeChanged(object sender, SizeChangedEventArgs e)
65
        {
66
            if(e.WidthChanged)
67
            {
68
                ImgListbox.UpdateLayout();
69
            }
70
        }
71
72
        public static readonly DependencyProperty FilteredThumbnailProperty =  DependencyProperty.Register("FilteredThumbnail", typeof(CollectionViewSource),typeof(Sample));
73
        public CollectionViewSource FilteredThumbnail
74
        {
75
            get { return (CollectionViewSource)GetValue(FilteredThumbnailProperty); }
76
            set { SetValue(FilteredThumbnailProperty, value); }
77
        }
78
79
        public static readonly DependencyProperty CurrentPageProperty 
80
            = DependencyProperty.Register("CurrentPage", typeof(ThumbnailItem), typeof(Sample),new PropertyMetadata(null,CurrentPageChnaged));
81
82
        private static void CurrentPageChnaged(DependencyObject d, DependencyPropertyChangedEventArgs e)
83
        {
84
            //var owner = d as Sample;
85
86
            //if (owner?.UsersCommentPagesList != null)
87
            //{
88
            //    owner.SetCommentPages();
89
            //}
90
        }
91
92
        public ThumbnailItem CurrentPage
93
        {
94
            get { return (ThumbnailItem)GetValue(CurrentPageProperty); }
95
            set { SetValue(CurrentPageProperty, value); }
96
        }
97
98 787a4489 KangIngu
        public ObservableCollection<ThumbnailItem> _thumbnailItems;
99
        private List<DOCPAGE> _PageList = null;
100
        private string _DefaultUri = null;
101
        public int PageCount = 0;
102
        private bool _Initialize;
103 54a28343 taeseongkim
104
        public event EventHandler<EventArgs> ThumbInitialized;
105 787a4489 KangIngu
        public event EventHandler<PageChangeEventArgs> PageChanged;
106
        public event EventHandler<PageChangeEventArgs> PageChanging;
107 f65e6c02 taeseongkim
108
        private List<UsersCommentPagesMember> _UsersCommentPagesList;
109
110
        public List<UsersCommentPagesMember> UsersCommentPagesList
111
        {
112
            get {
113
                if(_UsersCommentPagesList == null)
114
                {
115
                    _UsersCommentPagesList = new List<UsersCommentPagesMember>();
116
                }
117
118
                return _UsersCommentPagesList; }
119
            set { _UsersCommentPagesList = value; }
120
        }
121
122 787a4489 KangIngu
        public class PageChangeEventArgs : EventArgs
123
        {
124
            public DOCPAGE CurrentPage { get; set; }
125
            public string PageUri { get; set; }
126
            public int PageNumber { get; set; }
127
        }
128
        private bool _IsFitOn { get; set; }
129
        public bool IsFitOn
130
        {
131
            get
132
            {
133
                return _IsFitOn;
134
            }
135
            set
136
            {
137
                _IsFitOn = value;
138
                RaisePropertyChanged("IsFitOn");
139
            }
140
        }
141
142
        public void RaisePropertyChanged(string propName)
143
        {
144
            if (PropertyChanged != null)
145
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
146
        }
147
148 54a28343 taeseongkim
        public async Task SetPageNaviAsync(List<DOCPAGE> PageList, string DefaultUri)
149 787a4489 KangIngu
        {
150 6c687be8 taeseongkim
            //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked);
151
            //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked);
152
153 787a4489 KangIngu
            this._PageList = PageList;
154
            this._DefaultUri = DefaultUri;
155 54a28343 taeseongkim
156
            string tempStoragePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName());
157
158 6c687be8 taeseongkim
            //samplePageStorage = new PageManager.PageStorage(_DefaultUri, tempStoragePath,"jpg", _PageList.Count(), _PageList.Count());
159 54a28343 taeseongkim
160 d18ea2bd taeseongkim
            await this.Dispatcher.InvokeAsync(()=> ThumbnailSetAsync());
161 54a28343 taeseongkim
            
162 787a4489 KangIngu
            this.PageCount = PageList.Count();
163 54a28343 taeseongkim
164 787a4489 KangIngu
            //ThumbNmailSet();
165 6c687be8 taeseongkim
            
166 787a4489 KangIngu
        }
167 39f0624f ljiyeon
168 787a4489 KangIngu
        void rdoCommented_Checked(object sender, RoutedEventArgs e)
169
        {
170 548c696e ljiyeon
            Logger.sendCheckLog("rdoCommented_Checked", 1);
171 787a4489 KangIngu
            SetCommentPages();
172
        }
173
174
        void rdoFavoritePages_Checked(object sender, RoutedEventArgs e)
175
        {
176 548c696e ljiyeon
            Logger.sendCheckLog("rdoFavoritePages_Checked", 1);
177 d18ea2bd taeseongkim
            //if (rdoFavoritePages.IsChecked == true)
178
            //    expCommentPages.IsExpanded = false;
179 992a98b4 KangIngu
180 d18ea2bd taeseongkim
            //_FavoriteSet = _FavoriteSet == null ? new List<FAVORITE_DOC>() : _FavoriteSet;
181
            //if (_FavoriteSet.Count > 0)
182
            //{
183
            //    SetCommentPages(); //수정    
184
            //}
185
            //else
186
            //{
187
            //    rdoAllPages.IsChecked = true;
188
            //    rdoFavoritePages.IsChecked = false;
189
            //}
190 992a98b4 KangIngu
        }
191
192 6c687be8 taeseongkim
        private async void ShowPageChange(object sender, RoutedEventArgs e)
193 992a98b4 KangIngu
        {
194 d18ea2bd taeseongkim
            if (_Initialize)
195 6c687be8 taeseongkim
            {
196 d18ea2bd taeseongkim
                //if (rdoAllPages.IsChecked == true) expCommentPages.IsExpanded = false;
197
                await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
198 6c687be8 taeseongkim
            }
199 787a4489 KangIngu
        }
200 992a98b4 KangIngu
201 787a4489 KangIngu
        void expCommentPages_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
202
        {
203
            //txtThumbCount.Visibility = Visibility.Collapsed;            
204
        }
205
206
        void expCommentPages_PreviewExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
207
        {
208 548c696e ljiyeon
            Logger.sendCheckLog("expCommentPages_PreviewExpanded", 1);
209 787a4489 KangIngu
            rdoAllPages.IsChecked = false;
210
            rdoFavoritePages.IsChecked = false;
211
            //txtThumbCount.Visibility = Visibility.Visible;
212
            SetCommentPages();
213
        }
214
215 129ca191 humkyung
        /// <summary>
216
        /// called when image list box's selection is changed
217
        /// </summary>
218
        /// <param name="sender"></param>
219
        /// <param name="e"></param>
220 ac4f1e13 taeseongkim
        private async void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
221 eeb0a39c taeseongkim
        {
222
            if(e.AddedItems.Count > 0)
223 787a4489 KangIngu
            {
224 ac4f1e13 taeseongkim
                await ImgListbox.Dispatcher.InvokeAsync(() =>
225
                {
226
                    var number = (e.AddedItems[0] as KCOM.Common.ThumbnailItem).PageNumber;
227 eeb0a39c taeseongkim
228 ac4f1e13 taeseongkim
                    ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
229 787a4489 KangIngu
230 ac4f1e13 taeseongkim
                    this.CurrentPage = e.AddedItems[0] as KCOM.Common.ThumbnailItem;
231
232
                    PageChanging(this, new PageChangeEventArgs
233
                    {
234
                        CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == number).First(),
235
                        PageNumber = number,
236
                        PageUri = null
237
                    });
238 eeb0a39c taeseongkim
239
                });
240 787a4489 KangIngu
            }
241 eeb0a39c taeseongkim
            
242
243
            //if (ImgListbox.SelectedItem != null)
244
            //{
245
            //    int _CurrentPageNo = -1;
246
            //    if (this.CurrentPage != null)
247
            //    {
248
            //        ViewerDataModel.Instance.SystemMain.dzTopMenu._SaveEvent(null, null);   /// save controls
249
250
            //        _CurrentPageNo = this.CurrentPage.PageNumber;
251
            //    }
252
253
            //    this.CurrentPage = ImgListbox.SelectedItem as ThumbnailItem;
254
            //    int iPageNo = this.CurrentPage.PageNumber;
255
            //    if(_CurrentPageNo != iPageNo)
256
            //    {
257
            //        PageChanging(this, new PageChangeEventArgs
258
            //        {
259
            //            CurrentPage = this._PageList.Where(p => p.PAGE_NUMBER == iPageNo).First(),
260
            //            PageNumber = iPageNo,
261
            //            PageUri = null
262
            //        });
263
            //    }
264
            //}
265 3908a575 humkyung
266 2d584f1a djkim
            //var border = VisualTreeHelper.GetChild(ImgListbox, 0);
267
            //if (border != null)
268
            //{
269
            //    IEnumerable<ScrollViewer> scrollViewer = border.ChildrenOfType<ScrollViewer>();
270
271
            //}
272
            //ScrollViewer scrollViewer = (sender as RadListBox) as ScrollViewer;
273
274
            
275
            //System.Diagnostics.Debug.WriteLine("page:"+ImgListbox.SelectedIndex);
276 787a4489 KangIngu
        }
277
278
        public bool GotoPageFlag = false;
279
280 b2a6b24a humkyung
        /// <summary>
281
        /// 해당 썸네일로 이동
282
        /// </summary>
283 3908a575 humkyung
        /// <param name="_pageNumber">이동할 페이지 번호</param>
284 787a4489 KangIngu
        public void GotoPage(int _pageNumber)
285
        {
286 90e7968d ljiyeon
            try
287 787a4489 KangIngu
            {
288 a1142a6b taeseongkim
                System.Threading.Tasks.Task.Factory.StartNew(() => { 
289
290
                    var _page = _thumbnailItems.Where(item => item.PageNumber == _pageNumber);
291
                    if (_page.Count() > 0)
292 90e7968d ljiyeon
                    {
293 a1142a6b taeseongkim
                        ThumbnailItem thumbnailitem = _page.First();
294
                        if (PageChanging != null)
295
                        {
296
297
                            ImgListbox.Dispatcher.InvokeAsync(() => {  
298
                                var _itemIndex = this._thumbnailItems.IndexOf(thumbnailitem);
299
                                ImgListbox.SelectedItem = thumbnailitem;
300
                            });
301
                            //ImgListbox.Items.MoveCurrentTo(thumbnailitem);
302
                            //if (_itemIndex < _thumbnailItems.Count() - 1)
303
                            //    ImgListbox.ScrollIntoView(_itemIndex);
304
                            //else
305
                            //    ImgListbox.ScrollIntoView(this._thumbnailItems.Count() - 1);
306
                        }
307 90e7968d ljiyeon
                    }
308 a1142a6b taeseongkim
309
                }).ConfigureAwait(true);
310 787a4489 KangIngu
            }
311 90e7968d ljiyeon
            catch(Exception ex)
312
            {
313
                Logger.sendResLog("GotoPage", ex.Message, 0);
314
            }
315
        }
316 787a4489 KangIngu
317 3908a575 humkyung
        /// <summary>
318
        /// 주어진 페이지로 변경한다
319
        /// </summary>
320
        /// <param name="iPageNo">변경할 페이지 번호</param>
321
        public void ChangePage(int iPageNo)
322 787a4489 KangIngu
        {
323 3908a575 humkyung
            var thumbitem = this._thumbnailItems.Where(item => item.PageNumber == iPageNo).FirstOrDefault();
324
            if ((PageChanged != null) && (thumbitem != null))
325 787a4489 KangIngu
            {
326 d48260a2 djkim
                var uri = thumbitem.PageUri.ToString();
327
                    //_DefaultUri.Replace("{PageNo}", thumbitem.PageNumber.ToString());
328 3908a575 humkyung
329 d48260a2 djkim
                var _DocPages = _PageList.Where(p => p.PAGE_NUMBER == thumbitem.PageNumber).FirstOrDefault();
330
                if (_DocPages != null)
331 3908a575 humkyung
                {
332
                    PageChanged(this, new PageChangeEventArgs
333 787a4489 KangIngu
                    {
334 d48260a2 djkim
                        CurrentPage = _DocPages,
335 3908a575 humkyung
                        PageUri = uri,
336
                        PageNumber = thumbitem.PageNumber
337 787a4489 KangIngu
                    });
338 2d584f1a djkim
                    //ImgListbox.SelectedItem = thumbitem;                    
339
                    //ImgListbox.Items.MoveCurrentTo(thumbitem);
340
                    
341 944be2fa djkim
                    this.CurrentPage = thumbitem;
342 3908a575 humkyung
                }
343
                else
344
                {
345
                    //System.Diagnostics.Debug.WriteLine("페이지 정보가 없습니다");
346 787a4489 KangIngu
                }
347
            }
348
        }
349 64f6713a humkyung
350 d974f3f8 ljiyeon
        public void GotoPageTALK(int _pageNumber, int _angle)
351
        {
352
            int _PageNo = -1;
353
354
            if (int.TryParse(_pageNumber.ToString(), out _PageNo))
355
            {
356
                var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo);
357
                if (_page.Count() > 0)
358
                {
359
                    ThumbnailItem _item = _page.First();
360
                    setPageChangeTALK(_item, _angle);
361
                    this.ImgListbox.SelectedIndex = _pageNumber - 1;
362 6443ebfe djkim
                    //this.ImgListbox.ScrollIntoView(_pageNumber - 1);
363 d974f3f8 ljiyeon
                }
364
            }
365
        }
366
367
        public void setPageChangeTALK(ThumbnailItem thumbnailItem, int _angle)
368
        {
369
            if (thumbnailItem != null)
370
            {
371
                if (PageChanging != null)
372 90e7968d ljiyeon
                {
373 3908a575 humkyung
                    ///this.CurrentPage = _NextPage;
374
                    ///_NextPage = thumbnailItem;
375 d974f3f8 ljiyeon
                    PageChanging(this, new PageChangeEventArgs
376
                    {
377
                        CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(),
378
                        PageNumber = Convert.ToInt32(thumbnailItem.PageNumber),
379
                        PageUri = null
380
                    });
381
382
                    var instanceMain = this.ParentOfType<MainWindow>();
383
384
                    var rotationNum = (_angle - instanceMain.dzMainMenu.rotate.Angle) / 90;
385
386
                    if (rotationNum > 0) // 1, 2, 3
387
                    {
388 90e7968d ljiyeon
                        for (int i = 0; i < rotationNum; i++)
389 d974f3f8 ljiyeon
                        {
390
                            drawingPannelRotate(true);
391
                        }
392
                    }
393 90e7968d ljiyeon
                    else if (rotationNum < 0)// -1, -2, -3
394 d974f3f8 ljiyeon
                    {
395
                        for (int i = 0; i < -rotationNum; i++)
396
                        {
397
                            drawingPannelRotate(false);
398
                        }
399 90e7968d ljiyeon
                    }
400 d974f3f8 ljiyeon
                }
401
            }
402
        }
403 90e7968d ljiyeon
404 d974f3f8 ljiyeon
        public void drawingPannelRotate(bool Flag)
405
        {
406
            var instanceMain = this.ParentOfType<MainWindow>();
407
408
            if (Flag)
409
            {
410
                if (instanceMain.dzMainMenu.rotate.Angle == 270)
411
                {
412
                    instanceMain.dzMainMenu.rotate.Angle = 0;
413
                }
414
                else
415
                {
416
                    instanceMain.dzMainMenu.rotate.Angle += 90;
417
                }
418
            }
419
            else
420
            {
421
                if (instanceMain.dzMainMenu.rotate.Angle == 0)
422
                {
423
                    instanceMain.dzMainMenu.rotate.Angle = 270;
424
                }
425
                else
426
                {
427
                    instanceMain.dzMainMenu.rotate.Angle -= 90;
428
                }
429
            }
430
431
            if (instanceMain.dzMainMenu.zoomAndPanCanvas.Width == ViewerDataModel.Instance.ContentWidth)
432
            {
433
                double emptySize = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
434
                instanceMain.dzMainMenu.zoomAndPanCanvas.Width = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
435
                instanceMain.dzMainMenu.zoomAndPanCanvas.Height = emptySize;
436
            }
437 90e7968d ljiyeon
438 d974f3f8 ljiyeon
            if (instanceMain.dzMainMenu.rotate.Angle == 0)
439
            {
440
                instanceMain.dzMainMenu.translate.X = 0;
441
                instanceMain.dzMainMenu.translate.Y = 0;
442
            }
443
            else if (instanceMain.dzMainMenu.rotate.Angle == 90)
444
            {
445
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
446
                instanceMain.dzMainMenu.translate.Y = 0;
447
            }
448
            else if (instanceMain.dzMainMenu.rotate.Angle == 180)
449
            {
450
                instanceMain.dzMainMenu.translate.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
451
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
452
            }
453
            else
454
            {
455
                instanceMain.dzMainMenu.translate.X = 0;
456
                instanceMain.dzMainMenu.translate.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
457
            }
458
459
            instanceMain.dzMainMenu.zoomAndPanControl.RotationAngle = instanceMain.dzMainMenu.rotate.Angle;
460
            ViewerDataModel.Instance.ContentWidth = instanceMain.dzMainMenu.zoomAndPanCanvas.Width;
461
            ViewerDataModel.Instance.ContentHeight = instanceMain.dzMainMenu.zoomAndPanCanvas.Height;
462
            ViewerDataModel.Instance.AngleOffsetX = instanceMain.dzMainMenu.translate.X;
463
            ViewerDataModel.Instance.AngleOffsetY = instanceMain.dzMainMenu.translate.Y;
464
            ViewerDataModel.Instance.Angle = instanceMain.dzMainMenu.rotate.Angle;
465
466
            instanceMain.dzMainMenu.pageNavigator._thumbnailItems.Where(info => info.PageNumber == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).ToList().ForEach(data =>
467
            {
468
                data.Angle = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
469
470 d18ea2bd taeseongkim
                //instanceMain.dzMainMenu.pageNavigator.ImgListbox.ItemsSource = instanceMain.dzMainMenu.pageNavigator._thumbnailItems;
471 d974f3f8 ljiyeon
                var instance = instanceMain.dzMainMenu.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == instanceMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber).FirstOrDefault();
472
                instance.PAGE_ANGLE = int.Parse(instanceMain.dzMainMenu.rotate.Angle.ToString());
473
474
                var rotationdoc = ViewerDataModel.Instance.RotationDocs.Where(d => d.ID == instance.ID).FirstOrDefault();
475
                if (rotationdoc != null)
476
                {
477
                    rotationdoc.PAGE_ANGLE = instance.PAGE_ANGLE;
478
                }
479
                else
480
                {
481
                    ViewerDataModel.Instance.RotationDocs.Add(instance);
482
                }
483 3908a575 humkyung
                instanceMain.dzMainMenu.pageNavigator.GotoPage(data.PageNumber);
484 d974f3f8 ljiyeon
            });
485
        }
486
487 787a4489 KangIngu
        void lstSelectComment_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
488
        {
489
            SetCommentPages();
490
        }
491 39f0624f ljiyeon
        
492 787a4489 KangIngu
        void user_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
493
        {
494
            SetCommentPages();
495 6c781c0c djkim
            //System.Diagnostics.Debug.WriteLine(e.PropertyName);
496 787a4489 KangIngu
        }
497 39f0624f ljiyeon
498 54a28343 taeseongkim
        public async void SetCommentPages()
499 787a4489 KangIngu
        {
500 d18ea2bd taeseongkim
            await this.Dispatcher.InvokeAsync(() => ThumbnailSetAsync());
501 787a4489 KangIngu
        }
502
503
        public void SetCommentList(List<UsersCommentPagesMember> UsersCommentPagesList)
504
        {
505 548c696e ljiyeon
            Logger.sendCheckLog("SetCommentList", 1);
506 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_기존 Comment 색상 제거", 1);
507 787a4489 KangIngu
            #region 기존 색상 제거 작업
508 6c687be8 taeseongkim
509 787a4489 KangIngu
            foreach (var item in this._thumbnailItems)
510
            {
511 6c687be8 taeseongkim
                if (item.DisplayColorItems != null)
512
                {
513
                    item.DisplayColorItems.Clear();
514
                }
515 122914ba ljiyeon
            }
516 787a4489 KangIngu
            #endregion
517
518 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_delItem select 및 remove", 1);
519 787a4489 KangIngu
            List<UsersCommentPagesMember> _delItem = new List<UsersCommentPagesMember>();
520
521 f65e6c02 taeseongkim
            this.UsersCommentPagesList.ToList().ForEach(item =>
522 787a4489 KangIngu
            {
523
                var _comm = UsersCommentPagesList.Where(a => a.MarkupInfoID == item.MarkupInfoID);
524
525
                if (_comm.Count() == 0)
526
                {
527
                    _delItem.Add(item);
528
                }
529
            });
530
531 f65e6c02 taeseongkim
            _delItem.ForEach(f => this.UsersCommentPagesList.Remove(f));
532 787a4489 KangIngu
533 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_UsersCommentPagesMember_PropertyChanged", 1);
534 81e3a60f 송근호
            List<SetColorMarkupItem> setColorMarkupItems = new List<SetColorMarkupItem>();
535
536 787a4489 KangIngu
            UsersCommentPagesList.ForEach(user =>
537
            {
538
                user.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
539
                user.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(user_PropertyChanged);
540
541 f65e6c02 taeseongkim
                var _commLst = this.UsersCommentPagesList.Where(o => o.MarkupInfoID == user.MarkupInfoID);
542 787a4489 KangIngu
543
                if (_commLst.Count() == 0)
544
                {
545 f65e6c02 taeseongkim
                    this.UsersCommentPagesList.Add(user);
546 787a4489 KangIngu
                }
547
                else
548
                {
549
                    if (_commLst.First().PageNumber != user.PageNumber)
550
                        _commLst.First().PageNumber = user.PageNumber;
551
                }
552
553
                user.PageNumber.ForEach(page =>
554
                {
555
                    var _items = this._thumbnailItems.Where(item => item.PageNumber == page);
556
557
                    if (_items.Count() > 0)
558 81e3a60f 송근호
                    {
559
                        setColorMarkupItems.Add(new SetColorMarkupItem { DisplayColor = user.SetColor, markupID = user.MarkupInfoID, Page = page });
560
                        
561
                    }
562
                        
563 787a4489 KangIngu
                });
564
            });
565
566 81e3a60f 송근호
            foreach (var item in this._thumbnailItems)
567
            {
568 8ff1bf3a 송근호
                item.DisplayColorItems = setColorMarkupItems.Where(color => color.Page == item.PageNumber).ToList();
569 81e3a60f 송근호
            }
570 d18ea2bd taeseongkim
571 122914ba ljiyeon
            Logger.sendCheckLog("SetCommentList_SelectComment.ItemsSource 설정", 1);
572 f65e6c02 taeseongkim
            var data = UsersCommentPagesList.OrderByDescending(p => p.isConSolidation == Convert.ToInt32(true)).ToList();
573 787a4489 KangIngu
            if (data.Count() != 0)
574
            {
575
                if (Convert.ToBoolean(data.First().isConSolidation))
576
                {
577
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().UserName = "Consolidated";
578
                    data.Where(p => p.isConSolidation == Convert.ToInt32(true)).FirstOrDefault().Depart = "";
579
                    this.lstSelectComment.ItemsSource = data;
580
                }
581
                else
582
                {
583 f65e6c02 taeseongkim
                    this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
584 787a4489 KangIngu
                }
585
            }
586
            else
587
            {
588 f65e6c02 taeseongkim
                this.lstSelectComment.ItemsSource = this.UsersCommentPagesList;  //섬네일   
589 787a4489 KangIngu
            }
590 f65e6c02 taeseongkim
591 81e3a60f 송근호
            Logger.sendCheckLog("SetComme6ntList_ImgListbox 설정", 1);
592 90e7968d ljiyeon
593 2d584f1a djkim
594 81e3a60f 송근호
            //var template = this.ImgListbox.ItemTemplate;
595
            //this.ImgListbox.ItemTemplate = null;
596
            //this.ImgListbox.ItemTemplate = template;
597 2d584f1a djkim
598 787a4489 KangIngu
        }
599
600 d18ea2bd taeseongkim
        List<int> FilterPages = null;
601 6c687be8 taeseongkim
602 d18ea2bd taeseongkim
        private void ThumbnailSetAsync()
603 787a4489 KangIngu
        {
604 548c696e ljiyeon
            Logger.sendCheckLog("ThumbnailSet", 1);
605 787a4489 KangIngu
606 d18ea2bd taeseongkim
            if (FilteredThumbnail == null)
607 6c687be8 taeseongkim
            {
608 d18ea2bd taeseongkim
                var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0");
609 787a4489 KangIngu
610 d18ea2bd taeseongkim
                var pageList = ViewerDataModel.Instance.Document_Info;
611 54a28343 taeseongkim
612 6c687be8 taeseongkim
                var items = from page in pageList
613
                            let pageLink = uri.Replace("{PageNo}", page.PAGE_NUMBER.ToString())
614
                            orderby page.PAGE_NUMBER
615
                            select new ThumbnailItem
616
                            {
617
                                ImageUri = new Uri(pageLink),
618
                                PageUri = new Uri(pageLink.Replace("jpg", "png")),
619
                                PageNumber = page.PAGE_NUMBER,
620
                                Angle = page.PAGE_ANGLE
621
                            };
622 54a28343 taeseongkim
623 d18ea2bd taeseongkim
                _thumbnailItems = new ObservableCollection<ThumbnailItem>(items);
624
                FilteredThumbnail = new CollectionViewSource();
625
                FilteredThumbnail.Source = _thumbnailItems;
626 787a4489 KangIngu
627 d18ea2bd taeseongkim
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
628
629
                FilteredThumbnail.Filter += (snd,evt) =>
630 787a4489 KangIngu
                {
631 d18ea2bd taeseongkim
                    if (FilterPages?.Count() > 0 && evt.Item != null)
632 787a4489 KangIngu
                    {
633 d18ea2bd taeseongkim
                        evt.Accepted = FilterPages.Contains((evt.Item as ThumbnailItem).PageNumber);
634 276fdd9b KangIngu
                    }
635 d18ea2bd taeseongkim
                    else
636 787a4489 KangIngu
                    {
637 d18ea2bd taeseongkim
                        evt.Accepted = false;
638 6c687be8 taeseongkim
                    }
639 d18ea2bd taeseongkim
                };
640 54a28343 taeseongkim
641 d18ea2bd taeseongkim
            }
642 787a4489 KangIngu
643 d18ea2bd taeseongkim
            FilterPages.Clear();
644 448c5399 taeseongkim
645 d18ea2bd taeseongkim
646
            if (rdoAllPages.IsChecked == true)
647
            {
648
                FilterPages = _thumbnailItems.Select(x=>x.PageNumber).ToList();
649
            }
650
            else if (rdoFavoritePages.IsChecked == true)
651
            {
652
                if (_FavoriteSet != null)
653
                {
654
                    FilterPages = (from thumb in _thumbnailItems
655
                                where _FavoriteSet.Where(data => data.PAGE_NO == thumb.PageNumber).FirstOrDefault() != null
656
                                select thumb.PageNumber).ToList();
657
                }
658
            }
659
            else if (rdoCommentPages.IsChecked == true)
660
            {
661
                if (this.lstSelectComment.ItemsSource != null)
662
                {
663
                    var commentPages = (from commentPage in this.UsersCommentPagesList
664
                                        where commentPage.IsSelected == true
665
                                        select commentPage.PageNumber).SelectMany(x => x).Distinct();
666
667
                    if (commentPages?.Count() > 0)
668
                    {
669
                        FilterPages = (from thumb in _thumbnailItems
670
                                       where commentPages.Where(s => s == thumb.PageNumber).Count() > 0
671
                                       select thumb.PageNumber).ToList();
672 787a4489 KangIngu
                    }
673 d18ea2bd taeseongkim
                }
674
            }
675
676
            if (FilterPages != null)
677
            {
678
                FilteredThumbnail.View.Refresh();
679
680
                if (FilterPages.Count() > 0)
681
                {
682
                    ImgListbox.SelectedItem = _thumbnailItems.Where(x=>x.PageNumber == FilterPages.FirstOrDefault()).FirstOrDefault();
683
                    //SetCommentList(UsersCommentPagesList.ToList());
684
                }
685
                else
686
                {
687
                    ImgListbox.SelectedItem = null;
688
                }
689
690
                if (ThumbInitialized != null)
691
                {
692
                    ThumbInitialized(this, new EventArgs());
693
                    ThumbInitialized = null;
694 787a4489 KangIngu
                }
695 54a28343 taeseongkim
            }
696 787a4489 KangIngu
        }
697
698 ac4f1e13 taeseongkim
        private async void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
699 787a4489 KangIngu
        {
700
            if (e.ClickCount >= 2)
701
            {
702 39f0624f ljiyeon
                var selectItem = MarkupList.SelectedItem as IKCOM.MarkupItem;
703 ac4f1e13 taeseongkim
704 787a4489 KangIngu
                GotoPage(selectItem.PageNumber);
705 ac4f1e13 taeseongkim
706
                var result = await MarkupParser.GetBaseControlAsync(selectItem.Data);
707
708 90e7968d ljiyeon
                Rect rect = new Rect(new Point(result.StartPoint.X - 100, result.StartPoint.Y - 100), new Point(result.EndPoint.X + 100, result.EndPoint.Y + 100));
709 787a4489 KangIngu
                this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
710
                //bool isGO = false;
711
712
                //var imageViewer = this.ParentOfType<KCOM.Views.MainMenu>().imageViewer;
713
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Fit;
714
                //imageViewer.InteractiveMode = Leadtools.Windows.Controls.InteractiveMode.UserRectangle;
715
                //imageViewer.InteractiveUserRectangle += (sen, ea) =>
716
                //{
717
                //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
718
                //    if (ea.Status == Leadtools.Windows.Controls.InteractiveModeStatus.End)
719
                //    {
720
                //        this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(ea.Bounds);                        
721
                //    }
722
723
                //};
724
                //imageViewer.SizeMode = Leadtools.Windows.Controls.SizeMode.Normal;
725
726 39f0624f ljiyeon
                //GotoPage(MarkupList.SelectedItem as MarkupList)
727 787a4489 KangIngu
            }
728
        }
729
730
        public class MarkupInfoItemSmall
731
        {
732
            public string Id { get; set; }
733
            public string UserName { get; set; }
734
            public string UserID { get; set; }
735
            public int PageNumber { get; set; }
736
            public string Data { get; set; }
737
            public int Data_Type { get; set; }
738 eeb0a39c taeseongkim
            public bool IsConsolidate { get; set; }
739 787a4489 KangIngu
        }
740
741
        private List<MarkupInfoItemSmall> _MarkupInfoSmallList { get; set; }
742
        public List<MarkupInfoItemSmall> MarkupInfoSmallList
743
        {
744
            get
745
            {
746
                if (_MarkupInfoSmallList == null)
747
                {
748
                    _MarkupInfoSmallList = new List<MarkupInfoItemSmall>();
749
                }
750
                return _MarkupInfoSmallList;
751
            }
752
            set
753
            {
754 90e7968d ljiyeon
755 787a4489 KangIngu
                _MarkupInfoSmallList = value;
756
                RaisePropertyChanged("MarkupInfoSmallList");
757
            }
758
        }
759
760 2aaf9645 humkyung
        /// <summary>
761
        /// goto page and select item selected by user
762
        /// </summary>
763
        /// <param name="sender"></param>
764
        /// <param name="e"></param>
765 ac4f1e13 taeseongkim
        private async void RadButton_Click_OLD(object sender, RoutedEventArgs e)
766 787a4489 KangIngu
        {
767
            var clickButtonItem = sender as RadButton;
768
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
769
            {
770
                try
771
                {
772
                    Rect rect = new Rect();
773
                    Point s_point = new Point();
774
                    Point e_point = new Point();
775
776
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
777
                    GotoPage(Convert.ToInt32(gaza.PageNumber));
778 2aaf9645 humkyung
779 ac4f1e13 taeseongkim
                    var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(gaza.Data.ToString()); //언패킹작업
780 787a4489 KangIngu
                    switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), gaza.Data_Type.ToString()))
781
                    {
782
                        case MarkupToPDF.Controls.Common.ControlType.TextControl:
783
                            {
784
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
785
                                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));
786
                            }
787
                            break;
788
                        case MarkupToPDF.Controls.Common.ControlType.TextBorder:
789
                            {
790
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
791
                                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));
792
                            }
793
                            break;
794
                        case MarkupToPDF.Controls.Common.ControlType.TextCloud:
795
                            {
796
                                MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
797
                                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));
798
                            }
799
                            break;
800
                        case MarkupToPDF.Controls.Common.ControlType.PolygonControl:
801
                            {
802
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
803
804
                                foreach (Point A in instance.PointSet)
805
                                {
806
                                    if (s_point == new Point())
807
                                    {
808
                                        s_point = A;
809
                                        e_point = A;
810
                                    }
811
                                    s_point.X = Math.Min(s_point.X, A.X);
812
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
813
                                    e_point.X = Math.Max(e_point.X, A.X);
814
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
815
                                }
816
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
817
                            }
818
                            break;
819
                        case MarkupToPDF.Controls.Common.ControlType.PolygonCloud:
820
                            {
821
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
822
823
                                foreach (Point A in instance.PointSet)
824
                                {
825
                                    if (s_point == new Point())
826
                                    {
827
                                        s_point = A;
828
                                        e_point = A;
829
                                    }
830
                                    s_point.X = Math.Min(s_point.X, A.X);
831
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
832
                                    e_point.X = Math.Max(e_point.X, A.X);
833
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
834
                                }
835
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
836
                            }
837
                            break;
838
                        case MarkupToPDF.Controls.Common.ControlType.ChainLine:
839
                            {
840
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
841
842
                                foreach (Point A in instance.PointSet)
843
                                {
844
                                    if (s_point == new Point())
845
                                    {
846
                                        s_point = A;
847
                                        e_point = A;
848
                                    }
849
                                    s_point.X = Math.Min(s_point.X, A.X);
850
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
851
                                    e_point.X = Math.Max(e_point.X, A.X);
852
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
853
                                }
854
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
855
                            }
856
                            break;
857
                        case MarkupToPDF.Controls.Common.ControlType.Ink:
858
                            {
859
                                MarkupToPDF.Serialize.S_Control.S_BaseControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
860
861
                                foreach (Point A in instance.PointSet)
862
                                {
863
                                    if (s_point == new Point())
864
                                    {
865
                                        s_point = A;
866
                                        e_point = A;
867
                                    }
868
                                    s_point.X = Math.Min(s_point.X, A.X);
869
                                    s_point.Y = Math.Min(s_point.Y, A.Y);
870
                                    e_point.X = Math.Max(e_point.X, A.X);
871
                                    e_point.Y = Math.Max(e_point.Y, A.Y);
872
                                }
873
                                rect = new Rect(new Point(s_point.X - 100, s_point.Y - 100), new Point(e_point.X + 100, e_point.Y + 100));
874
                            }
875
                            break;
876
                        default:
877
                            MarkupToPDF.Serialize.S_Control.S_BaseControl item = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_BaseControl>(data);
878
                            rect = new Rect(new Point(item.StartPoint.X - 100, item.StartPoint.Y - 100), new Point(item.EndPoint.X + 100, item.EndPoint.Y + 100));
879
                            break;
880
                    }
881
882 077896be humkyung
                    SelectionSet.Instance.SelectItemByRect(rect, this.ParentOfType<KCOM.Views.MainMenu>());
883 787a4489 KangIngu
                    this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
884
                }
885
                catch (Exception ex)
886
                {
887 2aaf9645 humkyung
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
888 787a4489 KangIngu
                }
889
            }
890
        }
891
892 2089959a taeseongkim
893
        private void btGotoMarkup_Click(object sender, RoutedEventArgs e)
894
        {
895
            var clickButtonItem = sender as RadButton;
896
            if (clickButtonItem != null && clickButtonItem.CommandParameter != null)
897
            {
898
                try
899
                {
900
             
901
902
                    MarkupInfoItemSmall gaza = clickButtonItem.CommandParameter as MarkupInfoItemSmall;
903
                    MarkupList.SelectedItem = gaza;
904
905 c7fde400 taeseongkim
                    MarkupHelper.GotoMarkup(new[] { gaza.Id });
906 2089959a taeseongkim
                }
907
                catch (Exception ex)
908
                {
909
                    this.ParentOfType<KCOM.Views.MainMenu>().DialogMessage_Alert(ex.Message, "Error");
910
                }
911
            }
912
        }
913
914 c7fde400 taeseongkim
        ///// <summary>
915
        ///// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
916
        ///// </summary>
917
        ///// <param name="CommentIdList"></param>
918
        //private void GotoMarkup(IEnumerable<string> CommentIdList)
919
        //{
920
        //    var instance = Common.ViewerDataModel.Instance;
921
922
        //    SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
923
924
        //    var commentList = instance._markupInfoList.Where(x => x.MarkupList != null).SelectMany(x => x.MarkupList).Where(f => f.ID == CommentIdList.First());
925
926
        //    if (commentList.Count() > 0)
927
        //    {
928
        //        //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
929
        //        #region markup list grid select items
930
931
        //        var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0);
932
933
        //        if (infoItem.Count() > 0)
934
        //        {
935
936
        //            var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
937
        //            gridMarkup.SelectedItems.Clear();
938
        //            gridMarkup.SelectedItems.Add(infoItem.First());
939
        //        }
940
941
        //        #endregion
942
943
        //        var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
944
945
        //        if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
946
        //        {
947
        //            GotoSelectedMarkup(CommentIdList);
948
        //        }
949
        //        else
950
        //        {
951
        //            EventHandler<Sample.PageChangeEventArgs> handler = null;
952
953
        //            handler = (snd, evt) =>
954
        //            {
955
        //                GotoSelectedMarkup(CommentIdList);
956
        //                pageNavigator.PageChanged -= handler;
957
        //            };
958
959
        //            pageNavigator.PageChanged += handler;
960
961
        //            pageNavigator.GotoPage(commentList.First().PageNumber);
962
        //        }
963
        //    }
964
        //}
965
966
        ///// <summary>
967
        ///// 페이지 이동 후 마크업을 선택하고 Zoom을 한다.
968
        ///// 마크업이 페이지보다 크면 Zoom을 하지 않음.
969
        ///// </summary>
970
        ///// <param name="CommentIdList"></param>
971
        //private void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
972
        //{
973
        //    var instance = Common.ViewerDataModel.Instance;
974
975
        //    var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
976
        //    var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
977
978
        //    if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
979
        //    {
980
        //        commentUserInfo.ForEach(x => x.IsSelected = true);
981
        //        commentUserInfo.AddRange(selectOrderComments);
982
983
        //        if (commentUserInfo?.Count() > 0)
984
        //        {
985
        //            var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
986
987
        //            try
988
        //            {
989
        //                if(Common.ViewerDataModel.Instance.Angle != 0)
990
        //                {
991
        //                    for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
992
        //                    {
993
        //                        Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
994
        //                    } 
995 5beaf28e taeseongkim
                            
996 c7fde400 taeseongkim
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
997
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
998
        //                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
999
        //                }
1000 5beaf28e taeseongkim
1001 c7fde400 taeseongkim
        //                Rect rect = commentUserInfo.First().ItemRect;
1002 2089959a taeseongkim
1003 c7fde400 taeseongkim
        //                foreach (var UserInfo in commentUserInfo)
1004
        //                {
1005
        //                    rect = Rect.Union(rect, UserInfo.ItemRect);
1006
        //                }
1007 2089959a taeseongkim
1008 c7fde400 taeseongkim
        //                SelectionSet.Instance.SelectItemByRect(rect, main);
1009 2089959a taeseongkim
1010 c7fde400 taeseongkim
        //                var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
1011
        //                //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1012
        //                //rect.Transform(matrix);
1013 2089959a taeseongkim
1014 c7fde400 taeseongkim
        //                double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
1015
        //                double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
1016
        //                double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
1017
        //                double positionX = 0;
1018
        //                double positionY = 0;
1019 2089959a taeseongkim
1020 c7fde400 taeseongkim
        //                if (Common.ViewerDataModel.Instance.Angle == 90)
1021
        //                {
1022
        //                    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
1023
        //                    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
1024
        //                }
1025 2089959a taeseongkim
1026 c7fde400 taeseongkim
        //                main.zoomAndPanControl.ContentScale = newScale;
1027
        //                main.zoomAndPanControl.ContentOffsetX = positionX;
1028
        //                main.zoomAndPanControl.ContentOffsetY = positionY;
1029 2089959a taeseongkim
1030
              
1031 c7fde400 taeseongkim
        //                var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
1032
1033
        //                double pageAngle = Common.ViewerDataModel.Instance.Angle;
1034
1035
        //                if (pageAngle == 90)
1036
        //                {
1037
        //                    pageAngle = 270;
1038
        //                }
1039
        //                else
1040
        //                {
1041
        //                    pageAngle = 90;
1042
        //                }
1043
1044
        //                if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
1045
        //                {
1046
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1047
        //                    rect.Transform(matrix);
1048
1049
        //                    main.zoomAndPanControl.ZoomTo(rect);
1050
        //                }
1051
        //                else
1052
        //                {
1053
        //                    rect.Inflate(rect.Width * 3, rect.Height * 3);
1054
1055
        //                    var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
1056
        //                    rect.Transform(matrix);
1057
1058
1059
        //                    main.zoomAndPanControl.ZoomTo(rect);
1060
        //                }
1061
        //            }
1062
        //            catch (Exception ex)
1063
        //            {
1064
        //                main.DialogMessage_Alert(ex.Message, "Error");
1065
        //            }
1066
        //        }
1067
        //    }
1068
        //}
1069 2089959a taeseongkim
1070 39f0624f ljiyeon
        private void MarkupList_Loaded(object sender, RoutedEventArgs e)
1071 787a4489 KangIngu
        {
1072
            if (MarkupInfoSmallList.Count == 0)
1073
            {
1074
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1075
                {
1076
                    if (d.MarkupList != null)
1077
                    {
1078
                        d.MarkupList.ForEach(b =>
1079
                        {
1080 eeb0a39c taeseongkim
                            bool isConsolidate = false;
1081
1082
                            if(d.Consolidate == 1 && d.AvoidConsolidate == 0)
1083
                            {
1084
                                isConsolidate = true;
1085
                            }
1086
1087
                            System.Diagnostics.Debug.WriteLine($"UserID : {d.UserID} Consolidate : {d.Consolidate}  AvoidConsolidate : {d.AvoidConsolidate}");
1088
1089 787a4489 KangIngu
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1090
                            {
1091
                                Id = b.ID,
1092
                                Data = b.Data,
1093
                                Data_Type = b.Data_Type,
1094
                                PageNumber = b.PageNumber,
1095
                                UserID = d.UserID,
1096
                                UserName = d.UserName,
1097 eeb0a39c taeseongkim
                                IsConsolidate = isConsolidate
1098
1099 787a4489 KangIngu
                            });
1100
                        });
1101
                    }
1102
                });
1103 39f0624f ljiyeon
                MarkupList.ItemsSource = null;
1104
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1105 787a4489 KangIngu
1106 eeb0a39c taeseongkim
                FilterUpdate();
1107 787a4489 KangIngu
            }
1108
        }
1109
1110 39f0624f ljiyeon
        public void MarkupListUpdate(MarkupReturn res, Event_Type eventType, string CommentID, MarkupInfoItem item)
1111 4eb052e4 ljiyeon
        {
1112
            if (MarkupInfoSmallList.Count == 0)
1113
            {
1114
                ViewerDataModel.Instance._markupInfoList.ToList().ForEach(d =>
1115
                {
1116
                    if (d.MarkupList != null)
1117
                    {
1118
                        d.MarkupList.ForEach(b =>
1119
                        {
1120
                            MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1121
                            {
1122
                                Id = b.ID,
1123
                                Data = b.Data,
1124
                                Data_Type = b.Data_Type,
1125
                                PageNumber = b.PageNumber,
1126
                                UserID = d.UserID,
1127
                                UserName = d.UserName,
1128
                            });
1129
                        });
1130
                    }
1131
                });
1132 39f0624f ljiyeon
                MarkupList.ItemsSource = null;
1133
                MarkupList.ItemsSource = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1134 4eb052e4 ljiyeon
            }
1135
1136
            switch (eventType)
1137
            {
1138
                case Event_Type.Create:
1139
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1140
                    {
1141
                        Id = res.CommentID,
1142
                        Data = res.ConvertData,
1143
                        Data_Type = res.DATA_TYPE,
1144
                        PageNumber = CurrentPage.PageNumber,
1145
                        UserID = App.ViewInfo.UserID,
1146
                        UserName = App.UserName,
1147
                    });
1148
                    break;
1149
                case Event_Type.Delete:
1150
                    if(CommentID == null) //user information list delete btn
1151
                    {
1152
                        foreach (var delItem in item.MarkupList)
1153
                        {
1154
                            MarkupInfoSmallList.RemoveAll(p => p.Id == delItem.ID);
1155
                        }
1156
                    }
1157
                    else //delete, cut, 
1158
                    {
1159
                        MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(CommentID));
1160
                    }                    
1161
                    break;
1162 39f0624f ljiyeon
                case Event_Type.Thumb://이동 회전
1163 4eb052e4 ljiyeon
                    MarkupInfoSmallList.RemoveAll(p => p.Id.Equals(res.CommentID));
1164
                    MarkupInfoSmallList.Add(new MarkupInfoItemSmall
1165
                    {
1166
                        Id = res.CommentID,
1167
                        Data = res.ConvertData,
1168
                        Data_Type = res.DATA_TYPE,
1169
                        PageNumber = CurrentPage.PageNumber,
1170
                        UserID = App.ViewInfo.UserID,
1171
                        UserName = App.UserName,
1172
                    });
1173
                    break;
1174
                default:
1175
                    break;
1176
            }
1177
1178 39f0624f ljiyeon
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1179 4eb052e4 ljiyeon
1180 eeb0a39c taeseongkim
            bool IsConsolidation = false;
1181
            string UserId = null;
1182
1183
            if (commentUser.SelectedValue != null)
1184
            {
1185
                if (((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName != "Consolidated")
1186
                {
1187
                    UserId = ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).UserName;
1188
                }
1189
                else
1190
                {
1191
                    IsConsolidation = true;
1192
                }
1193
            }
1194
1195
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1196
                                 .WhereIf(UserId != null, d => d.UserName == ((KCOM.Common.UsersCommentPagesMember)commentUser.SelectedValue).ToString())
1197
                                 .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1198 4eb052e4 ljiyeon
1199 eeb0a39c taeseongkim
            MarkupList.ItemsSource = TempMarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1200 39f0624f ljiyeon
1201 eeb0a39c taeseongkim
            FilterUpdate();
1202 4eb052e4 ljiyeon
        }
1203
1204 eeb0a39c taeseongkim
        private void FilterUpdate(string selectUser = null)
1205 787a4489 KangIngu
        {
1206 eeb0a39c taeseongkim
            //var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1207 4eb052e4 ljiyeon
1208 eeb0a39c taeseongkim
            //commentType.ItemsSource = items.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1209
            //commentPage.ItemsSource = items.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1210 0cda2a88 taeseongkim
1211 b2c6901f swate0609
1212 eeb0a39c taeseongkim
            var items = MarkupList.ItemsSource as List<MarkupInfoItemSmall>;
1213
 
1214
            var filterUsers = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1215
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1216
1217
            var filterTypes = MarkupInfoSmallList.WhereIf(selectUser != null, d => d.UserName == selectUser)
1218
                                .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1219
1220
            var filterPages = MarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1221
                              .WhereIf(selectUser != null, d => d.UserName == selectUser);
1222
1223
            commentUser.ItemsSource = filterUsers.Select(d => d.UserName).Distinct().OrderBy(d => d).ToList();
1224
            commentType.ItemsSource = filterTypes.Select(d => d.Data_Type).Distinct().OrderBy(d => d).ToList();
1225
            commentPage.ItemsSource = filterPages.Select(d => d.PageNumber).Distinct().OrderBy(d => d).ToList();
1226 b2c6901f swate0609
        }
1227
1228 eeb0a39c taeseongkim
        
1229
1230
        private void commentFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
1231 b2c6901f swate0609
        {
1232
            MarkupList.ItemsSource = null;
1233
            txtSearch.Text = string.Empty;
1234
1235
            List<MarkupInfoItemSmall> TempMarkupInfoSmallList = MarkupInfoSmallList.OrderBy(d => d.PageNumber).ToList();
1236
1237 eeb0a39c taeseongkim
            bool IsConsolidation = false;
1238
            string userName = null;
1239 4eb052e4 ljiyeon
1240 eeb0a39c taeseongkim
            if (commentUser.SelectedValue != null)
1241
            {
1242
                if(commentUser.SelectedValue?.ToString() != "Consolidated")
1243
                {
1244
                    userName = commentUser.SelectedValue.ToString();
1245
                }
1246
                else
1247
                {
1248
                    IsConsolidation = true;
1249
                }
1250
            }
1251 4eb052e4 ljiyeon
1252 eeb0a39c taeseongkim
            var filterItems = TempMarkupInfoSmallList.WhereIf(commentType.SelectedValue != null, d => d.Data_Type == Convert.ToInt32(commentType.SelectedValue))
1253
                                   .WhereIf(userName != null, d => d.UserName == userName)
1254
                                   .WhereIf(IsConsolidation,d=>d.IsConsolidate == IsConsolidation)
1255
                                   .WhereIf(commentPage.SelectedValue != null, d => d.PageNumber == Convert.ToInt32(commentPage.SelectedValue));
1256
1257
            MarkupList.ItemsSource = filterItems.OrderBy(d => d.PageNumber).ToList();
1258
1259
            FilterUpdate();
1260 787a4489 KangIngu
        }
1261
1262
        private void btnPanorama_Click(object sender, RoutedEventArgs e)
1263
        {
1264
            ViewerDataModel.Instance.SystemMain.dzTopMenu.PanoramaShow();
1265
        }
1266 79f3f21a djkim
1267 ac4f1e13 taeseongkim
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
1268 79f3f21a djkim
        {
1269 2089959a taeseongkim
            string search_str = txtSearch.Text;
1270
1271
            if(string.IsNullOrWhiteSpace(search_str))
1272
            {
1273
                return;
1274
            }
1275
1276 79f3f21a djkim
            var sel_type = commentType.SelectedItem;
1277
            var sel_user = commentUser.SelectedItem;
1278
            var sel_page = commentPage.SelectedItem;
1279
            List<MarkupInfoItemSmall> small_list = new List<MarkupInfoItemSmall>();
1280
            List<MarkupInfoItemSmall> list = MarkupInfoSmallList;
1281 90e7968d ljiyeon
            if (sel_page != null)
1282 79f3f21a djkim
            {
1283
                list = list.Where(d => d.PageNumber == Convert.ToInt32(sel_page)).ToList();
1284
            }
1285 90e7968d ljiyeon
            if (sel_type != null)
1286 79f3f21a djkim
            {
1287
                list = list.Where(d => d.Data_Type == Convert.ToInt32(sel_type)).ToList();
1288
            }
1289
            if (sel_user != null)
1290
            {
1291
                list = list.Where(d => d.UserID == (sel_user as MarkupInfoItem).UserID).ToList();
1292
            }
1293
            foreach (var item in list)
1294
            {
1295 ac4f1e13 taeseongkim
                var data = await MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressStringAsync(item.Data.ToString());
1296 90e7968d ljiyeon
1297 79f3f21a djkim
                switch (Enum.Parse(typeof(MarkupToPDF.Controls.Common.ControlType), item.Data_Type.ToString()))
1298 90e7968d ljiyeon
                {
1299 79f3f21a djkim
                    case MarkupToPDF.Controls.Common.ControlType.TextControl:
1300
                    case MarkupToPDF.Controls.Common.ControlType.TextBorder:
1301
                    case MarkupToPDF.Controls.Common.ControlType.TextCloud:
1302
                        {
1303
                            MarkupToPDF.Serialize.S_Control.S_TextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_TextControl>(data);
1304 2089959a taeseongkim
1305
                            if (!string.IsNullOrWhiteSpace(instance.Text))
1306 90e7968d ljiyeon
                            {
1307 2089959a taeseongkim
                                if (instance.Text.ToLower().Contains(search_str.ToLower()))
1308
                                {
1309
                                    small_list.Add(item);
1310
                                }
1311 79f3f21a djkim
                            }
1312
                        }
1313
                        break;
1314
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextBorderControl:
1315
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextCloudControl:
1316
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTextControl:
1317
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextBorderControl:
1318
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextCloudControl:
1319
                    case MarkupToPDF.Controls.Common.ControlType.ArrowTransTextControl:
1320
                        {
1321
                            MarkupToPDF.Serialize.S_Control.S_ArrowTextControl instance = MarkupToPDF.Serialize.Core.JsonSerializerHelper.JsonDeserialize<MarkupToPDF.Serialize.S_Control.S_ArrowTextControl>(data);
1322 2089959a taeseongkim
1323
                            if (!string.IsNullOrWhiteSpace(instance.ArrowText))
1324 79f3f21a djkim
                            {
1325 2089959a taeseongkim
                                if (instance.ArrowText.Contains(search_str))
1326
                                {
1327
                                    small_list.Add(item);
1328
                                }
1329 79f3f21a djkim
                            }
1330
                        }
1331
                        break;
1332
                }
1333
            }
1334 90e7968d ljiyeon
1335 39f0624f ljiyeon
            MarkupList.ItemsSource = null;
1336
            MarkupList.ItemsSource = small_list.OrderBy(d => d.PageNumber).ToList();
1337 2089959a taeseongkim
        }
1338
1339
        private void TxtSearch_KeyDown(object sender, KeyEventArgs e)
1340
        {
1341
            if(e.Key == Key.Enter || e.Key == Key.Return)
1342
            {
1343
                btnSearch_Click(sender, new RoutedEventArgs());
1344
            }
1345 79f3f21a djkim
        }
1346 6c687be8 taeseongkim
1347 787a4489 KangIngu
    }
1348
}
클립보드 이미지 추가 (최대 크기: 500 MB)