MeasurePLine.cs 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1.  using PaintDotNet.Annotation.Enum;
  2. using PaintDotNet.Base.SettingModel;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Globalization;
  8. using System.Windows.Forms;
  9. using PaintDotNet.Base.CommTool;
  10. using PaintDotNet.Annotation.Measure;
  11. using System.Linq;
  12. namespace PaintDotNet.Annotation.Measure
  13. {
  14. using PointList = List<PointF>;
  15. /// <summary>
  16. /// 测量->点垂线->点垂线
  17. /// </summary>
  18. public class MeasurePLine : MeasureDrawObject
  19. {
  20. public PointList pointArray;
  21. /// <summary>
  22. /// Graphic objects for hit test
  23. /// </summary>
  24. private GraphicsPath areaPath = null;
  25. private Pen areaPen = null;
  26. private Region areaRegion = null;
  27. /// <summary>
  28. /// 总长度
  29. /// </summary>
  30. private double Length = 0.0;
  31. /// <summary>
  32. /// 测量信息矩形定义
  33. /// </summary>
  34. private RectangleF rectangleF1 = new RectangleF();
  35. private RectangleF rectangleF2 = new RectangleF();
  36. private RectangleF rectangleF3 = new RectangleF();
  37. private RectangleF rectangleF4 = new RectangleF();
  38. private RectangleF rectangleF5 = new RectangleF();
  39. private RectangleF rectangleF6 = new RectangleF();
  40. private RectangleF rectangleF7 = new RectangleF();
  41. private RectangleF rectangleF8 = new RectangleF();
  42. private RectangleF rectangleF9 = new RectangleF();
  43. /// <summary>
  44. /// 文本上用于拖动的点
  45. /// </summary>
  46. private Point pointL = new Point();
  47. /// <summary>
  48. /// 绘制限制(第一次绘制时)
  49. /// </summary>
  50. public bool pointChange = true;
  51. /// <summary>
  52. /// 属性绘制点
  53. /// </summary>
  54. private PointF rotationPoint;
  55. private PointF rotationPoint1;
  56. /// <summary>
  57. /// 区分移动文本
  58. /// </summary>
  59. private int moveKb;
  60. /// <summary>
  61. /// 绘制限制(从配置文件加载)
  62. /// </summary>
  63. public bool configurationFile = false;
  64. /// <summary>
  65. /// 绘制限制(更改属性时)
  66. /// </summary>
  67. private bool SavePointChange;
  68. /// <summary>
  69. /// 绘制属性
  70. /// </summary>
  71. private string[] drawingPropertiesList;
  72. /// <summary>
  73. /// 绘制属性(克隆)
  74. /// </summary>
  75. private string[] drawingPropertiesListClone;
  76. /// <summary>
  77. /// 旋转角度
  78. /// </summary>
  79. private double angleClass;
  80. /// <summary>
  81. /// 旋转角度
  82. /// </summary>
  83. private double angleClass1;
  84. private bool drawing;
  85. /// <summary>
  86. /// 限制绘制(绘制中)
  87. /// </summary>
  88. public bool mouseUpPointChange = false;
  89. /// <summary>
  90. /// 测量样式信息model
  91. /// </summary>
  92. private MeasureStyleModel.MeasurePLine measureStyleModel;
  93. public MeasureStyleModel.MeasurePLine MeasureStyleModel
  94. {
  95. set
  96. {
  97. this.measureStyleModel = value;
  98. }
  99. }
  100. public MeasurePLine(ISurfaceBox surfaceBox, int x1, int y1, bool clone) : base(surfaceBox)
  101. {
  102. this.objectType = DrawClass.Measure;
  103. this.drawToolType = DrawToolType.MeasurePLine;
  104. measureStyleModel = surfaceBox.GetMeasureStyleModel().measurePLine;
  105. pointArray = new PointList();
  106. startPoint.X = x1;
  107. startPoint.Y = y1;
  108. if (clone)
  109. {
  110. drawing = true;
  111. pointArray.Add(new Point(x1, y1));
  112. }
  113. this.measurementUnit = (MeasurementUnit)System.Enum.Parse(typeof(MeasurementUnit), surfaceBox.GetPxPerUnit()[0]);
  114. this.unitString = surfaceBox.GetPxPerUnit()[1];
  115. this.unit = surfaceBox.GetPxPerUnit()[2];
  116. Initialize();
  117. }
  118. /// <summary>
  119. /// 测量属性
  120. /// </summary>
  121. /// <returns></returns>
  122. public override Dictionary<System.Enum, object> GetData()
  123. {
  124. if (data.ContainsKey(MeasureAttributes.MeasureMethod))
  125. data[MeasureAttributes.MeasureMethod] = PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text");
  126. else
  127. data.Add(MeasureAttributes.MeasureMethod, PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text"));
  128. if (data.ContainsKey(MeasureAttributes.MeasureUnitCN))
  129. data[MeasureAttributes.MeasureUnitCN] = this.unitString;
  130. else
  131. data.Add(MeasureAttributes.MeasureUnitCN, this.unitString);
  132. if (data.ContainsKey(MeasureAttributes.MeasureUnitEN))
  133. data[MeasureAttributes.MeasureUnitEN] = this.unit;
  134. else
  135. data.Add(MeasureAttributes.MeasureUnitEN, this.unit);
  136. if (data.ContainsKey(MeasureAttributes.PixelStartX))
  137. data[MeasureAttributes.PixelStartX] = startPoint.X;
  138. else
  139. data.Add(MeasureAttributes.PixelStartX, startPoint.X);
  140. if (data.ContainsKey(MeasureAttributes.PixelStartY))
  141. data[MeasureAttributes.PixelStartY] = startPoint.Y;
  142. else
  143. data.Add(MeasureAttributes.PixelStartY, startPoint.Y);
  144. if (data.ContainsKey(MeasureAttributes.PhysicalStartX))
  145. data[MeasureAttributes.PhysicalStartX] = Math.Round(startPoint.X * unitLength, decimalPlaces);
  146. else
  147. data.Add(MeasureAttributes.PhysicalStartX, Math.Round(startPoint.X * unitLength, decimalPlaces));
  148. if (data.ContainsKey(MeasureAttributes.PhysicalStartY))
  149. data[MeasureAttributes.PhysicalStartY] = Math.Round(startPoint.Y * unitLength, decimalPlaces);
  150. else
  151. data.Add(MeasureAttributes.PhysicalStartY, Math.Round(startPoint.Y * unitLength, decimalPlaces));
  152. if (data.ContainsKey(MeasureAttributes.PixelLength))
  153. data[MeasureAttributes.PixelLength] = Math.Round(Length, decimalPlaces);
  154. else
  155. data.Add(MeasureAttributes.PixelLength, Math.Round(Length, decimalPlaces));
  156. string s = Math.Round(Length * unitLength, decimalPlaces).ToString();
  157. if (s.IndexOf(".") == -1)
  158. {
  159. for (int i = 0; i < decimalPlaces; i++)
  160. {
  161. if (i == 0)
  162. s += ".";
  163. s += "0";
  164. }
  165. }
  166. else
  167. {
  168. int a = s.Length - s.IndexOf(".") - 1;
  169. if (a < decimalPlaces)
  170. {
  171. for (int i = 0; i < decimalPlaces - a; i++)
  172. {
  173. s += "0";
  174. }
  175. }
  176. }
  177. if (data.ContainsKey(MeasureAttributes.PhysicalLength))
  178. data[MeasureAttributes.PhysicalLength] = s;
  179. else
  180. data.Add(MeasureAttributes.PhysicalLength, s);
  181. return data;
  182. }
  183. public MeasurePLine(ISurfaceBox surfaceBox, List<PointF> points, ParentStyleModel parentStyleModel, Object content) : base()
  184. {
  185. this.objectType = DrawClass.Measure;
  186. this.drawToolType = DrawToolType.MeasurePLine;
  187. this.ISurfaceBox = surfaceBox;
  188. measureStyleModel = (MeasureStyleModel.MeasurePLine)parentStyleModel;
  189. pointArray = DrawRulerHelper.DeepCopyListByReflect(points);
  190. startPoint = points[0];
  191. this.measurementUnit = (MeasurementUnit)System.Enum.Parse(typeof(MeasurementUnit), surfaceBox.GetPxPerUnit()[0]);
  192. this.unitString = surfaceBox.GetPxPerUnit()[1];
  193. this.unit = surfaceBox.GetPxPerUnit()[2];
  194. this.configurationFile = true;
  195. }
  196. /// <summary>
  197. /// Clone this instance
  198. /// </summary>
  199. public override DrawObject Clone()
  200. {
  201. MeasurePLine drawPolygon = new MeasurePLine(ISurfaceBox, (int)pointArray[0].X, (int)pointArray[0].Y, false);
  202. drawPolygon.ISurfaceBox = ISurfaceBox;
  203. foreach (PointF p in this.pointArray)
  204. {
  205. drawPolygon.pointArray.Add(p);
  206. }
  207. if (drawingPropertiesList != null)
  208. drawPolygon.drawingPropertiesListClone = drawingPropertiesList;
  209. FillDrawObjectFields(drawPolygon);
  210. return drawPolygon;
  211. }
  212. public override DrawObject Clone(ISurfaceBox surfaceBox)
  213. {
  214. MeasurePLine drawPolygon = new MeasurePLine(surfaceBox, this.GetPoints(), this.measureStyleModel, null);
  215. if (drawingPropertiesList != null)
  216. drawPolygon.drawingPropertiesListClone = drawingPropertiesList;
  217. FillDrawObjectFields(drawPolygon);
  218. return drawPolygon;
  219. }
  220. public override void Draw(Graphics g)
  221. {
  222. measureStyleModel = this.ISurfaceBox.GetMeasureStyleModel().measurePLine;
  223. drawingProperties.TryGetValue(this.drawToolType, out drawingPropertiesList);
  224. if (drawingPropertiesList == null)
  225. {
  226. drawingPropertiesList = drawingPropertiesListClone;
  227. if (!this.drawing)
  228. this.configurationFile = true;
  229. }
  230. pointChangeObject.TryGetValue(this.drawToolType, out SavePointChange);
  231. if (HandleCount - 1 >= 2)
  232. {
  233. string frontStr = string.Empty;
  234. if (this.measureStyleModel.showSuffix)
  235. {
  236. frontStr = this.measureStyleModel.suffixName;
  237. }
  238. if (this.measureStyleModel.showSerial)
  239. {
  240. #region [获取序号]
  241. List<DrawObject> newGraphicsList = new List<DrawObject>();
  242. int n = ISurfaceBox.GraphicsList.Count;
  243. int num = 0;
  244. for (int i = n - 1; i >= 0; i--)
  245. {
  246. newGraphicsList.Add(ISurfaceBox.GraphicsList[i].Clone());
  247. }
  248. var newGraphics = newGraphicsList.Where(m => m.ID.Equals(this.ID)).FirstOrDefault();
  249. if (newGraphics != null)
  250. {
  251. num = newGraphicsList.IndexOf(newGraphics) + 1;
  252. }
  253. #endregion
  254. frontStr = $"[{ num }]{frontStr}";
  255. }
  256. if (this.measureStyleModel.showAlias)
  257. {
  258. frontStr = this.measureStyleModel.aliasName + frontStr;
  259. }
  260. Font textfont = new Font(measureStyleModel.font, measureStyleModel.fontSize);
  261. Brush textbrush = new SolidBrush(Color.FromArgb(measureStyleModel.textColor));
  262. g.SmoothingMode = SmoothingMode.AntiAlias;
  263. Color color = Color.FromArgb(this.measureStyleModel.lineColor);
  264. Pen pen = new Pen(color, this.measureStyleModel.lineWidth);
  265. pen.DashStyle = (DashStyle)this.measureStyleModel.lineStyle;
  266. if (this.Selected)
  267. {
  268. if (measureStyleModel.chooseStyle != null)
  269. {
  270. textfont = new Font(measureStyleModel.chooseStyle.font, measureStyleModel.chooseStyle.fontSize);
  271. textbrush = new SolidBrush(Color.FromArgb(measureStyleModel.chooseStyle.textColor));
  272. pen = new Pen(Color.FromArgb(measureStyleModel.chooseStyle.lineColor), measureStyleModel.chooseStyle.lineWidth);
  273. pen.DashStyle = (DashStyle)measureStyleModel.chooseStyle.lineStyle;
  274. }
  275. }
  276. if (!this.Selected)
  277. {
  278. this.pointChange = true;
  279. rectangleF1 = new RectangleF();
  280. rectangleF2 = new RectangleF();
  281. rectangleF3 = new RectangleF();
  282. rectangleF4 = new RectangleF();
  283. rectangleF5 = new RectangleF();
  284. rectangleF6 = new RectangleF();
  285. rectangleF7 = new RectangleF();
  286. rectangleF8 = new RectangleF();
  287. rectangleF9 = new RectangleF();
  288. }
  289. g.DrawLine(pen, pointArray[0], pointArray[1]);
  290. if (HandleCount - 1 == 3)
  291. {
  292. SizeF sizeF = new SizeF();
  293. // 垂足坐标
  294. PointF footPoint = BasicCalculationHelper.GetDropFeet(pointArray[1], pointArray[0], pointArray[2]);
  295. g.DrawLine(pen, pointArray[2], footPoint);
  296. // 点到直线距离
  297. double length = BasicCalculationHelper.GetDistance(footPoint, pointArray[2], 2);
  298. // 直线长度
  299. double length1 = BasicCalculationHelper.GetDistance(pointArray[0], pointArray[1], 2);
  300. Length = length;
  301. // 长度文本显示
  302. //g.DrawString(Math.Round(length1 * unitLength, decimalPlaces) + unit, textfont, textbrush, pointArray[0].X, pointArray[0].Y);
  303. //g.DrawString(Math.Round(length * unitLength, decimalPlaces) + unit, textfont, textbrush, pointArray[2].X, pointArray[2].Y);
  304. Matrix mtxSave = g.Transform;
  305. Matrix matrix = g.Transform;
  306. //计算需要旋转的角度
  307. this.angleClass = BasicCalculationHelper.Angle(pointArray[0], pointArray[1], new PointF(pointArray[0].X, pointArray[1].Y));
  308. int offsetValuePoint = measureStyleModel.fontSize + measureStyleModel.fontSize / 2;
  309. int offsetValue1Point = measureStyleModel.lineWidth * 2 / 3;
  310. int offsetPoint = offsetValue1Point;
  311. if (drawingPropertiesList != null)
  312. {
  313. // 测量方式
  314. if (drawingPropertiesList.Contains(MeasureAttributes.MeasureMethod.ToString()))
  315. {
  316. offsetPoint += offsetValuePoint;
  317. }
  318. // 测量单位(中文)
  319. if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitCN.ToString()))
  320. {
  321. offsetPoint += offsetValuePoint;
  322. }
  323. // 测量单位(英文)
  324. if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitEN.ToString()))
  325. {
  326. offsetPoint += offsetValuePoint;
  327. }
  328. }
  329. PointF pointF1;
  330. PointF pointF2;
  331. if (angleClass < 90)
  332. pointF1 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[0].X + offsetPoint, (int)pointArray[0].Y), pointArray[0], angleClass - 90);
  333. else
  334. pointF1 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[0].X + offsetPoint, (int)pointArray[0].Y), pointArray[0], angleClass + 90);
  335. if (angleClass < 90)
  336. pointF2 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[1].X + offsetPoint, (int)pointArray[1].Y), pointArray[1], angleClass - 90);
  337. else
  338. pointF2 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[1].X + offsetPoint, (int)pointArray[1].Y), pointArray[1], angleClass + 90);
  339. PointF pointF3 = new PointF((pointF1.X + pointF2.X) / 2, (pointF1.Y + pointF2.Y) / 2);
  340. if (measureStyleModel.linePositionL == 0)
  341. this.rotationPoint = pointF1;
  342. else if (measureStyleModel.linePositionL == 1)
  343. this.rotationPoint = pointF3;
  344. else if (measureStyleModel.linePositionL == 2)
  345. this.rotationPoint = pointF2;
  346. else if (measureStyleModel.linePositionL == 3)
  347. this.rotationPoint = pointArray[0];
  348. else if (measureStyleModel.linePositionL == 4)
  349. this.rotationPoint = new PointF(Math.Abs(pointArray[0].X + pointArray[1].X) / 2, Math.Abs(pointArray[0].Y + pointArray[1].Y) / 2);
  350. else if (measureStyleModel.linePositionL == 5)
  351. this.rotationPoint = pointArray[1];
  352. // 画布旋转
  353. if (this.angleClass < 90)
  354. {
  355. matrix.RotateAt((float)this.angleClass, this.rotationPoint);
  356. g.Transform = matrix;
  357. }
  358. else
  359. {
  360. this.angleClass = BasicCalculationHelper.Angle(pointArray[1], pointArray[0], new PointF(pointArray[1].X, pointArray[0].Y));
  361. matrix.RotateAt((float)this.angleClass, this.rotationPoint);
  362. g.Transform = matrix;
  363. }
  364. // 是否绘制
  365. if (this.pointChange || this.SavePointChange || this.mouseUpPointChange || this.mouseUpAttribute)
  366. {
  367. // 属性文本的间隔定义
  368. int offsetValue = measureStyleModel.fontSize + measureStyleModel.fontSize / 2;
  369. int offsetValue1 = measureStyleModel.lineWidth * 2 / 3;
  370. int offset0 = offsetValue1;
  371. int offset2 = offsetValue1;
  372. this.pointL = new Point((int)this.rotationPoint.X, (int)this.rotationPoint.Y);
  373. if (drawingPropertiesList != null)
  374. {
  375. // 测量方式
  376. if (drawingPropertiesList.Contains(MeasureAttributes.MeasureMethod.ToString()))
  377. {
  378. sizeF = g.MeasureString("" + PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text"), textfont);
  379. rectangleF1.Location = new Point((int)this.rotationPoint.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint.Y + offset0);
  380. offset0 += offsetValue;
  381. }
  382. // 测量单位(中文)
  383. if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitCN.ToString()))
  384. {
  385. sizeF = g.MeasureString("" + this.unitString, textfont);
  386. rectangleF2.Location = new Point((int)this.rotationPoint.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint.Y + offset0);
  387. offset0 += offsetValue;
  388. }
  389. // 测量单位(英文)
  390. if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitEN.ToString()))
  391. {
  392. sizeF = g.MeasureString("" + this.unit, textfont);
  393. rectangleF3.Location = new Point((int)this.rotationPoint.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint.Y + offset0);
  394. offset0 += offsetValue;
  395. }
  396. }
  397. }
  398. if (drawingPropertiesList != null)
  399. {
  400. // 测量方式
  401. if (drawingPropertiesList.Contains(MeasureAttributes.MeasureMethod.ToString()))
  402. {
  403. sizeF = g.MeasureString(frontStr + "" + PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text"), textfont);
  404. rectangleF1.Width = sizeF.Width;
  405. rectangleF1.Height = sizeF.Height;
  406. g.DrawString(frontStr + "" + PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text"), textfont, textbrush, rectangleF1);
  407. }
  408. else
  409. {
  410. rectangleF1 = new RectangleF();
  411. }
  412. // 测量单位(中文)
  413. if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitCN.ToString()))
  414. {
  415. sizeF = g.MeasureString(frontStr + "" + this.unitString, textfont);
  416. rectangleF2.Width = sizeF.Width;
  417. rectangleF2.Height = sizeF.Height;
  418. g.DrawString(frontStr + "" + this.unitString, textfont, textbrush, rectangleF2);
  419. }
  420. else
  421. {
  422. rectangleF2 = new RectangleF();
  423. }
  424. // 测量单位(英文)
  425. if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitEN.ToString()))
  426. {
  427. sizeF = g.MeasureString(frontStr + "" + this.unit, textfont);
  428. rectangleF3.Width = sizeF.Width;
  429. rectangleF3.Height = sizeF.Height;
  430. g.DrawString(frontStr + "" + this.unit, textfont, textbrush, rectangleF3);
  431. }
  432. else
  433. {
  434. rectangleF3 = new RectangleF();
  435. }
  436. }
  437. //还原为原始旋转矩阵
  438. g.Transform = mtxSave;
  439. matrix.Dispose();
  440. Matrix mtxSave1 = g.Transform;
  441. Matrix matrix1 = g.Transform;
  442. //计算需要旋转的角度
  443. this.angleClass1 = BasicCalculationHelper.Angle(footPoint, pointArray[2], new PointF(footPoint.X, pointArray[2].Y));
  444. offsetValuePoint = measureStyleModel.fontSize + measureStyleModel.fontSize / 2;
  445. offsetValue1Point = measureStyleModel.lineWidth * 2 / 3;
  446. offsetPoint = offsetValue1Point;
  447. if (drawingPropertiesList != null)
  448. {
  449. // 像素长度
  450. if (drawingPropertiesList.Contains(MeasureAttributes.PixelLength.ToString()))
  451. {
  452. offsetPoint += offsetValuePoint;
  453. }
  454. // 物理长度
  455. if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalLength.ToString()))
  456. {
  457. offsetPoint += offsetValuePoint;
  458. }
  459. // 像素起始点X
  460. if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartX.ToString()))
  461. {
  462. offsetPoint += offsetValuePoint;
  463. }
  464. // 像素起始点Y
  465. if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartY.ToString()))
  466. {
  467. offsetPoint += offsetValuePoint;
  468. }
  469. // 物理起始点X
  470. if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartX.ToString()))
  471. {
  472. offsetPoint += offsetValuePoint;
  473. }
  474. // 物理起始点Y
  475. if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartY.ToString()))
  476. {
  477. offsetPoint += offsetValuePoint;
  478. }
  479. }
  480. if (angleClass1 < 90)
  481. pointF1 = BasicCalculationHelper.GetAnglePoint(new Point((int)footPoint.X + offsetPoint + offsetValue1Point, (int)footPoint.Y), footPoint, angleClass1 - 90);
  482. else
  483. pointF1 = BasicCalculationHelper.GetAnglePoint(new Point((int)footPoint.X + offsetPoint + offsetValue1Point, (int)footPoint.Y), footPoint, angleClass1 + 90);
  484. if (angleClass1 < 90)
  485. pointF2 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[2].X + offsetPoint + offsetValue1Point, (int)pointArray[2].Y), pointArray[2], angleClass1 - 90);
  486. else
  487. pointF2 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[2].X + offsetPoint + offsetValue1Point, (int)pointArray[2].Y), pointArray[2], angleClass1 + 90);
  488. pointF3 = new PointF((pointF1.X + pointF2.X) / 2, (pointF1.Y + pointF2.Y) / 2);
  489. if (measureStyleModel.linePositionP == 0)
  490. this.rotationPoint1 = pointF1;
  491. else if (measureStyleModel.linePositionP == 1)
  492. this.rotationPoint1 = pointF3;
  493. else if (measureStyleModel.linePositionP == 2)
  494. this.rotationPoint1 = pointF2;
  495. else if (measureStyleModel.linePositionP == 3)
  496. this.rotationPoint1 = footPoint;
  497. else if (measureStyleModel.linePositionP == 4)
  498. this.rotationPoint1 = new PointF(Math.Abs(footPoint.X + pointArray[2].X) / 2, Math.Abs(footPoint.Y + pointArray[2].Y) / 2);
  499. else if (measureStyleModel.linePositionP == 5)
  500. this.rotationPoint1 = pointArray[2];
  501. // 画布旋转
  502. if (this.angleClass1 < 90)
  503. {
  504. matrix1.RotateAt((float)this.angleClass1, this.rotationPoint1);
  505. g.Transform = matrix1;
  506. }
  507. else
  508. {
  509. this.angleClass1 = BasicCalculationHelper.Angle(pointArray[2], footPoint, new PointF(pointArray[2].X, footPoint.Y));
  510. matrix1.RotateAt((float)this.angleClass1, this.rotationPoint1);
  511. g.Transform = matrix1;
  512. }
  513. // 是否绘制
  514. if (this.pointChange || this.SavePointChange || this.mouseUpPointChange)
  515. {
  516. // 属性文本的间隔定义
  517. int offsetValue = measureStyleModel.fontSize + measureStyleModel.fontSize / 2;
  518. int offsetValue1 = measureStyleModel.lineWidth * 2 / 3;
  519. int offset0 = offsetValue1;
  520. int offset2 = offsetValue1;
  521. this.pointL = new Point((int)this.rotationPoint1.X, (int)this.rotationPoint1.Y);
  522. if (drawingPropertiesList != null)
  523. {
  524. // 像素长度
  525. if (drawingPropertiesList.Contains(MeasureAttributes.PixelLength.ToString()))
  526. {
  527. sizeF = g.MeasureString(frontStr + "" + Math.Round(length, decimalPlaces) + "px", textfont);
  528. rectangleF8.Location = new Point((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset2);
  529. offset2 += offsetValue;
  530. }
  531. // 物理长度
  532. if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalLength.ToString()))
  533. {
  534. string s = Math.Round(length * unitLength, decimalPlaces).ToString();
  535. if (s.IndexOf(".") == -1)
  536. {
  537. for (int i = 0; i < decimalPlaces; i++)
  538. {
  539. if (i == 0)
  540. s += ".";
  541. s += "0";
  542. }
  543. }
  544. else
  545. {
  546. int a = s.Length - s.IndexOf(".") - 1;
  547. if (a < decimalPlaces)
  548. {
  549. for (int i = 0; i < decimalPlaces - a; i++)
  550. {
  551. s += "0";
  552. }
  553. }
  554. }
  555. sizeF = g.MeasureString(frontStr + s + this.unit, textfont);
  556. rectangleF9.Location = new Point((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset2);
  557. offset2 += offsetValue;
  558. }
  559. // 像素起始点X
  560. if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartX.ToString()))
  561. {
  562. sizeF = g.MeasureString(frontStr + "" + pointArray[2].X, textfont);
  563. rectangleF4.Location = new Point((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset2);
  564. offset2 += offsetValue;
  565. }
  566. // 像素起始点Y
  567. if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartY.ToString()))
  568. {
  569. sizeF = g.MeasureString(frontStr + "" + pointArray[2].Y, textfont);
  570. rectangleF5.Location = new Point((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset2);
  571. offset2 += offsetValue;
  572. }
  573. // 物理起始点X
  574. if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartX.ToString()))
  575. {
  576. sizeF = g.MeasureString(frontStr + "" + Math.Round(pointArray[2].X * unitLength, decimalPlaces), textfont);
  577. rectangleF6.Location = new Point((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset2);
  578. offset2 += offsetValue;
  579. }
  580. // 物理起始点Y
  581. if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartY.ToString()))
  582. {
  583. sizeF = g.MeasureString(frontStr + "" + Math.Round(pointArray[2].Y * unitLength, decimalPlaces), textfont);
  584. rectangleF7.Location = new Point((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset2);
  585. offset2 += offsetValue;
  586. }
  587. }
  588. }
  589. if (drawingPropertiesList != null)
  590. {
  591. // 像素长度
  592. if (drawingPropertiesList.Contains(MeasureAttributes.PixelLength.ToString()))
  593. {
  594. sizeF = g.MeasureString(frontStr + "" + Math.Round(length, decimalPlaces) + "px", textfont);
  595. rectangleF8.Width = sizeF.Width;
  596. rectangleF8.Height = sizeF.Height;
  597. g.DrawString(frontStr + "" + Math.Round(length, decimalPlaces) + "px", textfont, textbrush, rectangleF8);
  598. }
  599. else
  600. {
  601. rectangleF8 = new RectangleF();
  602. }
  603. // 物理长度
  604. if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalLength.ToString()))
  605. {
  606. string s = Math.Round(length * unitLength, decimalPlaces).ToString();
  607. if (s.IndexOf(".") == -1)
  608. {
  609. for (int i = 0; i < decimalPlaces; i++)
  610. {
  611. if (i == 0)
  612. s += ".";
  613. s += "0";
  614. }
  615. }
  616. else
  617. {
  618. int a = s.Length - s.IndexOf(".") - 1;
  619. if (a < decimalPlaces)
  620. {
  621. for (int i = 0; i < decimalPlaces - a; i++)
  622. {
  623. s += "0";
  624. }
  625. }
  626. }
  627. sizeF = g.MeasureString(frontStr + s + this.unit, textfont);
  628. rectangleF9.Width = sizeF.Width;
  629. rectangleF9.Height = sizeF.Height;
  630. g.DrawString(frontStr + s + this.unit, textfont, textbrush, rectangleF9);
  631. }
  632. else
  633. {
  634. rectangleF9 = new RectangleF();
  635. }
  636. // 像素起始点X
  637. if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartX.ToString()))
  638. {
  639. sizeF = g.MeasureString(frontStr + "" + pointArray[2].X, textfont);
  640. rectangleF4.Width = sizeF.Width;
  641. rectangleF4.Height = sizeF.Height;
  642. g.DrawString(frontStr + "" + pointArray[2].X, textfont, textbrush, rectangleF4);
  643. }
  644. else
  645. {
  646. rectangleF4 = new RectangleF();
  647. }
  648. // 像素起始点Y
  649. if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartY.ToString()))
  650. {
  651. sizeF = g.MeasureString(frontStr + "" + pointArray[2].Y, textfont);
  652. rectangleF5.Width = sizeF.Width;
  653. rectangleF5.Height = sizeF.Height;
  654. g.DrawString(frontStr + "" + pointArray[2].Y, textfont, textbrush, rectangleF5);
  655. }
  656. else
  657. {
  658. rectangleF5 = new RectangleF();
  659. }
  660. // 物理起始点X
  661. if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartX.ToString()))
  662. {
  663. sizeF = g.MeasureString(frontStr + "" + Math.Round(pointArray[2].X * unitLength, decimalPlaces), textfont);
  664. rectangleF6.Width = sizeF.Width;
  665. rectangleF6.Height = sizeF.Height;
  666. g.DrawString(frontStr + "" + Math.Round(pointArray[2].X * unitLength, decimalPlaces), textfont, textbrush, rectangleF6);
  667. }
  668. else
  669. {
  670. rectangleF6 = new RectangleF();
  671. }
  672. // 物理起始点Y
  673. if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartY.ToString()))
  674. {
  675. sizeF = g.MeasureString(frontStr + "" + Math.Round(pointArray[2].Y * unitLength, decimalPlaces), textfont);
  676. rectangleF7.Width = sizeF.Width;
  677. rectangleF7.Height = sizeF.Height;
  678. g.DrawString(frontStr + "" + Math.Round(pointArray[2].Y * unitLength, decimalPlaces), textfont, textbrush, rectangleF7);
  679. }
  680. else
  681. {
  682. rectangleF7 = new RectangleF();
  683. }
  684. }
  685. //还原为原始旋转矩阵
  686. g.Transform = mtxSave1;
  687. matrix1.Dispose();
  688. pen.Dispose();
  689. }
  690. }
  691. if (this.configurationFile)
  692. this.pointChange = false;
  693. this.mouseUpAttribute = false;
  694. pointChangeObject.Remove(this.drawToolType);
  695. }
  696. /// <summary>
  697. /// 停止绘制时
  698. /// </summary>
  699. /// <param name="up"></param>
  700. public override void MouseUp(bool up)
  701. {
  702. mouseUpPointChange = up;
  703. }
  704. public void AddPoint(Point point)
  705. {
  706. pointArray.Add(point);
  707. }
  708. public override int HandleCount
  709. {
  710. get
  711. {
  712. return pointArray.Count + 1;
  713. }
  714. }
  715. /// <summary>
  716. /// Get handle pointscroll by 1-based number
  717. /// </summary>
  718. /// <param name="handleNumber"></param>
  719. /// <returns></returns>
  720. public override PointF GetHandle(int handleNumber)
  721. {
  722. if (handleNumber < 1)
  723. handleNumber = 1;
  724. if (handleNumber > pointArray.Count && handleNumber != pointArray.Count + 1)
  725. handleNumber = pointArray.Count;
  726. if (handleNumber == pointArray.Count + 1)
  727. return this.pointL;
  728. else
  729. return pointArray[handleNumber - 1];
  730. }
  731. public override Cursor GetHandleCursor(int handleNumber)
  732. {
  733. return handleCursor;
  734. }
  735. public override void MoveHandleTo(Point point, int handleNumber)
  736. {
  737. if (handleNumber < 1)
  738. handleNumber = 1;
  739. if (handleNumber > pointArray.Count && handleNumber != pointArray.Count + 1)
  740. handleNumber = pointArray.Count;
  741. if (handleNumber == pointArray.Count + 1)
  742. {
  743. if(this.moveKb == 1 || this.moveKb == 2 || this.moveKb == 3)
  744. {
  745. point = SetOffsetAfterRotation(point, rotationPoint, angleClass);
  746. if (this.moveKb == 1)
  747. this.rectangleF1.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
  748. else if (this.moveKb == 2)
  749. this.rectangleF2.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
  750. else if (this.moveKb == 3)
  751. this.rectangleF3.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
  752. }
  753. else
  754. {
  755. point = SetOffsetAfterRotation(point, rotationPoint1, angleClass1);
  756. if (this.moveKb == 4)
  757. this.rectangleF4.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
  758. else if (this.moveKb == 5)
  759. this.rectangleF5.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
  760. else if (this.moveKb == 6)
  761. this.rectangleF6.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
  762. else if (this.moveKb == 7)
  763. this.rectangleF7.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
  764. else if (this.moveKb == 8)
  765. this.rectangleF8.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
  766. else if (this.moveKb == 9)
  767. this.rectangleF9.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
  768. }
  769. this.pointL = point;
  770. }
  771. else
  772. {
  773. this.mouseUpPointChange = true;
  774. if (handleNumber == 3)
  775. {
  776. this.rectangleF4.Offset(point.X - this.pointArray[2].X, point.Y - this.pointArray[2].Y);
  777. this.rectangleF5.Offset(point.X - this.pointArray[2].X, point.Y - this.pointArray[2].Y);
  778. this.rectangleF6.Offset(point.X - this.pointArray[2].X, point.Y - this.pointArray[2].Y);
  779. this.rectangleF7.Offset(point.X - this.pointArray[2].X, point.Y - this.pointArray[2].Y);
  780. this.rectangleF8.Offset(point.X - this.pointArray[2].X, point.Y - this.pointArray[2].Y);
  781. this.rectangleF9.Offset(point.X - this.pointArray[2].X, point.Y - this.pointArray[2].Y);
  782. }
  783. else if(handleNumber == 1)
  784. {
  785. this.rectangleF1.Offset(point.X - this.pointArray[0].X, point.Y - this.pointArray[0].Y);
  786. this.rectangleF2.Offset(point.X - this.pointArray[0].X, point.Y - this.pointArray[0].Y);
  787. this.rectangleF3.Offset(point.X - this.pointArray[0].X, point.Y - this.pointArray[0].Y);
  788. }
  789. pointArray[handleNumber - 1] = point;
  790. }
  791. Invalidate();
  792. }
  793. public override void Move(int deltaX, int deltaY)
  794. {
  795. int n = pointArray.Count;
  796. for (int i = 0; i < n; i++)
  797. {
  798. PointF point = new PointF(pointArray[i].X + ISurfaceBox.UnscaleScalar(deltaX), pointArray[i].Y + ISurfaceBox.UnscaleScalar(deltaY));
  799. pointArray[i] = point;
  800. }
  801. this.startPoint = pointArray[0];
  802. int x = ISurfaceBox.UnscaleScalar(deltaX);
  803. int y = ISurfaceBox.UnscaleScalar(deltaY);
  804. pointL.X += x;
  805. pointL.Y += y;
  806. this.rectangleF1.Offset(x, y);
  807. this.rectangleF2.Offset(x, y);
  808. this.rectangleF3.Offset(x, y);
  809. this.rectangleF4.Offset(x, y);
  810. this.rectangleF5.Offset(x, y);
  811. this.rectangleF6.Offset(x, y);
  812. this.rectangleF7.Offset(x, y);
  813. this.rectangleF8.Offset(x, y);
  814. this.rectangleF9.Offset(x, y);
  815. Invalidate();
  816. }
  817. /// <summary>
  818. /// 用于创建一个路径或者是闭合的范围
  819. /// 用于响应点击选中
  820. /// 需要咨询用户是仅点击线还是矩形选择
  821. /// </summary>
  822. protected virtual void CreateObjects()
  823. {
  824. if (AreaPath != null)
  825. return;
  826. AreaPath = new GraphicsPath();
  827. AreaPath.AddRectangle(GetBoundingBox());
  828. AreaPath.CloseFigure();
  829. AreaRegion = new Region(AreaPath);
  830. }
  831. /// <summary>
  832. /// Invalidate object.
  833. /// When object is invalidated, path used for hit test
  834. /// is released and should be created again.
  835. /// </summary>
  836. protected void Invalidate()
  837. {
  838. if (AreaPath != null)
  839. {
  840. AreaPath.Dispose();
  841. AreaPath = null;
  842. }
  843. if (AreaPen != null)
  844. {
  845. AreaPen.Dispose();
  846. AreaPen = null;
  847. }
  848. if (AreaRegion != null)
  849. {
  850. AreaRegion.Dispose();
  851. AreaRegion = null;
  852. }
  853. }
  854. protected GraphicsPath AreaPath
  855. {
  856. get
  857. {
  858. return areaPath;
  859. }
  860. set
  861. {
  862. areaPath = value;
  863. }
  864. }
  865. protected Pen AreaPen
  866. {
  867. get
  868. {
  869. return areaPen;
  870. }
  871. set
  872. {
  873. areaPen = value;
  874. }
  875. }
  876. protected Region AreaRegion
  877. {
  878. get
  879. {
  880. return areaRegion;
  881. }
  882. set
  883. {
  884. areaRegion = value;
  885. }
  886. }
  887. /// <summary>
  888. /// Draw tracker for selected object
  889. /// </summary>
  890. /// <param name="g"></param>
  891. public override void DrawTracker(Graphics g)
  892. {
  893. if (!Selected)
  894. return;
  895. SolidBrush brush = new SolidBrush(Color.FromArgb(MarkpointAreaColor));
  896. Pen pen = new Pen(Color.FromArgb(MarkpointLineColor), MarkpointLineWidth);
  897. for (int i = 1; i <= HandleCount; i++)
  898. {
  899. if (i == HandleCount)
  900. {
  901. brush = new SolidBrush(Color.Transparent);
  902. pen = new Pen(Color.Transparent);
  903. }
  904. switch (MarkpointStyle)
  905. {
  906. case 0:
  907. g.FillRectangle(brush, GetHandleRectangle(i));
  908. g.DrawRectangle(pen, GetHandleRectangle(i));
  909. break;
  910. case 1:
  911. g.FillEllipse(brush, GetHandleRectangle(i));
  912. g.DrawEllipse(pen, GetHandleRectangle(i));
  913. break;
  914. case 2:
  915. g.FillPolygon(brush, GetHandlePoint(i));
  916. g.DrawPolygon(pen, GetHandlePoint(i));
  917. break;
  918. }
  919. }
  920. pen.Dispose();
  921. brush.Dispose();
  922. }
  923. /// <summary>
  924. /// Hit test.
  925. /// Return value: -1 - no hit
  926. /// 0 - hit anywhere
  927. /// > 1 - handle number
  928. /// </summary>
  929. /// <param name="pointscroll"></param>
  930. /// <returns></returns>
  931. public override int HitTest(Point point)
  932. {
  933. if (Selected)
  934. {
  935. for (int i = 1; i <= HandleCount; i++)
  936. {
  937. if (GetHandleRectangle(i).Contains(point))
  938. return i;
  939. }
  940. if (GetRectanglePosition(this.rectangleF1, point, rotationPoint, angleClass))
  941. {
  942. this.pointL = SetOffsetAfterRotation(point, rotationPoint, angleClass);
  943. moveKb = 1;
  944. return this.pointArray.Count + 1;
  945. }
  946. else if (GetRectanglePosition(this.rectangleF2, point, rotationPoint, angleClass))
  947. {
  948. this.pointL = SetOffsetAfterRotation(point, rotationPoint, angleClass);
  949. moveKb = 2;
  950. return this.pointArray.Count + 1;
  951. }
  952. else if (GetRectanglePosition(this.rectangleF3, point, rotationPoint, angleClass))
  953. {
  954. this.pointL = SetOffsetAfterRotation(point, rotationPoint, angleClass);
  955. moveKb = 3;
  956. return this.pointArray.Count + 1;
  957. }
  958. else if (GetRectanglePosition(this.rectangleF4, point, rotationPoint1, angleClass1))
  959. {
  960. this.pointL = SetOffsetAfterRotation(point, rotationPoint1, angleClass1);
  961. moveKb = 4;
  962. return this.pointArray.Count + 1;
  963. }
  964. else if (GetRectanglePosition(this.rectangleF5, point, rotationPoint1, angleClass1))
  965. {
  966. this.pointL = SetOffsetAfterRotation(point, rotationPoint1, angleClass1);
  967. moveKb = 5;
  968. return this.pointArray.Count + 1;
  969. }
  970. else if (GetRectanglePosition(this.rectangleF6, point, rotationPoint1, angleClass1))
  971. {
  972. this.pointL = SetOffsetAfterRotation(point, rotationPoint1, angleClass1);
  973. moveKb = 6;
  974. return this.pointArray.Count + 1;
  975. }
  976. else if (GetRectanglePosition(this.rectangleF7, point, rotationPoint1, angleClass1))
  977. {
  978. this.pointL = SetOffsetAfterRotation(point, rotationPoint1, angleClass1);
  979. moveKb = 7;
  980. return this.pointArray.Count + 1;
  981. }
  982. else if (GetRectanglePosition(this.rectangleF8, point, rotationPoint1, angleClass1))
  983. {
  984. this.pointL = SetOffsetAfterRotation(point, rotationPoint1, angleClass1);
  985. moveKb = 8;
  986. return this.pointArray.Count + 1;
  987. }
  988. else if (GetRectanglePosition(this.rectangleF9, point, rotationPoint1, angleClass1))
  989. {
  990. this.pointL = SetOffsetAfterRotation(point, rotationPoint1, angleClass1);
  991. moveKb = 9;
  992. return this.pointArray.Count + 1;
  993. }
  994. }
  995. if (PointInObject(point))
  996. return 0;
  997. return -1;
  998. }
  999. protected override bool PointInObject(Point point)
  1000. {
  1001. CreateObjects();
  1002. return AreaRegion.IsVisible(point);
  1003. }
  1004. public override bool IntersectsWith(Rectangle rectangle)
  1005. {
  1006. CreateObjects();
  1007. return AreaRegion.IsVisible(rectangle);
  1008. }
  1009. public override RectangleF GetBoundingBox()
  1010. {
  1011. float minx = 0, maxx = 0, miny = 0, maxy = 0;
  1012. for (int i = 0; i < pointArray.Count; i++)
  1013. {
  1014. if (i == 0)
  1015. {
  1016. minx = maxx = pointArray[i].X;
  1017. miny = maxy = pointArray[i].Y;
  1018. }
  1019. else
  1020. {
  1021. if (pointArray[i].X > maxx) maxx = pointArray[i].X;
  1022. if (pointArray[i].X < minx) minx = pointArray[i].X;
  1023. if (pointArray[i].Y > maxy) maxy = pointArray[i].Y;
  1024. if (pointArray[i].Y < miny) miny = pointArray[i].Y;
  1025. }
  1026. }
  1027. return new RectangleF(minx, miny, maxx - minx, maxy - miny);
  1028. }
  1029. internal void setNextPoint(Point p)
  1030. {
  1031. AddPoint(p);
  1032. //startPoint = endPoint;
  1033. //endPoint = p;
  1034. }
  1035. internal void setEndPoint(Point p)
  1036. {
  1037. endPoint = p;
  1038. }
  1039. public override List<PointF> GetPoints()
  1040. {
  1041. return pointArray;
  1042. }
  1043. public override ParentStyleModel GetStyle()
  1044. {
  1045. return measureStyleModel;
  1046. }
  1047. }
  1048. }