GasText.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. *
  3. * @author seagle
  4. * @date 2024-7-22
  5. * @Description 管路图元件对象封装
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace MECF.Framework.UI.Core.DxfScript
  13. {
  14. public class GasText: GasBaseShape
  15. {
  16. public double X { get; set; }
  17. public double Y { get; set; }
  18. public string Text { get; set; }
  19. public double FontSize { get; set; } = 0;
  20. public double TextHeight { get; set; } = 0;
  21. public double RectHeight { get; set; } = 0;
  22. public double RectWidth { get; set; } = 0;
  23. public double LineSpace { get; set; } = 0;
  24. public int Alignment = 5; //1 = 左上;2 = 中上;3 = 右上 4 = 左中;5 = 正中;6 = 右中 7 = 左下;8 = 中下;9 = 右下
  25. public GasText( double x,double y, string text)
  26. {
  27. X = x;
  28. Y = y;
  29. Text = text;
  30. Id = CreateId(ShapeType.TEXT, x, y);
  31. }
  32. public override bool Contains(double x, double y)
  33. {
  34. double left = 0;
  35. double top = 0;
  36. double right = 0;
  37. double bottom = 0;
  38. switch (Alignment)
  39. {
  40. case 1:
  41. left =X;
  42. top=Y;
  43. break;
  44. case 4:
  45. left = X;
  46. top = Y+RectHeight/2;
  47. break;
  48. case 7:
  49. left =X;
  50. top = Y + RectHeight;
  51. break;
  52. case 2:
  53. left = X - RectWidth / 2;
  54. top = Y;
  55. break;
  56. case 5:
  57. left = X - RectWidth / 2;
  58. top = Y + RectHeight / 2;
  59. break;
  60. case 8:
  61. left = X - RectWidth / 2;
  62. top = Y + RectHeight;
  63. break;
  64. case 3:
  65. left = X - RectWidth ;
  66. top = Y;
  67. break;
  68. case 6:
  69. left = X - RectWidth;
  70. top = Y + RectHeight / 2;
  71. break;
  72. case 9:
  73. left = X - RectWidth;
  74. top = Y + RectHeight;
  75. break;
  76. }
  77. right = left + RectWidth;
  78. bottom = top -RectHeight;
  79. if (x>=left-E && x<=right+E &&
  80. y>=bottom-E && y <= top+E)
  81. {
  82. return true;
  83. }
  84. else
  85. {
  86. return false;
  87. }
  88. }
  89. public override void Move(double x, double y)
  90. {
  91. X += x;
  92. Y += y;
  93. }
  94. }
  95. }