AnnotationContentViewModel.cs 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. using ComPDFKit.Import;
  2. using ComPDFKit.PDFAnnotation;
  3. using ComPDFKit.PDFDocument;
  4. using ComPDFKit.PDFPage;
  5. using ComPDFKitViewer;
  6. using ComPDFKitViewer.AnnotEvent;
  7. using ComPDFKitViewer.PdfViewer;
  8. using DryIoc;
  9. using ImTools;
  10. using Microsoft.Office.Interop.Excel;
  11. using Microsoft.Office.Interop.PowerPoint;
  12. using Microsoft.Office.Interop.Word;
  13. using PDF_Office.CustomControl;
  14. using PDF_Office.DataConvert;
  15. using PDF_Office.Helper;
  16. using PDF_Office.Model;
  17. using PDF_Office.Model.BOTA;
  18. using PDF_Office.Views.BOTA;
  19. using PDF_Office.Views.PropertyPanel.AnnotPanel;
  20. using PDF_Office.Views.Scan;
  21. using Prism.Commands;
  22. using Prism.Mvvm;
  23. using Prism.Regions;
  24. using Prism.Services.Dialogs;
  25. using System;
  26. using System.Collections.Generic;
  27. using System.Collections.ObjectModel;
  28. using System.ComponentModel;
  29. using System.Configuration;
  30. using System.Drawing;
  31. using System.Linq;
  32. using System.Text;
  33. using System.Threading.Tasks;
  34. using System.Windows;
  35. using System.Windows.Annotations;
  36. using System.Windows.Annotations.Storage;
  37. using System.Windows.Controls;
  38. using System.Windows.Data;
  39. using System.Windows.Documents;
  40. using System.Windows.Forms;
  41. using System.Windows.Markup;
  42. using System.Windows.Media;
  43. using System.Windows.Media.Imaging;
  44. using System.Windows.Shapes;
  45. using static Dropbox.Api.Files.SearchMatchType;
  46. using static Dropbox.Api.TeamLog.SpaceCapsType;
  47. using static System.Net.Mime.MediaTypeNames;
  48. using static System.Windows.Forms.VisualStyles.VisualStyleElement;
  49. using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolBar;
  50. using Border = System.Windows.Controls.Border;
  51. using ListBox = System.Windows.Controls.ListBox;
  52. using Task = System.Threading.Tasks.Task;
  53. using TextBox = System.Windows.Controls.TextBox;
  54. using Winform = System.Windows.Forms;
  55. namespace PDF_Office.ViewModels.BOTA
  56. {
  57. public class AnnotationContentViewModel : BindableBase, INavigationAware
  58. {
  59. private ListBox listBox;
  60. private IRegionManager region;
  61. private IDialogService dialogs;
  62. private Visibility isEmptyPanelVisibility = Visibility.Visible;
  63. public ViewContentViewModel ViewContentViewModel { get; set; }
  64. public CPDFViewer PdfViewer { get; set; }
  65. public Visibility IsEmptyPanelVisibility
  66. {
  67. get { return isEmptyPanelVisibility; }
  68. set
  69. {
  70. SetProperty(ref isEmptyPanelVisibility, value);
  71. }
  72. }
  73. private ObservableCollection<AnnotationHandlerEventArgs> currentAnnotationArgs = new ObservableCollection<AnnotationHandlerEventArgs>();
  74. public ObservableCollection<AnnotationHandlerEventArgs> CurrentAnnotationArgs { get => currentAnnotationArgs; set => currentAnnotationArgs = value; }
  75. private AnnotationSortOrder annotationSortOrder = AnnotationSortOrder.PageIndexAscending;
  76. public AnnotationSortOrder AnnotationSortOrder
  77. {
  78. get { return annotationSortOrder; }
  79. set { annotationSortOrder = value; }
  80. }
  81. private ObservableCollection<AnnotationHandlerEventArgs> annotationListItems;
  82. public ObservableCollection<AnnotationHandlerEventArgs> AnnotationListItems
  83. {
  84. get { return annotationListItems; }
  85. set
  86. {
  87. SetProperty(ref annotationListItems, value);
  88. }
  89. }
  90. private List<string> colors = new List<string>();
  91. private List<string> authors = new List<string>();
  92. private List<AnnotArgsType> annotArgsTypes = new List<AnnotArgsType>();
  93. public DelegateCommand<object> LoadedCommand { get; set; }
  94. public DelegateCommand<object> ListBoxItemPreviewMouseLeftButtonDown { get; set; }
  95. public DelegateCommand<object> AddNotesCommand { get; set; }
  96. public DelegateCommand<object> ScreenCommand { get; set; }
  97. public DelegateCommand<object> ExportCommentsCommand { get; set; }
  98. public DelegateCommand<object> ImportCommentsCommand { get; set; }
  99. public DelegateCommand<object> DeleteCommand { get; set; }
  100. public DelegateCommand DeleteAllCommand { get; set; }
  101. public DelegateCommand PageSortCommand { get; set; }
  102. public DelegateCommand TimeAscendingCommand { get; set; }
  103. public DelegateCommand TimeDescendingCommand { get; set; }
  104. public AnnotationContentViewModel(IRegionManager regionManager, IDialogService dialogService)
  105. {
  106. region = regionManager;
  107. dialogs = dialogService;
  108. LoadedCommand = new DelegateCommand<object>(Loaded);
  109. ListBoxItemPreviewMouseLeftButtonDown = new DelegateCommand<object>(ListBoxItem_PreviewMouseLeftButtonDown);
  110. AddNotesCommand = new DelegateCommand<object>(AddNotesEvent);
  111. ScreenCommand = new DelegateCommand<object>(ScreenEvent);
  112. ExportCommentsCommand = new DelegateCommand<object>(ExportCommentsEvent);
  113. ImportCommentsCommand = new DelegateCommand<object>(ImportCommentsEvent);
  114. DeleteCommand = new DelegateCommand<object>(DelegateEvent);
  115. DeleteAllCommand = new DelegateCommand(DeleteAllEvent);
  116. PageSortCommand = new DelegateCommand(PageSortEvent);
  117. TimeAscendingCommand = new DelegateCommand(TimeAscendingEvent);
  118. TimeDescendingCommand = new DelegateCommand(TimeDescendingEvent);
  119. }
  120. /// <summary>
  121. /// 导入注释
  122. /// </summary>
  123. /// <param name="obj"></param>
  124. private async void ImportCommentsEvent(object obj)
  125. {
  126. Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
  127. dlg.Filter = "PDF|*.xfdf";
  128. dlg.DefaultExt = ".xfdf";
  129. if (dlg.ShowDialog() == true)
  130. {
  131. string fileName = dlg.FileName;
  132. await Task.Delay(5);
  133. var result = PdfViewer.ImportAnnotationFromXFDFPath(fileName);
  134. if (result == false)
  135. {
  136. //MessageBoxEx.Show("导入失败", "", Winform.MessageBoxButtons.OK, Winform.MessageBoxIcon.Error);
  137. AlertsMessage alertsMessage = new AlertsMessage();
  138. alertsMessage.Show("提示", "导入失败!", "OK");
  139. return;
  140. }
  141. PdfViewer.ReloadVisibleAnnots();
  142. //提取出来的注释文件 时间为空 则显示未系统当前时间
  143. CurrentAnnotationArgs = GetDocumentAnnotionList();
  144. AnnotationListItems.Clear();
  145. AnnotationListItems.AddRange(CurrentAnnotationArgs);
  146. await Task.Delay(5);
  147. RefreshAnnotationListItems(null);
  148. PdfViewer.UndoManager.CanSave = true;
  149. }
  150. }
  151. /// <summary>
  152. /// 时间倒序
  153. /// </summary>
  154. private void TimeDescendingEvent()
  155. {
  156. ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
  157. CreateTimeToDate createTimeToDate = new CreateTimeToDate();
  158. v.GroupDescriptions.Clear();
  159. v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.CreateTime), createTimeToDate));
  160. v.SortDescriptions.Clear();
  161. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.CreateTime), ListSortDirection.Descending));
  162. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Descending));
  163. AnnotationSortOrder = AnnotationSortOrder.TimeDescending;
  164. }
  165. /// <summary>
  166. /// 时间正序
  167. /// </summary>
  168. private void TimeAscendingEvent()
  169. {
  170. ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
  171. CreateTimeToDate createTimeToDate = new CreateTimeToDate();
  172. v.GroupDescriptions.Clear();
  173. v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.CreateTime), createTimeToDate));
  174. v.SortDescriptions.Clear();
  175. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.CreateTime), ListSortDirection.Ascending));
  176. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
  177. AnnotationSortOrder = AnnotationSortOrder.TimeAscending;
  178. }
  179. /// <summary>
  180. /// 页面排序
  181. /// </summary>
  182. private void PageSortEvent()
  183. {
  184. ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
  185. v.GroupDescriptions.Clear();
  186. v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.PageIndex)));
  187. v.SortDescriptions.Clear();
  188. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
  189. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
  190. AnnotationSortOrder = AnnotationSortOrder.PageIndexAscending;
  191. }
  192. /// <summary>
  193. /// 删除所有注释
  194. /// </summary>
  195. private void DeleteAllEvent()
  196. {
  197. //调用集中删除的接口 方便一次性undo
  198. Dictionary<int, List<int>> deleteLists = new Dictionary<int, List<int>>();
  199. for (int i = 0; i < AnnotationListItems.Count; i++)
  200. {
  201. AnnotationHandlerEventArgs item = AnnotationListItems[i] as AnnotationHandlerEventArgs;
  202. if (!deleteLists.ContainsKey(item.PageIndex))
  203. {
  204. deleteLists.Add(item.PageIndex, new List<int>() { item.AnnotIndex });
  205. }
  206. else
  207. {
  208. var pagelist = deleteLists[item.PageIndex];
  209. pagelist.Add(item.AnnotIndex);
  210. }
  211. }
  212. PdfViewer.RemovePageAnnot(deleteLists);
  213. AnnotationListItems.Clear();
  214. CurrentAnnotationArgs.Clear();
  215. PdfViewer.UndoManager.CanSave = true;
  216. }
  217. /// <summary>
  218. /// 删除注释,单个/多个
  219. /// </summary>
  220. /// <param name="obj"></param>
  221. private void DelegateEvent(object obj)
  222. {
  223. if (obj is AnnotationHandlerEventArgs annotation)
  224. {
  225. if (annotation != null)
  226. {
  227. var result = PdfViewer.RemovePageAnnot(annotation.PageIndex, annotation.AnnotIndex);
  228. if (result)
  229. {
  230. AnnotationListItems.Remove(annotation);
  231. var annotation1 = CurrentAnnotationArgs.FirstOrDefault(x => x.PageIndex == annotation.PageIndex && x.AnnotIndex == annotation.AnnotIndex);
  232. CurrentAnnotationArgs.Remove(annotation1);
  233. //记录是删除了哪些页面的注释,然后更新对应页面的注释即可
  234. UpdateAnnotListAfterDelete(annotation.PageIndex, annotation.AnnotIndex);
  235. PdfViewer.UndoManager.CanSave = true;
  236. }
  237. }
  238. }
  239. }
  240. /// <summary>
  241. /// 删除之后,更新
  242. /// </summary>
  243. /// <param name="pageIndex"></param>
  244. /// <param name="annoteIndex"></param>
  245. private void UpdateAnnotListAfterDelete(int pageIndex, int annoteIndex)
  246. {
  247. var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  248. for (int j = 0; j < items.Count; j++)//用修改赋值的方式 可以解决删除后表头折叠的问题
  249. {
  250. if (items[j].AnnotIndex >= annoteIndex)//只需要更新比删除元素索引大的注释
  251. {
  252. for (int k = 0; k < AnnotationListItems.Count; k++)
  253. {
  254. //相当于将后面的索引-1
  255. if (AnnotationListItems[k].PageIndex == pageIndex &&
  256. AnnotationListItems[k].AnnotIndex == (items[j].AnnotIndex + 1) &&
  257. string.Equals(AnnotationListItems[k].MarkupContent, items[j].MarkupContent) &&
  258. string.Equals(AnnotationListItems[k].Content, items[j].Content) &&
  259. string.Equals(AnnotationListItems[k].CreateTime, items[j].CreateTime) &&
  260. string.Equals(AnnotationListItems[k].Author, items[j].Author)
  261. )
  262. {
  263. AnnotationListItems[k].AnnotHandlerEventArgs = items[j];
  264. AnnotationListItems[k].PageIndex = items[j].PageIndex;
  265. AnnotationListItems[k].AnnotIndex = items[j].AnnotIndex;
  266. AnnotationListItems[k].EventType = items[j].EventType;
  267. AnnotationListItems[k].CreateTime = items[j].CreateTime;
  268. AnnotationListItems[k].UpdateTime = items[j].UpdateTime;
  269. if (items[j].EventType == AnnotArgsType.AnnotFreehand)
  270. {
  271. WriteableBitmap bitmap = GetAnnotImage(PdfViewer.Document, items[j].PageIndex, items[j].AnnotIndex);
  272. AnnotationListItems[k].WriteableBitmap = bitmap;
  273. }
  274. AnnotationListItems[k].Content = items[j].Content;
  275. AnnotationListItems[k].MarkupContent = items[j].MarkupContent;
  276. AnnotationListItems[k].Author = items[j].Author;
  277. AnnotationListItems[k].Locked = items[j].Locked;
  278. AnnotationListItems[k].ReadOnly = items[j].ReadOnly;
  279. AnnotationListItems[k].FormField = items[j].FormField;
  280. AnnotationListItems[k].Document = PdfViewer.Document;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. /// <summary>
  287. /// 导出注释
  288. /// </summary>
  289. /// <param name="obj"></param>
  290. private void ExportCommentsEvent(object obj)
  291. {
  292. if (ViewContentViewModel.CanSave)
  293. {
  294. ViewContentViewModel.SaveFile.Execute();
  295. }
  296. Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
  297. dlg.Filter = "PDF|*.xfdf";
  298. dlg.DefaultExt = ".xfdf";
  299. dlg.FileName = PdfViewer.Document.FileName;
  300. if (dlg.ShowDialog() == true)
  301. {
  302. string fileName = dlg.FileName;
  303. var result = PdfViewer.ExportAnnotationToXFDFPath(fileName);
  304. if (result)
  305. {
  306. //MessageBoxEx.Show("导出成功", "", Winform.MessageBoxButtons.OK);
  307. AlertsMessage alertsMessage = new AlertsMessage();
  308. alertsMessage.Show("提示", "导出成功!", "OK");
  309. }
  310. else
  311. {
  312. AlertsMessage alertsMessage = new AlertsMessage();
  313. alertsMessage.Show("提示", "导出失败!", "OK");
  314. //MessageBoxEx.Show("导出失败", "", Winform.MessageBoxButtons.OK, Winform.MessageBoxIcon.Error);
  315. }
  316. }
  317. }
  318. /// <summary>
  319. /// 筛选注释
  320. /// </summary>
  321. /// <param name="obj"></param>
  322. private void ScreenEvent(object obj)
  323. {
  324. if (obj is System.Windows.Controls.Button button)
  325. {
  326. DialogParameters value = new DialogParameters();
  327. value.Add(ParameterNames.AnnotationList, CurrentAnnotationArgs);
  328. value.Add(ParameterNames.AnnotArgsTypes, annotArgsTypes);
  329. value.Add(ParameterNames.AnnotationColors, colors);
  330. value.Add(ParameterNames.AnnotationAuthor, authors);
  331. dialogs.ShowDialog(DialogNames.ScreenAnnotationDialog, value, e =>
  332. {
  333. if (e.Result == ButtonResult.OK && e.Parameters != null)
  334. {
  335. bool cleanState = false;
  336. if (e.Parameters.ContainsKey(ParameterNames.AnnotationCleanState))
  337. {
  338. cleanState = e.Parameters.GetValue<bool>(ParameterNames.AnnotationCleanState);
  339. if (cleanState)
  340. {
  341. colors.Clear();
  342. authors.Clear();
  343. annotArgsTypes.Clear();
  344. AnnotationListItems.Clear();
  345. AnnotationListItems.AddRange(CurrentAnnotationArgs);
  346. RefreshAnnotationListItems(button);
  347. }
  348. else
  349. {
  350. if (e.Parameters.ContainsKey(ParameterNames.AnnotArgsTypes))
  351. {
  352. annotArgsTypes = e.Parameters.GetValue<List<AnnotArgsType>>(ParameterNames.AnnotArgsTypes);
  353. }
  354. if (e.Parameters.ContainsKey(ParameterNames.AnnotationColors))
  355. {
  356. colors = e.Parameters.GetValue<List<string>>(ParameterNames.AnnotationColors);
  357. }
  358. if (e.Parameters.ContainsKey(ParameterNames.AnnotationAuthor))
  359. {
  360. authors = e.Parameters.GetValue<List<string>>(ParameterNames.AnnotationAuthor);
  361. }
  362. ObservableCollection<AnnotationHandlerEventArgs> screenAnnotationArgs = SelectAnnotationListItems(annotArgsTypes, colors, authors);
  363. AnnotationListItems.Clear();
  364. AnnotationListItems.AddRange(screenAnnotationArgs);
  365. RefreshAnnotationListItems(button);
  366. }
  367. }
  368. }
  369. else if (e.Result == ButtonResult.Cancel && e.Parameters != null)
  370. {
  371. colors.Clear();
  372. authors.Clear();
  373. annotArgsTypes.Clear();
  374. AnnotationListItems.Clear();
  375. AnnotationListItems.AddRange(CurrentAnnotationArgs);
  376. RefreshAnnotationListItems(button);
  377. }
  378. });
  379. }
  380. }
  381. /// <summary>
  382. /// 刷新列表数据
  383. /// </summary>
  384. /// <param name="button"></param>
  385. private async void RefreshAnnotationListItems(System.Windows.Controls.Button button)
  386. {
  387. switch (AnnotationSortOrder)
  388. {
  389. case AnnotationSortOrder.TimeAscending:
  390. TimeAscendingEvent();
  391. break;
  392. case AnnotationSortOrder.TimeDescending:
  393. TimeDescendingEvent();
  394. break;
  395. case AnnotationSortOrder.PageIndexAscending:
  396. PageSortEvent();
  397. break;
  398. default:
  399. break;
  400. }
  401. if (AnnotationListItems.Count > 0)
  402. {
  403. IsEmptyPanelVisibility = Visibility.Collapsed;
  404. await Task.Delay(2);
  405. //展开数据
  406. ExpandGroupHeader(AnnotationListItems, listBox);
  407. }
  408. else
  409. {
  410. if (button != null)
  411. {
  412. button.IsEnabled = true;
  413. }
  414. IsEmptyPanelVisibility = Visibility.Visible;
  415. //AnnotationListItems.AddRange(currentAnnotationArgs);
  416. //RefreshAnnotationListItems();
  417. }
  418. }
  419. /// <summary>
  420. /// 根据条件筛选列表数据
  421. /// </summary>
  422. /// <param name="annotArgsTypes"></param>
  423. /// <param name="colors"></param>
  424. /// <param name="authors"></param>
  425. /// <returns></returns>
  426. private ObservableCollection<AnnotationHandlerEventArgs> SelectAnnotationListItems(List<AnnotArgsType> annotArgsTypes, List<string> colors, List<string> authors)
  427. {
  428. ObservableCollection<AnnotationHandlerEventArgs> annotationArgs = new ObservableCollection<AnnotationHandlerEventArgs>();
  429. #region 类型 颜色 作者
  430. if (annotArgsTypes.Count > 0 && colors.Count > 0 && authors.Count > 0)
  431. {
  432. foreach (var item in CurrentAnnotationArgs)
  433. {
  434. foreach (var type in annotArgsTypes)
  435. {
  436. foreach (var color in colors)
  437. {
  438. foreach (var author in authors)
  439. {
  440. if (item.EventType == type && item.Author == author)
  441. {
  442. SelectAnnotationColors(item, color, annotationArgs);
  443. }
  444. }
  445. }
  446. }
  447. }
  448. }
  449. #endregion 类型 颜色 作者
  450. #region 颜色 作者
  451. else if (colors.Count > 0 && authors.Count > 0)
  452. {
  453. foreach (var item in CurrentAnnotationArgs)
  454. {
  455. foreach (var color in colors)
  456. {
  457. foreach (var author in authors)
  458. {
  459. if (item.Author == author)
  460. {
  461. SelectAnnotationColors(item, color, annotationArgs);
  462. }
  463. }
  464. }
  465. }
  466. }
  467. #endregion 颜色 作者
  468. #region 类型 作者
  469. else if (annotArgsTypes.Count > 0 && authors.Count > 0)
  470. {
  471. foreach (var item in CurrentAnnotationArgs)
  472. {
  473. foreach (var type in annotArgsTypes)
  474. {
  475. foreach (var author in authors)
  476. {
  477. if (item.EventType == type && item.Author == author)
  478. {
  479. annotationArgs.Add(item);
  480. }
  481. }
  482. }
  483. }
  484. }
  485. #endregion 类型 作者
  486. #region 类型 颜色
  487. else if (annotArgsTypes.Count > 0 && colors.Count > 0)
  488. {
  489. foreach (var item in CurrentAnnotationArgs)
  490. {
  491. foreach (var type in annotArgsTypes)
  492. {
  493. foreach (var color in colors)
  494. {
  495. if (item.EventType == type)
  496. {
  497. SelectAnnotationColors(item, color, annotationArgs);
  498. }
  499. }
  500. }
  501. }
  502. }
  503. #endregion 类型 颜色
  504. #region 类型
  505. else if (annotArgsTypes.Count > 0)
  506. {
  507. foreach (var item in CurrentAnnotationArgs)
  508. {
  509. foreach (var type in annotArgsTypes)
  510. {
  511. if (item.EventType == type)
  512. {
  513. annotationArgs.Add(item);
  514. }
  515. }
  516. }
  517. }
  518. #endregion 类型
  519. #region 颜色
  520. else if (colors.Count > 0)
  521. {
  522. foreach (var item in CurrentAnnotationArgs)
  523. {
  524. foreach (var color in colors)
  525. {
  526. SelectAnnotationColors(item, color, annotationArgs);
  527. }
  528. }
  529. }
  530. #endregion 颜色
  531. #region 作者
  532. else if (authors.Count > 0)
  533. {
  534. foreach (var item in CurrentAnnotationArgs)
  535. {
  536. foreach (var author in authors)
  537. {
  538. if (item.Author == author)
  539. {
  540. annotationArgs.Add(item);
  541. }
  542. }
  543. }
  544. }
  545. #endregion 作者
  546. return annotationArgs;
  547. }
  548. /// <summary>
  549. /// 根据颜色筛选注释
  550. /// </summary>
  551. /// <param name="item"></param>
  552. /// <param name="color"></param>
  553. /// <param name="annotationArgs"></param>
  554. private void SelectAnnotationColors(AnnotationHandlerEventArgs item, string color, ObservableCollection<AnnotationHandlerEventArgs> annotationArgs)
  555. {
  556. AnnotHandlerEventArgs data = item.AnnotHandlerEventArgs;
  557. switch (item.EventType)
  558. {
  559. case AnnotArgsType.AnnotFreeText://文本
  560. if (data is FreeTextAnnotArgs textAnnotArgs)
  561. {
  562. AddScreenAnnotationArgs(textAnnotArgs.FontColor, color, item, annotationArgs);
  563. }
  564. break;
  565. case AnnotArgsType.AnnotHighlight://高亮
  566. if (data is TextHighlightAnnotArgs highlightAnnotArgs)
  567. {
  568. AddScreenAnnotationArgs(highlightAnnotArgs.Color, color, item, annotationArgs);
  569. }
  570. break;
  571. case AnnotArgsType.AnnotFreehand://手绘
  572. if (data is FreehandAnnotArgs freehandAnnotArgs)
  573. {
  574. AddScreenAnnotationArgs(freehandAnnotArgs.InkColor, color, item, annotationArgs);
  575. }
  576. break;
  577. case AnnotArgsType.AnnotSquiggly://波浪线
  578. break;
  579. case AnnotArgsType.AnnotStamp://图章
  580. break;
  581. case AnnotArgsType.AnnotStrikeout://删除线
  582. if (data is TextStrikeoutAnnotArgs textStrikeoutAnnotArgs)
  583. {
  584. AddScreenAnnotationArgs(textStrikeoutAnnotArgs.Color, color, item, annotationArgs);
  585. }
  586. break;
  587. case AnnotArgsType.AnnotSticky://便签
  588. if (data is StickyAnnotArgs stickyAnnotArgs)
  589. {
  590. AddScreenAnnotationArgs(stickyAnnotArgs.Color, color, item, annotationArgs);
  591. }
  592. break;
  593. case AnnotArgsType.AnnotUnderline://下划线
  594. if (data is TextUnderlineAnnotArgs textUnderlineAnnotArgs)
  595. {
  596. AddScreenAnnotationArgs(textUnderlineAnnotArgs.Color, color, item, annotationArgs);
  597. }
  598. break;
  599. case AnnotArgsType.AnnotLine:
  600. //if ((item.AnnotHandlerEventArgs as LineAnnotArgs).HeadLineType >= (C_LINE_TYPE)1 || (item.AnnotHandlerEventArgs as LineAnnotArgs).TailLineType >= (C_LINE_TYPE)1)
  601. //{
  602. // //箭头
  603. //}
  604. //else
  605. //{
  606. // //线
  607. //}
  608. if (data is LineAnnotArgs lineAnnotArgs)
  609. {
  610. AddScreenAnnotationArgs(lineAnnotArgs.LineColor, color, item, annotationArgs);
  611. }
  612. break;
  613. case AnnotArgsType.AnnotSquare://矩形
  614. if (data is SquareAnnotArgs squareAnnotArgs)
  615. {
  616. AddScreenAnnotationArgs(squareAnnotArgs.LineColor, color, item, annotationArgs);
  617. AddScreenAnnotationArgs(squareAnnotArgs.BgColor, color, item, annotationArgs);
  618. }
  619. break;
  620. case AnnotArgsType.AnnotCircle://圆
  621. if (data is CircleAnnotArgs circleAnnotArgs)
  622. {
  623. AddScreenAnnotationArgs(circleAnnotArgs.LineColor, color, item, annotationArgs);
  624. AddScreenAnnotationArgs(circleAnnotArgs.BgColor, color, item, annotationArgs);
  625. }
  626. break;
  627. }
  628. }
  629. /// <summary>
  630. /// 对比颜色
  631. /// </summary>
  632. /// <param name="color1"></param>
  633. /// <param name="color"></param>
  634. /// <param name="item"></param>
  635. /// <param name="annotationArgs"></param>
  636. private void AddScreenAnnotationArgs(System.Windows.Media.Color color1, string color, AnnotationHandlerEventArgs item, ObservableCollection<AnnotationHandlerEventArgs> annotationArgs)
  637. {
  638. if (color1.ToString() == color)
  639. {
  640. annotationArgs.Add(item);
  641. }
  642. }
  643. /// <summary>
  644. /// 添加附注的注释
  645. /// </summary>
  646. /// <param name="obj"></param>
  647. private void AddNotesEvent(object obj)
  648. {
  649. if (obj is ListBoxItem listBoxItem)
  650. {
  651. if (listBoxItem.DataContext is AnnotationHandlerEventArgs args)
  652. {
  653. if (args.EventType != AnnotArgsType.AnnotSticky && args.EventType != AnnotArgsType.AnnotFreeText && args.EventType != AnnotArgsType.AnnotLink)
  654. {
  655. DialogParameters value = new DialogParameters();
  656. value.Add(ParameterNames.Annotation, args);
  657. dialogs.ShowDialog(DialogNames.AddAnnotationDialog, value, async e =>
  658. {
  659. if (e.Result == ButtonResult.OK && e.Parameters != null)
  660. {
  661. PdfViewer.UndoManager.CanSave = true;
  662. if (e.Parameters.ContainsKey(ParameterNames.Annotation) && e.Parameters.ContainsKey(ParameterNames.AnnotEvent))
  663. {
  664. AnnotationHandlerEventArgs annotation = e.Parameters.GetValue<AnnotationHandlerEventArgs>(ParameterNames.Annotation);
  665. RefreshOneListItem(annotation.AnnotHandlerEventArgs);
  666. }
  667. }
  668. });
  669. }
  670. }
  671. }
  672. }
  673. private async void RefreshOneListItem(AnnotHandlerEventArgs annotation)
  674. {
  675. for (int i = 0; i < AnnotationListItems.Count; i++)
  676. {
  677. if (AnnotationListItems[i].PageIndex == annotation.PageIndex && AnnotationListItems[i].AnnotIndex == annotation.AnnotIndex)
  678. {
  679. AnnotationListItems[i] = GetAddAnnotEventArgs(annotation);
  680. for (int j = 0; j < CurrentAnnotationArgs.Count; j++)
  681. {
  682. if (CurrentAnnotationArgs[j].PageIndex == annotation.PageIndex && CurrentAnnotationArgs[j].AnnotIndex == annotation.AnnotIndex)
  683. {
  684. CurrentAnnotationArgs[j] = GetAddAnnotEventArgs(annotation);
  685. break;
  686. }
  687. }
  688. if (!listBox.SelectedItems.Contains(AnnotationListItems[i]))
  689. {
  690. listBox.SelectedItem = AnnotationListItems[i];
  691. }
  692. await Task.Delay(1);//不加延时 每页的第一个注释不会展开
  693. ExpandGroupHeader(AnnotationListItems[i], listBox);
  694. await Task.Delay(1);//不加延时 会有不滚动的现象
  695. listBox.ScrollIntoView(AnnotationListItems[i]);
  696. break;
  697. }
  698. }
  699. }
  700. /// <summary>
  701. /// listboxitem鼠标左键点击,显示分组的数据
  702. /// </summary>
  703. /// <param name="obj"></param>
  704. private void ListBoxItem_PreviewMouseLeftButtonDown(object obj)
  705. {
  706. if (obj is ListBoxItem item)
  707. {
  708. var data = item.DataContext as AnnotationHandlerEventArgs;
  709. if (data != null)
  710. {
  711. PdfViewer.SelectAnnotation(data.PageIndex, data.AnnotIndex);
  712. }
  713. }
  714. }
  715. public async void UpdateAddedAnnot(int pageIndex, int annotIndex)
  716. {
  717. var annots = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  718. for (int i = 0; i < annots.Count; i++)
  719. {
  720. AnnotHandlerEventArgs item = annots[i];
  721. if (item.AnnotIndex == annotIndex && item.EventType != AnnotArgsType.AnnotRedaction)
  722. {
  723. AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
  724. if (args.AnnotHandlerEventArgs != null)
  725. {
  726. AnnotationListItems.Add(args);
  727. CurrentAnnotationArgs.Add(args);
  728. await Task.Delay(1);//不加延时 每页的第一个注释不会展开
  729. ExpandGroupHeader(args, listBox);
  730. listBox.SelectedItem = item;
  731. await Task.Delay(1);//不加延时 会有不滚动的现象
  732. listBox.ScrollIntoView(item);
  733. if (!listBox.SelectedItems.Contains(args))
  734. {
  735. listBox.SelectedItem = args;
  736. //PdfViewer.SelectAnnotation(args.PageIndex, args.AnnotIndex);
  737. }
  738. }
  739. }
  740. }
  741. if (IsEmptyPanelVisibility == Visibility.Visible && AnnotationListItems.Count > 0)
  742. {
  743. IsEmptyPanelVisibility = Visibility.Collapsed;
  744. }
  745. }
  746. public async void UpdateModifiedAnnot(int pageIndex, int annotIndex, bool isDelete)
  747. {
  748. try
  749. {
  750. var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  751. if (isDelete && items.Count == 0)//当前页的最后一次删除
  752. {
  753. for (int k = 0; k < AnnotationListItems.Count; k++)
  754. {
  755. if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  756. {
  757. AnnotationListItems.RemoveAt(k);
  758. AnnotationHandlerEventArgs annotation1 = CurrentAnnotationArgs.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  759. CurrentAnnotationArgs.Remove(annotation1);
  760. UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  761. return;
  762. }
  763. }
  764. }
  765. if (isDelete)//删除
  766. {
  767. for (int k = 0; k < AnnotationListItems.Count; k++)
  768. {
  769. //不能加item[j].annoteIndex = annotIndex 删除后必匹配不上
  770. if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  771. {
  772. AnnotationListItems.RemoveAt(k);
  773. AnnotationHandlerEventArgs annotation1 = CurrentAnnotationArgs.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  774. CurrentAnnotationArgs.Remove(annotation1);
  775. UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  776. return;
  777. }
  778. }
  779. }
  780. for (int j = 0; j < items.Count; j++)
  781. {
  782. for (int k = 0; k < AnnotationListItems.Count; k++)
  783. {
  784. if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex && items[j].AnnotIndex == annotIndex)
  785. {
  786. //AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(items[j]);
  787. AnnotationListItems[k] = GetAddAnnotEventArgs(items[j]);
  788. for (int i = 0; i < CurrentAnnotationArgs.Count; i++)
  789. {
  790. if (CurrentAnnotationArgs[i].PageIndex == pageIndex && CurrentAnnotationArgs[i].AnnotIndex == annotIndex)
  791. {
  792. CurrentAnnotationArgs[i] = GetAddAnnotEventArgs(items[j]);
  793. break;
  794. }
  795. }
  796. if (!listBox.SelectedItems.Contains(AnnotationListItems[k]))
  797. {
  798. listBox.SelectedItem = AnnotationListItems[k];
  799. //PdfViewer.SelectAnnotation(args.PageIndex, args.AnnotIndex);
  800. }
  801. await Task.Delay(1);//不加延时 每页的第一个注释不会展开
  802. ExpandGroupHeader(AnnotationListItems[k], listBox);
  803. await Task.Delay(1);//不加延时 会有不滚动的现象
  804. listBox.ScrollIntoView(AnnotationListItems[k]);
  805. }
  806. }
  807. }
  808. }
  809. catch { }
  810. }
  811. /// <summary>
  812. /// 展开item所在分组
  813. /// </summary>
  814. private void ExpandGroupHeader(AnnotationHandlerEventArgs item, ListBox listBox)
  815. {
  816. try
  817. {
  818. var groups = listBox.Items.Groups;
  819. for (int i = 0; i < groups.Count; i++)
  820. {
  821. var l = groups[i] as CollectionViewGroup;
  822. if (l.Items.Contains(item))
  823. {
  824. var scroller = GetScrollHost(listBox);
  825. var stackpanel = CommonHelper.FindVisualChild<StackPanel>(scroller);
  826. int count = VisualTreeHelper.GetChildrenCount(stackpanel);
  827. var groupItem = VisualTreeHelper.GetChild(stackpanel, i) as GroupItem;
  828. var g = CommonHelper.FindVisualChild<Expander>(groupItem);
  829. if (g != null)
  830. g.IsExpanded = true;
  831. }
  832. }
  833. }
  834. catch { }
  835. }
  836. /// <summary>
  837. /// 页面加载时
  838. /// </summary>
  839. /// <param name="obj"></param>
  840. private void Loaded(object obj)
  841. {
  842. if (obj is CompositeCommandParameter composite)
  843. {
  844. if (composite.Parameter is ListBox listBox)
  845. {
  846. this.listBox = listBox;
  847. SetGroupHeader(listBox);
  848. }
  849. }
  850. }
  851. public bool IsNavigationTarget(NavigationContext navigationContext)
  852. {
  853. return true;
  854. }
  855. public void OnNavigatedFrom(NavigationContext navigationContext)
  856. {
  857. }
  858. public void OnNavigatedTo(NavigationContext navigationContext)
  859. {
  860. var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
  861. var viewContentViewModel = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as ViewContentViewModel;
  862. if (pdfview != null && viewContentViewModel != null)
  863. {
  864. ViewContentViewModel = viewContentViewModel;
  865. PdfViewer = pdfview;
  866. AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>();
  867. AnnotationListItems = GetDocumentAnnotionList();
  868. CurrentAnnotationArgs.AddRange(AnnotationListItems);
  869. AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
  870. }
  871. }
  872. /// <summary>
  873. /// 默认按照PageIndex,分组 排序
  874. /// </summary>
  875. /// <param name="listBox"></param>
  876. private async void SetGroupHeader(ListBox listBox)
  877. {
  878. //按照PageIndex,分组 排序
  879. ICollectionView iCollectionView = CollectionViewSource.GetDefaultView(AnnotationListItems);
  880. iCollectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationHandlerEventArgs.PageIndex)));
  881. iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
  882. iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
  883. if (AnnotationListItems.Count > 0)
  884. {
  885. IsEmptyPanelVisibility = Visibility.Collapsed;
  886. await Task.Delay(5);
  887. //展开数据
  888. ExpandGroupHeader(AnnotationListItems, listBox);
  889. }
  890. else
  891. {
  892. IsEmptyPanelVisibility = Visibility.Visible;
  893. }
  894. }
  895. /// <summary>
  896. /// 展开列表项
  897. /// </summary>
  898. /// <param name="annotationListItems"></param>
  899. /// <param name="listBox"></param>
  900. private void ExpandGroupHeader(ObservableCollection<AnnotationHandlerEventArgs> annotationListItems, ListBox listBox)
  901. {
  902. try
  903. {
  904. foreach (var item in annotationListItems)
  905. {
  906. var groups = listBox.Items.Groups;
  907. for (int i = 0; i < groups.Count; i++)
  908. {
  909. var group = groups[i] as CollectionViewGroup;
  910. if (group.Items.Contains(item))
  911. {
  912. var scroller = GetScrollHost(listBox);
  913. var stackpanel = CommonHelper.FindVisualChild<StackPanel>(scroller);
  914. int count = VisualTreeHelper.GetChildrenCount(stackpanel);
  915. var groupItem = VisualTreeHelper.GetChild(stackpanel, i) as GroupItem;
  916. var g = CommonHelper.FindVisualChild<Expander>(groupItem);
  917. if (g != null)
  918. {
  919. g.IsExpanded = true;
  920. }
  921. }
  922. }
  923. }
  924. }
  925. catch { }
  926. }
  927. private ScrollViewer GetScrollHost(ListBox listBox)
  928. {
  929. if (VisualTreeHelper.GetChildrenCount(listBox) > 0)
  930. {
  931. int s = VisualTreeHelper.GetChildrenCount(listBox);
  932. Border border = VisualTreeHelper.GetChild(listBox, 0) as Border;
  933. if (border != null)
  934. {
  935. return VisualTreeHelper.GetChild(border, 0) as ScrollViewer;
  936. }
  937. }
  938. return null;
  939. }
  940. /// <summary>
  941. /// 获取listbox绑定数据
  942. /// </summary>
  943. /// <returns></returns>
  944. private ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList()
  945. {
  946. ObservableCollection<AnnotationHandlerEventArgs> list = new ObservableCollection<AnnotationHandlerEventArgs>();
  947. for (int i = 0; i < PdfViewer.Document.PageCount; i++)
  948. {
  949. var items = PdfViewer.GetAnnotCommentList(i, PdfViewer.Document);
  950. foreach (var item in items)
  951. {
  952. //原型图上,目前对波浪线的类型,在注释列表不显示
  953. if (item.EventType != AnnotArgsType.AnnotRedaction && item.EventType != AnnotArgsType.AnnotSquiggly)
  954. {
  955. AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
  956. if (args.AnnotHandlerEventArgs != null)
  957. {
  958. list.Add(args);
  959. }
  960. }
  961. }
  962. }
  963. return list;
  964. }
  965. private AnnotationHandlerEventArgs GetAddAnnotEventArgs(AnnotHandlerEventArgs item)
  966. {
  967. AnnotationHandlerEventArgs args = new AnnotationHandlerEventArgs();
  968. if (item.EventType == AnnotArgsType.AnnotFreehand)
  969. {
  970. WriteableBitmap bitmap = GetAnnotImage(PdfViewer.Document, item.PageIndex, item.AnnotIndex);
  971. args.WriteableBitmap = bitmap;
  972. }
  973. args.AnnotHandlerEventArgs = item;
  974. args.PageIndex = item.PageIndex;
  975. args.AnnotIndex = item.AnnotIndex;
  976. args.EventType = item.EventType;
  977. args.CreateTime = item.CreateTime;
  978. args.UpdateTime = item.UpdateTime;
  979. args.Content = item.Content;
  980. args.MarkupContent = item.MarkupContent;
  981. args.Author = item.Author;
  982. args.Locked = item.Locked;
  983. args.ReadOnly = item.ReadOnly;
  984. args.FormField = item.FormField;
  985. args.Document = PdfViewer.Document;
  986. return args;
  987. }
  988. /// <summary>
  989. /// 获取手绘图案
  990. /// </summary>
  991. /// <param name="doc"></param>
  992. /// <param name="pageIndex"></param>
  993. /// <param name="annotIndex"></param>
  994. /// <returns></returns>
  995. public WriteableBitmap GetAnnotImage(CPDFDocument doc, int pageIndex, int annotIndex)
  996. {
  997. if (doc == null)
  998. {
  999. return null;
  1000. }
  1001. CPDFPage docPage = doc.PageAtIndex(pageIndex, false);
  1002. if (docPage == null)
  1003. {
  1004. return null;
  1005. }
  1006. List<CPDFAnnotation> docAnnots = docPage.GetAnnotations();
  1007. foreach (CPDFAnnotation annot in docAnnots)
  1008. {
  1009. if (docAnnots.IndexOf(annot) == annotIndex)
  1010. {
  1011. CRect rawRect = annot.GetRect();
  1012. double scaleDpi = 96.0 / 72.0;
  1013. Rect paintRect = new Rect(rawRect.left * scaleDpi, rawRect.top * scaleDpi, rawRect.width() * scaleDpi, rawRect.height() * scaleDpi);
  1014. int drawWidth = (int)paintRect.Width;
  1015. int drawHeight = (int)paintRect.Height;
  1016. byte[] bitmapArray = new byte[drawWidth * drawHeight * 4];
  1017. annot.UpdateAp();
  1018. annot.RenderAnnot(drawWidth, drawHeight, bitmapArray);
  1019. WriteableBitmap wirteBitmap = new WriteableBitmap(drawWidth, drawHeight, 96, 96, PixelFormats.Bgra32, null);
  1020. wirteBitmap.WritePixels(new Int32Rect(0, 0, drawWidth, drawHeight), bitmapArray, wirteBitmap.BackBufferStride, 0);
  1021. return wirteBitmap;
  1022. }
  1023. }
  1024. return null;
  1025. }
  1026. /// <summary>
  1027. /// listbox的itemsource发生变化时
  1028. /// </summary>
  1029. /// <param name="sender"></param>
  1030. /// <param name="e"></param>
  1031. private void AnnotationListItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  1032. {
  1033. if (sender is ObservableCollection<AnnotationHandlerEventArgs> obsSender)
  1034. {
  1035. //currentAnnotationArgs.Clear();
  1036. //currentAnnotationArgs.AddRange(obsSender);
  1037. if (obsSender.Count < 1)
  1038. {
  1039. IsEmptyPanelVisibility = Visibility.Visible;
  1040. //currentAnnotationArgs.Clear();
  1041. }
  1042. else
  1043. {
  1044. IsEmptyPanelVisibility = Visibility.Collapsed;
  1045. }
  1046. }
  1047. else
  1048. {
  1049. IsEmptyPanelVisibility = Visibility.Visible;
  1050. }
  1051. }
  1052. }
  1053. }