MeasureLine.cs 50 KB

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