Extensions.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using FastReport.Export.Hpgl.Commands;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. namespace FastReport.Export.Hpgl
  8. {
  9. public static class Extensions
  10. {
  11. public static void SelectPen(this List<CommandBase> commands)
  12. {
  13. commands.Add(new SelectPen());
  14. }
  15. public static void PenUp(this List<CommandBase> commands)
  16. {
  17. commands.Add(new PenUp());
  18. }
  19. public static void PlotAbsolute(this List<CommandBase> commands, float x, float y)
  20. {
  21. commands.Add(new PlotAbsolute(x, y));
  22. }
  23. public static void PlotRelative(this List<CommandBase> commands, float x, float y)
  24. {
  25. commands.Add(new PlotRelative(x, y));
  26. }
  27. public static void PenDown(this List<CommandBase> commands)
  28. {
  29. commands.Add(new PenDown());
  30. }
  31. /// <summary>
  32. /// PT command
  33. /// It is used together with FP, FT, RR, RA, and WG command, and space (unit mm) of painting out
  34. /// is specified between 0.1 and 5.0 in accordance with thickness of pen. Initial value is 0.3mm.
  35. /// </summary>
  36. public static void PenThickness(this List<CommandBase> commands, float thickness)
  37. {
  38. float t = (thickness > 5.0f) ? 5.0f : ((thickness < 0.1f) ? 0.1f : thickness);
  39. commands.Add(new PenThickness(t));
  40. }
  41. public static void LineType(this List<CommandBase> commands, LinePattern pattern)
  42. {
  43. commands.Add(new LineType(pattern));
  44. }
  45. public static void Initialize(this List<CommandBase> commands)
  46. {
  47. commands.Add(new Initialize());
  48. }
  49. public static void InputP1P2(this List<CommandBase> commands, PointF p1, PointF p2)
  50. {
  51. commands.Add(new InputP1P2(p1, p2));
  52. }
  53. public static void Scale(this List<CommandBase> commands, int xMin, int xMax, int yMin, int yMax)
  54. {
  55. commands.Add(new Scale(xMin, xMax, yMin, yMax));
  56. }
  57. public static void EdgePolygon(this List<CommandBase> commands)
  58. {
  59. commands.Add(new EdgePolygon());
  60. }
  61. public static void PolygonMode(this List<CommandBase> commands, PolygonType type)
  62. {
  63. commands.Add(new PolygonMode(type));
  64. }
  65. public static void FillType(this List<CommandBase> commands, ShadingModel shading)
  66. {
  67. commands.Add(new FillType(shading));
  68. }
  69. public static void FillPolygon(this List<CommandBase> commands)
  70. {
  71. commands.Add(new FillPolygon());
  72. }
  73. }
  74. }