AnnotationContentViewModel.cs 48 KB

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