MeasureClosedCurve.cs 51 KB

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