AnnotationContentViewModel.cs 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710
  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.PowerPoint;
  11. using Microsoft.Office.Interop.Word;
  12. using PDF_Master.CustomControl;
  13. using PDF_Master.DataConvert;
  14. using PDF_Master.EventAggregators;
  15. using PDF_Master.Helper;
  16. using PDF_Master.Model;
  17. using PDF_Master.Model.BOTA;
  18. using PDF_Master.Views.BOTA;
  19. using PDF_Master.Views.PropertyPanel.AnnotPanel;
  20. using PDF_Master.Views.Scan;
  21. using Prism.Commands;
  22. using Prism.Events;
  23. using Prism.Mvvm;
  24. using Prism.Regions;
  25. using Prism.Services.Dialogs;
  26. using System;
  27. using System.Collections;
  28. using System.Collections.Generic;
  29. using System.Collections.ObjectModel;
  30. using System.ComponentModel;
  31. using System.Configuration;
  32. using System.Drawing;
  33. using System.IO;
  34. using System.Linq;
  35. using System.Management.Instrumentation;
  36. using System.Text;
  37. using System.Threading.Tasks;
  38. using System.Windows;
  39. using System.Windows.Annotations;
  40. using System.Windows.Annotations.Storage;
  41. using System.Windows.Controls;
  42. using System.Windows.Data;
  43. using System.Windows.Documents;
  44. using System.Windows.Forms;
  45. using System.Windows.Input;
  46. using System.Windows.Markup;
  47. using System.Windows.Media;
  48. using System.Windows.Media.Imaging;
  49. using System.Windows.Media.Media3D;
  50. using System.Windows.Shapes;
  51. using static Dropbox.Api.Files.SearchMatchType;
  52. using static Dropbox.Api.TeamLog.SpaceCapsType;
  53. using static System.Net.Mime.MediaTypeNames;
  54. using static System.Windows.Forms.VisualStyles.VisualStyleElement;
  55. using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolBar;
  56. using Border = System.Windows.Controls.Border;
  57. using ListBox = System.Windows.Controls.ListBox;
  58. using Task = System.Threading.Tasks.Task;
  59. using TextBox = System.Windows.Controls.TextBox;
  60. using Winform = System.Windows.Forms;
  61. namespace PDF_Master.ViewModels.BOTA
  62. {
  63. public class AnnotationContentViewModel : BindableBase, INavigationAware
  64. {
  65. #region 文案
  66. private string T_expand;
  67. public string T_Expand
  68. {
  69. get { return T_expand; }
  70. set
  71. {
  72. SetProperty(ref T_expand, value);
  73. }
  74. }
  75. private string T_collapse;
  76. public string T_Collapse
  77. {
  78. get { return T_collapse; }
  79. set
  80. {
  81. SetProperty(ref T_collapse, value);
  82. }
  83. }
  84. private string T_import;
  85. public string T_Import
  86. {
  87. get { return T_import; }
  88. set
  89. {
  90. SetProperty(ref T_import, value);
  91. }
  92. }
  93. private string T_copyText;
  94. public string T_CopyText
  95. {
  96. get { return T_copyText; }
  97. set
  98. {
  99. SetProperty(ref T_copyText, value);
  100. }
  101. }
  102. private string T_export;
  103. public string T_Export
  104. {
  105. get { return T_export; }
  106. set
  107. {
  108. SetProperty(ref T_export, value);
  109. }
  110. }
  111. private string T_deleteAll;
  112. public string T_DeleteAll
  113. {
  114. get { return T_deleteAll; }
  115. set
  116. {
  117. SetProperty(ref T_deleteAll, value);
  118. }
  119. }
  120. private string T_emptyTitle;
  121. public string T_EmptyTitle
  122. {
  123. get { return T_emptyTitle; }
  124. set
  125. {
  126. SetProperty(ref T_emptyTitle, value);
  127. }
  128. }
  129. private string T_emptyContext;
  130. public string T_EmptyContext
  131. {
  132. get { return T_emptyContext; }
  133. set
  134. {
  135. SetProperty(ref T_emptyContext, value);
  136. }
  137. }
  138. private string T_delete;
  139. public string T_Delete
  140. {
  141. get { return T_delete; }
  142. set
  143. {
  144. SetProperty(ref T_delete, value);
  145. }
  146. }
  147. private Visibility screen = Visibility.Collapsed;
  148. /// <summary>
  149. /// 是否有筛选条件
  150. /// </summary>
  151. public Visibility Screen
  152. {
  153. get { return screen; }
  154. set
  155. {
  156. SetProperty(ref screen, value);
  157. }
  158. }
  159. private void InitString()
  160. {
  161. T_Expand = App.MainPageLoader.GetString("Annotation_MenuExpand");
  162. T_Collapse = App.MainPageLoader.GetString("Annotation_MenuCollapse");
  163. T_Import = App.MainPageLoader.GetString("Annotation_MenuImport");
  164. T_Export = App.MainPageLoader.GetString("Annotation_MenuExport");
  165. T_DeleteAll = App.MainPageLoader.GetString("Annotation_MenuDeleteAll");
  166. T_EmptyTitle = App.MainPageLoader.GetString("Annotation_EmptyTitle");
  167. T_EmptyContext = App.MainPageLoader.GetString("Annotation_EmptyContext");
  168. T_CopyText = App.MainPageLoader.GetString("Annotation_MenuCopyText");
  169. T_Delete = App.MainPageLoader.GetString("Annotation_MenuDelete");
  170. }
  171. #endregion 文案
  172. private ListBox listBox;
  173. private IRegionManager region;
  174. private IDialogService dialogs;
  175. private IEventAggregator events;
  176. private Visibility isEmptyPanelVisibility = Visibility.Visible;
  177. public ViewContentViewModel ViewContentViewModel { get; set; }
  178. public CPDFViewer PdfViewer { get; set; }
  179. public Visibility IsEmptyPanelVisibility
  180. {
  181. get { return isEmptyPanelVisibility; }
  182. set
  183. {
  184. SetProperty(ref isEmptyPanelVisibility, value);
  185. }
  186. }
  187. private Visibility isHideAnnotPanelVisibility = Visibility.Collapsed;
  188. public Visibility IsHideAnnotPanelVisibility
  189. {
  190. get { return isHideAnnotPanelVisibility; }
  191. set
  192. {
  193. SetProperty(ref isHideAnnotPanelVisibility, value);
  194. }
  195. }
  196. private ObservableCollection<AnnotationHandlerEventArgs> currentAnnotationArgs = new ObservableCollection<AnnotationHandlerEventArgs>();
  197. public ObservableCollection<AnnotationHandlerEventArgs> CurrentAnnotationLists { get => currentAnnotationArgs; set => currentAnnotationArgs = value; }
  198. private AnnotationSortOrder annotationSortOrder = AnnotationSortOrder.PageIndexAscending;
  199. public AnnotationSortOrder AnnotationSortOrder
  200. {
  201. get { return annotationSortOrder; }
  202. set { annotationSortOrder = value; }
  203. }
  204. private ObservableCollection<AnnotationHandlerEventArgs> annotationListItems;
  205. public ObservableCollection<AnnotationHandlerEventArgs> AnnotationListItems
  206. {
  207. get { return annotationListItems; }
  208. set
  209. {
  210. SetProperty(ref annotationListItems, value);
  211. }
  212. }
  213. private bool CanIsEnabled()
  214. {
  215. if (AnnotationListItems.Count > 0)
  216. {
  217. return true;
  218. }
  219. else
  220. {
  221. return false;
  222. }
  223. }
  224. private List<string> colors = new List<string>();
  225. private List<string> authors = new List<string>();
  226. private List<AnnotArgsType> annotArgsTypes = new List<AnnotArgsType>();
  227. public DelegateCommand<object> LoadedCommand { get; set; }
  228. public DelegateCommand<object> ListBoxItemPreviewMouseLeftButtonDown { get; set; }
  229. public DelegateCommand<object> AddNotesCommand { get; set; }
  230. public DelegateCommand<object> ScreenCommand { get; set; }
  231. public DelegateCommand ExportCommentsCommand { get; set; }
  232. public DelegateCommand ImportCommentsCommand { get; set; }
  233. public DelegateCommand<object> DeleteCommand { get; set; }
  234. public DelegateCommand DeleteAllCommand { get; set; }
  235. public DelegateCommand PageSortCommand { get; set; }
  236. public DelegateCommand TimeAscendingCommand { get; set; }
  237. public DelegateCommand TimeDescendingCommand { get; set; }
  238. public string Unicode { get; private set; }
  239. private bool IsFirst = true;
  240. public AnnotationContentViewModel(IRegionManager regionManager, IDialogService dialogService, IEventAggregator eventAggregator)
  241. {
  242. region = regionManager;
  243. dialogs = dialogService;
  244. events = eventAggregator;
  245. Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
  246. LoadedCommand = new DelegateCommand<object>(Loaded);
  247. ListBoxItemPreviewMouseLeftButtonDown = new DelegateCommand<object>(ListBoxItem_PreviewMouseLeftButtonDown);
  248. AddNotesCommand = new DelegateCommand<object>(AddNotesEvent);
  249. ScreenCommand = new DelegateCommand<object>(ScreenEvent);
  250. ExportCommentsCommand = new DelegateCommand(ExportCommentsEvent, CanIsEnabled).ObservesProperty(() => AnnotationListItems);
  251. ImportCommentsCommand = new DelegateCommand(ImportCommentsEvent);
  252. DeleteCommand = new DelegateCommand<object>(DelegateEvent);
  253. DeleteAllCommand = new DelegateCommand(DeleteAllEvent, CanIsEnabled).ObservesProperty(() => AnnotationListItems);
  254. PageSortCommand = new DelegateCommand(PageSortEvent);
  255. TimeAscendingCommand = new DelegateCommand(TimeAscendingEvent);
  256. TimeDescendingCommand = new DelegateCommand(TimeDescendingEvent);
  257. InitString();
  258. events.GetEvent<RefreshAnnotEvent>().Subscribe(RefreshData, e => e.Unicode == Unicode);
  259. events.GetEvent<PageEditNotifyEvent>().Subscribe(OnNotifyEvent, e => e.Unicode == Unicode && e.Type == NotifyType.PageCountChanged);
  260. }
  261. private void OnNotifyEvent(PageEditNotifyEventArgs obj)
  262. {
  263. RefreshAnnotationListItems();
  264. }
  265. private bool isHiddenAnnot = false;
  266. public void HiddenAnnot()
  267. {
  268. isHiddenAnnot = true;
  269. colors.Clear();
  270. authors.Clear();
  271. annotArgsTypes.Clear();
  272. AnnotationListItems.Clear();
  273. CurrentAnnotationLists = GetDocumentAnnotionList(out HideAnnots);
  274. AnnotationListItems.AddRange(CurrentAnnotationLists);
  275. Screen = Visibility.Collapsed;
  276. }
  277. public void DisplayAnnot()
  278. {
  279. isHiddenAnnot = false;
  280. colors.Clear();
  281. authors.Clear();
  282. annotArgsTypes.Clear();
  283. AnnotationListItems.Clear();
  284. //AnnotationListItems = GetDocumentAnnotionList(out ObservableCollection<AnnotationHandlerEventArgs> HideAnnots);
  285. CurrentAnnotationLists = GetDocumentAnnotionList(out HideAnnots);
  286. AnnotationListItems.AddRange(CurrentAnnotationLists);
  287. RefreshAnnotationListItems();
  288. Screen = Visibility.Collapsed;
  289. }
  290. /// <summary>
  291. /// 导入注释
  292. /// </summary>
  293. /// <param name="obj"></param>
  294. private async void ImportCommentsEvent()
  295. {
  296. Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
  297. dlg.Filter = "PDF|*.xfdf";
  298. dlg.DefaultExt = ".xfdf";
  299. if (dlg.ShowDialog() == true)
  300. {
  301. try
  302. {
  303. string fileName = dlg.FileName;
  304. await Task.Delay(10);
  305. var result = PdfViewer.ImportAnnotationFromXFDFPath(fileName);
  306. if (result == false)
  307. {
  308. //MessageBoxEx.Show("导入失败", "", Winform.MessageBoxButtons.OK, Winform.MessageBoxIcon.Error);
  309. AlertsMessage alertsMessage = new AlertsMessage();
  310. alertsMessage.ShowDialog(App.MainPageLoader.GetString("Dialog_Hint"), App.MainPageLoader.GetString("Annot_ExportFailWarning"), App.ServiceLoader.GetString("Text_ok"));
  311. return;
  312. }
  313. PdfViewer.ReloadVisibleAnnots();
  314. //提取出来的注释文件 时间为空 则显示未系统当前时间
  315. CurrentAnnotationLists = GetDocumentAnnotionList(out HideAnnots);
  316. //BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
  317. //CurrentAnnotationLists = new ObservableCollection<AnnotationHandlerEventArgs>(CurrentAnnotationLists.OrderBy(item => item.ClientRect.X).ThenBy(item => item.ClientRect.Y));
  318. AnnotationListItems.Clear();
  319. AnnotationListItems.AddRange(CurrentAnnotationLists);
  320. await Task.Delay(5);
  321. RefreshAnnotationListItems(null);
  322. PdfViewer.UndoManager.CanSave = true;
  323. }
  324. catch (Exception ex)
  325. {
  326. AlertsMessage alertsMessage = new AlertsMessage();
  327. alertsMessage.ShowDialog(App.MainPageLoader.GetString("Dialog_Hint"), App.MainPageLoader.GetString("Annot_ExportFailWarning")+ex.Message, App.ServiceLoader.GetString("Text_ok"));
  328. }
  329. }
  330. }
  331. /// <summary>
  332. /// 时间倒序
  333. /// </summary>
  334. private void TimeDescendingEvent()
  335. {
  336. ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
  337. CreateTimeToDate createTimeToDate = new CreateTimeToDate();
  338. v.GroupDescriptions.Clear();
  339. v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.CreateTime), createTimeToDate));
  340. v.SortDescriptions.Clear();
  341. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.CreateTime), ListSortDirection.Descending));
  342. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Descending));
  343. AnnotationSortOrder = AnnotationSortOrder.TimeDescending;
  344. }
  345. /// <summary>
  346. /// 时间正序
  347. /// </summary>
  348. private void TimeAscendingEvent()
  349. {
  350. ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
  351. CreateTimeToDate createTimeToDate = new CreateTimeToDate();
  352. v.GroupDescriptions.Clear();
  353. v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.CreateTime), createTimeToDate));
  354. v.SortDescriptions.Clear();
  355. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.CreateTime), ListSortDirection.Ascending));
  356. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
  357. AnnotationSortOrder = AnnotationSortOrder.TimeAscending;
  358. }
  359. /// <summary>
  360. /// 页面排序
  361. /// </summary>
  362. private void PageSortEvent()
  363. {
  364. if (AnnotationListItems == null) return;
  365. if (AnnotationListItems.Count < 0) return;
  366. ICollectionView v = CollectionViewSource.GetDefaultView(AnnotationListItems);
  367. v.GroupDescriptions.Clear();
  368. v.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotHandlerEventArgs.PageIndex)));
  369. v.SortDescriptions.Clear();
  370. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
  371. v.SortDescriptions.Add(new SortDescription(nameof(AnnotHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
  372. AnnotationSortOrder = AnnotationSortOrder.PageIndexAscending;
  373. }
  374. /// <summary>
  375. /// 删除所有注释
  376. /// </summary>
  377. private void DeleteAllEvent()
  378. {
  379. //调用集中删除的接口 方便一次性undo
  380. Dictionary<int, List<int>> deleteLists = new Dictionary<int, List<int>>();
  381. for (int i = 0; i < AnnotationListItems.Count; i++)
  382. {
  383. AnnotationHandlerEventArgs item = AnnotationListItems[i] as AnnotationHandlerEventArgs;
  384. if (!deleteLists.ContainsKey(item.PageIndex))
  385. {
  386. deleteLists.Add(item.PageIndex, new List<int>() { item.AnnotIndex });
  387. }
  388. else
  389. {
  390. var pagelist = deleteLists[item.PageIndex];
  391. pagelist.Add(item.AnnotIndex);
  392. }
  393. }
  394. AlertsMessage alertsMessage = new AlertsMessage();
  395. alertsMessage.ShowDialog(" ", App.MainPageLoader.GetString("DeleteAllAnnotation_Warning"), App.ServiceLoader.GetString("Text_cancel"), App.ServiceLoader.GetString("Text_ok"));
  396. if (alertsMessage.result == ContentResult.Ok)
  397. {
  398. PdfViewer.RemovePageAnnot(deleteLists);
  399. AnnotationListItems.Clear();
  400. CurrentAnnotationLists.Clear();
  401. PdfViewer.UndoManager.CanSave = true;
  402. }
  403. }
  404. /// <summary>
  405. /// 删除注释,单个/多个
  406. /// </summary>
  407. /// <param name="obj"></param>
  408. private void DelegateEvent(object obj)
  409. {
  410. if (obj is AnnotationHandlerEventArgs annotation)
  411. {
  412. if (annotation != null)
  413. {
  414. var result = PdfViewer.RemovePageAnnot(annotation.PageIndex, annotation.AnnotIndex);
  415. if (result)
  416. {
  417. RemoveItem(annotation);
  418. }
  419. }
  420. }
  421. }
  422. public void RemoveItem(AnnotationHandlerEventArgs annotation)
  423. {
  424. AnnotationListItems.Remove(annotation);
  425. var annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == annotation.PageIndex && x.AnnotIndex == annotation.AnnotIndex);
  426. CurrentAnnotationLists.Remove(annotation1);
  427. //记录是删除了哪些页面的注释,然后更新对应页面的注释即可
  428. UpdateAnnotListAfterDelete(annotation.PageIndex, annotation.AnnotIndex);
  429. PdfViewer.UndoManager.CanSave = true;
  430. }
  431. /// <summary>
  432. /// 删除之后,更新
  433. /// </summary>
  434. /// <param name="pageIndex"></param>
  435. /// <param name="annoteIndex"></param>
  436. private void UpdateAnnotListAfterDelete(int pageIndex, int annoteIndex)
  437. {
  438. var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  439. for (int j = 0; j < items.Count; j++)//用修改赋值的方式 可以解决删除后表头折叠的问题
  440. {
  441. if (items[j].AnnotIndex >= annoteIndex)//只需要更新比删除元素索引大的注释
  442. {
  443. for (int k = 0; k < AnnotationListItems.Count; k++)
  444. {
  445. //相当于将后面的索引-1
  446. if (AnnotationListItems[k].PageIndex == pageIndex &&
  447. AnnotationListItems[k].AnnotIndex == (items[j].AnnotIndex + 1) &&
  448. string.Equals(AnnotationListItems[k].MarkupContent, items[j].MarkupContent) &&
  449. string.Equals(AnnotationListItems[k].Content, items[j].Content) &&
  450. string.Equals(AnnotationListItems[k].CreateTime, items[j].CreateTime) &&
  451. string.Equals(AnnotationListItems[k].Author, items[j].Author)
  452. )
  453. {
  454. AnnotationListItems[k].AnnotHandlerEventArgs = items[j];
  455. AnnotationListItems[k].PageIndex = items[j].PageIndex;
  456. AnnotationListItems[k].AnnotIndex = items[j].AnnotIndex;
  457. AnnotationListItems[k].EventType = items[j].EventType;
  458. AnnotationListItems[k].CreateTime = items[j].CreateTime;
  459. AnnotationListItems[k].UpdateTime = items[j].UpdateTime;
  460. if (items[j].EventType == AnnotArgsType.AnnotFreehand)
  461. {
  462. BitmapImage bitmap = GetAnnotImage(PdfViewer.Document, items[j].PageIndex, items[j].AnnotIndex);
  463. if (bitmap != null)
  464. AnnotationListItems[k].WriteableBitmap = bitmap;
  465. }
  466. AnnotationListItems[k].Content = items[j].Content;
  467. AnnotationListItems[k].MarkupContent = items[j].MarkupContent;
  468. AnnotationListItems[k].Author = items[j].Author;
  469. AnnotationListItems[k].Locked = items[j].Locked;
  470. AnnotationListItems[k].ReadOnly = items[j].ReadOnly;
  471. AnnotationListItems[k].FormField = items[j].FormField;
  472. AnnotationListItems[k].Document = PdfViewer.Document;
  473. }
  474. }
  475. }
  476. }
  477. }
  478. /// <summary>
  479. /// 导出注释
  480. /// </summary>
  481. /// <param name="obj"></param>
  482. private void ExportCommentsEvent()
  483. {
  484. if (ViewContentViewModel.CanSave)
  485. {
  486. ViewContentViewModel.SaveFile.Execute();
  487. }
  488. Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
  489. dlg.Filter = "PDF|*.xfdf";
  490. dlg.DefaultExt = ".xfdf";
  491. dlg.FileName = PdfViewer.Document.FileName;
  492. if (dlg.ShowDialog() == true)
  493. {
  494. string fileName = dlg.FileName;
  495. var result = PdfViewer.ExportAnnotationToXFDFPath(fileName);
  496. if (result)
  497. {
  498. AlertsMessage alertsMessage = new AlertsMessage();
  499. alertsMessage.ShowDialog(App.MainPageLoader.GetString("Dialog_Hint"), App.MainPageLoader.GetString("Annot_ExportSuccess"), App.ServiceLoader.GetString("Text_ok"));
  500. }
  501. else
  502. {
  503. AlertsMessage alertsMessage = new AlertsMessage();
  504. alertsMessage.ShowDialog(App.MainPageLoader.GetString("Dialog_Hint"), App.MainPageLoader.GetString("Annot_ExportSuccess"), App.ServiceLoader.GetString("Text_ok"));
  505. }
  506. }
  507. }
  508. /// <summary>
  509. /// 筛选注释
  510. /// </summary>
  511. /// <param name="obj"></param>
  512. private void ScreenEvent(object obj)
  513. {
  514. if (obj is System.Windows.Controls.Button button)
  515. {
  516. DialogParameters value = new DialogParameters();
  517. value.Add(ParameterNames.AnnotationList, CurrentAnnotationLists);
  518. value.Add(ParameterNames.AnnotArgsTypes, annotArgsTypes);
  519. value.Add(ParameterNames.AnnotationColors, colors);
  520. value.Add(ParameterNames.AnnotationAuthor, authors);
  521. dialogs.ShowDialog(DialogNames.ScreenAnnotationDialog, value, e =>
  522. {
  523. if (e.Result == ButtonResult.OK && e.Parameters != null)
  524. {
  525. if (e.Parameters.ContainsKey(ParameterNames.AnnotArgsTypes))
  526. {
  527. annotArgsTypes = e.Parameters.GetValue<List<AnnotArgsType>>(ParameterNames.AnnotArgsTypes);
  528. }
  529. if (e.Parameters.ContainsKey(ParameterNames.AnnotationColors))
  530. {
  531. colors = e.Parameters.GetValue<List<string>>(ParameterNames.AnnotationColors);
  532. }
  533. if (e.Parameters.ContainsKey(ParameterNames.AnnotationAuthor))
  534. {
  535. authors = e.Parameters.GetValue<List<string>>(ParameterNames.AnnotationAuthor);
  536. }
  537. if (annotArgsTypes.Count > 0 || colors.Count > 0 || authors.Count > 0)
  538. {
  539. ObservableCollection<AnnotationHandlerEventArgs> screenAnnotationArgs = SelectAnnotationListItems(annotArgsTypes, colors, authors);
  540. AnnotationListItems.Clear();
  541. AnnotationListItems.AddRange(screenAnnotationArgs);
  542. //BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
  543. //AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>(AnnotationListItems.OrderBy(item => item.ClientRect.Y).ThenBy(item => item.ClientRect.X));
  544. RefreshAnnotationListItems(button);
  545. //AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
  546. Screen = Visibility.Visible;
  547. }
  548. else
  549. {
  550. CleanAnnotation(button);
  551. Screen = Visibility.Collapsed;
  552. }
  553. }
  554. else if (e.Result == ButtonResult.Cancel && e.Parameters != null)
  555. {
  556. //CleanAnnotation(button);
  557. }
  558. });
  559. }
  560. }
  561. private void CleanAnnotation(System.Windows.Controls.Button button)
  562. {
  563. colors.Clear();
  564. authors.Clear();
  565. annotArgsTypes.Clear();
  566. AnnotationListItems.Clear();
  567. AnnotationListItems.AddRange(CurrentAnnotationLists);
  568. //BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
  569. //AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>(AnnotationListItems.OrderBy(item => item.ClientRect.Y).ThenBy(item => item.ClientRect.X));
  570. RefreshAnnotationListItems(button);
  571. //AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
  572. }
  573. /// <summary>
  574. /// 刷新列表数据
  575. /// </summary>
  576. /// <param name="button"></param>
  577. public async void RefreshAnnotationListItems(System.Windows.Controls.Button button = null)
  578. {
  579. switch (AnnotationSortOrder)
  580. {
  581. case AnnotationSortOrder.TimeAscending:
  582. TimeAscendingEvent();
  583. break;
  584. case AnnotationSortOrder.TimeDescending:
  585. TimeDescendingEvent();
  586. break;
  587. case AnnotationSortOrder.PageIndexAscending:
  588. PageSortEvent();
  589. break;
  590. default:
  591. break;
  592. }
  593. if (AnnotationListItems == null) return;
  594. if (AnnotationListItems.Count > 0)
  595. {
  596. IsEmptyPanelVisibility = Visibility.Collapsed;
  597. await Task.Delay(5);
  598. //展开数据
  599. ExpandGroupHeader(AnnotationListItems, listBox);
  600. }
  601. else
  602. {
  603. if (button != null)
  604. {
  605. button.IsEnabled = true;
  606. }
  607. IsEmptyPanelVisibility = Visibility.Visible;
  608. IsHideAnnotPanelVisibility = Visibility.Visible;
  609. }
  610. }
  611. /// <summary>
  612. /// 根据条件筛选列表数据
  613. /// </summary>
  614. /// <param name="annotArgsTypes"></param>
  615. /// <param name="colors"></param>
  616. /// <param name="authors"></param>
  617. /// <returns></returns>
  618. private ObservableCollection<AnnotationHandlerEventArgs> SelectAnnotationListItems(List<AnnotArgsType> annotArgsTypes, List<string> colors, List<string> authors)
  619. {
  620. ObservableCollection<AnnotationHandlerEventArgs> annotationArgs = new ObservableCollection<AnnotationHandlerEventArgs>();
  621. #region 类型 颜色 作者
  622. if (annotArgsTypes.Count > 0 && colors.Count > 0 && authors.Count > 0)
  623. {
  624. foreach (var item in CurrentAnnotationLists)
  625. {
  626. foreach (var type in annotArgsTypes)
  627. {
  628. foreach (var color in colors)
  629. {
  630. foreach (var author in authors)
  631. {
  632. if (item.EventType == type && item.Author == author)
  633. {
  634. SelectAnnotationColors(item, color, annotationArgs);
  635. }
  636. }
  637. }
  638. }
  639. }
  640. }
  641. #endregion 类型 颜色 作者
  642. #region 颜色 作者
  643. else if (colors.Count > 0 && authors.Count > 0)
  644. {
  645. foreach (var item in CurrentAnnotationLists)
  646. {
  647. foreach (var color in colors)
  648. {
  649. foreach (var author in authors)
  650. {
  651. if (item.Author == author)
  652. {
  653. SelectAnnotationColors(item, color, annotationArgs);
  654. }
  655. }
  656. }
  657. }
  658. }
  659. #endregion 颜色 作者
  660. #region 类型 作者
  661. else if (annotArgsTypes.Count > 0 && authors.Count > 0)
  662. {
  663. foreach (var item in CurrentAnnotationLists)
  664. {
  665. foreach (var type in annotArgsTypes)
  666. {
  667. foreach (var author in authors)
  668. {
  669. if (item.EventType == type && item.Author == author)
  670. {
  671. annotationArgs.Add(item);
  672. }
  673. }
  674. }
  675. }
  676. }
  677. #endregion 类型 作者
  678. #region 类型 颜色
  679. else if (annotArgsTypes.Count > 0 && colors.Count > 0)
  680. {
  681. foreach (var item in CurrentAnnotationLists)
  682. {
  683. foreach (var type in annotArgsTypes)
  684. {
  685. foreach (var color in colors)
  686. {
  687. if (item.EventType == type)
  688. {
  689. SelectAnnotationColors(item, color, annotationArgs);
  690. }
  691. }
  692. }
  693. }
  694. }
  695. #endregion 类型 颜色
  696. #region 类型
  697. else if (annotArgsTypes.Count > 0)
  698. {
  699. foreach (var item in CurrentAnnotationLists)
  700. {
  701. foreach (var type in annotArgsTypes)
  702. {
  703. if (item.EventType == type)
  704. {
  705. annotationArgs.Add(item);
  706. }
  707. }
  708. }
  709. }
  710. #endregion 类型
  711. #region 颜色
  712. else if (colors.Count > 0)
  713. {
  714. foreach (var item in CurrentAnnotationLists)
  715. {
  716. foreach (var color in colors)
  717. {
  718. SelectAnnotationColors(item, color, annotationArgs);
  719. }
  720. }
  721. }
  722. #endregion 颜色
  723. #region 作者
  724. else if (authors.Count > 0)
  725. {
  726. foreach (var item in CurrentAnnotationLists)
  727. {
  728. foreach (var author in authors)
  729. {
  730. if (item.Author == author)
  731. {
  732. annotationArgs.Add(item);
  733. }
  734. }
  735. }
  736. }
  737. #endregion 作者
  738. return annotationArgs;
  739. }
  740. /// <summary>
  741. /// 根据颜色筛选注释
  742. /// </summary>
  743. /// <param name="item"></param>
  744. /// <param name="color"></param>
  745. /// <param name="annotationArgs"></param>
  746. private void SelectAnnotationColors(AnnotationHandlerEventArgs item, string color, ObservableCollection<AnnotationHandlerEventArgs> annotationArgs)
  747. {
  748. AnnotHandlerEventArgs data = item.AnnotHandlerEventArgs;
  749. switch (item.EventType)
  750. {
  751. case AnnotArgsType.AnnotFreeText://文本
  752. if (data is FreeTextAnnotArgs textAnnotArgs)
  753. {
  754. AddScreenAnnotationArgs(textAnnotArgs.FontColor, color, item, annotationArgs);
  755. }
  756. break;
  757. case AnnotArgsType.AnnotHighlight://高亮
  758. if (data is TextHighlightAnnotArgs highlightAnnotArgs)
  759. {
  760. AddScreenAnnotationArgs(highlightAnnotArgs.Color, color, item, annotationArgs);
  761. }
  762. break;
  763. case AnnotArgsType.AnnotFreehand://手绘
  764. if (data is FreehandAnnotArgs freehandAnnotArgs)
  765. {
  766. AddScreenAnnotationArgs(freehandAnnotArgs.InkColor, color, item, annotationArgs);
  767. }
  768. break;
  769. case AnnotArgsType.AnnotSquiggly://波浪线
  770. break;
  771. case AnnotArgsType.AnnotStamp://图章
  772. break;
  773. case AnnotArgsType.AnnotStrikeout://删除线
  774. if (data is TextStrikeoutAnnotArgs textStrikeoutAnnotArgs)
  775. {
  776. AddScreenAnnotationArgs(textStrikeoutAnnotArgs.Color, color, item, annotationArgs);
  777. }
  778. break;
  779. case AnnotArgsType.AnnotSticky://便签
  780. if (data is StickyAnnotArgs stickyAnnotArgs)
  781. {
  782. AddScreenAnnotationArgs(stickyAnnotArgs.Color, color, item, annotationArgs);
  783. }
  784. break;
  785. case AnnotArgsType.AnnotUnderline://下划线
  786. if (data is TextUnderlineAnnotArgs textUnderlineAnnotArgs)
  787. {
  788. AddScreenAnnotationArgs(textUnderlineAnnotArgs.Color, color, item, annotationArgs);
  789. }
  790. break;
  791. case AnnotArgsType.AnnotLine:
  792. //if ((item.AnnotHandlerEventArgs as LineAnnotArgs).HeadLineType >= (C_LINE_TYPE)1 || (item.AnnotHandlerEventArgs as LineAnnotArgs).TailLineType >= (C_LINE_TYPE)1)
  793. //{
  794. // //箭头
  795. //}
  796. //else
  797. //{
  798. // //线
  799. //}
  800. if (data is LineAnnotArgs lineAnnotArgs)
  801. {
  802. AddScreenAnnotationArgs(lineAnnotArgs.LineColor, color, item, annotationArgs);
  803. }
  804. break;
  805. case AnnotArgsType.AnnotSquare://矩形
  806. if (data is SquareAnnotArgs squareAnnotArgs)
  807. {
  808. AddScreenAnnotationArgs(squareAnnotArgs.LineColor, color, item, annotationArgs);
  809. AddScreenAnnotationArgs(squareAnnotArgs.BgColor, color, item, annotationArgs);
  810. }
  811. break;
  812. case AnnotArgsType.AnnotCircle://圆
  813. if (data is CircleAnnotArgs circleAnnotArgs)
  814. {
  815. AddScreenAnnotationArgs(circleAnnotArgs.LineColor, color, item, annotationArgs);
  816. AddScreenAnnotationArgs(circleAnnotArgs.BgColor, color, item, annotationArgs);
  817. }
  818. break;
  819. }
  820. }
  821. /// <summary>
  822. /// 对比颜色
  823. /// </summary>
  824. /// <param name="color1"></param>
  825. /// <param name="color"></param>
  826. /// <param name="item"></param>
  827. /// <param name="annotationArgs"></param>
  828. private void AddScreenAnnotationArgs(System.Windows.Media.Color color1, string color, AnnotationHandlerEventArgs item, ObservableCollection<AnnotationHandlerEventArgs> annotationArgs)
  829. {
  830. if (color1.ToString() == color)
  831. {
  832. annotationArgs.Add(item);
  833. }
  834. }
  835. /// <summary>
  836. /// 添加附注的注释
  837. /// </summary>
  838. /// <param name="obj"></param>
  839. private void AddNotesEvent(object obj)
  840. {
  841. if (obj is ListBoxItem listBoxItem)
  842. {
  843. if (listBoxItem.DataContext is AnnotationHandlerEventArgs args)
  844. {
  845. //if (args.EventType != AnnotArgsType.AnnotSticky && args.EventType != AnnotArgsType.AnnotFreeText && args.EventType != AnnotArgsType.AnnotLink)
  846. if (args.EventType != AnnotArgsType.AnnotSticky && args.EventType != AnnotArgsType.AnnotFreeText && args.EventType != AnnotArgsType.AnnotLink/*&&
  847. args.EventType != AnnotArgsType.AnnotHighlight && args.EventType != AnnotArgsType.AnnotUnderline
  848. && args.EventType != AnnotArgsType.AnnotStrikeout*/)
  849. {
  850. DialogParameters value = new DialogParameters();
  851. value.Add(ParameterNames.Annotation, args);
  852. dialogs.ShowDialog(DialogNames.AddAnnotationDialog, value, e =>
  853. {
  854. if (e.Result == ButtonResult.OK && e.Parameters != null)
  855. {
  856. PdfViewer.UndoManager.CanSave = true;
  857. if (e.Parameters.ContainsKey(ParameterNames.Annotation) && e.Parameters.ContainsKey(ParameterNames.AnnotEvent))
  858. {
  859. AnnotationHandlerEventArgs annotation = e.Parameters.GetValue<AnnotationHandlerEventArgs>(ParameterNames.Annotation);
  860. RefreshOneListItem(annotation.AnnotHandlerEventArgs);
  861. }
  862. }
  863. });
  864. }
  865. //else if (args.EventType == AnnotArgsType.AnnotFreeText)
  866. //{
  867. // StackPanel stackPanel = CommonHelper.FindVisualChild<StackPanel>(listBoxItem);
  868. // TextBox textBox = CommonHelper.FindVisualChild<TextBox>(stackPanel);
  869. // TextBlock textBlock = CommonHelper.FindVisualChild<TextBlock>(stackPanel);
  870. // textBlock.Visibility = Visibility.Collapsed;
  871. // textBox.Visibility = Visibility.Visible;
  872. // textBox.Dispatcher.BeginInvoke(new Action(() =>
  873. // {
  874. // textBox.Focus();
  875. // textBox.SelectAll();
  876. // }));
  877. //}
  878. }
  879. }
  880. }
  881. private async void RefreshOneListItem(AnnotHandlerEventArgs annotation)
  882. {
  883. for (int i = 0; i < AnnotationListItems.Count; i++)
  884. {
  885. if (AnnotationListItems[i].PageIndex == annotation.PageIndex && AnnotationListItems[i].AnnotIndex == annotation.AnnotIndex)
  886. {
  887. AnnotationListItems[i] = GetAddAnnotEventArgs(annotation);
  888. for (int j = 0; j < CurrentAnnotationLists.Count; j++)
  889. {
  890. if (CurrentAnnotationLists[j].PageIndex == annotation.PageIndex && CurrentAnnotationLists[j].AnnotIndex == annotation.AnnotIndex)
  891. {
  892. CurrentAnnotationLists[j] = GetAddAnnotEventArgs(annotation);
  893. break;
  894. }
  895. }
  896. if (!listBox.SelectedItems.Contains(AnnotationListItems[i]))
  897. {
  898. listBox.SelectedItem = AnnotationListItems[i];
  899. }
  900. await Task.Delay(1);//不加延时 每页的第一个注释不会展开
  901. ExpandGroupHeader(AnnotationListItems[i], listBox);
  902. await Task.Delay(1);//不加延时 会有不滚动的现象
  903. listBox.ScrollIntoView(AnnotationListItems[i]);
  904. break;
  905. }
  906. }
  907. }
  908. public async void ScrollToAnnot(int pageindex, int annotindex, ListBox AnnotationList)
  909. {
  910. //var list = PdfViewer.GetAnnotCommentList(pageindex, PdfViewer.Document);
  911. for (int i = 0; i < AnnotationList.Items.Count; i++)
  912. {
  913. if(AnnotationList.Items[i] is AnnotationHandlerEventArgs item)
  914. {
  915. if (item.AnnotIndex == annotindex && item.PageIndex == pageindex)
  916. {
  917. //var item = AnnotationList.Items[i] as AnnotationHandlerEventArgs;
  918. if (item.EventType != AnnotArgsType.AnnotLink)
  919. {
  920. //需要手动搜寻在哪一个分组 展开分组头
  921. ExpandGroupHeader(item, AnnotationList);
  922. if (AnnotationList.SelectedItems.IndexOf(item) == -1)
  923. {
  924. AnnotationList.SelectedItem = item;
  925. }
  926. await Task.Delay(1);
  927. AnnotationList.ScrollIntoView(item);
  928. }
  929. }
  930. }
  931. }
  932. }
  933. /// <summary>
  934. /// listboxitem鼠标左键点击,显示分组的数据
  935. /// </summary>
  936. /// <param name="obj"></param>
  937. private void ListBoxItem_PreviewMouseLeftButtonDown(object obj)
  938. {
  939. if (obj is ListBoxItem item)
  940. {
  941. var data = item.DataContext as AnnotationHandlerEventArgs;
  942. if (data != null)
  943. {
  944. PdfViewer.SelectAnnotation(data.PageIndex, data.AnnotIndex);
  945. }
  946. }
  947. if (obj is AnnotationHandlerEventArgs annotation)
  948. {
  949. PdfViewer.SelectAnnotation(annotation.PageIndex, annotation.AnnotIndex);
  950. }
  951. if (obj is Dictionary<int, List<int>> eventArgs)
  952. {
  953. PdfViewer.SelectAnnotation(eventArgs);
  954. }
  955. }
  956. public async void UpdateAddedAnnot(int pageIndex, int annotIndex)
  957. {
  958. var annots = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  959. for (int i = 0; i < annots.Count; i++)
  960. {
  961. AnnotHandlerEventArgs item = annots[i];
  962. if (item.AnnotIndex == annotIndex && item.EventType != AnnotArgsType.AnnotRedaction)
  963. {
  964. AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
  965. // 注释列表 不显示链接
  966. if (args.AnnotHandlerEventArgs is LinkAnnotArgs)
  967. {
  968. continue;
  969. }
  970. if (args.AnnotHandlerEventArgs != null)
  971. {
  972. AnnotationListItems.Add(args);
  973. CurrentAnnotationLists.Add(args);
  974. await Task.Delay(5);//不加延时 每页的第一个注释不会展开
  975. //添加 时 ,形状、图章、签名,添加后选中
  976. if (args.EventType == AnnotArgsType.AnnotSquare ||
  977. args.EventType == AnnotArgsType.AnnotCircle ||
  978. args.EventType == AnnotArgsType.AnnotLine ||
  979. args.EventType == AnnotArgsType.AnnotStamp
  980. /* ||args.EventType == AnnotArgsType.AnnotLink*/)
  981. {
  982. listBox.SelectedItem = args;
  983. }
  984. ExpandGroupHeader(args, listBox);
  985. // 关闭后选中关闭前的位置
  986. if (ViewContentViewModel.OpenBOTA)
  987. {
  988. await Task.Delay(5);//不加延时 会有不滚动的现象
  989. //events.GetEvent<ScrollIntoAnnotViewEvent>().Publish(new ScrollIntoAnnotViewArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, Annotation = item });
  990. listBox.ScrollIntoView(args);
  991. }
  992. //if (!listBox.SelectedItems.Contains(args))
  993. //{
  994. // listBox.SelectedItem = args;
  995. // //PdfViewer.SelectAnnotation(args.PageIndex, args.AnnotIndex);
  996. //}
  997. }
  998. }
  999. }
  1000. listBox.UpdateLayout();
  1001. //SetGroupHeader(listBox);
  1002. if (IsEmptyPanelVisibility == Visibility.Visible && AnnotationListItems.Count > 0)
  1003. {
  1004. IsEmptyPanelVisibility = Visibility.Collapsed;
  1005. }
  1006. }
  1007. public void DeleteModifiedAnnot(int pageIndex, int annotIndex)
  1008. {
  1009. var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  1010. //if (items.Count == 0)
  1011. //{
  1012. // for (int k = 0; k < AnnotationListItems.Count; k++)
  1013. // {
  1014. // if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  1015. // {
  1016. // AnnotationListItems.RemoveAt(k);
  1017. // AnnotationHandlerEventArgs annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  1018. // CurrentAnnotationLists.Remove(annotation1);
  1019. // UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  1020. // return;
  1021. // }
  1022. // }
  1023. //}
  1024. //else
  1025. //{
  1026. for (int k = 0; k < AnnotationListItems.Count; k++)
  1027. {
  1028. //不能加item[j].annoteIndex = annotIndex 删除后必匹配不上
  1029. if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  1030. {
  1031. AnnotationHandlerEventArgs annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  1032. CurrentAnnotationLists.Remove(annotation1);
  1033. AnnotationListItems.RemoveAt(k);
  1034. UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  1035. return;
  1036. }
  1037. }
  1038. //}
  1039. }
  1040. public async void UpdateModifiedAnnot(int pageIndex, int annotIndex/*, bool isDelete*/)
  1041. {
  1042. try
  1043. {
  1044. var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  1045. #region 删除
  1046. //if (isDelete && items.Count == 0)//当前页的最后一次删除
  1047. //{
  1048. // for (int k = 0; k < AnnotationListItems.Count; k++)
  1049. // {
  1050. // if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  1051. // {
  1052. // AnnotationListItems.RemoveAt(k);
  1053. // AnnotationHandlerEventArgs annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  1054. // CurrentAnnotationLists.Remove(annotation1);
  1055. // UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  1056. // return;
  1057. // }
  1058. // }
  1059. //}
  1060. //if (isDelete)//删除
  1061. //{
  1062. // for (int k = 0; k < AnnotationListItems.Count; k++)
  1063. // {
  1064. // //不能加item[j].annoteIndex = annotIndex 删除后必匹配不上
  1065. // if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  1066. // {
  1067. // AnnotationListItems.RemoveAt(k);
  1068. // AnnotationHandlerEventArgs annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  1069. // CurrentAnnotationLists.Remove(annotation1);
  1070. // UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  1071. // return;
  1072. // }
  1073. // }
  1074. //}
  1075. #endregion 删除
  1076. for (int j = 0; j < items.Count; j++)
  1077. {
  1078. for (int k = 0; k < AnnotationListItems.Count; k++)
  1079. {
  1080. if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex && items[j].AnnotIndex == annotIndex)
  1081. {
  1082. AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(items[j]);
  1083. AnnotationListItems[k] = GetAddAnnotEventArgs(items[j]);
  1084. for (int i = 0; i < CurrentAnnotationLists.Count; i++)
  1085. {
  1086. if (CurrentAnnotationLists[i].PageIndex == pageIndex && CurrentAnnotationLists[i].AnnotIndex == annotIndex)
  1087. {
  1088. CurrentAnnotationLists[i] = GetAddAnnotEventArgs(items[j]);
  1089. break;
  1090. }
  1091. }
  1092. await Task.Delay(5);//不加延时 每页的第一个注释不会展开
  1093. if (ViewContentViewModel.IsMultiSelected == false)
  1094. {
  1095. if (listBox.SelectedItems.IndexOf(AnnotationListItems[k]) == -1)
  1096. //if (!listBox.SelectedItems.Contains(AnnotationListItems[k]))
  1097. {
  1098. listBox.SelectedItem = AnnotationListItems[k];
  1099. //PdfViewer.SelectAnnotation(args.PageIndex, args.AnnotIndex);
  1100. }
  1101. }
  1102. ExpandGroupHeader(AnnotationListItems[k], listBox);
  1103. await Task.Delay(5);//不加延时 会有不滚动的现象
  1104. listBox.ScrollIntoView(AnnotationListItems[k]);
  1105. }
  1106. }
  1107. }
  1108. listBox.UpdateLayout();
  1109. //SetGroupHeader(listBox);
  1110. }
  1111. catch { }
  1112. }
  1113. /// <summary>
  1114. /// 展开item所在分组
  1115. /// </summary>
  1116. private void ExpandGroupHeader(AnnotationHandlerEventArgs item, ListBox listBox)
  1117. {
  1118. try
  1119. {
  1120. var groups = listBox.Items.Groups;
  1121. if (groups != null && groups.Count > 0)
  1122. {
  1123. for (int i = 0; i < groups.Count; i++)
  1124. {
  1125. var l = groups[i] as CollectionViewGroup;
  1126. if (l.Items.Contains(item))
  1127. {
  1128. var scroller = GetScrollHost(listBox);
  1129. var stackpanel = CommonHelper.FindVisualChild<StackPanel>(scroller);
  1130. int count = VisualTreeHelper.GetChildrenCount(stackpanel);
  1131. var groupItem = VisualTreeHelper.GetChild(stackpanel, i) as GroupItem;
  1132. var g = CommonHelper.FindVisualChild<Expander>(groupItem);
  1133. if (g != null)
  1134. g.IsExpanded = true;
  1135. }
  1136. }
  1137. }
  1138. }
  1139. catch { }
  1140. }
  1141. /// <summary>
  1142. /// 页面加载时
  1143. /// </summary>
  1144. /// <param name="obj"></param>
  1145. private void Loaded(object obj)
  1146. {
  1147. if (obj is CompositeCommandParameter composite)
  1148. {
  1149. if (composite.Parameter is ListBox listBox)
  1150. {
  1151. this.listBox = listBox;
  1152. //RefreshAnnotationListItems();
  1153. SetGroupHeader(listBox);
  1154. }
  1155. }
  1156. }
  1157. public bool IsNavigationTarget(NavigationContext navigationContext)
  1158. {
  1159. return true;
  1160. }
  1161. public void OnNavigatedFrom(NavigationContext navigationContext)
  1162. {
  1163. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  1164. }
  1165. private ObservableCollection<AnnotationHandlerEventArgs> HideAnnots;
  1166. public void OnNavigatedTo(NavigationContext navigationContext)
  1167. {
  1168. var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
  1169. var viewContentViewModel = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as ViewContentViewModel;
  1170. if (pdfview != null && viewContentViewModel != null)
  1171. {
  1172. ViewContentViewModel = viewContentViewModel;
  1173. PdfViewer = pdfview;
  1174. }
  1175. if (IsFirst)
  1176. {
  1177. IsFirst = false;
  1178. CurrentAnnotationLists = GetDocumentAnnotionList(out HideAnnots);
  1179. AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>();
  1180. AnnotationListItems.AddRange(CurrentAnnotationLists);
  1181. ICollectionView iCollectionView = CollectionViewSource.GetDefaultView(AnnotationListItems);
  1182. iCollectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationHandlerEventArgs.PageIndex)));
  1183. iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
  1184. iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
  1185. //按照PageIndex,分组 排序
  1186. SetGroupHeader(listBox);
  1187. Screen = Visibility.Collapsed;
  1188. colors.Clear();
  1189. authors.Clear();
  1190. annotArgsTypes.Clear();
  1191. }
  1192. AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
  1193. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  1194. KeyEventsHelper.KeyDown += ShortCut_KeyDown;
  1195. }
  1196. private void RefreshData(RefreshAnnotArgs obj)
  1197. {
  1198. if (obj.Annotation != null)
  1199. {
  1200. RefreshOneListItem(obj.Annotation.AnnotHandlerEventArgs);
  1201. }
  1202. }
  1203. private void ShortCut_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
  1204. {
  1205. if (KeyEventsHelper.IsSingleKey(System.Windows.Input.Key.Escape))
  1206. {
  1207. if (listBox != null)
  1208. {
  1209. if (listBox.SelectedItems == null)
  1210. {
  1211. return;
  1212. }
  1213. listBox.SelectedItems.Clear();
  1214. }
  1215. }
  1216. if (KeyEventsHelper.IsSingleKey(System.Windows.Input.Key.Delete))
  1217. {
  1218. if (listBox != null)
  1219. {
  1220. if (listBox.SelectedItems == null)
  1221. {
  1222. return;
  1223. }
  1224. List<int> pagelist = new List<int>();
  1225. for (int i = 0; i < listBox.SelectedItems.Count; i++)
  1226. {
  1227. AnnotationHandlerEventArgs annotation = listBox.SelectedItems[i] as AnnotationHandlerEventArgs;
  1228. pagelist.Add(listBox.Items.IndexOf(annotation));
  1229. }
  1230. pagelist.Sort();
  1231. for (int i = 0; i < pagelist.Count; i++)
  1232. {
  1233. AnnotationHandlerEventArgs annotation = listBox.Items[pagelist[pagelist.Count - i - 1]] as AnnotationHandlerEventArgs;
  1234. if (annotation == null)
  1235. {
  1236. continue;
  1237. }
  1238. DeleteCommand.Execute(annotation);
  1239. }
  1240. }
  1241. }
  1242. }
  1243. /// <summary>
  1244. /// 默认按照PageIndex,分组 排序
  1245. /// </summary>
  1246. /// <param name="listBox"></param>
  1247. private async void SetGroupHeader(ListBox listBox)
  1248. {
  1249. if (listBox == null) { return; }
  1250. #region BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
  1251. //AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>(AnnotationListItems.OrderBy(item => item.ClientRect.Y).ThenBy(item => item.ClientRect.X));
  1252. //CurrentAnnotationLists.AddRange(AnnotationListItems);
  1253. //AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
  1254. //ICollectionView iCollectionView = CollectionViewSource.GetDefaultView(AnnotationListItems);
  1255. //iCollectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationHandlerEventArgs.PageIndex)));
  1256. //iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
  1257. ////iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
  1258. //iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.ClientRect.Y), ListSortDirection.Ascending));
  1259. //iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.ClientRect.X), ListSortDirection.Ascending));
  1260. #endregion BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
  1261. if (AnnotationListItems == null)
  1262. {
  1263. return;
  1264. }
  1265. if (AnnotationListItems.Count > 0)
  1266. {
  1267. IsEmptyPanelVisibility = Visibility.Collapsed;
  1268. await Task.Delay(5);
  1269. //展开数据
  1270. ExpandGroupHeader(AnnotationListItems, listBox);
  1271. }
  1272. else
  1273. {
  1274. if (CurrentAnnotationLists.Count <= 0 && HideAnnots.Count > 1)
  1275. {
  1276. IsEmptyPanelVisibility = Visibility.Visible;
  1277. IsHideAnnotPanelVisibility = Visibility.Visible;
  1278. }
  1279. else
  1280. {
  1281. IsEmptyPanelVisibility = Visibility.Visible;
  1282. IsHideAnnotPanelVisibility = Visibility.Visible;
  1283. }
  1284. }
  1285. }
  1286. /// <summary>
  1287. /// 展开列表项
  1288. /// </summary>
  1289. /// <param name="annotationListItems"></param>
  1290. /// <param name="listBox"></param>
  1291. private void ExpandGroupHeader(ObservableCollection<AnnotationHandlerEventArgs> annotationListItems, ListBox listBox)
  1292. {
  1293. try
  1294. {
  1295. foreach (var item in annotationListItems)
  1296. {
  1297. var groups = listBox.Items.Groups;
  1298. for (int i = 0; i < groups.Count; i++)
  1299. {
  1300. var group = groups[i] as CollectionViewGroup;
  1301. if (group.Items.Contains(item))
  1302. {
  1303. var scroller = GetScrollHost(listBox);
  1304. var stackpanel = CommonHelper.FindVisualChild<StackPanel>(scroller);
  1305. int count = VisualTreeHelper.GetChildrenCount(stackpanel);
  1306. var groupItem = VisualTreeHelper.GetChild(stackpanel, i) as GroupItem;
  1307. var g = CommonHelper.FindVisualChild<Expander>(groupItem);
  1308. if (g != null)
  1309. {
  1310. g.IsExpanded = true;
  1311. }
  1312. }
  1313. }
  1314. }
  1315. }
  1316. catch { }
  1317. }
  1318. private ScrollViewer GetScrollHost(ListBox listBox)
  1319. {
  1320. if (VisualTreeHelper.GetChildrenCount(listBox) > 0)
  1321. {
  1322. int s = VisualTreeHelper.GetChildrenCount(listBox);
  1323. Border border = VisualTreeHelper.GetChild(listBox, 0) as Border;
  1324. if (border != null)
  1325. {
  1326. return VisualTreeHelper.GetChild(border, 0) as ScrollViewer;
  1327. }
  1328. }
  1329. return null;
  1330. }
  1331. /// <summary>
  1332. /// 获取listbox绑定数据
  1333. /// </summary>
  1334. /// <returns></returns>
  1335. public ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList(out ObservableCollection<AnnotationHandlerEventArgs> HideAnnots)
  1336. {
  1337. ObservableCollection<AnnotationHandlerEventArgs> list = new ObservableCollection<AnnotationHandlerEventArgs>();
  1338. HideAnnots = new ObservableCollection<AnnotationHandlerEventArgs>();
  1339. for (int i = 0; i < PdfViewer.Document.PageCount; i++)
  1340. {
  1341. var items = PdfViewer.GetAnnotCommentList(i, PdfViewer.Document);
  1342. foreach (var item in items)
  1343. {
  1344. //原型图上,目前对波浪线的类型,在注释列表不显示
  1345. //注释列表 不显示链接注释
  1346. if (item.EventType != AnnotArgsType.AnnotRedaction && item.EventType != AnnotArgsType.AnnotSquiggly
  1347. && item.EventType != AnnotArgsType.AnnotLink)
  1348. {
  1349. if (item.EventType == AnnotArgsType.AnnotLink)
  1350. {
  1351. if (item is LinkAnnotArgs link)
  1352. {
  1353. if (link.LinkType == LINK_TYPE.URI)
  1354. {
  1355. continue;
  1356. }
  1357. }
  1358. }
  1359. AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
  1360. bool isVisible = PdfViewer.CheckAnnotVisible(args.PageIndex, args.AnnotIndex);
  1361. if (args.AnnotHandlerEventArgs != null)
  1362. {
  1363. if (isVisible)
  1364. {
  1365. list.Add(args);
  1366. }
  1367. else
  1368. {
  1369. HideAnnots.Add(args);
  1370. }
  1371. }
  1372. }
  1373. }
  1374. }
  1375. return list;
  1376. }
  1377. public AnnotationHandlerEventArgs GetAddAnnotEventArgs(AnnotHandlerEventArgs item)
  1378. {
  1379. AnnotationHandlerEventArgs args = new AnnotationHandlerEventArgs();
  1380. if (item.EventType == AnnotArgsType.AnnotFreehand)
  1381. {
  1382. BitmapImage bitmap = GetAnnotImage(PdfViewer.Document, item.PageIndex, item.AnnotIndex);
  1383. if (bitmap != null)
  1384. args.WriteableBitmap = bitmap;
  1385. }
  1386. args.ClientRect = item.ClientRect;
  1387. args.AnnotHandlerEventArgs = item;
  1388. args.PageIndex = item.PageIndex;
  1389. args.AnnotIndex = item.AnnotIndex;
  1390. args.EventType = item.EventType;
  1391. args.CreateTime = item.CreateTime;
  1392. args.UpdateTime = item.UpdateTime;
  1393. args.Content = item.Content;
  1394. args.MarkupContent = item.MarkupContent;
  1395. args.Author = item.Author;
  1396. args.Locked = item.Locked;
  1397. args.ReadOnly = item.ReadOnly;
  1398. args.FormField = item.FormField;
  1399. args.Document = PdfViewer.Document;
  1400. return args;
  1401. }
  1402. /// <summary>
  1403. /// 获取手绘图案
  1404. /// </summary>
  1405. /// <param name="doc"></param>
  1406. /// <param name="pageIndex"></param>
  1407. /// <param name="annotIndex"></param>
  1408. /// <returns></returns>
  1409. public BitmapImage GetAnnotImage(CPDFDocument doc, int pageIndex, int annotIndex)
  1410. {
  1411. if (doc == null)
  1412. {
  1413. return null;
  1414. }
  1415. CPDFPage docPage = doc.PageAtIndex(pageIndex, false);
  1416. if (docPage == null)
  1417. {
  1418. return null;
  1419. }
  1420. List<CPDFAnnotation> docAnnots = docPage.GetAnnotations();
  1421. foreach (CPDFAnnotation annot in docAnnots)
  1422. {
  1423. if (docAnnots.IndexOf(annot) == annotIndex)
  1424. {
  1425. CPDFInkAnnotation cPDFInk = (CPDFInkAnnotation)docAnnots[annotIndex];
  1426. //CRect rawRect = annot.GetRect();
  1427. CRect rawRect = cPDFInk.Rect;
  1428. double scaleDpi = 96.0 / 72.0;
  1429. Rect paintRect = new Rect(rawRect.left * scaleDpi, rawRect.top * scaleDpi, rawRect.width() * scaleDpi, rawRect.height() * scaleDpi);
  1430. int drawWidth = (int)paintRect.Width;
  1431. int drawHeight = (int)paintRect.Height;
  1432. switch (docPage.Rotation)
  1433. {
  1434. case 0:
  1435. case 2:
  1436. drawWidth = (int)paintRect.Width;
  1437. drawHeight = (int)paintRect.Height;
  1438. break;
  1439. case 1:
  1440. case 3:
  1441. drawWidth = (int)paintRect.Height;
  1442. drawHeight = (int)paintRect.Width;
  1443. break;
  1444. }
  1445. byte[] bitmapArray = new byte[drawWidth * drawHeight * 4];
  1446. annot.UpdateAp();
  1447. annot.RenderAnnot(drawWidth, drawHeight, bitmapArray);
  1448. BitmapImage bitmapImage = null;
  1449. if (drawWidth != 0 && drawHeight != 0)
  1450. {
  1451. WriteableBitmap wirteBitmap = new WriteableBitmap(drawWidth, drawHeight, 96, 96, PixelFormats.Bgra32, null);
  1452. wirteBitmap.WritePixels(new Int32Rect(0, 0, drawWidth, drawHeight), bitmapArray, wirteBitmap.BackBufferStride, 0);
  1453. bitmapImage = ConvertWriteableBitmapToBitmapImage(wirteBitmap, docPage.Rotation);
  1454. }
  1455. else
  1456. {
  1457. bitmapImage = null;
  1458. }
  1459. cPDFInk.SetRect(rawRect);
  1460. // 测试
  1461. //using (FileStream stream = new FileStream(@"C:\Users\oyxh\Desktop\images\1.png", FileMode.Create))
  1462. //{
  1463. // PngBitmapEncoder bitmapEncoder = new PngBitmapEncoder();
  1464. // bitmapEncoder.Frames.Add(BitmapFrame.Create(wirteBitmap));
  1465. // bitmapEncoder.Save(stream);
  1466. //}
  1467. return bitmapImage;
  1468. }
  1469. }
  1470. return null;
  1471. }
  1472. public BitmapImage ConvertWriteableBitmapToBitmapImage(WriteableBitmap wbm, int rotation)
  1473. {
  1474. BitmapImage bmImage = new BitmapImage();
  1475. using (MemoryStream stream = new MemoryStream())
  1476. {
  1477. PngBitmapEncoder encoder = new PngBitmapEncoder();
  1478. encoder.Frames.Add(BitmapFrame.Create(wbm));
  1479. encoder.Save(stream);
  1480. bmImage.BeginInit();
  1481. bmImage.CacheOption = BitmapCacheOption.OnLoad;
  1482. bmImage.StreamSource = stream;
  1483. switch (rotation)
  1484. {
  1485. case 0:
  1486. bmImage.Rotation = Rotation.Rotate0;
  1487. break;
  1488. case 1:
  1489. bmImage.Rotation = Rotation.Rotate90;
  1490. break;
  1491. case 2:
  1492. bmImage.Rotation = Rotation.Rotate180;
  1493. break;
  1494. case 3:
  1495. bmImage.Rotation = Rotation.Rotate270;
  1496. break;
  1497. }
  1498. bmImage.EndInit();
  1499. bmImage.Freeze();
  1500. }
  1501. return bmImage;
  1502. }
  1503. /// <summary>
  1504. /// listbox的itemsource发生变化时
  1505. /// </summary>
  1506. /// <param name="sender"></param>
  1507. /// <param name="e"></param>
  1508. private void AnnotationListItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  1509. {
  1510. if (sender is ObservableCollection<AnnotationHandlerEventArgs> obsSender)
  1511. {
  1512. //currentAnnotationArgs.Clear();
  1513. //currentAnnotationArgs.AddRange(obsSender);
  1514. if (obsSender.Count < 1)
  1515. {
  1516. if (CurrentAnnotationLists.Count <= 0)
  1517. {
  1518. IsHideAnnotPanelVisibility = Visibility.Collapsed;
  1519. IsEmptyPanelVisibility = Visibility.Visible;
  1520. }
  1521. else
  1522. {
  1523. if (isHiddenAnnot)
  1524. {
  1525. IsHideAnnotPanelVisibility = Visibility.Collapsed;
  1526. IsEmptyPanelVisibility = Visibility.Visible;
  1527. }
  1528. else
  1529. {
  1530. IsEmptyPanelVisibility = Visibility.Visible;
  1531. IsHideAnnotPanelVisibility = Visibility.Visible;
  1532. }
  1533. }
  1534. //IsEmptyPanelVisibility = Visibility.Visible;
  1535. }
  1536. else
  1537. {
  1538. IsEmptyPanelVisibility = Visibility.Collapsed;
  1539. IsHideAnnotPanelVisibility = Visibility.Collapsed;
  1540. }
  1541. }
  1542. else
  1543. {
  1544. IsEmptyPanelVisibility = Visibility.Visible;
  1545. }
  1546. }
  1547. }
  1548. }