ChartRenderingEngine.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. //
  5. // Purpose: ChartRenderingEngine class provides a common interface
  6. // to the graphics rendering and animation engines.
  7. // Internally it uses SvgChartGraphics, FlashGraphics or
  8. // GdiGraphics classes depending on the ActiveRenderingType
  9. // property settings.
  10. // ValueA, PointA, RectangleA and ColorA classes are
  11. // used to store data about animated values like colors
  12. // position or rectangles. They store starting value/time,
  13. // end value/time, repeat flags and other settings. These
  14. // clases are used with animation engines.
  15. //
  16. using System.Diagnostics.CodeAnalysis;
  17. using System.Drawing;
  18. using System.Drawing.Drawing2D;
  19. using System.Drawing.Imaging;
  20. using System.Drawing.Text;
  21. namespace FastReport.DataVisualization.Charting
  22. {
  23. #region Enumerations
  24. /// <summary>
  25. /// Specify Rendering AxisName
  26. /// </summary>
  27. internal enum RenderingType
  28. {
  29. /// <summary>
  30. /// GDI+ AxisName
  31. /// </summary>
  32. [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gdi")]
  33. Gdi,
  34. /// <summary>
  35. /// SVG AxisName
  36. /// </summary>
  37. [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Svg")]
  38. Svg,
  39. }
  40. #endregion // Enumerations
  41. /// <summary>
  42. /// The ChartGraphics class provides a common interface to the
  43. /// graphics rendering.
  44. /// </summary>
  45. public partial class ChartGraphics
  46. {
  47. #region Fields
  48. // Current rendering type
  49. private RenderingType _activeRenderingType = RenderingType.Gdi;
  50. // GDI+ rendering engine
  51. private GdiGraphics _gdiGraphics = new GdiGraphics();
  52. // Document title used for SVG rendering
  53. //private string documentTitle = string.Empty;
  54. // True if text should be clipped
  55. internal bool IsTextClipped = false;
  56. #endregion // Fields
  57. #region Drawing Methods
  58. /// <summary>
  59. /// Draws a line connecting two PointF structures.
  60. /// </summary>
  61. /// <param name="pen">Pen object that determines the color, width, and style of the line.</param>
  62. /// <param name="pt1">PointF structure that represents the first point to connect.</param>
  63. /// <param name="pt2">PointF structure that represents the second point to connect.</param>
  64. internal void DrawLine(
  65. Pen pen,
  66. PointF pt1,
  67. PointF pt2
  68. )
  69. {
  70. RenderingObject.DrawLine( pen, pt1, pt2 );
  71. }
  72. /// <summary>
  73. /// Draws a line connecting the two points specified by coordinate pairs.
  74. /// </summary>
  75. /// <param name="pen">Pen object that determines the color, width, and style of the line.</param>
  76. /// <param name="x1">x-coordinate of the first point.</param>
  77. /// <param name="y1">y-coordinate of the first point.</param>
  78. /// <param name="x2">x-coordinate of the second point.</param>
  79. /// <param name="y2">y-coordinate of the second point.</param>
  80. internal void DrawLine(
  81. Pen pen,
  82. float x1,
  83. float y1,
  84. float x2,
  85. float y2
  86. )
  87. {
  88. RenderingObject.DrawLine( pen, x1, y1, x2, y2 );
  89. }
  90. /// <summary>
  91. /// Draws the specified portion of the specified Image object at the specified location and with the specified size.
  92. /// </summary>
  93. /// <param name="image">Image object to draw.</param>
  94. /// <param name="destRect">Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.</param>
  95. /// <param name="srcX">x-coordinate of the upper-left corner of the portion of the source image to draw.</param>
  96. /// <param name="srcY">y-coordinate of the upper-left corner of the portion of the source image to draw.</param>
  97. /// <param name="srcWidth">Width of the portion of the source image to draw.</param>
  98. /// <param name="srcHeight">Height of the portion of the source image to draw.</param>
  99. /// <param name="srcUnit">Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.</param>
  100. /// <param name="imageAttr">ImageAttributes object that specifies recoloring and gamma information for the image object.</param>
  101. internal void DrawImage(
  102. System.Drawing.Image image,
  103. Rectangle destRect,
  104. int srcX,
  105. int srcY,
  106. int srcWidth,
  107. int srcHeight,
  108. GraphicsUnit srcUnit,
  109. ImageAttributes imageAttr
  110. )
  111. {
  112. RenderingObject.DrawImage(
  113. image,
  114. destRect,
  115. srcX,
  116. srcY,
  117. srcWidth,
  118. srcHeight,
  119. srcUnit,
  120. imageAttr
  121. );
  122. }
  123. /// <summary>
  124. /// Draws an ellipse defined by a bounding rectangle specified by
  125. /// a pair of coordinates, a height, and a width.
  126. /// </summary>
  127. /// <param name="pen">Pen object that determines the color, width, and style of the ellipse.</param>
  128. /// <param name="x">x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.</param>
  129. /// <param name="y">y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.</param>
  130. /// <param name="width">Width of the bounding rectangle that defines the ellipse.</param>
  131. /// <param name="height">Height of the bounding rectangle that defines the ellipse.</param>
  132. internal void DrawEllipse(
  133. Pen pen,
  134. float x,
  135. float y,
  136. float width,
  137. float height
  138. )
  139. {
  140. RenderingObject.DrawEllipse( pen, x, y, width, height );
  141. }
  142. /// <summary>
  143. /// Draws a cardinal spline through a specified array of PointF structures
  144. /// using a specified tension. The drawing begins offset from
  145. /// the beginning of the array.
  146. /// </summary>
  147. /// <param name="pen">Pen object that determines the color, width, and height of the curve.</param>
  148. /// <param name="points">Array of PointF structures that define the spline.</param>
  149. /// <param name="offset">Offset from the first element in the array of the points parameter to the starting point in the curve.</param>
  150. /// <param name="numberOfSegments">Number of segments after the starting point to include in the curve.</param>
  151. /// <param name="tension">Value greater than or equal to 0.0F that specifies the tension of the curve.</param>
  152. internal void DrawCurve(
  153. Pen pen,
  154. PointF[] points,
  155. int offset,
  156. int numberOfSegments,
  157. float tension
  158. )
  159. {
  160. ChartGraphics chartGraphics = this as ChartGraphics;
  161. if (chartGraphics == null || !chartGraphics.IsMetafile)
  162. {
  163. RenderingObject.DrawCurve(pen, points, offset, numberOfSegments, tension);
  164. }
  165. else
  166. {
  167. // Special handling required for the metafiles. We cannot pass large array of
  168. // points because they will be persisted inside EMF file and cause exponential
  169. // increase in emf file size. Draw curve method uses additional 2, 3 or 4 points
  170. // depending on which segement is drawn.
  171. PointF[] pointsExact = null;
  172. if (offset == 0 && numberOfSegments == points.Length - 1)
  173. {
  174. // In case the array contains the minimum required number of points
  175. // to draw segments - just call the curve drawing method
  176. RenderingObject.DrawCurve(pen, points, offset, numberOfSegments, tension);
  177. }
  178. else
  179. {
  180. if (offset == 0 && numberOfSegments < points.Length - 1)
  181. {
  182. // Segment is at the beginning of the array with more points following
  183. pointsExact = new PointF[numberOfSegments + 2];
  184. for (int index = 0; index < numberOfSegments + 2; index++)
  185. {
  186. pointsExact[index] = points[index];
  187. }
  188. }
  189. else if (offset > 0 && (offset + numberOfSegments) == points.Length - 1)
  190. {
  191. // Segment is at the end of the array with more points prior to it
  192. pointsExact = new PointF[numberOfSegments + 2];
  193. for (int index = 0; index < numberOfSegments + 2; index++)
  194. {
  195. pointsExact[index] = points[offset + index - 1];
  196. }
  197. offset = 1;
  198. }
  199. else if (offset > 0 && (offset + numberOfSegments) < points.Length - 1)
  200. {
  201. // Segment in the middle of the array with points prior and following it
  202. pointsExact = new PointF[numberOfSegments + 3];
  203. for (int index = 0; index < numberOfSegments + 3; index++)
  204. {
  205. pointsExact[index] = points[offset + index - 1];
  206. }
  207. offset = 1;
  208. }
  209. // Render the curve using minimum number of required points in the array
  210. RenderingObject.DrawCurve(pen, pointsExact, offset, numberOfSegments, tension);
  211. }
  212. }
  213. }
  214. /// <summary>
  215. /// Draws a rectangle specified by a coordinate pair, a width, and a height.
  216. /// </summary>
  217. /// <param name="pen">Pen object that determines the color, width, and style of the rectangle.</param>
  218. /// <param name="x">x-coordinate of the upper-left corner of the rectangle to draw.</param>
  219. /// <param name="y">y-coordinate of the upper-left corner of the rectangle to draw.</param>
  220. /// <param name="width">Width of the rectangle to draw.</param>
  221. /// <param name="height">Height of the rectangle to draw.</param>
  222. internal void DrawRectangle(
  223. Pen pen,
  224. int x,
  225. int y,
  226. int width,
  227. int height
  228. )
  229. {
  230. RenderingObject.DrawRectangle( pen, x, y, width, height );
  231. }
  232. /// <summary>
  233. /// Draws a polygon defined by an array of PointF structures.
  234. /// </summary>
  235. /// <param name="pen">Pen object that determines the color, width, and style of the polygon.</param>
  236. /// <param name="points">Array of PointF structures that represent the vertices of the polygon.</param>
  237. internal void DrawPolygon(
  238. Pen pen,
  239. PointF[] points
  240. )
  241. {
  242. RenderingObject.DrawPolygon( pen, points );
  243. }
  244. /// <summary>
  245. /// Draws the specified text string in the specified rectangle with the specified Brush and Font objects using the formatting properties of the specified StringFormat object.
  246. /// </summary>
  247. /// <param name="s">String to draw.</param>
  248. /// <param name="font">Font object that defines the text format of the string.</param>
  249. /// <param name="brush">Brush object that determines the color and texture of the drawn text.</param>
  250. /// <param name="layoutRectangle">RectangleF structure that specifies the location of the drawn text.</param>
  251. /// <param name="format">StringFormat object that specifies formatting properties, such as line spacing and alignment, that are applied to the drawn text.</param>
  252. internal void DrawString(
  253. string s,
  254. Font font,
  255. Brush brush,
  256. RectangleF layoutRectangle,
  257. StringFormat format
  258. )
  259. {
  260. using (StringFormat fmt = (StringFormat)format.Clone())
  261. {
  262. if ( IsRightToLeft )
  263. fmt.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
  264. if (!IsTextClipped && (fmt.FormatFlags & StringFormatFlags.NoClip) != StringFormatFlags.NoClip)
  265. fmt.FormatFlags |= StringFormatFlags.NoClip;
  266. RenderingObject.DrawString(s, font, brush, layoutRectangle, fmt);
  267. }
  268. }
  269. /// <summary>
  270. /// Draws the specified text string at the specified location with the specified Brush and Font objects using the formatting properties of the specified StringFormat object.
  271. /// </summary>
  272. /// <param name="s">String to draw.</param>
  273. /// <param name="font">Font object that defines the text format of the string.</param>
  274. /// <param name="brush">Brush object that determines the color and texture of the drawn text.</param>
  275. /// <param name="point">PointF structure that specifies the upper-left corner of the drawn text.</param>
  276. /// <param name="format">StringFormat object that specifies formatting properties, such as line spacing and alignment, that are applied to the drawn text.</param>
  277. internal void DrawString(
  278. string s,
  279. Font font,
  280. Brush brush,
  281. PointF point,
  282. StringFormat format
  283. )
  284. {
  285. if (IsRightToLeft)
  286. {
  287. using (StringFormat fmt = (StringFormat)format.Clone())
  288. {
  289. fmt.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
  290. if (fmt.Alignment == StringAlignment.Far)
  291. {
  292. fmt.Alignment = StringAlignment.Near;
  293. }
  294. else if (fmt.Alignment == StringAlignment.Near)
  295. {
  296. fmt.Alignment = StringAlignment.Far;
  297. }
  298. RenderingObject.DrawString(s, font, brush, point, fmt);
  299. }
  300. }
  301. else
  302. RenderingObject.DrawString(s, font, brush, point, format);
  303. }
  304. /// <summary>
  305. /// Draws the specified portion of the specified Image object at the specified location and with the specified size.
  306. /// </summary>
  307. /// <param name="image">Image object to draw.</param>
  308. /// <param name="destRect">Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.</param>
  309. /// <param name="srcX">x-coordinate of the upper-left corner of the portion of the source image to draw.</param>
  310. /// <param name="srcY">y-coordinate of the upper-left corner of the portion of the source image to draw.</param>
  311. /// <param name="srcWidth">Width of the portion of the source image to draw.</param>
  312. /// <param name="srcHeight">Height of the portion of the source image to draw.</param>
  313. /// <param name="srcUnit">Member of the GraphicsUnit enumeration that specifies the units of measure used to determine the source rectangle.</param>
  314. /// <param name="imageAttrs">ImageAttributes object that specifies recoloring and gamma information for the image object.</param>
  315. internal void DrawImage(
  316. System.Drawing.Image image,
  317. Rectangle destRect,
  318. float srcX,
  319. float srcY,
  320. float srcWidth,
  321. float srcHeight,
  322. GraphicsUnit srcUnit,
  323. ImageAttributes imageAttrs
  324. )
  325. {
  326. RenderingObject.DrawImage( image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttrs );
  327. }
  328. /// <summary>
  329. /// Draws a rectangle specified by a coordinate pair, a width, and a height.
  330. /// </summary>
  331. /// <param name="pen">A Pen object that determines the color, width, and style of the rectangle.</param>
  332. /// <param name="x">The x-coordinate of the upper-left corner of the rectangle to draw.</param>
  333. /// <param name="y">The y-coordinate of the upper-left corner of the rectangle to draw.</param>
  334. /// <param name="width">The width of the rectangle to draw.</param>
  335. /// <param name="height">The height of the rectangle to draw.</param>
  336. internal void DrawRectangle(
  337. Pen pen,
  338. float x,
  339. float y,
  340. float width,
  341. float height
  342. )
  343. {
  344. RenderingObject.DrawRectangle( pen, x, y, width, height );
  345. }
  346. /// <summary>
  347. /// Draws a GraphicsPath object.
  348. /// </summary>
  349. /// <param name="pen">Pen object that determines the color, width, and style of the path.</param>
  350. /// <param name="path">GraphicsPath object to draw.</param>
  351. internal void DrawPath(
  352. Pen pen,
  353. GraphicsPath path
  354. )
  355. {
  356. // Check if path is empty
  357. if(path == null ||
  358. path.PointCount == 0)
  359. {
  360. return;
  361. }
  362. RenderingObject.DrawPath( pen, path );
  363. }
  364. /// <summary>
  365. /// Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, and a height and two radial lines.
  366. /// </summary>
  367. /// <param name="pen">Pen object that determines the color, width, and style of the pie shape.</param>
  368. /// <param name="x">x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.</param>
  369. /// <param name="y">y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.</param>
  370. /// <param name="width">Width of the bounding rectangle that defines the ellipse from which the pie shape comes.</param>
  371. /// <param name="height">Height of the bounding rectangle that defines the ellipse from which the pie shape comes.</param>
  372. /// <param name="startAngle">Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.</param>
  373. /// <param name="sweepAngle">Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.</param>
  374. internal void DrawPie(
  375. Pen pen,
  376. float x,
  377. float y,
  378. float width,
  379. float height,
  380. float startAngle,
  381. float sweepAngle
  382. )
  383. {
  384. RenderingObject.DrawPie( pen, x, y, width, height, startAngle, sweepAngle );
  385. }
  386. /// <summary>
  387. /// Draws an ellipse defined by a bounding RectangleF.
  388. /// </summary>
  389. /// <param name="pen">Pen object that determines the color, width, and style of the ellipse.</param>
  390. /// <param name="rect">RectangleF structure that defines the boundaries of the ellipse.</param>
  391. internal void DrawEllipse(
  392. Pen pen,
  393. RectangleF rect
  394. )
  395. {
  396. RenderingObject.DrawEllipse( pen, rect );
  397. }
  398. /// <summary>
  399. /// Draws a series of line segments that connect an array of PointF structures.
  400. /// </summary>
  401. /// <param name="pen">Pen object that determines the color, width, and style of the line segments.</param>
  402. /// <param name="points">Array of PointF structures that represent the points to connect.</param>
  403. internal void DrawLines(
  404. Pen pen,
  405. PointF[] points
  406. )
  407. {
  408. RenderingObject.DrawLines( pen, points );
  409. }
  410. #endregion // Drawing Methods
  411. #region Filling Methods
  412. /// <summary>
  413. /// Fills the interior of an ellipse defined by a bounding rectangle
  414. /// specified by a RectangleF structure.
  415. /// </summary>
  416. /// <param name="brush">Brush object that determines the characteristics of the fill.</param>
  417. /// <param name="rect">RectangleF structure that represents the bounding rectangle that defines the ellipse.</param>
  418. internal void FillEllipse(
  419. Brush brush,
  420. RectangleF rect
  421. )
  422. {
  423. RenderingObject.FillEllipse( brush, rect );
  424. }
  425. /// <summary>
  426. /// Fills the interior of a GraphicsPath object.
  427. /// </summary>
  428. /// <param name="brush">Brush object that determines the characteristics of the fill.</param>
  429. /// <param name="path">GraphicsPath object that represents the path to fill.</param>
  430. internal void FillPath(
  431. Brush brush,
  432. GraphicsPath path
  433. )
  434. {
  435. // Check if path is empty
  436. if(path == null ||
  437. path.PointCount == 0)
  438. {
  439. return;
  440. }
  441. RenderingObject.FillPath( brush, path );
  442. }
  443. /// <summary>
  444. /// Fills the interior of a Region object.
  445. /// </summary>
  446. /// <param name="brush">Brush object that determines the characteristics of the fill.</param>
  447. /// <param name="region">Region object that represents the area to fill.</param>
  448. internal void FillRegion(
  449. Brush brush,
  450. Region region
  451. )
  452. {
  453. RenderingObject.FillRegion( brush, region );
  454. }
  455. /// <summary>
  456. /// Fills the interior of a rectangle specified by a RectangleF structure.
  457. /// </summary>
  458. /// <param name="brush">Brush object that determines the characteristics of the fill.</param>
  459. /// <param name="rect">RectangleF structure that represents the rectangle to fill.</param>
  460. internal void FillRectangle(
  461. Brush brush,
  462. RectangleF rect
  463. )
  464. {
  465. RenderingObject.FillRectangle( brush, rect );
  466. }
  467. /// <summary>
  468. /// Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height.
  469. /// </summary>
  470. /// <param name="brush">Brush object that determines the characteristics of the fill.</param>
  471. /// <param name="x">x-coordinate of the upper-left corner of the rectangle to fill.</param>
  472. /// <param name="y">y-coordinate of the upper-left corner of the rectangle to fill.</param>
  473. /// <param name="width">Width of the rectangle to fill.</param>
  474. /// <param name="height">Height of the rectangle to fill.</param>
  475. internal void FillRectangle(
  476. Brush brush,
  477. float x,
  478. float y,
  479. float width,
  480. float height
  481. )
  482. {
  483. RenderingObject.FillRectangle( brush, x, y, width, height );
  484. }
  485. /// <summary>
  486. /// Fills the interior of a polygon defined by an array of points specified by PointF structures .
  487. /// </summary>
  488. /// <param name="brush">Brush object that determines the characteristics of the fill.</param>
  489. /// <param name="points">Array of PointF structures that represent the vertices of the polygon to fill.</param>
  490. internal void FillPolygon(
  491. Brush brush,
  492. PointF[] points
  493. )
  494. {
  495. RenderingObject.FillPolygon( brush, points );
  496. }
  497. /// <summary>
  498. /// Fills the interior of a pie section defined by an ellipse
  499. /// specified by a pair of coordinates, a width, and a height
  500. /// and two radial lines.
  501. /// </summary>
  502. /// <param name="brush">Brush object that determines the characteristics of the fill.</param>
  503. /// <param name="x">x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.</param>
  504. /// <param name="y">y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie section comes.</param>
  505. /// <param name="width">Width of the bounding rectangle that defines the ellipse from which the pie section comes.</param>
  506. /// <param name="height">Height of the bounding rectangle that defines the ellipse from which the pie section comes.</param>
  507. /// <param name="startAngle">Angle in degrees measured clockwise from the x-axis to the first side of the pie section.</param>
  508. /// <param name="sweepAngle">Angle in degrees measured clockwise from the startAngle parameter to the second side of the pie section.</param>
  509. internal void FillPie(
  510. Brush brush,
  511. float x,
  512. float y,
  513. float width,
  514. float height,
  515. float startAngle,
  516. float sweepAngle
  517. )
  518. {
  519. RenderingObject.FillPie( brush, x, y, width, height, startAngle, sweepAngle );
  520. }
  521. #endregion // Filling Methods
  522. #region Other Methods
  523. /// <summary>
  524. /// This method starts SVG Selection mode
  525. /// </summary>
  526. /// <param name="url">The location of the referenced object, expressed as a URI reference.</param>
  527. /// <param name="title">Title which could be used for tooltips.</param>
  528. internal void StartHotRegion( string url, string title )
  529. {
  530. RenderingObject.BeginSelection( url, title );
  531. }
  532. /// <summary>
  533. /// This method starts SVG Selection mode
  534. /// </summary>
  535. /// <param name="point">Data Point which properties are used for SVG selection</param>
  536. internal void StartHotRegion(DataPoint point)
  537. {
  538. StartHotRegion( point, false );
  539. }
  540. /// <summary>
  541. /// This method starts SVG Selection mode
  542. /// </summary>
  543. /// <param name="point">Data Point which properties are used for SVG selection</param>
  544. /// <param name="labelRegion">Indicates if point label region is processed.</param>
  545. internal void StartHotRegion(DataPoint point, bool labelRegion)
  546. {
  547. string hRef = string.Empty;
  548. string tooltip = (labelRegion) ? point.LabelToolTip : point.ToolTip;
  549. if (hRef.Length > 0 || tooltip.Length > 0)
  550. {
  551. RenderingObject.BeginSelection(
  552. point.ReplaceKeywords( hRef ),
  553. point.ReplaceKeywords( tooltip ) );
  554. }
  555. }
  556. /// <summary>
  557. /// This method stops SVG Selection mode
  558. /// </summary>
  559. internal void EndHotRegion()
  560. {
  561. RenderingObject.EndSelection();
  562. }
  563. /// <summary>
  564. /// Measures the specified string when drawn with the specified
  565. /// Font object and formatted with the specified StringFormat object.
  566. /// </summary>
  567. /// <param name="text">String to measure.</param>
  568. /// <param name="font">Font object defines the text format of the string.</param>
  569. /// <param name="layoutArea">SizeF structure that specifies the maximum layout area for the text.</param>
  570. /// <param name="stringFormat">StringFormat object that represents formatting information, such as line spacing, for the string.</param>
  571. /// <returns>This method returns a SizeF structure that represents the size, in pixels, of the string specified in the text parameter as drawn with the font parameter and the stringFormat parameter.</returns>
  572. internal SizeF MeasureString(
  573. string text,
  574. Font font,
  575. SizeF layoutArea,
  576. StringFormat stringFormat
  577. )
  578. {
  579. return RenderingObject.MeasureString( text, font, layoutArea, stringFormat );
  580. }
  581. /// <summary>
  582. /// Measures the specified string when drawn with the specified
  583. /// Font object and formatted with the specified StringFormat object.
  584. /// </summary>
  585. /// <param name="text">String to measure.</param>
  586. /// <param name="font">Font object defines the text format of the string.</param>
  587. /// <returns>This method returns a SizeF structure that represents the size, in pixels, of the string specified in the text parameter as drawn with the font parameter and the stringFormat parameter.</returns>
  588. internal SizeF MeasureString(
  589. string text,
  590. Font font
  591. )
  592. {
  593. return RenderingObject.MeasureString( text, font );
  594. }
  595. /// <summary>
  596. /// Saves the current state of this Graphics object and identifies the saved state with a GraphicsState object.
  597. /// </summary>
  598. /// <returns>This method returns a GraphicsState object that represents the saved state of this Graphics object.</returns>
  599. internal IGraphicsState Save()
  600. {
  601. return RenderingObject.Save();
  602. }
  603. /// <summary>
  604. /// Restores the state of this Graphics object to the state represented by a GraphicsState object.
  605. /// </summary>
  606. /// <param name="gstate">GraphicsState object that represents the state to which to restore this Graphics object.</param>
  607. internal void Restore(
  608. IGraphicsState gstate
  609. )
  610. {
  611. RenderingObject.Restore( gstate );
  612. }
  613. /// <summary>
  614. /// Resets the clip region of this Graphics object to an infinite region.
  615. /// </summary>
  616. internal void ResetClip()
  617. {
  618. RenderingObject.ResetClip();
  619. }
  620. /// <summary>
  621. /// Sets the clipping region of this Graphics object to the rectangle specified by a RectangleF structure.
  622. /// </summary>
  623. /// <param name="rect">RectangleF structure that represents the new clip region.</param>
  624. internal void SetClipAbs(RectangleF rect)
  625. {
  626. RenderingObject.SetClip( rect );
  627. }
  628. /// <summary>
  629. /// Prepends the specified translation to the transformation matrix of this Graphics object.
  630. /// </summary>
  631. /// <param name="dx">x component of the translation.</param>
  632. /// <param name="dy">y component of the translation.</param>
  633. internal void TranslateTransform(
  634. float dx,
  635. float dy
  636. )
  637. {
  638. RenderingObject.TranslateTransform( dx, dy );
  639. }
  640. #endregion // Other Methods
  641. #region Properties
  642. /// <summary>
  643. /// Gets current rendering object.
  644. /// </summary>
  645. internal IChartRenderingEngine RenderingObject
  646. {
  647. get
  648. {
  649. return _gdiGraphics;
  650. }
  651. }
  652. /// <summary>
  653. /// Gets the active rendering type.
  654. /// </summary>
  655. internal RenderingType ActiveRenderingType
  656. {
  657. get
  658. {
  659. return _activeRenderingType;
  660. }
  661. }
  662. /// <summary>
  663. /// Gets or sets the rendering mode for text associated with this Graphics object.
  664. /// </summary>
  665. internal TextRenderingHint TextRenderingHint
  666. {
  667. get
  668. {
  669. return RenderingObject.TextRenderingHint;
  670. }
  671. set
  672. {
  673. RenderingObject.TextRenderingHint = value;
  674. }
  675. }
  676. /// <summary>
  677. /// Gets or sets the world transformation for this Graphics object.
  678. /// </summary>
  679. internal Matrix Transform
  680. {
  681. get
  682. {
  683. return RenderingObject.Transform;
  684. }
  685. set
  686. {
  687. RenderingObject.Transform = value;
  688. }
  689. }
  690. /// <summary>
  691. /// Gets or sets the rendering quality for this Graphics object.
  692. /// </summary>
  693. internal SmoothingMode SmoothingMode
  694. {
  695. get
  696. {
  697. return RenderingObject.SmoothingMode;
  698. }
  699. set
  700. {
  701. RenderingObject.SmoothingMode = value;
  702. }
  703. }
  704. /// <summary>
  705. /// Gets or sets a Region object that limits the drawing region of this Graphics object.
  706. /// </summary>
  707. internal Region Clip
  708. {
  709. get
  710. {
  711. return RenderingObject.Clip;
  712. }
  713. set
  714. {
  715. RenderingObject.Clip = value;
  716. }
  717. }
  718. /// <summary>
  719. /// Gets a value indicating whether the clipping region of this Graphics object is empty.
  720. /// </summary>
  721. internal bool IsClipEmpty {
  722. get
  723. {
  724. return RenderingObject.IsClipEmpty;
  725. }
  726. }
  727. /// <summary>
  728. /// Gets or sets the reference to the Graphics object.
  729. /// </summary>
  730. public IGraphics Graphics
  731. {
  732. get
  733. {
  734. return RenderingObject.Graphics;
  735. }
  736. set
  737. {
  738. RenderingObject.Graphics = value;
  739. }
  740. }
  741. #endregion // Properties
  742. }
  743. }