GasBaseShape.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using MECF.Framework.UI.Core.DxfScript;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Media;
  9. using System.Windows.Shapes;
  10. namespace MECF.Framework.UI.Core.DxfScript
  11. {
  12. public abstract class GasBaseShape : UIElement
  13. {
  14. public enum ShapeType { HLINE = 1, VLINE = 2, ACUTE = 3, OBTUSE = 4, POLY = 5, CIRCLE = 6, TEXT = 7, FUNNEL = 8 };
  15. public int Id { get; set; } = 0;
  16. public Script BoolCondition { get; set; } = null;
  17. public Script StringCondition { get; set; } = null;
  18. public Script ClickCondition { get; set; } = null;
  19. public static double E { get; set; } = 2;
  20. public bool Enable { get; set; } = true;
  21. public Brush Brush { get; set; } = null;
  22. /// <summary>
  23. /// 点击坐标是否在元素内部
  24. /// </summary>
  25. /// <param name="x"></param>
  26. /// <param name="y"></param>
  27. /// <returns>true在则选中该元素 ;false不在</returns>
  28. public abstract bool Contains(double x, double y);
  29. public static int CreateId(ShapeType shapeType, double x, double y)
  30. {
  31. int xx = (int)(Math.Round(x + 0.0001) / 2);
  32. int yy = (int)(Math.Round(y + 0.0001) / 2);
  33. return ((int)shapeType) * 1000000 + xx * 1000 + yy;
  34. }
  35. public bool IsSamePoint(double x, double y, double ox, double oy)
  36. {
  37. return Math.Abs(x - ox) < E && Math.Abs(y - oy) < E;
  38. }
  39. /// <summary>
  40. /// 页面拖拽坐标点随之改变
  41. /// </summary>
  42. /// <param name="x"></param>
  43. /// <param name="y"></param>
  44. public abstract void Move(double x, double y);
  45. }
  46. }