CVisualSampleArea.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.VisualGDIObjects;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
  9. {
  10. public class CVisualSampleArea
  11. {
  12. CDisplayGDIObject m_SampleHoleGDIObject;//
  13. CMeasureArea m_MeasureGDIObject;//path
  14. public float GetZoomNum()
  15. {
  16. return m_SampleHoleGDIObject.GetZoomNumber();
  17. }
  18. public PointF GetDisplayRefPoint()
  19. {
  20. return m_SampleHoleGDIObject.GetDisplayRefPoint();
  21. }
  22. public CVisualSampleArea()
  23. {
  24. m_SampleHoleGDIObject = new CDisplayGDIObject();
  25. //测量区域
  26. m_MeasureGDIObject = new CMeasureArea();
  27. }
  28. public CDisplayGDIObject GetSampleGDIObject()
  29. {
  30. return m_SampleHoleGDIObject;
  31. }
  32. public void SetSampleGDIObject(CDisplayGDIObject value)
  33. {
  34. m_SampleHoleGDIObject = value;
  35. }
  36. public CMeasureArea GetMeasureGDIObject()
  37. {
  38. return m_MeasureGDIObject;
  39. }
  40. public void SetMeasureGDIObject(CMeasureArea value)
  41. {
  42. m_MeasureGDIObject = value;
  43. }
  44. public string GetSampleName()
  45. {
  46. return m_SampleHoleGDIObject.SampleName;
  47. }
  48. public void SetSampleName(string value)
  49. {
  50. m_SampleHoleGDIObject.SampleName = value;
  51. }
  52. public bool IsWorkSample()
  53. {
  54. return m_SampleHoleGDIObject.IsWorkSample;
  55. }
  56. public void SetIsWorkSample(bool value)
  57. {
  58. m_SampleHoleGDIObject.IsWorkSample = value;
  59. }
  60. public List<CVisualFieldGDIObject> GetMeasureFieldGDIObjects()
  61. {
  62. return m_MeasureGDIObject.SubItems();
  63. }
  64. public RectangleF GetAllGDIObjectsRectangle()
  65. {
  66. double left, top, right, bottom;
  67. var items = m_MeasureGDIObject.SubItems();
  68. var itm1 = items[0];
  69. var rec1 = itm1.GetZoomedRegionF();
  70. left = rec1.Left;
  71. top = rec1.Top;
  72. right = rec1.Right;
  73. bottom = rec1.Bottom;
  74. foreach (var itm in items)
  75. {
  76. var rec = itm.GetZoomedRegionF();
  77. if (rec.Left < left)
  78. {
  79. left = rec.Left;
  80. }
  81. if (rec.Top < top)
  82. {
  83. top = rec.Top;
  84. }
  85. if (rec.Right > right)
  86. {
  87. right = rec.Right;
  88. }
  89. if(rec.Bottom > bottom)
  90. {
  91. bottom = rec.Bottom;
  92. }
  93. }
  94. return new RectangleF((float)left, (float)top, (float)(right -left), (float)(bottom -top));
  95. }
  96. public void SetMeasureFieldGDIObjects(List<CVisualFieldGDIObject> value)
  97. {
  98. m_MeasureGDIObject.ClearSubItems();
  99. foreach (var gdi in value)
  100. {
  101. m_MeasureGDIObject.AddSubItems(gdi);
  102. }
  103. }
  104. public void AddFieldGDIObject( CVisualFieldGDIObject gdi)
  105. {
  106. gdi.SetZoomNumber(m_MeasureGDIObject.GetZoomNumber());
  107. gdi.SetDisplayRefPoint(m_MeasureGDIObject.GetDisplayRefPoint());
  108. m_MeasureGDIObject.AddSubItems(gdi);
  109. }
  110. }
  111. }