ReportPage.PreviewExt.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Drawing;
  2. using System.ComponentModel;
  3. using System.Drawing.Printing;
  4. using FastReport.Utils;
  5. namespace FastReport
  6. {
  7. partial class ReportPage
  8. {
  9. #region Public Methods
  10. internal void DrawSearchHighlight(FRPaintEventArgs e, int objIndex, CharacterRange range)
  11. {
  12. IGraphics g = e.Graphics;
  13. float leftMargin = LeftMargin * Units.Millimeters * e.ScaleX;
  14. float topMargin = TopMargin * Units.Millimeters * e.ScaleY;
  15. ObjectCollection allObjects = AllObjects;
  16. if (objIndex < 0 && objIndex >= allObjects.Count)
  17. return;
  18. ISearchable obj = allObjects[objIndex] as ISearchable;
  19. if (obj != null)
  20. {
  21. g.TranslateTransform(leftMargin, topMargin);
  22. try
  23. {
  24. obj.DrawSearchHighlight(e, range);
  25. }
  26. finally
  27. {
  28. g.TranslateTransform(-leftMargin, -topMargin);
  29. }
  30. }
  31. }
  32. internal void Print(FRPaintEventArgs e)
  33. {
  34. try
  35. {
  36. SetPrinting(true);
  37. SetDesigning(false);
  38. Draw(e);
  39. }
  40. finally
  41. {
  42. SetPrinting(false);
  43. }
  44. }
  45. internal ReportComponentBase HitTest(PointF mouse)
  46. {
  47. mouse.X -= LeftMargin * Units.Millimeters;
  48. mouse.Y -= TopMargin * Units.Millimeters;
  49. ObjectCollection allObjects = AllObjects;
  50. for (int i = allObjects.Count - 1; i >= 0; i--)
  51. {
  52. ReportComponentBase c = allObjects[i] as ReportComponentBase;
  53. if (c != null)
  54. {
  55. if (c.PointInObject(mouse))
  56. return c;
  57. }
  58. }
  59. return null;
  60. }
  61. #endregion
  62. private void InitPreview()
  63. {
  64. firstPageSource = 7;
  65. otherPagesSource = 7;
  66. lastPageSource = 7;
  67. duplex = Duplex.Default;
  68. }
  69. }
  70. }