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