AnnotationContentViewModel.cs 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706
  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] as AnnotationHandlerEventArgs).AnnotIndex == annotindex && (AnnotationList.Items[i] as AnnotationHandlerEventArgs).PageIndex == pageindex)
  914. {
  915. var item = AnnotationList.Items[i] as AnnotationHandlerEventArgs;
  916. if (item.EventType != AnnotArgsType.AnnotLink)
  917. {
  918. //需要手动搜寻在哪一个分组 展开分组头
  919. ExpandGroupHeader(item, AnnotationList);
  920. if (AnnotationList.SelectedItems.IndexOf(item) == -1)
  921. {
  922. AnnotationList.SelectedItem = item;
  923. }
  924. await Task.Delay(1);
  925. AnnotationList.ScrollIntoView(item);
  926. }
  927. }
  928. }
  929. }
  930. /// <summary>
  931. /// listboxitem鼠标左键点击,显示分组的数据
  932. /// </summary>
  933. /// <param name="obj"></param>
  934. private void ListBoxItem_PreviewMouseLeftButtonDown(object obj)
  935. {
  936. if (obj is ListBoxItem item)
  937. {
  938. var data = item.DataContext as AnnotationHandlerEventArgs;
  939. if (data != null)
  940. {
  941. PdfViewer.SelectAnnotation(data.PageIndex, data.AnnotIndex);
  942. }
  943. }
  944. if (obj is AnnotationHandlerEventArgs annotation)
  945. {
  946. PdfViewer.SelectAnnotation(annotation.PageIndex, annotation.AnnotIndex);
  947. }
  948. if (obj is Dictionary<int, List<int>> eventArgs)
  949. {
  950. PdfViewer.SelectAnnotation(eventArgs);
  951. }
  952. }
  953. public async void UpdateAddedAnnot(int pageIndex, int annotIndex)
  954. {
  955. var annots = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  956. for (int i = 0; i < annots.Count; i++)
  957. {
  958. AnnotHandlerEventArgs item = annots[i];
  959. if (item.AnnotIndex == annotIndex && item.EventType != AnnotArgsType.AnnotRedaction)
  960. {
  961. AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
  962. // 注释列表 不显示链接
  963. if (args.AnnotHandlerEventArgs is LinkAnnotArgs)
  964. {
  965. continue;
  966. }
  967. if (args.AnnotHandlerEventArgs != null)
  968. {
  969. AnnotationListItems.Add(args);
  970. CurrentAnnotationLists.Add(args);
  971. await Task.Delay(5);//不加延时 每页的第一个注释不会展开
  972. //添加 时 ,形状、图章、签名,添加后选中
  973. if (args.EventType == AnnotArgsType.AnnotSquare ||
  974. args.EventType == AnnotArgsType.AnnotCircle ||
  975. args.EventType == AnnotArgsType.AnnotLine ||
  976. args.EventType == AnnotArgsType.AnnotStamp
  977. /* ||args.EventType == AnnotArgsType.AnnotLink*/)
  978. {
  979. listBox.SelectedItem = args;
  980. }
  981. ExpandGroupHeader(args, listBox);
  982. // 关闭后选中关闭前的位置
  983. if (ViewContentViewModel.OpenBOTA)
  984. {
  985. await Task.Delay(5);//不加延时 会有不滚动的现象
  986. //events.GetEvent<ScrollIntoAnnotViewEvent>().Publish(new ScrollIntoAnnotViewArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, Annotation = item });
  987. listBox.ScrollIntoView(args);
  988. }
  989. //if (!listBox.SelectedItems.Contains(args))
  990. //{
  991. // listBox.SelectedItem = args;
  992. // //PdfViewer.SelectAnnotation(args.PageIndex, args.AnnotIndex);
  993. //}
  994. }
  995. }
  996. }
  997. listBox.UpdateLayout();
  998. //SetGroupHeader(listBox);
  999. if (IsEmptyPanelVisibility == Visibility.Visible && AnnotationListItems.Count > 0)
  1000. {
  1001. IsEmptyPanelVisibility = Visibility.Collapsed;
  1002. }
  1003. }
  1004. public void DeleteModifiedAnnot(int pageIndex, int annotIndex)
  1005. {
  1006. var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  1007. //if (items.Count == 0)
  1008. //{
  1009. // for (int k = 0; k < AnnotationListItems.Count; k++)
  1010. // {
  1011. // if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  1012. // {
  1013. // AnnotationListItems.RemoveAt(k);
  1014. // AnnotationHandlerEventArgs annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  1015. // CurrentAnnotationLists.Remove(annotation1);
  1016. // UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  1017. // return;
  1018. // }
  1019. // }
  1020. //}
  1021. //else
  1022. //{
  1023. for (int k = 0; k < AnnotationListItems.Count; k++)
  1024. {
  1025. //不能加item[j].annoteIndex = annotIndex 删除后必匹配不上
  1026. if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  1027. {
  1028. AnnotationHandlerEventArgs annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  1029. CurrentAnnotationLists.Remove(annotation1);
  1030. AnnotationListItems.RemoveAt(k);
  1031. UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  1032. return;
  1033. }
  1034. }
  1035. //}
  1036. }
  1037. public async void UpdateModifiedAnnot(int pageIndex, int annotIndex/*, bool isDelete*/)
  1038. {
  1039. try
  1040. {
  1041. var items = PdfViewer.GetAnnotCommentList(pageIndex, PdfViewer.Document);
  1042. #region 删除
  1043. //if (isDelete && items.Count == 0)//当前页的最后一次删除
  1044. //{
  1045. // for (int k = 0; k < AnnotationListItems.Count; k++)
  1046. // {
  1047. // if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  1048. // {
  1049. // AnnotationListItems.RemoveAt(k);
  1050. // AnnotationHandlerEventArgs annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  1051. // CurrentAnnotationLists.Remove(annotation1);
  1052. // UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  1053. // return;
  1054. // }
  1055. // }
  1056. //}
  1057. //if (isDelete)//删除
  1058. //{
  1059. // for (int k = 0; k < AnnotationListItems.Count; k++)
  1060. // {
  1061. // //不能加item[j].annoteIndex = annotIndex 删除后必匹配不上
  1062. // if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex)
  1063. // {
  1064. // AnnotationListItems.RemoveAt(k);
  1065. // AnnotationHandlerEventArgs annotation1 = CurrentAnnotationLists.FirstOrDefault(x => x.PageIndex == AnnotationListItems[k].PageIndex && x.AnnotIndex == AnnotationListItems[k].AnnotIndex);
  1066. // CurrentAnnotationLists.Remove(annotation1);
  1067. // UpdateAnnotListAfterDelete(pageIndex, annotIndex);
  1068. // return;
  1069. // }
  1070. // }
  1071. //}
  1072. #endregion 删除
  1073. for (int j = 0; j < items.Count; j++)
  1074. {
  1075. for (int k = 0; k < AnnotationListItems.Count; k++)
  1076. {
  1077. if (AnnotationListItems[k].PageIndex == pageIndex && AnnotationListItems[k].AnnotIndex == annotIndex && items[j].AnnotIndex == annotIndex)
  1078. {
  1079. AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(items[j]);
  1080. AnnotationListItems[k] = GetAddAnnotEventArgs(items[j]);
  1081. for (int i = 0; i < CurrentAnnotationLists.Count; i++)
  1082. {
  1083. if (CurrentAnnotationLists[i].PageIndex == pageIndex && CurrentAnnotationLists[i].AnnotIndex == annotIndex)
  1084. {
  1085. CurrentAnnotationLists[i] = GetAddAnnotEventArgs(items[j]);
  1086. break;
  1087. }
  1088. }
  1089. await Task.Delay(5);//不加延时 每页的第一个注释不会展开
  1090. if (ViewContentViewModel.IsMultiSelected == false)
  1091. {
  1092. if (listBox.SelectedItems.IndexOf(AnnotationListItems[k]) == -1)
  1093. //if (!listBox.SelectedItems.Contains(AnnotationListItems[k]))
  1094. {
  1095. listBox.SelectedItem = AnnotationListItems[k];
  1096. //PdfViewer.SelectAnnotation(args.PageIndex, args.AnnotIndex);
  1097. }
  1098. }
  1099. ExpandGroupHeader(AnnotationListItems[k], listBox);
  1100. await Task.Delay(5);//不加延时 会有不滚动的现象
  1101. listBox.ScrollIntoView(AnnotationListItems[k]);
  1102. }
  1103. }
  1104. }
  1105. listBox.UpdateLayout();
  1106. //SetGroupHeader(listBox);
  1107. }
  1108. catch { }
  1109. }
  1110. /// <summary>
  1111. /// 展开item所在分组
  1112. /// </summary>
  1113. private void ExpandGroupHeader(AnnotationHandlerEventArgs item, ListBox listBox)
  1114. {
  1115. try
  1116. {
  1117. var groups = listBox.Items.Groups;
  1118. if (groups != null && groups.Count > 0)
  1119. {
  1120. for (int i = 0; i < groups.Count; i++)
  1121. {
  1122. var l = groups[i] as CollectionViewGroup;
  1123. if (l.Items.Contains(item))
  1124. {
  1125. var scroller = GetScrollHost(listBox);
  1126. var stackpanel = CommonHelper.FindVisualChild<StackPanel>(scroller);
  1127. int count = VisualTreeHelper.GetChildrenCount(stackpanel);
  1128. var groupItem = VisualTreeHelper.GetChild(stackpanel, i) as GroupItem;
  1129. var g = CommonHelper.FindVisualChild<Expander>(groupItem);
  1130. if (g != null)
  1131. g.IsExpanded = true;
  1132. }
  1133. }
  1134. }
  1135. }
  1136. catch { }
  1137. }
  1138. /// <summary>
  1139. /// 页面加载时
  1140. /// </summary>
  1141. /// <param name="obj"></param>
  1142. private void Loaded(object obj)
  1143. {
  1144. if (obj is CompositeCommandParameter composite)
  1145. {
  1146. if (composite.Parameter is ListBox listBox)
  1147. {
  1148. this.listBox = listBox;
  1149. //RefreshAnnotationListItems();
  1150. SetGroupHeader(listBox);
  1151. }
  1152. }
  1153. }
  1154. public bool IsNavigationTarget(NavigationContext navigationContext)
  1155. {
  1156. return true;
  1157. }
  1158. public void OnNavigatedFrom(NavigationContext navigationContext)
  1159. {
  1160. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  1161. }
  1162. private ObservableCollection<AnnotationHandlerEventArgs> HideAnnots;
  1163. public void OnNavigatedTo(NavigationContext navigationContext)
  1164. {
  1165. var pdfview = navigationContext.Parameters[ParameterNames.PDFViewer] as CPDFViewer;
  1166. var viewContentViewModel = navigationContext.Parameters[ParameterNames.ViewContentViewModel] as ViewContentViewModel;
  1167. if (pdfview != null && viewContentViewModel != null)
  1168. {
  1169. ViewContentViewModel = viewContentViewModel;
  1170. PdfViewer = pdfview;
  1171. }
  1172. if (IsFirst)
  1173. {
  1174. IsFirst = false;
  1175. CurrentAnnotationLists = GetDocumentAnnotionList(out HideAnnots);
  1176. AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>();
  1177. AnnotationListItems.AddRange(CurrentAnnotationLists);
  1178. ICollectionView iCollectionView = CollectionViewSource.GetDefaultView(AnnotationListItems);
  1179. iCollectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationHandlerEventArgs.PageIndex)));
  1180. iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
  1181. iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
  1182. //按照PageIndex,分组 排序
  1183. SetGroupHeader(listBox);
  1184. Screen = Visibility.Collapsed;
  1185. colors.Clear();
  1186. authors.Clear();
  1187. annotArgsTypes.Clear();
  1188. }
  1189. AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
  1190. KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
  1191. KeyEventsHelper.KeyDown += ShortCut_KeyDown;
  1192. }
  1193. private void RefreshData(RefreshAnnotArgs obj)
  1194. {
  1195. if (obj.Annotation != null)
  1196. {
  1197. RefreshOneListItem(obj.Annotation.AnnotHandlerEventArgs);
  1198. }
  1199. }
  1200. private void ShortCut_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
  1201. {
  1202. if (KeyEventsHelper.IsSingleKey(System.Windows.Input.Key.Escape))
  1203. {
  1204. if (listBox != null)
  1205. {
  1206. if (listBox.SelectedItems == null)
  1207. {
  1208. return;
  1209. }
  1210. listBox.SelectedItems.Clear();
  1211. }
  1212. }
  1213. if (KeyEventsHelper.IsSingleKey(System.Windows.Input.Key.Delete))
  1214. {
  1215. if (listBox != null)
  1216. {
  1217. if (listBox.SelectedItems == null)
  1218. {
  1219. return;
  1220. }
  1221. List<int> pagelist = new List<int>();
  1222. for (int i = 0; i < listBox.SelectedItems.Count; i++)
  1223. {
  1224. AnnotationHandlerEventArgs annotation = listBox.SelectedItems[i] as AnnotationHandlerEventArgs;
  1225. pagelist.Add(listBox.Items.IndexOf(annotation));
  1226. }
  1227. pagelist.Sort();
  1228. for (int i = 0; i < pagelist.Count; i++)
  1229. {
  1230. AnnotationHandlerEventArgs annotation = listBox.Items[pagelist[pagelist.Count - i - 1]] as AnnotationHandlerEventArgs;
  1231. if (annotation == null)
  1232. {
  1233. continue;
  1234. }
  1235. DeleteCommand.Execute(annotation);
  1236. }
  1237. }
  1238. }
  1239. }
  1240. /// <summary>
  1241. /// 默认按照PageIndex,分组 排序
  1242. /// </summary>
  1243. /// <param name="listBox"></param>
  1244. private async void SetGroupHeader(ListBox listBox)
  1245. {
  1246. if (listBox == null) { return; }
  1247. #region BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
  1248. //AnnotationListItems = new ObservableCollection<AnnotationHandlerEventArgs>(AnnotationListItems.OrderBy(item => item.ClientRect.Y).ThenBy(item => item.ClientRect.X));
  1249. //CurrentAnnotationLists.AddRange(AnnotationListItems);
  1250. //AnnotationListItems.CollectionChanged += AnnotationListItems_CollectionChanged;
  1251. //ICollectionView iCollectionView = CollectionViewSource.GetDefaultView(AnnotationListItems);
  1252. //iCollectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AnnotationHandlerEventArgs.PageIndex)));
  1253. //iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.PageIndex), ListSortDirection.Ascending));
  1254. ////iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.AnnotIndex), ListSortDirection.Ascending));
  1255. //iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.ClientRect.Y), ListSortDirection.Ascending));
  1256. //iCollectionView.SortDescriptions.Add(new SortDescription(nameof(AnnotationHandlerEventArgs.ClientRect.X), ListSortDirection.Ascending));
  1257. #endregion BOTA,注释列表,添加在页面上的注释要默认按照页面上的位置排序,从上往下,从左往右排列
  1258. if (AnnotationListItems == null)
  1259. {
  1260. return;
  1261. }
  1262. if (AnnotationListItems.Count > 0)
  1263. {
  1264. IsEmptyPanelVisibility = Visibility.Collapsed;
  1265. await Task.Delay(5);
  1266. //展开数据
  1267. ExpandGroupHeader(AnnotationListItems, listBox);
  1268. }
  1269. else
  1270. {
  1271. if (CurrentAnnotationLists.Count <= 0 && HideAnnots.Count > 1)
  1272. {
  1273. IsEmptyPanelVisibility = Visibility.Visible;
  1274. IsHideAnnotPanelVisibility = Visibility.Visible;
  1275. }
  1276. else
  1277. {
  1278. IsEmptyPanelVisibility = Visibility.Visible;
  1279. IsHideAnnotPanelVisibility = Visibility.Visible;
  1280. }
  1281. }
  1282. }
  1283. /// <summary>
  1284. /// 展开列表项
  1285. /// </summary>
  1286. /// <param name="annotationListItems"></param>
  1287. /// <param name="listBox"></param>
  1288. private void ExpandGroupHeader(ObservableCollection<AnnotationHandlerEventArgs> annotationListItems, ListBox listBox)
  1289. {
  1290. try
  1291. {
  1292. foreach (var item in annotationListItems)
  1293. {
  1294. var groups = listBox.Items.Groups;
  1295. for (int i = 0; i < groups.Count; i++)
  1296. {
  1297. var group = groups[i] as CollectionViewGroup;
  1298. if (group.Items.Contains(item))
  1299. {
  1300. var scroller = GetScrollHost(listBox);
  1301. var stackpanel = CommonHelper.FindVisualChild<StackPanel>(scroller);
  1302. int count = VisualTreeHelper.GetChildrenCount(stackpanel);
  1303. var groupItem = VisualTreeHelper.GetChild(stackpanel, i) as GroupItem;
  1304. var g = CommonHelper.FindVisualChild<Expander>(groupItem);
  1305. if (g != null)
  1306. {
  1307. g.IsExpanded = true;
  1308. }
  1309. }
  1310. }
  1311. }
  1312. }
  1313. catch { }
  1314. }
  1315. private ScrollViewer GetScrollHost(ListBox listBox)
  1316. {
  1317. if (VisualTreeHelper.GetChildrenCount(listBox) > 0)
  1318. {
  1319. int s = VisualTreeHelper.GetChildrenCount(listBox);
  1320. Border border = VisualTreeHelper.GetChild(listBox, 0) as Border;
  1321. if (border != null)
  1322. {
  1323. return VisualTreeHelper.GetChild(border, 0) as ScrollViewer;
  1324. }
  1325. }
  1326. return null;
  1327. }
  1328. /// <summary>
  1329. /// 获取listbox绑定数据
  1330. /// </summary>
  1331. /// <returns></returns>
  1332. public ObservableCollection<AnnotationHandlerEventArgs> GetDocumentAnnotionList(out ObservableCollection<AnnotationHandlerEventArgs> HideAnnots)
  1333. {
  1334. ObservableCollection<AnnotationHandlerEventArgs> list = new ObservableCollection<AnnotationHandlerEventArgs>();
  1335. HideAnnots = new ObservableCollection<AnnotationHandlerEventArgs>();
  1336. for (int i = 0; i < PdfViewer.Document.PageCount; i++)
  1337. {
  1338. var items = PdfViewer.GetAnnotCommentList(i, PdfViewer.Document);
  1339. foreach (var item in items)
  1340. {
  1341. //原型图上,目前对波浪线的类型,在注释列表不显示
  1342. //注释列表 不显示链接注释
  1343. if (item.EventType != AnnotArgsType.AnnotRedaction && item.EventType != AnnotArgsType.AnnotSquiggly
  1344. && item.EventType != AnnotArgsType.AnnotLink)
  1345. {
  1346. if (item.EventType == AnnotArgsType.AnnotLink)
  1347. {
  1348. if (item is LinkAnnotArgs link)
  1349. {
  1350. if (link.LinkType == LINK_TYPE.URI)
  1351. {
  1352. continue;
  1353. }
  1354. }
  1355. }
  1356. AnnotationHandlerEventArgs args = GetAddAnnotEventArgs(item);
  1357. bool isVisible = PdfViewer.CheckAnnotVisible(args.PageIndex, args.AnnotIndex);
  1358. if (args.AnnotHandlerEventArgs != null)
  1359. {
  1360. if (isVisible)
  1361. {
  1362. list.Add(args);
  1363. }
  1364. else
  1365. {
  1366. HideAnnots.Add(args);
  1367. }
  1368. }
  1369. }
  1370. }
  1371. }
  1372. return list;
  1373. }
  1374. public AnnotationHandlerEventArgs GetAddAnnotEventArgs(AnnotHandlerEventArgs item)
  1375. {
  1376. AnnotationHandlerEventArgs args = new AnnotationHandlerEventArgs();
  1377. if (item.EventType == AnnotArgsType.AnnotFreehand)
  1378. {
  1379. BitmapImage bitmap = GetAnnotImage(PdfViewer.Document, item.PageIndex, item.AnnotIndex);
  1380. if (bitmap != null)
  1381. args.WriteableBitmap = bitmap;
  1382. }
  1383. args.ClientRect = item.ClientRect;
  1384. args.AnnotHandlerEventArgs = item;
  1385. args.PageIndex = item.PageIndex;
  1386. args.AnnotIndex = item.AnnotIndex;
  1387. args.EventType = item.EventType;
  1388. args.CreateTime = item.CreateTime;
  1389. args.UpdateTime = item.UpdateTime;
  1390. args.Content = item.Content;
  1391. args.MarkupContent = item.MarkupContent;
  1392. args.Author = item.Author;
  1393. args.Locked = item.Locked;
  1394. args.ReadOnly = item.ReadOnly;
  1395. args.FormField = item.FormField;
  1396. args.Document = PdfViewer.Document;
  1397. return args;
  1398. }
  1399. /// <summary>
  1400. /// 获取手绘图案
  1401. /// </summary>
  1402. /// <param name="doc"></param>
  1403. /// <param name="pageIndex"></param>
  1404. /// <param name="annotIndex"></param>
  1405. /// <returns></returns>
  1406. public BitmapImage GetAnnotImage(CPDFDocument doc, int pageIndex, int annotIndex)
  1407. {
  1408. if (doc == null)
  1409. {
  1410. return null;
  1411. }
  1412. CPDFPage docPage = doc.PageAtIndex(pageIndex, false);
  1413. if (docPage == null)
  1414. {
  1415. return null;
  1416. }
  1417. List<CPDFAnnotation> docAnnots = docPage.GetAnnotations();
  1418. foreach (CPDFAnnotation annot in docAnnots)
  1419. {
  1420. if (docAnnots.IndexOf(annot) == annotIndex)
  1421. {
  1422. CPDFInkAnnotation cPDFInk = (CPDFInkAnnotation)docAnnots[annotIndex];
  1423. //CRect rawRect = annot.GetRect();
  1424. CRect rawRect = cPDFInk.Rect;
  1425. double scaleDpi = 96.0 / 72.0;
  1426. Rect paintRect = new Rect(rawRect.left * scaleDpi, rawRect.top * scaleDpi, rawRect.width() * scaleDpi, rawRect.height() * scaleDpi);
  1427. int drawWidth = (int)paintRect.Width;
  1428. int drawHeight = (int)paintRect.Height;
  1429. switch (docPage.Rotation)
  1430. {
  1431. case 0:
  1432. case 2:
  1433. drawWidth = (int)paintRect.Width;
  1434. drawHeight = (int)paintRect.Height;
  1435. break;
  1436. case 1:
  1437. case 3:
  1438. drawWidth = (int)paintRect.Height;
  1439. drawHeight = (int)paintRect.Width;
  1440. break;
  1441. }
  1442. byte[] bitmapArray = new byte[drawWidth * drawHeight * 4];
  1443. annot.UpdateAp();
  1444. annot.RenderAnnot(drawWidth, drawHeight, bitmapArray);
  1445. BitmapImage bitmapImage = null;
  1446. if (drawWidth != 0 && drawHeight != 0)
  1447. {
  1448. WriteableBitmap wirteBitmap = new WriteableBitmap(drawWidth, drawHeight, 96, 96, PixelFormats.Bgra32, null);
  1449. wirteBitmap.WritePixels(new Int32Rect(0, 0, drawWidth, drawHeight), bitmapArray, wirteBitmap.BackBufferStride, 0);
  1450. bitmapImage = ConvertWriteableBitmapToBitmapImage(wirteBitmap, docPage.Rotation);
  1451. }
  1452. else
  1453. {
  1454. bitmapImage = null;
  1455. }
  1456. cPDFInk.SetRect(rawRect);
  1457. // 测试
  1458. //using (FileStream stream = new FileStream(@"C:\Users\oyxh\Desktop\images\1.png", FileMode.Create))
  1459. //{
  1460. // PngBitmapEncoder bitmapEncoder = new PngBitmapEncoder();
  1461. // bitmapEncoder.Frames.Add(BitmapFrame.Create(wirteBitmap));
  1462. // bitmapEncoder.Save(stream);
  1463. //}
  1464. return bitmapImage;
  1465. }
  1466. }
  1467. return null;
  1468. }
  1469. public BitmapImage ConvertWriteableBitmapToBitmapImage(WriteableBitmap wbm, int rotation)
  1470. {
  1471. BitmapImage bmImage = new BitmapImage();
  1472. using (MemoryStream stream = new MemoryStream())
  1473. {
  1474. PngBitmapEncoder encoder = new PngBitmapEncoder();
  1475. encoder.Frames.Add(BitmapFrame.Create(wbm));
  1476. encoder.Save(stream);
  1477. bmImage.BeginInit();
  1478. bmImage.CacheOption = BitmapCacheOption.OnLoad;
  1479. bmImage.StreamSource = stream;
  1480. switch (rotation)
  1481. {
  1482. case 0:
  1483. bmImage.Rotation = Rotation.Rotate0;
  1484. break;
  1485. case 1:
  1486. bmImage.Rotation = Rotation.Rotate90;
  1487. break;
  1488. case 2:
  1489. bmImage.Rotation = Rotation.Rotate180;
  1490. break;
  1491. case 3:
  1492. bmImage.Rotation = Rotation.Rotate270;
  1493. break;
  1494. }
  1495. bmImage.EndInit();
  1496. bmImage.Freeze();
  1497. }
  1498. return bmImage;
  1499. }
  1500. /// <summary>
  1501. /// listbox的itemsource发生变化时
  1502. /// </summary>
  1503. /// <param name="sender"></param>
  1504. /// <param name="e"></param>
  1505. private void AnnotationListItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  1506. {
  1507. if (sender is ObservableCollection<AnnotationHandlerEventArgs> obsSender)
  1508. {
  1509. //currentAnnotationArgs.Clear();
  1510. //currentAnnotationArgs.AddRange(obsSender);
  1511. if (obsSender.Count < 1)
  1512. {
  1513. if (CurrentAnnotationLists.Count <= 0)
  1514. {
  1515. IsHideAnnotPanelVisibility = Visibility.Collapsed;
  1516. IsEmptyPanelVisibility = Visibility.Visible;
  1517. }
  1518. else
  1519. {
  1520. if (isHiddenAnnot)
  1521. {
  1522. IsHideAnnotPanelVisibility = Visibility.Collapsed;
  1523. IsEmptyPanelVisibility = Visibility.Visible;
  1524. }
  1525. else
  1526. {
  1527. IsEmptyPanelVisibility = Visibility.Visible;
  1528. IsHideAnnotPanelVisibility = Visibility.Visible;
  1529. }
  1530. }
  1531. //IsEmptyPanelVisibility = Visibility.Visible;
  1532. }
  1533. else
  1534. {
  1535. IsEmptyPanelVisibility = Visibility.Collapsed;
  1536. IsHideAnnotPanelVisibility = Visibility.Collapsed;
  1537. }
  1538. }
  1539. else
  1540. {
  1541. IsEmptyPanelVisibility = Visibility.Visible;
  1542. }
  1543. }
  1544. }
  1545. }