MeasureHMulParallelLine.cs 56 KB

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