DXFGraphicsRenderer.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. using FastReport.Export.Dxf;
  2. using FastReport.Export.Dxf.Utils;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Drawing.Imaging;
  8. using System.Drawing.Text;
  9. namespace FastReport.Utils
  10. {
  11. public class DXFGraphicsRenderer : IGraphics
  12. {
  13. #region Private Fields
  14. private float barcodesGap;
  15. private DxfDocument dxfDocument;
  16. private DxfFillMode fillMode;
  17. private Bitmap internalImage;
  18. private Graphics measureGraphics;
  19. private System.Drawing.Drawing2D.Matrix transformMatrix;
  20. #endregion Private Fields
  21. #region Public Constructors
  22. // BarcodesGap shouldd be modified if DXFGraphicsRenderer will be used for any other purposes
  23. public DXFGraphicsRenderer(DxfDocument dxfDocument, DxfFillMode fillMode, float barcodesGap)
  24. {
  25. this.internalImage = new Bitmap(1, 1);
  26. this.dxfDocument = dxfDocument;
  27. this.measureGraphics = Graphics.FromImage(internalImage);
  28. transformMatrix = new System.Drawing.Drawing2D.Matrix();
  29. this.fillMode = fillMode;
  30. this.barcodesGap = barcodesGap;
  31. }
  32. float IGraphics.DpiY
  33. {
  34. get
  35. {
  36. throw new NotImplementedException();
  37. }
  38. }
  39. TextRenderingHint IGraphics.TextRenderingHint
  40. {
  41. get
  42. {
  43. throw new NotImplementedException();
  44. }
  45. set
  46. {
  47. throw new NotImplementedException();
  48. }
  49. }
  50. InterpolationMode IGraphics.InterpolationMode
  51. {
  52. get
  53. {
  54. throw new NotImplementedException();
  55. }
  56. set
  57. {
  58. throw new NotImplementedException();
  59. }
  60. }
  61. SmoothingMode IGraphics.SmoothingMode
  62. {
  63. get
  64. {
  65. throw new NotImplementedException();
  66. }
  67. set
  68. {
  69. throw new NotImplementedException();
  70. }
  71. }
  72. Graphics IGraphics.Graphics
  73. {
  74. get
  75. {
  76. throw new NotImplementedException();
  77. }
  78. }
  79. System.Drawing.Drawing2D.Matrix IGraphics.Transform
  80. {
  81. get
  82. {
  83. throw new NotImplementedException();
  84. }
  85. set
  86. {
  87. throw new NotImplementedException();
  88. }
  89. }
  90. GraphicsUnit IGraphics.PageUnit
  91. {
  92. get
  93. {
  94. throw new NotImplementedException();
  95. }
  96. set
  97. {
  98. throw new NotImplementedException();
  99. }
  100. }
  101. bool IGraphics.IsClipEmpty
  102. {
  103. get
  104. {
  105. throw new NotImplementedException();
  106. }
  107. }
  108. Region IGraphics.Clip
  109. {
  110. get
  111. {
  112. throw new NotImplementedException();
  113. }
  114. set
  115. {
  116. throw new NotImplementedException();
  117. }
  118. }
  119. float IGraphics.DpiX
  120. {
  121. get
  122. {
  123. throw new NotImplementedException();
  124. }
  125. }
  126. CompositingQuality IGraphics.CompositingQuality
  127. {
  128. get
  129. {
  130. throw new NotImplementedException();
  131. }
  132. set
  133. {
  134. throw new NotImplementedException();
  135. }
  136. }
  137. #endregion Public Constructors
  138. #region Public Methods
  139. public static PointF[] RotateVector(PointF[] vector, double angle, PointF center)
  140. {
  141. PointF[] rotatedVector = new PointF[vector.Length];
  142. for (int i = 0; i < vector.Length; i++)
  143. {
  144. rotatedVector[i].X = (float)(center.X + (vector[i].X - center.X) * Math.Cos(angle) + (center.Y - vector[i].Y) * Math.Sin(angle));
  145. rotatedVector[i].Y = (float)(center.Y + (vector[i].X - center.X) * Math.Sin(angle) + (vector[i].Y - center.Y) * Math.Cos(angle));
  146. }
  147. return rotatedVector;
  148. }
  149. public void Dispose()
  150. {
  151. //if (dxfDocument != null)
  152. //{
  153. // dxfDocument.Clear();
  154. // dxfDocument = null;
  155. //}
  156. if (measureGraphics != null)
  157. {
  158. measureGraphics.Dispose();
  159. measureGraphics = null;
  160. }
  161. }
  162. public void DrawEllipse(Pen pen, float left, float top, float width, float height)
  163. {
  164. LineStyle lineStyle = GetLineStyle(pen.DashStyle);
  165. // added gap
  166. dxfDocument.DrawEllipse(left + barcodesGap / 2 + transformMatrix.OffsetX, transformMatrix.OffsetY - top - barcodesGap / 2, width - barcodesGap, height - barcodesGap, pen.Color, pen.Width, lineStyle);
  167. }
  168. public void DrawLine(Pen pen, float x1, float y1, float x2, float y2)
  169. {
  170. LineStyle lineStyle = GetLineStyle(pen.DashStyle);
  171. if (fillMode != DxfFillMode.Border)
  172. dxfDocument.DrawLine(x1 + transformMatrix.OffsetX, transformMatrix.OffsetY - y1, x2 + transformMatrix.OffsetX, transformMatrix.OffsetY - y2, pen.Color, pen.Width, lineStyle);
  173. else
  174. {
  175. //added gap
  176. PointF[] points = new PointF[4];
  177. points[0] = GetOrtogonalPoint(new PointF(x1, y1), new PointF(x2, y2), pen.Width / 2 - barcodesGap);
  178. points[1] = GetOrtogonalPoint(new PointF(x2, y2), new PointF(x1, y1), pen.Width / 2 - barcodesGap);
  179. points[2] = GetOrtogonalPoint(new PointF(x2, y2), new PointF(x1, y1), -pen.Width / 2 - barcodesGap);
  180. points[3] = GetOrtogonalPoint(new PointF(x1, y1), new PointF(x2, y2), -pen.Width / 2 - barcodesGap);
  181. dxfDocument.DrawPolygon(transformMatrix.OffsetX, transformMatrix.OffsetY, DxfExtMethods.InvertY(points), new byte[points.Length], (pen.Brush as SolidBrush).Color, 1 / 100.0f, LineStyle.Solid);
  182. }
  183. }
  184. public void DrawString(string text, Font drawFont, Brush brush, float left, float top)
  185. {
  186. //ToDo - baseLine
  187. DrawStringInternal(text, drawFont, brush, left, top, 0);
  188. }
  189. public void DrawString(string text, Font drawFont, Brush brush, float left, float top, float baseLine)
  190. {
  191. DrawStringInternal(text, drawFont, brush, left, top, baseLine);
  192. }
  193. public void DrawString(string text, Font drawFont, Brush brush, RectangleF rectangleF)
  194. {
  195. //ToDo - baseLine
  196. DrawStringInternal(text, drawFont, brush, rectangleF.X, rectangleF.Y, 0);
  197. }
  198. public void FillPath(Brush brush, GraphicsPath path)
  199. {
  200. if (fillMode == DxfFillMode.Solid && brush is SolidBrush)
  201. FillGraphicsPath(transformMatrix.OffsetX, transformMatrix.OffsetY, path, (brush as SolidBrush).Color, true);
  202. else
  203. AddGraphicsPath(path, (brush as SolidBrush).Color, 1 / 100.0f, LineStyle.Solid, transformMatrix.OffsetX,
  204. transformMatrix.OffsetY, true, true, 0, new PointF(0, 0));
  205. }
  206. public void FillPolygon(Brush brush, PointF[] points)
  207. {
  208. if (fillMode == DxfFillMode.Solid && brush is SolidBrush)
  209. dxfDocument.FillPolygon(transformMatrix.OffsetX, transformMatrix.OffsetY, DxfExtMethods.InvertY(points), new byte[points.Length], (brush as SolidBrush).Color);
  210. else
  211. dxfDocument.DrawPolygon(transformMatrix.OffsetX, transformMatrix.OffsetY, DxfExtMethods.InvertY(points), new byte[points.Length], (brush as SolidBrush).Color, 1 / 100.0f, LineStyle.Solid);
  212. //if (brush is SolidBrush)
  213. // dxfDocument.FillPolygon(transformMatrix.OffsetX, transformMatrix.OffsetY, points.InvertY(), new byte[points.Length], (brush as SolidBrush).Color);
  214. }
  215. public void FillRectangle(Brush brush, float left, float top, float width, float height)
  216. {
  217. if (brush is SolidBrush)
  218. {
  219. //if o degies
  220. // dxfDocument.FillRectangle(left + transformMatrix.OffsetX, transformMatrix.OffsetY - top - height, width, height, (brush as SolidBrush).Color);
  221. //else
  222. PointF[] points = new PointF[4];
  223. points[0] = new PointF(left, top);
  224. points[1] = new PointF(left + width - barcodesGap, top);
  225. points[2] = new PointF(left + width - barcodesGap, top + height - barcodesGap);
  226. points[3] = new PointF(left, top + height - barcodesGap);
  227. TransformPoints(transformMatrix, points);
  228. points = DxfExtMethods.InvertY(points);
  229. if (fillMode == DxfFillMode.Solid && brush is SolidBrush)
  230. dxfDocument.FillPolygon(barcodesGap / 2, transformMatrix.OffsetY - barcodesGap / 2, points, new byte[points.Length], (brush as SolidBrush).Color);
  231. else
  232. dxfDocument.DrawPolygon(barcodesGap / 2, transformMatrix.OffsetY - barcodesGap / 2, points, new byte[points.Length], (brush as SolidBrush).Color, 1 / 100.0f, LineStyle.Solid);
  233. }
  234. }
  235. public SizeF MeasureString(string text, Font drawFont)
  236. {
  237. return this.measureGraphics.MeasureString(text, drawFont);
  238. }
  239. public void Restore(IGraphicsState state)
  240. {
  241. if (state is DXFGraphicsRendererState)
  242. {
  243. DXFGraphicsRendererState gState = state as DXFGraphicsRendererState;
  244. transformMatrix = gState.Matrix;
  245. }
  246. }
  247. public void RotateTransform(float angle)
  248. {
  249. transformMatrix.Rotate(angle);
  250. }
  251. public IGraphicsState Save()
  252. {
  253. return new DXFGraphicsRendererState(transformMatrix);
  254. }
  255. public void Scale(float scaleX, float scaleY)
  256. {
  257. transformMatrix.Scale(scaleX, scaleY);
  258. }
  259. public void TranslateTransform(float left, float top)
  260. {
  261. transformMatrix.Translate(left, top);
  262. }
  263. #endregion Public Methods
  264. #region Private Methods
  265. private void AddGraphicsPath(GraphicsPath path, Color borderColor, float borderWith,
  266. LineStyle borderLineStyle, float left, float top, bool isClosed, bool invertY, float angle, PointF center)
  267. {
  268. List<PointF> points = new List<PointF>();
  269. List<byte> pTypes = new List<byte>();
  270. byte[] pathTypes = path.PathTypes;
  271. PointF[] pathPoints = path.PathPoints;
  272. if (angle != 0)
  273. {
  274. // rotate
  275. pathPoints = RotateVector(pathPoints, angle, center);
  276. }
  277. if (invertY)
  278. pathPoints = DxfExtMethods.InvertY(pathPoints);
  279. for (int i = 0; i < pathTypes.Length; i++)
  280. {
  281. byte pType = pathTypes[i];
  282. PointF point = pathPoints[i];
  283. if (pType == 0 && points.Count > 0)
  284. {
  285. AddPath(points.ToArray(), pTypes.ToArray(), borderColor, borderWith,
  286. borderLineStyle, left, top, isClosed);
  287. points.Clear();
  288. pTypes.Clear();
  289. }
  290. points.Add(point);
  291. pTypes.Add(pType);
  292. if (i == pathTypes.Length - 1)
  293. {
  294. AddPath(points.ToArray(), pTypes.ToArray(), borderColor, borderWith,
  295. borderLineStyle, left, top, isClosed);
  296. }
  297. }
  298. }
  299. private void AddPath(PointF[] points, byte[] pointTypes, Color borderColor, float borderWidth,
  300. LineStyle borderLineStyle, float left, float top, bool isClosed)
  301. {
  302. float x = left;
  303. float y = top;
  304. dxfDocument.DrawPolyLine(x, y, points, pointTypes, borderColor, borderWidth / Units.Millimeters,
  305. borderLineStyle, isClosed);
  306. }
  307. void IGraphics.DrawArc(Pen pen, float x, float y, float dx, float dy, float v1, float v2)
  308. {
  309. throw new NotImplementedException();
  310. }
  311. void IGraphics.DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension)
  312. {
  313. throw new NotImplementedException();
  314. }
  315. void IGraphics.DrawEllipse(Pen pen, RectangleF pointerCircle)
  316. {
  317. throw new NotImplementedException();
  318. }
  319. void IGraphics.DrawImage(Image image, float x, float y)
  320. {
  321. throw new NotImplementedException();
  322. }
  323. void IGraphics.DrawImage(Image image, RectangleF rect1, RectangleF rect2, GraphicsUnit unit)
  324. {
  325. throw new NotImplementedException();
  326. }
  327. void IGraphics.DrawImage(Image image, RectangleF rect)
  328. {
  329. throw new NotImplementedException();
  330. }
  331. void IGraphics.DrawImage(Image image, float x, float y, float width, float height)
  332. {
  333. throw new NotImplementedException();
  334. }
  335. void IGraphics.DrawImage(Image image, PointF[] points)
  336. {
  337. throw new NotImplementedException();
  338. }
  339. void IGraphics.DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
  340. {
  341. throw new NotImplementedException();
  342. }
  343. void IGraphics.DrawImage(Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
  344. {
  345. throw new NotImplementedException();
  346. }
  347. void IGraphics.DrawImageUnscaled(Image image, Rectangle rect)
  348. {
  349. throw new NotImplementedException();
  350. }
  351. void IGraphics.DrawLine(Pen pen, PointF p1, PointF p2)
  352. {
  353. throw new NotImplementedException();
  354. }
  355. void IGraphics.DrawLines(Pen pen, PointF[] pointFs)
  356. {
  357. throw new NotImplementedException();
  358. }
  359. void IGraphics.DrawPath(Pen outlinePen, GraphicsPath path)
  360. {
  361. throw new NotImplementedException();
  362. }
  363. void IGraphics.DrawPie(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
  364. {
  365. throw new NotImplementedException();
  366. }
  367. void IGraphics.DrawPolygon(Pen pen, PointF[] diaPoints)
  368. {
  369. throw new NotImplementedException();
  370. }
  371. void IGraphics.DrawPolygon(Pen pen, Point[] points)
  372. {
  373. throw new NotImplementedException();
  374. }
  375. void IGraphics.DrawRectangle(Pen borderPen, float left, float top, float width, float height)
  376. {
  377. throw new NotImplementedException();
  378. }
  379. void IGraphics.DrawRectangle(Pen green, Rectangle rectangle)
  380. {
  381. throw new NotImplementedException();
  382. }
  383. void IGraphics.DrawString(string text, Font font, Brush textBrush, RectangleF textRect, StringFormat format)
  384. {
  385. throw new NotImplementedException();
  386. }
  387. void IGraphics.DrawString(string text, Font font, Brush brush, float left, float top, StringFormat format)
  388. {
  389. throw new NotImplementedException();
  390. }
  391. void IGraphics.DrawString(string s, Font font, Brush brush, PointF point, StringFormat format)
  392. {
  393. throw new NotImplementedException();
  394. }
  395. private void DrawStringInternal(string text, Font font, Brush brush, float left, float top, float baseLine)
  396. {
  397. if (!String.IsNullOrEmpty(text))
  398. {
  399. GraphicsPath myPath = new GraphicsPath();
  400. PointF origin = new PointF(0, 0);
  401. // Add the string to the path.
  402. myPath.AddString(text,
  403. font.FontFamily,
  404. (int)font.Style,
  405. font.Size,
  406. origin,
  407. StringFormat.GenericDefault);
  408. if (brush is SolidBrush)
  409. AddGraphicsPath(myPath, (brush as SolidBrush).Color, 1 / 100.0f, LineStyle.Solid, transformMatrix.OffsetX + left,
  410. transformMatrix.OffsetY - top, true, true, 0, new PointF(0, 0));
  411. }
  412. }
  413. void IGraphics.FillAndDrawEllipse(Pen pen, Brush brush, RectangleF rect)
  414. {
  415. throw new NotImplementedException();
  416. }
  417. void IGraphics.FillAndDrawEllipse(Pen pen, Brush brush, float left, float top, float width, float height)
  418. {
  419. throw new NotImplementedException();
  420. }
  421. void IGraphics.FillAndDrawPath(Pen pen, Brush brush, GraphicsPath path)
  422. {
  423. throw new NotImplementedException();
  424. }
  425. void IGraphics.FillAndDrawPolygon(Pen pen, Brush brush, Point[] points)
  426. {
  427. throw new NotImplementedException();
  428. }
  429. void IGraphics.FillAndDrawPolygon(Pen pen, Brush brush, PointF[] points)
  430. {
  431. throw new NotImplementedException();
  432. }
  433. void IGraphics.FillAndDrawRectangle(Pen pen, Brush brush, float left, float top, float width, float height)
  434. {
  435. throw new NotImplementedException();
  436. }
  437. void IGraphics.FillEllipse(Brush brush, float x, float y, float dx, float dy)
  438. {
  439. throw new NotImplementedException();
  440. }
  441. void IGraphics.FillEllipse(Brush brush, RectangleF pointerCircle)
  442. {
  443. throw new NotImplementedException();
  444. }
  445. private void FillGraphicsPath(float x, float y, GraphicsPath path, Color color, bool invertY)
  446. {
  447. List<PointF> points = new List<PointF>();
  448. List<byte> pTypes = new List<byte>();
  449. byte[] pathTypes = path.PathTypes;
  450. PointF[] pathPoints = path.PathPoints;
  451. if (invertY)
  452. pathPoints = DxfExtMethods.InvertY(pathPoints);
  453. for (int i = 0; i < pathTypes.Length; i++)
  454. {
  455. byte pType = pathTypes[i];
  456. PointF point = pathPoints[i];
  457. if (pType == 0 && points.Count > 0)
  458. {
  459. if (fillMode == DxfFillMode.Solid)
  460. dxfDocument.FillPolygon(x, y, points.ToArray(), pTypes.ToArray(), color);
  461. else
  462. dxfDocument.DrawPolygon(x, y, points.ToArray(), pTypes.ToArray(), color, 1 / 100.0f, LineStyle.Solid);
  463. points.Clear();
  464. pTypes.Clear();
  465. }
  466. points.Add(point);
  467. pTypes.Add(pType);
  468. if (i == pathTypes.Length - 1)
  469. {
  470. if (fillMode == DxfFillMode.Solid)
  471. dxfDocument.FillPolygon(0, 0, points.ToArray(), pTypes.ToArray(), color);
  472. else
  473. dxfDocument.DrawPolygon(0, 0, points.ToArray(), pTypes.ToArray(), color, 1 / 100.0f, LineStyle.Solid);
  474. }
  475. }
  476. }
  477. void IGraphics.FillPie(Brush brush, float x, float y, float dx, float dy, float v1, float v2)
  478. {
  479. throw new NotImplementedException();
  480. }
  481. void IGraphics.FillPolygon(Brush brush, Point[] points)
  482. {
  483. throw new NotImplementedException();
  484. }
  485. void IGraphics.FillRectangle(Brush brush, RectangleF drawRect)
  486. {
  487. throw new NotImplementedException();
  488. }
  489. void IGraphics.FillRegion(Brush brush, Region region)
  490. {
  491. throw new NotImplementedException();
  492. }
  493. private LineStyle GetLineStyle(DashStyle dashStyle)
  494. {
  495. LineStyle lineStyle;
  496. switch (dashStyle)
  497. {
  498. case DashStyle.Dash:
  499. lineStyle = LineStyle.Dash; break;
  500. case DashStyle.DashDot:
  501. lineStyle = LineStyle.DashDot; break;
  502. case DashStyle.DashDotDot:
  503. lineStyle = LineStyle.DashDotDot; break;
  504. case DashStyle.Dot:
  505. lineStyle = LineStyle.Dot; break;
  506. case DashStyle.Solid:
  507. default:
  508. lineStyle = LineStyle.Solid; break;
  509. }
  510. return lineStyle;
  511. }
  512. private PointF GetOrtogonalPoint(PointF a, PointF b, float bc)
  513. {
  514. float x2x1 = a.X - b.X;
  515. float y2y1 = a.Y - b.Y;
  516. float ab = (float)Math.Sqrt(x2x1 * x2x1 + y2y1 * y2y1);
  517. float v1x = (b.X - a.X) / ab;
  518. float v1y = (b.Y - a.Y) / ab;
  519. float v3x = (v1y > 0 ? -v1y : v1y) * bc;
  520. float v3y = (v1x > 0 ? v1x : -v1x) * bc;
  521. PointF c = new PointF();
  522. c.X = a.X + v3x;
  523. c.Y = a.Y + v3y;
  524. return c;
  525. }
  526. bool IGraphics.IsVisible(RectangleF objRect)
  527. {
  528. throw new NotImplementedException();
  529. }
  530. Region[] IGraphics.MeasureCharacterRanges(string text, Font font, RectangleF textRect, StringFormat format)
  531. {
  532. throw new NotImplementedException();
  533. }
  534. SizeF IGraphics.MeasureString(string text, Font font, SizeF size)
  535. {
  536. throw new NotImplementedException();
  537. }
  538. SizeF IGraphics.MeasureString(string text, Font font, int v, StringFormat format)
  539. {
  540. throw new NotImplementedException();
  541. }
  542. void IGraphics.MeasureString(string text, Font font, SizeF size, StringFormat format, out int charsFit, out int linesFit)
  543. {
  544. throw new NotImplementedException();
  545. }
  546. SizeF IGraphics.MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat)
  547. {
  548. throw new NotImplementedException();
  549. }
  550. void IGraphics.MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix, MatrixOrder prepend)
  551. {
  552. throw new NotImplementedException();
  553. }
  554. void IGraphics.ResetClip()
  555. {
  556. throw new NotImplementedException();
  557. }
  558. void IGraphics.ScaleTransform(float scaleX, float scaleY)
  559. {
  560. throw new NotImplementedException();
  561. }
  562. void IGraphics.SetClip(RectangleF textRect)
  563. {
  564. throw new NotImplementedException();
  565. }
  566. void IGraphics.SetClip(RectangleF displayRect, CombineMode intersect)
  567. {
  568. throw new NotImplementedException();
  569. }
  570. void IGraphics.SetClip(GraphicsPath path, CombineMode combineMode)
  571. {
  572. throw new NotImplementedException();
  573. }
  574. private void TransformPoints(System.Drawing.Drawing2D.Matrix fTransformMatrix, PointF[] points)
  575. {
  576. float a = fTransformMatrix.Elements[0]; // scale horizontal
  577. float b = fTransformMatrix.Elements[1]; // lean vert
  578. float c = fTransformMatrix.Elements[2]; // lean horizontal
  579. float d = fTransformMatrix.Elements[3]; //scale vertical
  580. float e = fTransformMatrix.Elements[4]; // x offset
  581. float f = 0;// fTransformMatrix.Elements[5]; // y offset
  582. for (int i = 0; i < points.Length; i++)
  583. {
  584. float x0 = points[i].X;
  585. float y0 = points[i].Y;
  586. float x1 = a * x0 + c * y0 + e;
  587. float y1 = b * x0 + d * y0 + f;
  588. points[i].X = x1;
  589. points[i].Y = y1;
  590. }
  591. }
  592. #endregion Private Methods
  593. }
  594. public class DXFGraphicsRendererState : IGraphicsState
  595. {
  596. #region Private Fields
  597. private System.Drawing.Drawing2D.Matrix matrix;
  598. #endregion Private Fields
  599. #region Public Properties
  600. public System.Drawing.Drawing2D.Matrix Matrix
  601. {
  602. get
  603. {
  604. return matrix;
  605. }
  606. }
  607. #endregion Public Properties
  608. #region Public Constructors
  609. public DXFGraphicsRendererState(System.Drawing.Drawing2D.Matrix matrix)
  610. {
  611. this.matrix = matrix;
  612. }
  613. #endregion Public Constructors
  614. }
  615. }