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