MeasureVMulParallelLine.cs 55 KB

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