CPDFAnnotationControl.xaml.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  1. using Compdfkit_Tools.Data;
  2. using Compdfkit_Tools.PDFControlUI;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Media.Imaging;
  8. using Compdfkit_Tools.Annotation.PDFAnnotationPanel.PDFAnnotationUI;
  9. using System.IO;
  10. using System.Windows.Ink;
  11. using Compdfkit_Tools.Annotation.PDFAnnotationUI;
  12. using Microsoft.Win32;
  13. using System.Windows.Media;
  14. using Compdfkit_Tools.Properties;
  15. using static ComPDFKit.Tool.CPDFToolManager;
  16. using ComPDFKit.PDFAnnotation;
  17. using ComPDFKit.Tool;
  18. using ComPDFKit.Tool.Help;
  19. using ComPDFKit.Tool.SettingParam;
  20. using ComPDFKit.Import;
  21. using ComPDFKitViewer.BaseObject;
  22. namespace Compdfkit_Tools.PDFControl
  23. {
  24. public partial class CPDFAnnotationControl : UserControl
  25. {
  26. private bool isTempPanel = false;
  27. private CPDFAnnotationType currentAnnotationType = CPDFAnnotationType.Unknow;
  28. private PDFViewControl pdfViewerControl;
  29. private UIElement annotationPanel = null;
  30. private UIElement tempAnnotationPanel = null;
  31. private CPDFMarkupUI pdfHighlightUI;
  32. private CPDFMarkupUI pdfUnderlineUI;
  33. private CPDFMarkupUI pdfSquigglyUI;
  34. private CPDFMarkupUI pdfStrikeoutUI;
  35. private CPDFShapeUI pdfSquareUI;
  36. private CPDFShapeUI pdfCircleUI;
  37. private CPDFShapeUI pdfLineUI;
  38. private CPDFShapeUI pdfArrowUI;
  39. private CPDFFreehandUI pdfFreehandUI;
  40. private CPDFFreeTextUI pdfFreeTextUI;
  41. private CPDFNoteUI pdfNoteUI;
  42. private CPDFStampUI pdfStampUI;
  43. private CPDFSignatureUI pdfSignatureUI;
  44. private CPDFLinkUI pdfLinkUI;
  45. private bool disableClean;
  46. public event EventHandler ClearAnnotationBar;
  47. public CPDFAnnotationControl()
  48. {
  49. InitializeComponent();
  50. }
  51. public void SetPDFViewer(PDFViewControl pdfViewer)
  52. {
  53. if (this.pdfViewerControl != null)
  54. {
  55. UnLoadPDFViewHandler();
  56. }
  57. this.pdfViewerControl = pdfViewer;
  58. LoadPDFViewHandler();
  59. }
  60. public void LoadPDFViewHandler()
  61. {
  62. if (this.pdfViewerControl != null)
  63. {
  64. pdfViewerControl.PDFToolManager.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler; ;
  65. //this.pdfViewerControl.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
  66. //this.pdfViewerControl.AnnotEditHandler -= PdfViewer_AnnotEditHandler;
  67. //this.pdfViewerControl.AnnotEditHandler += PdfViewer_AnnotEditHandler;
  68. }
  69. }
  70. //private void PdfViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  71. //{
  72. // if (e != null && e.Count > 0)
  73. // {
  74. // if (e[0].EditAction == ActionType.Del)
  75. // {
  76. // if (pdfViewerControl.MouseMode == MouseModes.AnnotCreate && pdfViewerControl.ToolManager.CurrentAnnotArgs is EraseArgs)
  77. // {
  78. // return;
  79. // }
  80. // SetAnnotEventData(null);
  81. // }
  82. // if (e[0].EditAction == ActionType.Modify && e[0].EditAnnotArgs != null && e[0].EditAnnotArgs.EventType == AnnotArgsType.AnnotSticky)
  83. // {
  84. // CPDFNoteUI tempUI = annotationPanel as CPDFNoteUI;
  85. // if (tempUI == null || tempUI.annotAttribEvent == null)
  86. // {
  87. // tempUI = tempAnnotationPanel as CPDFNoteUI;
  88. // }
  89. // if (tempUI == null || tempUI.annotAttribEvent == null)
  90. // {
  91. // tempUI = pdfNoteUI;
  92. // }
  93. // if (tempUI != null && tempUI.annotAttribEvent != null)
  94. // {
  95. // AnnotAttribEvent oldEvent = tempUI.annotAttribEvent;
  96. // oldEvent.Attribs[AnnotAttrib.NoteText] = e[0].EditAnnotArgs.Content;
  97. // tempUI.SetPresentAnnotAttrib(oldEvent);
  98. // }
  99. // }
  100. // if (e[0].EditAction == ActionType.Add && e[0].EditAnnotArgs.EventType == AnnotArgsType.AnnotStamp)
  101. // {
  102. // pdfViewerControl.SetMouseMode(MouseModes.PanTool);
  103. // }
  104. // }
  105. //}
  106. public void UnLoadPDFViewHandler()
  107. {
  108. if (this.pdfViewerControl != null)
  109. {
  110. //this.pdfViewerControl.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  111. }
  112. }
  113. private void AnnotationControl_Loaded(object sender, RoutedEventArgs e)
  114. {
  115. LoadPDFViewHandler();
  116. }
  117. private void AnnotationControl_Unloaded(object sender, RoutedEventArgs e)
  118. {
  119. UnLoadPDFViewHandler();
  120. }
  121. private UIElement GetAnnotationPanel()
  122. {
  123. return AnnotationPanelContainer.Child;
  124. }
  125. private void SetAnnotationPanel(UIElement newChild)
  126. {
  127. AnnotationPanelContainer.Child = newChild;
  128. }
  129. private void ExpandPanel()
  130. {
  131. AnnotationPanelContainer.Visibility = Visibility.Visible;
  132. }
  133. private void ChangeAnnotationData()
  134. {
  135. switch (currentAnnotationType)
  136. {
  137. case CPDFAnnotationType.Highlight:
  138. case CPDFAnnotationType.Underline:
  139. case CPDFAnnotationType.Squiggly:
  140. case CPDFAnnotationType.Strikeout:
  141. (annotationPanel as CPDFMarkupUI).PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
  142. (annotationPanel as CPDFMarkupUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
  143. SetAnnotationProperty((annotationPanel as CPDFMarkupUI).GetMarkupData());
  144. break;
  145. case CPDFAnnotationType.Square:
  146. case CPDFAnnotationType.Circle:
  147. case CPDFAnnotationType.Line:
  148. case CPDFAnnotationType.Arrow:
  149. (annotationPanel as CPDFShapeUI).PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
  150. (annotationPanel as CPDFShapeUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
  151. SetAnnotationProperty((annotationPanel as CPDFShapeUI).GetShapeData());
  152. break;
  153. case CPDFAnnotationType.Note:
  154. (annotationPanel as CPDFNoteUI).PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
  155. (annotationPanel as CPDFNoteUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
  156. SetAnnotationProperty((annotationPanel as CPDFNoteUI).GetNoteData());
  157. break;
  158. case CPDFAnnotationType.Freehand:
  159. (annotationPanel as CPDFFreehandUI).PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
  160. (annotationPanel as CPDFFreehandUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
  161. SetAnnotationProperty((annotationPanel as CPDFFreehandUI).GetFreehandData());
  162. break;
  163. case CPDFAnnotationType.FreeText:
  164. (annotationPanel as CPDFFreeTextUI).PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
  165. (annotationPanel as CPDFFreeTextUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
  166. SetAnnotationProperty((annotationPanel as CPDFFreeTextUI).GetFreeTextData());
  167. break;
  168. case CPDFAnnotationType.Stamp:
  169. (annotationPanel as CPDFStampUI).PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
  170. (annotationPanel as CPDFStampUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
  171. break;
  172. case CPDFAnnotationType.Signature:
  173. (annotationPanel as CPDFSignatureUI).PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
  174. (annotationPanel as CPDFSignatureUI).PropertyChanged += CPDFAnnotationControl_PropertyChanged;
  175. break;
  176. default:
  177. break;
  178. }
  179. }
  180. private void SetAnnotationProperty(CPDFAnnotationData pdfAnnotationData = null)
  181. {
  182. if (pdfAnnotationData == null)
  183. {
  184. pdfViewerControl.PDFToolManager.SetToolType(ToolType.Pan);
  185. return;
  186. }
  187. CPDFAnnotationType annotationType = pdfAnnotationData.AnnotationType;
  188. AnnotParam annotHandlerEventArgs = null;
  189. switch (annotationType)
  190. {
  191. case CPDFAnnotationType.Highlight:
  192. {
  193. CPDFMarkupData highlightData = pdfAnnotationData as CPDFMarkupData;
  194. annotHandlerEventArgs = new HighlightParam();
  195. byte[] Color = new byte[] { highlightData.Color.R, highlightData.Color.G, highlightData.Color.B };
  196. (annotHandlerEventArgs as HighlightParam).HighlightColor = Color;
  197. (annotHandlerEventArgs as HighlightParam).Transparency = (int)(highlightData.Opacity * 255);
  198. (annotHandlerEventArgs as HighlightParam).Content = highlightData.Note;
  199. (annotHandlerEventArgs as HighlightParam).Author = highlightData.Author;
  200. (annotHandlerEventArgs as HighlightParam).Locked = highlightData.IsLocked;
  201. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT);
  202. }
  203. break;
  204. case CPDFAnnotationType.Underline:
  205. {
  206. CPDFMarkupData underlineData = pdfAnnotationData as CPDFMarkupData;
  207. annotHandlerEventArgs = new UnderlineParam();
  208. byte[] Color = new byte[] { underlineData.Color.R, underlineData.Color.G, underlineData.Color.B };
  209. (annotHandlerEventArgs as UnderlineParam).UnderlineColor = Color;
  210. (annotHandlerEventArgs as UnderlineParam).Transparency = (int)(underlineData.Opacity * 255);
  211. (annotHandlerEventArgs as UnderlineParam).Author = underlineData.Author;
  212. (annotHandlerEventArgs as UnderlineParam).Content = underlineData.Note;
  213. (annotHandlerEventArgs as UnderlineParam).Locked = underlineData.IsLocked;
  214. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE);
  215. }
  216. break;
  217. case CPDFAnnotationType.Strikeout:
  218. {
  219. CPDFMarkupData strikeoutData = pdfAnnotationData as CPDFMarkupData;
  220. annotHandlerEventArgs = new StrikeoutParam();
  221. byte[] Color = new byte[] { strikeoutData.Color.R, strikeoutData.Color.G, strikeoutData.Color.B };
  222. (annotHandlerEventArgs as StrikeoutParam).StrikeoutColor = Color;
  223. (annotHandlerEventArgs as StrikeoutParam).Transparency = (int)(strikeoutData.Opacity * 255);
  224. (annotHandlerEventArgs as StrikeoutParam).Locked = strikeoutData.IsLocked;
  225. (annotHandlerEventArgs as StrikeoutParam).Author = strikeoutData.Author;
  226. (annotHandlerEventArgs as StrikeoutParam).Content = strikeoutData.Note;
  227. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT);
  228. }
  229. break;
  230. case CPDFAnnotationType.Squiggly:
  231. {
  232. CPDFMarkupData squigglyData = pdfAnnotationData as CPDFMarkupData;
  233. annotHandlerEventArgs = new SquigglyParam();
  234. byte[] Color = new byte[] { squigglyData.Color.R, squigglyData.Color.G, squigglyData.Color.B };
  235. (annotHandlerEventArgs as SquigglyParam).SquigglyColor = Color;
  236. (annotHandlerEventArgs as SquigglyParam).Transparency = (int)(squigglyData.Opacity * 255);
  237. (annotHandlerEventArgs as SquigglyParam).Locked = squigglyData.IsLocked;
  238. (annotHandlerEventArgs as SquigglyParam).Author = squigglyData.Author;
  239. (annotHandlerEventArgs as SquigglyParam).Content = squigglyData.Note;
  240. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY);
  241. }
  242. break;
  243. case CPDFAnnotationType.Square:
  244. {
  245. CPDFShapeData squareData = pdfAnnotationData as CPDFShapeData;
  246. annotHandlerEventArgs = new SquareParam();
  247. byte[] LineColor = new byte[] { squareData.BorderColor.R, squareData.BorderColor.G, squareData.BorderColor.B };
  248. (annotHandlerEventArgs as SquareParam).LineColor = LineColor;
  249. byte[] FillColor = new byte[] { squareData.FillColor.R, squareData.FillColor.G, squareData.FillColor.B };
  250. (annotHandlerEventArgs as SquareParam).BgColor = FillColor;
  251. (annotHandlerEventArgs as SquareParam).LineWidth = squareData.Thickness;
  252. (annotHandlerEventArgs as SquareParam).Transparency = (int)(squareData.Opacity * 255);
  253. ParamConverter.ParseDashStyle(squareData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle);
  254. (annotHandlerEventArgs as SquareParam).LineDash = LineDash;
  255. (annotHandlerEventArgs as SquareParam).BorderStyle = BorderStyle;
  256. (annotHandlerEventArgs as SquareParam).Author = squareData.Author;
  257. (annotHandlerEventArgs as SquareParam).Content = squareData.Note;
  258. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE);
  259. }
  260. break;
  261. case CPDFAnnotationType.Circle:
  262. {
  263. CPDFShapeData cicleData = pdfAnnotationData as CPDFShapeData;
  264. annotHandlerEventArgs = new CircleParam();
  265. byte[] LineColor = new byte[] { cicleData.BorderColor.R, cicleData.BorderColor.G, cicleData.BorderColor.B };
  266. (annotHandlerEventArgs as CircleParam).LineColor = LineColor;
  267. byte[] BgColor = new byte[] { cicleData.FillColor.R, cicleData.FillColor.G, cicleData.FillColor.B };
  268. (annotHandlerEventArgs as CircleParam).BgColor = BgColor;
  269. (annotHandlerEventArgs as CircleParam).LineWidth = cicleData.Thickness;
  270. (annotHandlerEventArgs as CircleParam).Transparency = (int)(cicleData.Opacity * 255);
  271. ParamConverter.ParseDashStyle(cicleData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle);
  272. (annotHandlerEventArgs as CircleParam).LineDash = LineDash;
  273. (annotHandlerEventArgs as CircleParam).BorderStyle = BorderStyle;
  274. (annotHandlerEventArgs as CircleParam).Author = cicleData.Author;
  275. (annotHandlerEventArgs as CircleParam).Content = cicleData.Note;
  276. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE);
  277. }
  278. break;
  279. case CPDFAnnotationType.Arrow:
  280. case CPDFAnnotationType.Line:
  281. {
  282. CPDFLineShapeData lineData = pdfAnnotationData as CPDFLineShapeData;
  283. annotHandlerEventArgs = new LineParam();
  284. byte[] LineColor = new byte[] { lineData.BorderColor.R, lineData.BorderColor.G, lineData.BorderColor.B };
  285. (annotHandlerEventArgs as LineParam).LineColor = LineColor;
  286. (annotHandlerEventArgs as LineParam).LineWidth = lineData.Thickness;
  287. (annotHandlerEventArgs as LineParam).Transparency = (int)(lineData.Opacity * 255);
  288. ParamConverter.ParseDashStyle(lineData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle);
  289. (annotHandlerEventArgs as LineParam).LineDash = LineDash;
  290. (annotHandlerEventArgs as LineParam).BorderStyle = BorderStyle;
  291. (annotHandlerEventArgs as LineParam).HeadLineType = lineData.LineType.HeadLineType;
  292. (annotHandlerEventArgs as LineParam).TailLineType = lineData.LineType.TailLineType;
  293. (annotHandlerEventArgs as LineParam).Author = lineData.Author;
  294. (annotHandlerEventArgs as LineParam).Content = lineData.Note;
  295. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINE);
  296. }
  297. break;
  298. case CPDFAnnotationType.Note:
  299. {
  300. CPDFNoteData noteData = pdfAnnotationData as CPDFNoteData;
  301. annotHandlerEventArgs = new StickyNoteParam();
  302. byte[] StickyNoteColor = new byte[] { noteData.BorderColor.R, noteData.BorderColor.G, noteData.BorderColor.B };
  303. (annotHandlerEventArgs as StickyNoteParam).StickyNoteColor = StickyNoteColor;
  304. (annotHandlerEventArgs as StickyNoteParam).Content = noteData.Note;
  305. (annotHandlerEventArgs as StickyNoteParam).Transparency = 1;
  306. (annotHandlerEventArgs as StickyNoteParam).Author = noteData.Author;
  307. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_TEXT);
  308. }
  309. break;
  310. case CPDFAnnotationType.Freehand:
  311. {
  312. CPDFFreehandData freehandData = pdfAnnotationData as CPDFFreehandData;
  313. annotHandlerEventArgs = new InkParam();
  314. byte[] LineColor = new byte[] { freehandData.BorderColor.R, freehandData.BorderColor.G, freehandData.BorderColor.B };
  315. (annotHandlerEventArgs as InkParam).InkColor = LineColor;
  316. (annotHandlerEventArgs as InkParam).Thickness = freehandData.Thickness;
  317. (annotHandlerEventArgs as InkParam).Transparency = (int)(freehandData.Opacity * 255);
  318. (annotHandlerEventArgs as InkParam).Content = freehandData.Note;
  319. (annotHandlerEventArgs as InkParam).Author = freehandData.Author;
  320. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_INK);
  321. }
  322. break;
  323. case CPDFAnnotationType.FreeText:
  324. {
  325. CPDFFreeTextData freeTextData = pdfAnnotationData as CPDFFreeTextData;
  326. annotHandlerEventArgs = new FreeTextParam();
  327. (annotHandlerEventArgs as FreeTextParam).Transparency = (int)(freeTextData.Opacity * 255);
  328. (annotHandlerEventArgs as FreeTextParam).FontName = freeTextData.FontFamily.ToString();
  329. byte[] FontColor = new byte[] { freeTextData.BorderColor.R, freeTextData.BorderColor.G, freeTextData.BorderColor.B };
  330. (annotHandlerEventArgs as FreeTextParam).FontColor = FontColor;
  331. (annotHandlerEventArgs as FreeTextParam).IsBold = freeTextData.IsBold;
  332. (annotHandlerEventArgs as FreeTextParam).IsItalic = freeTextData.IsItalic;
  333. (annotHandlerEventArgs as FreeTextParam).FontSize = freeTextData.FontSize;
  334. switch (freeTextData.TextAlignment)
  335. {
  336. case TextAlignment.Left:
  337. (annotHandlerEventArgs as FreeTextParam).Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_LEFT;
  338. break;
  339. case TextAlignment.Right:
  340. (annotHandlerEventArgs as FreeTextParam).Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_RIGHT;
  341. break;
  342. case TextAlignment.Center:
  343. (annotHandlerEventArgs as FreeTextParam).Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_CENTER;
  344. break;
  345. default:
  346. break;
  347. }
  348. (annotHandlerEventArgs as FreeTextParam).Content = freeTextData.Note;
  349. (annotHandlerEventArgs as FreeTextParam).Author = freeTextData.Author;
  350. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT);
  351. }
  352. break;
  353. case CPDFAnnotationType.Stamp:
  354. {
  355. StampParam stampParam = new StampParam();
  356. CPDFStampData stampData = pdfAnnotationData as CPDFStampData;
  357. SetStamp(ref stampParam, stampData);
  358. annotHandlerEventArgs = stampParam;
  359. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP);
  360. }
  361. break;
  362. case CPDFAnnotationType.Signature:
  363. AnnotParam signatureParam = new AnnotParam();
  364. CPDFSignatureData SignatureData = pdfAnnotationData as CPDFSignatureData;
  365. SetSignature(ref signatureParam, SignatureData);
  366. annotHandlerEventArgs = signatureParam;
  367. break;
  368. case CPDFAnnotationType.Link:
  369. if (annotHandlerEventArgs != null)
  370. {
  371. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINK);
  372. }
  373. break;
  374. case CPDFAnnotationType.Unknow:
  375. pdfViewerControl.PDFToolManager.SetToolType(ToolType.Pan);
  376. return;
  377. default:
  378. break;
  379. }
  380. pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
  381. DefaultSettingParam defaultSettingParam = pdfViewerControl.PDFViewTool.GetDefaultSettingParam();
  382. }
  383. public void SetSignature(ref AnnotParam annotParam, CPDFSignatureData stamp)
  384. {
  385. switch (stamp.Type)
  386. {
  387. case SignatureType.TextType:
  388. case SignatureType.ImageType:
  389. {
  390. annotParam = new StampParam();
  391. (annotParam as StampParam).Transparency = 1;
  392. (annotParam as StampParam).StampType = C_STAMP_TYPE.IMAGE_STAMP;
  393. if (!string.IsNullOrEmpty(stamp.SourcePath))
  394. {
  395. BitmapImage image = new BitmapImage(new Uri(stamp.SourcePath));
  396. PngBitmapEncoder encoder = new PngBitmapEncoder();
  397. encoder.Frames.Add(BitmapFrame.Create(image));
  398. MemoryStream memoryStream = new MemoryStream();
  399. encoder.Save(memoryStream);
  400. (annotParam as StampParam).ImageStream = memoryStream;
  401. }
  402. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP);
  403. }
  404. break;
  405. case SignatureType.Drawing:
  406. {
  407. annotParam = new InkParam();
  408. List<List<Point>> RawPointList = GetPoints(stamp.DrawingPath);
  409. List<CPoint> linqList = new List<CPoint>();
  410. if (RawPointList != null && RawPointList.Count > 0)
  411. {
  412. List<List<CPoint>> inkPath = new List<List<CPoint>>();
  413. foreach (List<Point> inkPoints in RawPointList)
  414. {
  415. List<CPoint> ink = new List<CPoint>();
  416. foreach (Point point in inkPoints)
  417. {
  418. ink.Add(new CPoint((float)point.X, (float)point.Y));
  419. linqList.Add(new CPoint((float)point.X, (float)point.Y));
  420. }
  421. if (ink.Count > 0)
  422. {
  423. inkPath.Add(ink);
  424. }
  425. }
  426. if (inkPath.Count > 0)
  427. {
  428. (annotParam as InkParam).InkPath = inkPath;
  429. }
  430. }
  431. (annotParam as InkParam).Thickness = stamp.inkThickness;
  432. byte[] InkColor = new byte[] { stamp.inkColor.R, stamp.inkColor.G, stamp.inkColor.B };
  433. (annotParam as InkParam).InkColor = InkColor;
  434. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_INK);
  435. }
  436. break;
  437. default:
  438. break;
  439. }
  440. }
  441. private List<List<Point>> GetPoints(string Path)
  442. {
  443. StrokeCollection Strokes;
  444. List<List<Point>> RawPointList = new List<List<Point>>();
  445. using (FileStream strokeStream = File.OpenRead(Path))
  446. {
  447. Strokes = new StrokeCollection(strokeStream);
  448. }
  449. for (int kk = 0; kk < Strokes.Count; kk++)
  450. {
  451. List<Point> p = new List<Point>();
  452. RawPointList.Add(p);
  453. for (int gg = 0; gg < Strokes[kk].StylusPoints.Count; gg++)
  454. {
  455. var point = Strokes[kk].StylusPoints[gg].ToPoint();
  456. if (point.X >= 0 && point.Y >= 0)
  457. RawPointList[kk].Add(point);
  458. }
  459. }
  460. return RawPointList;
  461. }
  462. private void SetStamp(ref StampParam stampParam, CPDFStampData stamp)
  463. {
  464. stampParam.StampText = stamp.StampText;
  465. stampParam.Author = stamp.Author;
  466. stampParam.Transparency = (int)(stamp.Opacity * 255);
  467. stampParam.DateText = stamp.StampTextDate;
  468. stampParam.TextStampColor = stamp.TextColor;
  469. stampParam.TextStampShape = stamp.TextSharp;
  470. if (!string.IsNullOrEmpty(stamp.SourcePath))
  471. {
  472. BitmapImage image = new BitmapImage(new Uri(stamp.SourcePath));
  473. PngBitmapEncoder encoder = new PngBitmapEncoder();
  474. encoder.Frames.Add(BitmapFrame.Create(image));
  475. MemoryStream memoryStream = new MemoryStream();
  476. encoder.Save(memoryStream);
  477. stampParam.ImageStream = memoryStream;
  478. }
  479. else
  480. {
  481. var i = pdfStampUI.CustomStampList.IndexOf(stamp);
  482. Settings.Default.CustomStampList.RemoveAt(i);
  483. Settings.Default.Save();
  484. pdfStampUI.LoadSettings();
  485. return;
  486. }
  487. stampParam.StampType = stamp.Type;
  488. }
  489. public void AnnotationCancel()
  490. {
  491. this.pdfViewerControl.PDFToolManager.SetToolType(ToolType.Pan);
  492. ClearPanel();
  493. }
  494. private void CPDFAnnotationControl_PropertyChanged(object sender, CPDFAnnotationData e)
  495. {
  496. SetAnnotationProperty(e);
  497. }
  498. public void InitAnnotationPanel(CPDFAnnotationType annotationType)
  499. {
  500. switch (annotationType)
  501. {
  502. case CPDFAnnotationType.Highlight:
  503. if (pdfHighlightUI == null)
  504. {
  505. pdfHighlightUI = new CPDFMarkupUI();
  506. }
  507. annotationPanel = pdfHighlightUI;
  508. (annotationPanel as CPDFMarkupUI).InitWithAnnotationType(annotationType);
  509. break;
  510. case CPDFAnnotationType.Underline:
  511. if (pdfUnderlineUI == null)
  512. {
  513. pdfUnderlineUI = new CPDFMarkupUI();
  514. }
  515. annotationPanel = pdfUnderlineUI;
  516. (annotationPanel as CPDFMarkupUI).InitWithAnnotationType(annotationType);
  517. break;
  518. case CPDFAnnotationType.Strikeout:
  519. if (pdfStrikeoutUI == null)
  520. {
  521. pdfStrikeoutUI = new CPDFMarkupUI();
  522. }
  523. annotationPanel = pdfStrikeoutUI;
  524. (annotationPanel as CPDFMarkupUI).InitWithAnnotationType(annotationType);
  525. break;
  526. case CPDFAnnotationType.Squiggly:
  527. if (pdfSquigglyUI == null)
  528. {
  529. pdfSquigglyUI = new CPDFMarkupUI();
  530. }
  531. annotationPanel = pdfSquigglyUI;
  532. (annotationPanel as CPDFMarkupUI).InitWithAnnotationType(annotationType);
  533. break;
  534. case CPDFAnnotationType.Square:
  535. if (pdfSquareUI == null)
  536. {
  537. pdfSquareUI = new CPDFShapeUI();
  538. }
  539. annotationPanel = pdfSquareUI;
  540. (annotationPanel as CPDFShapeUI).InitWithAnnotationType(annotationType);
  541. break;
  542. case CPDFAnnotationType.Circle:
  543. if (pdfCircleUI == null)
  544. {
  545. pdfCircleUI = new CPDFShapeUI();
  546. }
  547. annotationPanel = pdfCircleUI;
  548. (annotationPanel as CPDFShapeUI).InitWithAnnotationType(annotationType);
  549. break;
  550. case CPDFAnnotationType.Arrow:
  551. if (pdfArrowUI == null)
  552. {
  553. pdfArrowUI = new CPDFShapeUI();
  554. }
  555. annotationPanel = pdfArrowUI;
  556. (annotationPanel as CPDFShapeUI).InitWithAnnotationType(annotationType);
  557. break;
  558. case CPDFAnnotationType.Line:
  559. if (pdfLineUI == null)
  560. {
  561. pdfLineUI = new CPDFShapeUI();
  562. }
  563. annotationPanel = pdfLineUI;
  564. (annotationPanel as CPDFShapeUI).InitWithAnnotationType(annotationType);
  565. break;
  566. case CPDFAnnotationType.Freehand:
  567. if (pdfFreehandUI == null)
  568. {
  569. pdfFreehandUI = new CPDFFreehandUI();
  570. pdfFreehandUI.EraseClickHandler += PdfFreehandUI_EraseClickHandler;
  571. pdfFreehandUI.EraseChangeHandler += PdfFreehandUI_EraseChangeHandler;
  572. }
  573. annotationPanel = pdfFreehandUI;
  574. break;
  575. case CPDFAnnotationType.FreeText:
  576. if (pdfFreeTextUI == null)
  577. {
  578. pdfFreeTextUI = new CPDFFreeTextUI();
  579. }
  580. annotationPanel = pdfFreeTextUI;
  581. break;
  582. case CPDFAnnotationType.Note:
  583. if (pdfNoteUI == null)
  584. {
  585. pdfNoteUI = new CPDFNoteUI();
  586. }
  587. annotationPanel = pdfNoteUI;
  588. break;
  589. case CPDFAnnotationType.Stamp:
  590. if (pdfStampUI == null)
  591. {
  592. pdfStampUI = new CPDFStampUI();
  593. }
  594. annotationPanel = pdfStampUI;
  595. break;
  596. case CPDFAnnotationType.Signature:
  597. if (pdfSignatureUI == null)
  598. {
  599. pdfSignatureUI = new CPDFSignatureUI();
  600. }
  601. annotationPanel = pdfSignatureUI;
  602. break;
  603. case CPDFAnnotationType.Link:
  604. if (pdfLinkUI == null)
  605. {
  606. pdfLinkUI = new CPDFLinkUI();
  607. }
  608. LinkParam linkAnnotArgs = new LinkParam();
  609. if (this.pdfViewerControl != null&& pdfViewerControl.PDFViewTool!=null && pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument() != null)
  610. {
  611. pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
  612. pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINK);
  613. pdfLinkUI.InitLinkAnnotArgs(linkAnnotArgs, pdfViewerControl.PDFViewTool.GetCPDFViewer().GetDocument().PageCount);
  614. }
  615. annotationPanel = pdfLinkUI;
  616. break;
  617. case CPDFAnnotationType.Audio:
  618. //SoundAnnotArgs soundArgs = new SoundAnnotArgs();
  619. //OpenFileDialog openAudioDialog = new OpenFileDialog();
  620. //openAudioDialog.Filter = "Wave Files(*.wav)|*.wav|All Files(*.*;)|*.*;";
  621. //if (openAudioDialog.ShowDialog() == true)
  622. //{
  623. // soundArgs.SoundFilePath = openAudioDialog.FileName;
  624. // this.pdfViewerControl.SetMouseMode(MouseModes.AnnotCreate);
  625. // pdfViewerControl.SetToolParam(soundArgs);
  626. //}
  627. //else
  628. //{
  629. // this.pdfViewerControl.SetMouseMode(MouseModes.PanTool);
  630. // ClearAnnotationBar?.Invoke(this, EventArgs.Empty);
  631. //}
  632. ClearPanel();
  633. break;
  634. case CPDFAnnotationType.Image:
  635. //StampAnnotArgs stampArgs = new StampAnnotArgs();
  636. //stampArgs.Opacity = 1;
  637. //stampArgs.Type = StampType.IMAGE_STAMP;
  638. //OpenFileDialog openFileDialog = new OpenFileDialog();
  639. //openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
  640. //if (openFileDialog.ShowDialog() == true)
  641. //{
  642. // stampArgs.ImagePath = openFileDialog.FileName;
  643. // this.pdfViewerControl?.SetMouseMode(MouseModes.AnnotCreate);
  644. // this.pdfViewerControl?.SetToolParam(stampArgs);
  645. //}
  646. //else
  647. //{
  648. // this.pdfViewerControl.SetMouseMode(MouseModes.PanTool);
  649. //}
  650. //ClearAnnotationBar?.Invoke(this, EventArgs.Empty);
  651. ClearPanel();
  652. break;
  653. default:
  654. break;
  655. }
  656. }
  657. private void PdfFreehandUI_EraseChangeHandler(object sender, double e)
  658. {
  659. //if (pdfViewerControl != null && eraseArgs != null)
  660. //{
  661. // eraseArgs.Thickness = e;
  662. //}
  663. }
  664. private void PdfFreehandUI_EraseClickHandler(object sender, bool e)
  665. {
  666. //if (pdfViewerControl != null)
  667. //{
  668. // CPDFFreehandUI freehandUI = sender as CPDFFreehandUI;
  669. // if (e)
  670. // {
  671. // annotArgs = pdfViewerControl.ToolManager.CurrentAnnotArgs;
  672. // eraseArgs = new EraseArgs();
  673. // eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  674. // eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
  675. // if (freehandUI != null)
  676. // {
  677. // eraseArgs.Thickness = freehandUI.GetEraseThickness();
  678. // }
  679. // else
  680. // {
  681. // eraseArgs.Thickness = 1;
  682. // }
  683. // disableClean = true;
  684. // pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
  685. // pdfViewerControl.SetToolParam(eraseArgs);
  686. // disableClean = false;
  687. // EmptyMessage.Visibility = Visibility.Collapsed;
  688. // }
  689. // else
  690. // {
  691. // pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
  692. // FreehandAnnotArgs freehandAnnotArgs = annotArgs as FreehandAnnotArgs;
  693. // if (freehandAnnotArgs == null)
  694. // {
  695. // freehandAnnotArgs = new FreehandAnnotArgs();
  696. // freehandAnnotArgs.InkColor = Colors.Red;
  697. // freehandAnnotArgs.Transparency = 1;
  698. // freehandAnnotArgs.LineWidth = 1;
  699. // annotArgs = freehandAnnotArgs;
  700. // }
  701. // if (freehandUI != null)
  702. // {
  703. // freehandUI.PropertyChanged -= CPDFAnnotationControl_PropertyChanged;
  704. // Dictionary<AnnotAttrib, object> attribDict = new Dictionary<AnnotAttrib, object>();
  705. // attribDict[AnnotAttrib.Color] = freehandAnnotArgs.InkColor;
  706. // attribDict[AnnotAttrib.Transparency] = freehandAnnotArgs.Transparency;
  707. // attribDict[AnnotAttrib.Thickness] = freehandAnnotArgs.LineWidth;
  708. // attribDict[AnnotAttrib.NoteText] = freehandAnnotArgs.Content;
  709. // AnnotAttribEvent annotEvent = AnnotAttribEvent.GetAnnotAttribEvent(freehandAnnotArgs, attribDict);
  710. // freehandUI.SetPresentAnnotAttrib(annotEvent);
  711. // freehandUI.PropertyChanged += CPDFAnnotationControl_PropertyChanged;
  712. // freehandUI.ClearAnnotAttribEvent();
  713. // }
  714. // pdfViewerControl.SetToolParam(freehandAnnotArgs);
  715. // }
  716. //}
  717. }
  718. public void CreatTempAnnotationPanel(BaseAnnot baseAnnot)
  719. {
  720. //switch (baseAnnot.CurrentType)
  721. //{
  722. // case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
  723. // tempAnnotationPanel = new CPDFMarkupUI();
  724. // (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Highlight);
  725. // (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
  726. // break;
  727. // case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
  728. // tempAnnotationPanel = new CPDFMarkupUI();
  729. // (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Underline);
  730. // (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
  731. // break;
  732. // case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
  733. // tempAnnotationPanel = new CPDFMarkupUI();
  734. // (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Strikeout);
  735. // (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
  736. // break;
  737. // case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
  738. // tempAnnotationPanel = new CPDFMarkupUI();
  739. // (tempAnnotationPanel as CPDFMarkupUI).InitWithAnnotationType(CPDFAnnotationType.Squiggly);
  740. // (tempAnnotationPanel as CPDFMarkupUI).SetPresentAnnotAttrib(annotAttribEvent);
  741. // break;
  742. // case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
  743. // tempAnnotationPanel = new CPDFShapeUI();
  744. // (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Square);
  745. // (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotAttribEvent);
  746. // break;
  747. // case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
  748. // tempAnnotationPanel = new CPDFShapeUI();
  749. // (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Circle);
  750. // (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotAttribEvent);
  751. // break;
  752. // case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
  753. // tempAnnotationPanel = new CPDFShapeUI();
  754. // (tempAnnotationPanel as CPDFShapeUI).InitWithAnnotationType(CPDFAnnotationType.Line);
  755. // (tempAnnotationPanel as CPDFShapeUI).SetPresentAnnotAttrib(annotAttribEvent);
  756. // break;
  757. // case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
  758. // CPDFFreehandUI tempFreehandPanel = new CPDFFreehandUI();
  759. // tempFreehandPanel.SetPresentAnnotAttrib(annotAttribEvent);
  760. // tempFreehandPanel.EraseClickHandler += PdfFreehandUI_EraseClickHandler;
  761. // tempFreehandPanel.EraseChangeHandler += PdfFreehandUI_EraseChangeHandler;
  762. // tempAnnotationPanel = tempFreehandPanel;
  763. // break;
  764. // case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
  765. // tempAnnotationPanel = new CPDFFreeTextUI();
  766. // (tempAnnotationPanel as CPDFFreeTextUI).SetPresentAnnotAttrib(annotAttribEvent);
  767. // break;
  768. // case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
  769. // tempAnnotationPanel = new CPDFNoteUI();
  770. // (tempAnnotationPanel as CPDFNoteUI).SetPresentAnnotAttrib(annotAttribEvent);
  771. // break;
  772. // case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
  773. // tempAnnotationPanel = new CPDFTempStampUI();
  774. // (tempAnnotationPanel as CPDFTempStampUI).SetPresentAnnotAttrib(annotAttribEvent);
  775. // break;
  776. // case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
  777. // tempAnnotationPanel = new CPDFLinkUI();
  778. // (tempAnnotationPanel as CPDFLinkUI).SetPresentAnnotAttrib(annotAttribEvent, pdfViewerControl.Document.PageCount);
  779. // break;
  780. // case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
  781. // tempAnnotationPanel = null;
  782. // break;
  783. // default:
  784. // break;
  785. //}
  786. }
  787. public void LoadAnnotationPanel(CPDFAnnotationType annotationType)
  788. {
  789. this.pdfViewerControl.PDFToolManager.SetToolType(ToolType.Pan);
  790. currentAnnotationType = annotationType;
  791. annotationPanel = GetAnnotationPanel();
  792. InitAnnotationPanel(annotationType);
  793. ShowCurrentAnnotPanel();
  794. }
  795. private void ShowCurrentAnnotPanel()
  796. {
  797. if (annotationPanel != null)
  798. {
  799. if (annotationPanel is CPDFFreehandUI)
  800. {
  801. (annotationPanel as CPDFFreehandUI)?.SetEraseCheck(false);
  802. }
  803. SetAnnotationPanel(annotationPanel);
  804. ExpandPanel();
  805. ChangeAnnotationData();
  806. EmptyMessage.Visibility = Visibility.Collapsed;
  807. }
  808. else
  809. {
  810. EmptyMessage.Visibility = Visibility.Visible;
  811. SetAnnotationPanel(null);
  812. if (pdfViewerControl != null)
  813. {
  814. EmptyMessage.Visibility = Visibility.Collapsed;
  815. }
  816. }
  817. }
  818. private void ShowTempAnnotPanel()
  819. {
  820. BaseAnnot baseAnnot = pdfViewerControl.PDFToolManager.GetCacheHitTestAnnot();
  821. if (baseAnnot != null)
  822. {
  823. CreatTempAnnotationPanel(baseAnnot);
  824. SetAnnotationPanel(tempAnnotationPanel);
  825. ExpandPanel();
  826. if (tempAnnotationPanel != null)
  827. {
  828. EmptyMessage.Visibility = Visibility.Collapsed;
  829. }
  830. else
  831. {
  832. EmptyMessage.Visibility = Visibility.Visible;
  833. }
  834. }
  835. }
  836. private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
  837. {
  838. SetAnnotEventData();
  839. }
  840. public void ClearPanel()
  841. {
  842. annotationPanel = null;
  843. SetAnnotationPanel(annotationPanel);
  844. EmptyMessage.Visibility = Visibility.Visible;
  845. }
  846. public void SetAnnotEventData()
  847. {
  848. if (pdfViewerControl.PDFToolManager != null)
  849. {
  850. if (pdfViewerControl.PDFToolManager.GetCacheHitTestAnnot()==null && isTempPanel)
  851. {
  852. ShowCurrentAnnotPanel();
  853. isTempPanel = false;
  854. }
  855. else if (pdfViewerControl.PDFToolManager.GetCacheHitTestAnnot() != null)
  856. {
  857. ShowTempAnnotPanel();
  858. isTempPanel = true;
  859. }
  860. }
  861. else
  862. {
  863. if (pdfViewerControl != null && pdfViewerControl.PDFToolManager.GetToolType() == ToolType.CreateAnnot)
  864. {
  865. ShowCurrentAnnotPanel();
  866. isTempPanel = false;
  867. }
  868. else if (annotationPanel is CPDFStampUI && currentAnnotationType == CPDFAnnotationType.Stamp)
  869. {
  870. ShowCurrentAnnotPanel();
  871. }
  872. else if (annotationPanel is CPDFSignatureUI && currentAnnotationType == CPDFAnnotationType.Signature)
  873. {
  874. ShowCurrentAnnotPanel();
  875. }
  876. else if (disableClean == false)
  877. {
  878. ClearPanel();
  879. }
  880. }
  881. }
  882. }
  883. }