IGraphics.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Drawing;
  3. using System.Drawing.Drawing2D;
  4. using System.Drawing.Imaging;
  5. using System.Drawing.Text;
  6. namespace FastReport
  7. {
  8. /// <summary>
  9. /// The interface for unifying methods for drawing objects into different graphics
  10. /// </summary>
  11. public interface IGraphics : IDisposable
  12. {
  13. #region Properties
  14. Graphics Graphics { get; }
  15. float DpiY { get; }
  16. TextRenderingHint TextRenderingHint { get; set; }
  17. InterpolationMode InterpolationMode { get; set; }
  18. SmoothingMode SmoothingMode { get; set; }
  19. System.Drawing.Drawing2D.Matrix Transform { get; set; }
  20. GraphicsUnit PageUnit { get; set; }
  21. bool IsClipEmpty { get; }
  22. Region Clip { get; set; }
  23. float DpiX { get; }
  24. CompositingQuality CompositingQuality { get; set; }
  25. #endregion
  26. #region Draw and measure text
  27. void DrawString(string text, Font font, Brush brush, float left, float top);
  28. void DrawString(string text, Font font, Brush brush, float left, float top, StringFormat format);
  29. // in this case if a baseline is needed, it will not be calculated
  30. void DrawString(string text, Font font, Brush brush, RectangleF rectangleF);
  31. void DrawString(string text, Font font, Brush textBrush, RectangleF textRect, StringFormat format);
  32. void DrawString(string s, Font font, Brush brush, PointF point, StringFormat format);
  33. Region[] MeasureCharacterRanges(string text, Font font, RectangleF textRect, StringFormat format);
  34. SizeF MeasureString(string text, Font font);
  35. SizeF MeasureString(string text, Font font, SizeF size);
  36. SizeF MeasureString(string text, Font font, int v, StringFormat format);
  37. void MeasureString(string text, Font font, SizeF size, StringFormat format, out int charsFit, out int linesFit);
  38. SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat);
  39. #endregion
  40. #region Draw images
  41. void DrawImage(Image image, float x, float y);
  42. void DrawImage(Image image, RectangleF rect1, RectangleF rect2, GraphicsUnit unit);
  43. void DrawImage(Image image, RectangleF rect);
  44. void DrawImage(Image image, float x, float y, float width, float height);
  45. void DrawImage(Image image, PointF[] points);
  46. void DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr);
  47. void DrawImage(Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs);
  48. void DrawImageUnscaled(Image image, Rectangle rect);
  49. #endregion
  50. #region Draw geometry
  51. void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
  52. void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension);
  53. void DrawEllipse(Pen pen, float left, float top, float width, float height);
  54. void DrawEllipse(Pen pen, RectangleF rect);
  55. void DrawLine(Pen pen, float x1, float y1, float x2, float y2);
  56. void DrawLine(Pen pen, PointF p1, PointF p2);
  57. void DrawLines(Pen pen, PointF[] points);
  58. void DrawPath(Pen outlinePen, GraphicsPath path);
  59. void DrawPie(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
  60. void DrawPolygon(Pen pen, PointF[] points);
  61. void DrawPolygon(Pen pen, Point[] points);
  62. void DrawRectangle(Pen pen, float left, float top, float width, float height);
  63. void DrawRectangle(Pen pen, Rectangle rectangle);
  64. #endregion
  65. #region Fill geometry
  66. void FillEllipse(Brush brush, float left, float top, float width, float height);
  67. void FillEllipse(Brush brush, RectangleF rect);
  68. // Works with polygons only
  69. void FillPath(Brush brush, GraphicsPath path);
  70. void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle);
  71. void FillPolygon(Brush brush, PointF[] points);
  72. void FillPolygon(Brush brush, Point[] points);
  73. // Add rectangle to the graphics path
  74. void FillRectangle(Brush brush, RectangleF rect);
  75. void FillRectangle(Brush brush, float left, float top, float width, float height);
  76. void FillRegion(Brush brush, Region region);
  77. #endregion
  78. #region Fill and Draw
  79. void FillAndDrawPath(Pen pen, Brush brush, GraphicsPath path);
  80. void FillAndDrawEllipse(Pen pen, Brush brush, RectangleF rect);
  81. void FillAndDrawEllipse(Pen pen, Brush brush, float left, float top, float width, float height);
  82. void FillAndDrawPolygon(Pen pen, Brush brush, Point[] points);
  83. void FillAndDrawPolygon(Pen pen, Brush brush, PointF[] points);
  84. void FillAndDrawRectangle(Pen pen, Brush brush, float left, float top, float width, float height);
  85. #endregion
  86. #region Transform
  87. void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix, MatrixOrder prepend);
  88. void RotateTransform(float angle);
  89. void ScaleTransform(float scaleX, float scaleY);
  90. void TranslateTransform(float left, float top);
  91. #endregion
  92. #region State
  93. void Restore(IGraphicsState state);
  94. IGraphicsState Save();
  95. #endregion
  96. #region Clip
  97. bool IsVisible(RectangleF rect);
  98. void ResetClip();
  99. void SetClip(RectangleF rect);
  100. void SetClip(RectangleF rect, CombineMode combineMode);
  101. void SetClip(GraphicsPath path, CombineMode combineMode);
  102. #endregion
  103. }
  104. /// <summary>
  105. /// the interface for saving and restoring state
  106. /// </summary>
  107. public interface IGraphicsState
  108. {
  109. }
  110. }