MeasureLine.cs 51 KB

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