프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Sample.xaml.cs @ 54a28343

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