CPDFViewerTool.SelectImage.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using ComPDFKit.Tool.DrawTool;
  2. using ComPDFKitViewer.Helper;
  3. using ComPDFKitViewer.Layer;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. namespace ComPDFKit.Tool
  11. {
  12. public partial class CPDFViewerTool
  13. {
  14. int selectImageTag = -1;
  15. private void InsertSelectImageView()
  16. {
  17. SelectImage createAnnotTool = new SelectImage();
  18. int SelectTextindex = PDFViewer.GetMaxViewIndex();
  19. PDFViewer.InsertView(SelectTextindex, createAnnotTool);
  20. selectImageTag = createAnnotTool.GetResTag();
  21. }
  22. public bool DrawMoveSelectImage()
  23. {
  24. bool isSelect = false;
  25. if (PDFViewer.CurrentRenderFrame == null)
  26. {
  27. return isSelect;
  28. }
  29. BaseLayer baseLayer = PDFViewer.GetViewForTag(selectImageTag);
  30. PDFViewer.GetMousePointToPage(out int pageindex, out Point pagepoint);
  31. isSelect=(baseLayer as SelectImage).ProcessMouseMoveForSelectImage(
  32. new Point(DpiHelper.StandardNumToPDFNum(pagepoint.X / PDFViewer.CurrentRenderFrame.ZoomFactor),
  33. DpiHelper.StandardNumToPDFNum(pagepoint.Y / PDFViewer.CurrentRenderFrame.ZoomFactor)),
  34. pageindex, PDFViewer);
  35. (baseLayer as SelectImage).Draw(PDFViewer);
  36. return isSelect;
  37. }
  38. public bool DrawDownSelectImage(bool isNeedClear)
  39. {
  40. bool isSelect = false;
  41. if (PDFViewer.CurrentRenderFrame == null)
  42. {
  43. return isSelect;
  44. }
  45. BaseLayer baseLayer = PDFViewer.GetViewForTag(selectImageTag);
  46. PDFViewer.GetMousePointToPage(out int pageindex, out Point pagepoint);
  47. isSelect=(baseLayer as SelectImage).ProcessMouseDownForSelectImage(
  48. new Point(DpiHelper.StandardNumToPDFNum(pagepoint.X / PDFViewer.CurrentRenderFrame.ZoomFactor),
  49. DpiHelper.StandardNumToPDFNum(pagepoint.Y / PDFViewer.CurrentRenderFrame.ZoomFactor)),
  50. pageindex, PDFViewer, isNeedClear);
  51. (baseLayer as SelectImage).Draw(PDFViewer);
  52. return isSelect;
  53. }
  54. public void ReDrawSelectImage()
  55. {
  56. BaseLayer baseLayer = PDFViewer.GetViewForTag(selectImageTag);
  57. (baseLayer as SelectImage).Draw(PDFViewer);
  58. }
  59. public void CleanDrawSelectImage()
  60. {
  61. BaseLayer baseLayer = PDFViewer.GetViewForTag(selectImageTag);
  62. (baseLayer as SelectImage).CleanDraw(PDFViewer);
  63. }
  64. //public PageImageItem GetSelectImage()
  65. //{
  66. // BaseLayer baseLayer = PDFViewer.GetViewForTag(selectImageTag);
  67. // return (baseLayer as SelectImage).GetHoverImageItem();
  68. //}
  69. public Dictionary<int, List<PageImageItem>> GetSelectImageItems()
  70. {
  71. BaseLayer baseLayer = PDFViewer.GetViewForTag(selectImageTag);
  72. return (baseLayer as SelectImage).GetSelectImageItems();
  73. }
  74. }
  75. }