GrainSizeGuideClass.cs 94 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850
  1. using OpenCvSharp;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.SettingModel;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Drawing;
  8. using System.Drawing.Drawing2D;
  9. using System.IO;
  10. using System.Windows.Forms;
  11. using Point = System.Drawing.Point;
  12. namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass
  13. {
  14. class GrainSizeGuideClass
  15. {
  16. /// <summary>
  17. /// 0,GBT6394; 1,GBT4335; 2,GBT24177; 3,E112; 4,ISO643;5,YST347(XX)
  18. /// </summary>
  19. private int gbtType;
  20. /// <summary>
  21. /// 需要根据当前操作图片备份和读取的辅助线数据
  22. /// </summary>
  23. public GrainSizeGuideModel guideModel = new GrainSizeGuideModel();
  24. /// <summary>
  25. /// 根据图片保存辅助线参数
  26. /// </summary>
  27. public Dictionary<string, GrainSizeGuideModel> guideDict = new Dictionary<string, GrainSizeGuideModel>();
  28. public PointF m_StartPoint = Point.Empty;
  29. public bool m_canMove;
  30. /// <summary>
  31. /// 1上 2下 3左 4右
  32. /// </summary>
  33. private int m_MoveDirection = 0;
  34. private bool m0_canMove;
  35. /// <summary>
  36. /// 构造辅助线的工作结构
  37. /// </summary>
  38. public void createGuideClassModelsNamed(string modelName)
  39. {
  40. GrainSizeGuideStyleModel = XmlSerializeHelper.DESerializer<GrainSizeGuideStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\" + modelName, FileMode.Open));
  41. }
  42. /// <summary>
  43. /// 构造辅助线的工作结构
  44. /// </summary>
  45. public void createGuideAreaClassModelsNamed(string modelName)
  46. {
  47. GrainSizeGuideAreaMethodModel = XmlSerializeHelper.DESerializer<GrainSizeGuideAreaMethodModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\" + modelName, FileMode.Open));
  48. }
  49. public GrainSizeGuideAreaMethodModel GrainSizeGuideAreaMethodModel { get; private set; }
  50. public GrainSizeGuideStyleModel GrainSizeGuideStyleModel { get; private set; }
  51. public void updateRectangleSize(double physical_Micron = 1.0)
  52. {
  53. this.guideModel.rectangleFLineWidth = (float)(this.guideModel.rectangleFLine.Width * physical_Micron);
  54. this.guideModel.rectangleFLineHeight = (float)(this.guideModel.rectangleFLine.Height * physical_Micron);
  55. }
  56. /// <summary>
  57. /// 面积法-圆的直径
  58. /// </summary>
  59. public int GetMat_lineDiameter(double physical_Micron)
  60. {
  61. return Math.Max(1, (int)(guideModel.lineDiameter / physical_Micron));
  62. }
  63. /// <summary>
  64. /// 辅助线长度
  65. /// </summary>
  66. public double LineLength
  67. {
  68. get
  69. {
  70. return guideModel.lineLength;
  71. }
  72. }
  73. /// <summary>
  74. /// 辅助线数量
  75. /// </summary>
  76. public int LineDec
  77. {
  78. get
  79. {
  80. return guideModel.lineDec;
  81. }
  82. }
  83. /// <summary>
  84. /// 鼠标按下
  85. /// </summary>
  86. /// <param name="point1">换算后的点</param>
  87. /// <param name="e"></param>
  88. public void OnMouseDown(PointF point1, object sender, MouseEventArgs e)
  89. {
  90. if (e.Button == MouseButtons.Left && e.Clicks == 1)
  91. {
  92. RectangleF rectangleLeft = new RectangleF(this.guideModel.rectangleFLine.X - 5, this.guideModel.rectangleFLine.Y, 10, this.guideModel.rectangleFLine.Height);
  93. RectangleF rectangleRight = new RectangleF(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width - 5, this.guideModel.rectangleFLine.Y, 10, this.guideModel.rectangleFLine.Height);
  94. RectangleF rectangleTop = new RectangleF(this.guideModel.rectangleFLine.X, this.guideModel.rectangleFLine.Y - 5, this.guideModel.rectangleFLine.Width, 10);
  95. RectangleF rectangleBottom = new RectangleF(this.guideModel.rectangleFLine.X, this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height - 5, this.guideModel.rectangleFLine.Width, 10);
  96. if (rectangleLeft.Contains(point1))
  97. {
  98. ((SystemLayer.ScrollPanel)sender).Cursor = Cursors.SizeWE;
  99. m0_canMove = true;
  100. m_MoveDirection = 3;
  101. }
  102. else if (rectangleRight.Contains(point1))
  103. {
  104. ((SystemLayer.ScrollPanel)sender).Cursor = Cursors.SizeWE;
  105. m0_canMove = true;
  106. m_MoveDirection = 4;
  107. }
  108. else if (rectangleTop.Contains(point1))
  109. {
  110. ((SystemLayer.ScrollPanel)sender).Cursor = Cursors.SizeNS;
  111. m0_canMove = true;
  112. m_MoveDirection = 1;
  113. }
  114. else if (rectangleBottom.Contains(point1))
  115. {
  116. ((SystemLayer.ScrollPanel)sender).Cursor = Cursors.SizeNS;
  117. m0_canMove = true;
  118. m_MoveDirection = 2;
  119. }
  120. else
  121. ((SystemLayer.ScrollPanel)sender).Cursor = Cursors.Default;
  122. }
  123. }
  124. /// <summary>
  125. /// 面积法的鼠标移动
  126. /// </summary>
  127. /// <param name="point1">换算后的点</param>
  128. /// <param name="e"></param>
  129. public bool onMouseAreaMove(PointF point1, object SelectedItem, MouseEventArgs e, int surfaceWidth, int surfaceHeight, double physical_Micron = 1.0)
  130. {
  131. if (e.Button == MouseButtons.Left && m0_canMove)
  132. {
  133. // 缩放
  134. this.ScaleGuideAreaStyle(m_MoveDirection, SelectedItem, point1, surfaceWidth, surfaceHeight, physical_Micron);
  135. return true;
  136. }
  137. return false;
  138. }
  139. /// <summary>
  140. /// 缩放辅助线及其样式
  141. /// </summary>
  142. /// <param name="m_MoveDirection">1上 2下 3左 4右</param>
  143. /// <param name="SelectedItem"></param>
  144. /// <param name="startPoint"></param>
  145. /// <param name="endPoint"></param>
  146. private void ScaleGuideAreaStyle(int m_MoveDirection, object SelectedItem/*, PointF startPoint*/, PointF endPoint, int surfaceWidth, int surfaceHeight, double physical_Micron = 1.0)
  147. {
  148. double multiple = 1;
  149. switch (m_MoveDirection)
  150. {
  151. case 1:
  152. multiple = (this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height - endPoint.Y) / guideModel.originHeight;// (this.rectangleFLine.Y + this.rectangleFLine.Height - startPoint.Y);
  153. break;
  154. case 2:
  155. multiple = (endPoint.Y - this.guideModel.rectangleFLine.Y) / guideModel.originHeight;// (startPoint.Y - this.rectangleFLine.Y);
  156. break;
  157. case 3:
  158. multiple = (this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width - endPoint.X) / guideModel.originWidth;// (this.rectangleFLine.X + this.rectangleFLine.Width - startPoint.X);
  159. break;
  160. case 4:
  161. multiple = (endPoint.X - this.guideModel.rectangleFLine.X) / guideModel.originWidth;// (startPoint.X - this.rectangleFLine.X);
  162. break;
  163. default:
  164. break;
  165. }
  166. //向上移动或向左侧移动
  167. if (m_MoveDirection == 1 || m_MoveDirection == 3)
  168. {
  169. if (this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width - (int)(guideModel.originWidth * multiple) < 0)
  170. {
  171. multiple = (this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width) / guideModel.originWidth;
  172. }
  173. if (this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height - (int)(guideModel.originHeight * multiple) < 0)
  174. {
  175. multiple = (this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height) / guideModel.originHeight;
  176. }
  177. }
  178. else
  179. {
  180. if (this.guideModel.rectangleFLine.X + (int)(guideModel.originWidth * multiple) > surfaceWidth)
  181. {
  182. multiple = (surfaceWidth - this.guideModel.rectangleFLine.X) / guideModel.originWidth;
  183. }
  184. if (this.guideModel.rectangleFLine.Y + (int)(guideModel.originHeight * multiple) > surfaceHeight)
  185. {
  186. multiple = (surfaceHeight - this.guideModel.rectangleFLine.Y) / guideModel.originHeight;
  187. }
  188. }
  189. //避免操作异常
  190. if (guideModel.originWidth * multiple < 10 || guideModel.originHeight * multiple < 10)
  191. return;
  192. switch (m_MoveDirection)
  193. {
  194. case 1:
  195. this.guideModel.rectangleFLine = new RectangleF(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width - (int)(guideModel.originWidth * multiple), this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height - (int)(guideModel.originHeight * multiple), (int)(guideModel.originWidth * multiple), (int)(guideModel.originHeight * multiple));
  196. break;
  197. case 2:
  198. this.guideModel.rectangleFLine = new RectangleF(this.guideModel.rectangleFLine.X, this.guideModel.rectangleFLine.Y, (int)(guideModel.originWidth * multiple), (int)(guideModel.originHeight * multiple));
  199. break;
  200. case 3:
  201. this.guideModel.rectangleFLine = new RectangleF(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width - (int)(guideModel.originWidth * multiple), this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height - (int)(guideModel.originHeight * multiple), (int)(guideModel.originWidth * multiple), (int)(guideModel.originHeight * multiple));
  202. break;
  203. case 4:
  204. this.guideModel.rectangleFLine = new RectangleF(this.guideModel.rectangleFLine.X, this.guideModel.rectangleFLine.Y, (int)(guideModel.originWidth * multiple), (int)(guideModel.originHeight * multiple));
  205. break;
  206. default:
  207. break;
  208. }
  209. this.updateRectangleSize(physical_Micron);
  210. // 圆形
  211. if (GrainSizeGuideAreaMethodModel.circularGuideStyles != null)
  212. {
  213. foreach (var circularGuideStyle in GrainSizeGuideAreaMethodModel.circularGuideStyles)
  214. {
  215. if (SelectedItem.Equals(circularGuideStyle.tag))
  216. {
  217. this.guideModel.lineDiameter = multiple * this.guideModel.originLineDiameter;
  218. }
  219. }
  220. }
  221. // 矩形
  222. if (GrainSizeGuideAreaMethodModel.rectangleGuideStyles != null)
  223. {
  224. foreach (var rectangleGuideStyle in GrainSizeGuideAreaMethodModel.rectangleGuideStyles)
  225. {
  226. if (SelectedItem.Equals(rectangleGuideStyle.tag))
  227. {
  228. this.guideModel.lineRectangleWidth = multiple * this.guideModel.originLineRectangleWidth;
  229. this.guideModel.lineRectangleHeight = multiple * this.guideModel.originLineRectangleHeight;
  230. }
  231. }
  232. }
  233. }
  234. /// <summary>
  235. /// 移动
  236. /// </summary>
  237. /// <param name="point1">换算后的点</param>
  238. /// <param name="e"></param>
  239. public bool onMouseMove(PointF point1, object SelectedItem, MouseEventArgs e, int surfaceWidth, int surfaceHeight, double physical_Micron = 1.0)
  240. {
  241. if (e.Button == MouseButtons.Left && m0_canMove)
  242. {
  243. // 缩放
  244. this.ScaleGuideStyle(m_MoveDirection, SelectedItem, point1, surfaceWidth, surfaceHeight, physical_Micron);
  245. return true;
  246. }
  247. return false;
  248. }
  249. /// <summary>
  250. /// 鼠标抬起
  251. /// </summary>
  252. /// <param name="sender"></param>
  253. /// <param name="e"></param>
  254. public void onMouseUp(object sender, MouseEventArgs e)
  255. {
  256. m0_canMove = false;
  257. ((SystemLayer.ScrollPanel)sender).Cursor = Cursors.Default;
  258. }
  259. /// <summary>
  260. /// 更新辅助线及其样式
  261. /// </summary>
  262. public void UpdateScaleGuideAreaStyle(object SelectedItem, GrainSizeGuideModel guideModel, double multiple = 1.0)
  263. {
  264. if (GrainSizeGuideAreaMethodModel == null)
  265. return;
  266. // 圆形
  267. if (GrainSizeGuideAreaMethodModel.circularGuideStyles != null)
  268. {
  269. foreach (var circularGuideStyle in GrainSizeGuideAreaMethodModel.circularGuideStyles)
  270. {
  271. if (SelectedItem.Equals(circularGuideStyle.tag))
  272. {
  273. guideModel.lineDiameter = multiple * guideModel.lineDiameter;
  274. }
  275. }
  276. }
  277. // 矩形
  278. if (GrainSizeGuideAreaMethodModel.rectangleGuideStyles != null)
  279. {
  280. foreach (var rectangleGuideStyle in GrainSizeGuideAreaMethodModel.rectangleGuideStyles)
  281. {
  282. if (SelectedItem.Equals(rectangleGuideStyle.tag))
  283. {
  284. guideModel.lineRectangleWidth = multiple * guideModel.lineRectangleWidth;
  285. guideModel.lineRectangleHeight = multiple * guideModel.lineRectangleHeight;
  286. }
  287. }
  288. }
  289. }
  290. /// <summary>
  291. /// 缩放辅助线及其样式更新数据
  292. /// </summary>
  293. /// <param name="SelectedItem"></param>
  294. public void UpdateScaleGuideStyle(object SelectedItem, GrainSizeGuideModel guideModel, float recWidth, float recHeight, double physical_Micron = 1.0, double multiple = 1.0)
  295. {
  296. if (GrainSizeGuideStyleModel == null)
  297. {
  298. return;
  299. }
  300. // 垂直辅助线
  301. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.vGuideStyles != null)
  302. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  303. if (SelectedItem.Equals(vGuideStyle.tag))
  304. guideModel.updateWithGuideModel1(multiple, physical_Micron, recWidth);
  305. // 水平辅助线
  306. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.hGuideStyles != null)
  307. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  308. if (SelectedItem.Equals(hGuideStyle.tag))
  309. guideModel.updateWithGuideModel2(multiple, physical_Micron, recHeight);
  310. // 单圆辅助线
  311. if (this.gbtType != 1 && GrainSizeGuideStyleModel.cGuideStyles != null)
  312. foreach (var cGuideStyle in GrainSizeGuideStyleModel.cGuideStyles)
  313. if (SelectedItem.Equals(cGuideStyle.tag))
  314. guideModel.updateWithGuideModel3(multiple, physical_Micron);
  315. // 三圆辅助线
  316. if (GrainSizeGuideStyleModel.tCGuideStyles != null)
  317. foreach (var tCGuideStyle in GrainSizeGuideStyleModel.tCGuideStyles)
  318. if (SelectedItem.Equals(tCGuideStyle.tag))
  319. guideModel.updateWithGuideModel4(multiple, physical_Micron);
  320. // 复合辅助线
  321. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.rGuideStyles != null)
  322. foreach (var rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  323. if (SelectedItem.Equals(rGuideStyle.tag))
  324. guideModel.updateWithGuideModel5(multiple, physical_Micron);
  325. }
  326. /// <summary>
  327. /// 缩放辅助线及其样式
  328. /// </summary>
  329. /// <param name="m_MoveDirection">1上 2下 3左 4右</param>
  330. /// <param name="SelectedItem"></param>
  331. /// <param name="endPoint"></param>
  332. private void ScaleGuideStyle(int m_MoveDirection, object SelectedItem, PointF endPoint, int surfaceWidth, int surfaceHeight, double physical_Micron = 1.0)
  333. {
  334. double multiple = 1;
  335. switch (m_MoveDirection)
  336. {
  337. case 1:
  338. multiple = (this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height - endPoint.Y) / guideModel.originHeight;// (this.rectangleFLine.Y + this.rectangleFLine.Height - startPoint.Y);
  339. break;
  340. case 2:
  341. multiple = (endPoint.Y - this.guideModel.rectangleFLine.Y) / guideModel.originHeight;
  342. break;
  343. case 3:
  344. multiple = (this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width - endPoint.X) / guideModel.originWidth;// (this.rectangleFLine.X + this.rectangleFLine.Width - startPoint.X);
  345. break;
  346. case 4:
  347. multiple = (endPoint.X - this.guideModel.rectangleFLine.X) / guideModel.originWidth;
  348. break;
  349. default:
  350. break;
  351. }
  352. //避免操作异常
  353. if (guideModel.originWidth * multiple < 10 || guideModel.originHeight * multiple < 10)
  354. return;
  355. //向上移动或向左侧移动
  356. if (m_MoveDirection == 1 || m_MoveDirection == 3)
  357. {
  358. if (this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width - (int)(guideModel.originWidth * multiple) < 0)
  359. {
  360. multiple = (this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width) / guideModel.originWidth;
  361. }
  362. if (this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height - (int)(guideModel.originHeight * multiple) < 0)
  363. {
  364. multiple = (this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height) / guideModel.originHeight;
  365. }
  366. }
  367. else
  368. {
  369. if (this.guideModel.rectangleFLine.X + (int)(guideModel.originWidth * multiple) > surfaceWidth)
  370. {
  371. multiple = (surfaceWidth - this.guideModel.rectangleFLine.X) / guideModel.originWidth;
  372. }
  373. if (this.guideModel.rectangleFLine.Y + (int)(guideModel.originHeight * multiple) > surfaceHeight)
  374. {
  375. multiple = (surfaceHeight - this.guideModel.rectangleFLine.Y) / guideModel.originHeight;
  376. }
  377. }
  378. switch (m_MoveDirection)
  379. {
  380. case 1://向上移动
  381. {
  382. this.guideModel.rectangleFLine = new RectangleF(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width - (int)(guideModel.originWidth * multiple), this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height - (int)(guideModel.originHeight * multiple), (int)(guideModel.originWidth * multiple), (int)(guideModel.originHeight * multiple));
  383. }
  384. break;
  385. case 2:
  386. {
  387. this.guideModel.rectangleFLine = new RectangleF(this.guideModel.rectangleFLine.X, this.guideModel.rectangleFLine.Y, (int)(guideModel.originWidth * multiple), (int)(guideModel.originHeight * multiple));
  388. }
  389. break;
  390. case 3://向左侧移动
  391. {
  392. this.guideModel.rectangleFLine = new RectangleF(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width - (int)(guideModel.originWidth * multiple), this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height - (int)(guideModel.originHeight * multiple), (int)(guideModel.originWidth * multiple), (int)(guideModel.originHeight * multiple));
  393. }
  394. break;
  395. case 4:
  396. {
  397. this.guideModel.rectangleFLine = new RectangleF(this.guideModel.rectangleFLine.X, this.guideModel.rectangleFLine.Y, (int)(guideModel.originWidth * multiple), (int)(guideModel.originHeight * multiple));
  398. }
  399. break;
  400. default:
  401. break;
  402. }
  403. this.updateRectangleSize(physical_Micron);
  404. // 垂直辅助线
  405. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.vGuideStyles != null)
  406. {
  407. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  408. {
  409. if (SelectedItem.Equals(vGuideStyle.tag))
  410. {
  411. this.guideModel.updateWithGuideModel1(multiple, physical_Micron, -1);//###
  412. }
  413. }
  414. }
  415. // 水平辅助线
  416. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.hGuideStyles != null)
  417. {
  418. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  419. {
  420. if (SelectedItem.Equals(hGuideStyle.tag))
  421. {
  422. this.guideModel.updateWithGuideModel2(multiple, physical_Micron, -1);//###
  423. }
  424. }
  425. }
  426. // 单圆辅助线
  427. if (this.gbtType != 1 && GrainSizeGuideStyleModel.cGuideStyles != null)
  428. {
  429. foreach (var cGuideStyle in GrainSizeGuideStyleModel.cGuideStyles)
  430. {
  431. if (SelectedItem.Equals(cGuideStyle.tag))
  432. {
  433. this.guideModel.updateWithGuideModel3(multiple, physical_Micron, true);//###
  434. }
  435. }
  436. }
  437. // 三圆辅助线
  438. if (GrainSizeGuideStyleModel.tCGuideStyles != null)
  439. {
  440. foreach (var tCGuideStyle in GrainSizeGuideStyleModel.tCGuideStyles)
  441. {
  442. if (SelectedItem.Equals(tCGuideStyle.tag))
  443. {
  444. this.guideModel.updateWithGuideModel4(multiple, physical_Micron, true);//###
  445. }
  446. }
  447. }
  448. // 复合辅助线
  449. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.rGuideStyles != null)
  450. {
  451. foreach (var rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  452. {
  453. if (SelectedItem.Equals(rGuideStyle.tag))
  454. {
  455. this.guideModel.updateWithGuideModel5(multiple, physical_Micron, true);//###
  456. }
  457. }
  458. }
  459. }
  460. /// <summary>
  461. /// 面积法绘制辅助线
  462. /// </summary>
  463. /// <param name="graphics"></param>
  464. /// <param name="SelectedItem"></param>
  465. public void DrawAreaGuide(Graphics graphics, object SelectedItem, GrainSizeGuideModel cal_CuideModel)
  466. {
  467. if (SelectedItem == null)
  468. return;
  469. // 以下为绘制样式
  470. Pen linePen = new Pen(Color.FromArgb(cal_CuideModel.lineColor), cal_CuideModel.lineWidth);
  471. // 圆形
  472. if (GrainSizeGuideAreaMethodModel.circularGuideStyles != null)
  473. {
  474. foreach (var circularGuideStyle in GrainSizeGuideAreaMethodModel.circularGuideStyles)
  475. {
  476. if (SelectedItem.Equals(circularGuideStyle.tag))
  477. {
  478. graphics.DrawEllipse(linePen, cal_CuideModel.rectangleFLine.X, cal_CuideModel.rectangleFLine.Y, cal_CuideModel.rectangleFLine.Width, cal_CuideModel.rectangleFLine.Height);
  479. }
  480. }
  481. }
  482. // 矩形
  483. if (GrainSizeGuideAreaMethodModel.rectangleGuideStyles != null)
  484. {
  485. foreach (var rectangleGuideStyle in GrainSizeGuideAreaMethodModel.rectangleGuideStyles)
  486. {
  487. if (SelectedItem.Equals(rectangleGuideStyle.tag))
  488. {
  489. graphics.DrawRectangle(linePen, cal_CuideModel.rectangleFLine.X, cal_CuideModel.rectangleFLine.Y, cal_CuideModel.rectangleFLine.Width, cal_CuideModel.rectangleFLine.Height);
  490. }
  491. }
  492. }
  493. }
  494. /// <summary>
  495. /// 绘制辅助线
  496. /// </summary>
  497. public void DrawGuideLines(Graphics graphics, object SelectedItem, GrainSizeGuideModel cal_CuideModel)
  498. {
  499. if (SelectedItem == null)
  500. return;
  501. // 垂直辅助线
  502. if (GrainSizeGuideStyleModel.vGuideStyles != null)
  503. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  504. if (SelectedItem.Equals(vGuideStyle.tag))
  505. cal_CuideModel.DrawGuideLines1(graphics);
  506. // 水平辅助线
  507. if (GrainSizeGuideStyleModel.hGuideStyles != null)
  508. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  509. if (SelectedItem.Equals(hGuideStyle.tag))
  510. cal_CuideModel.DrawGuideLines2(graphics);
  511. // 单圆辅助线
  512. if (GrainSizeGuideStyleModel.cGuideStyles != null)
  513. foreach (var cGuideStyle in GrainSizeGuideStyleModel.cGuideStyles)
  514. if (SelectedItem.Equals(cGuideStyle.tag))
  515. cal_CuideModel.DrawGuideLines3(graphics);
  516. // 三圆辅助线
  517. if (GrainSizeGuideStyleModel.tCGuideStyles != null)
  518. foreach (var tCGuideStyle in GrainSizeGuideStyleModel.tCGuideStyles)
  519. if (SelectedItem.Equals(tCGuideStyle.tag))
  520. cal_CuideModel.DrawGuideLines4(graphics);
  521. // 复合辅助线
  522. if (GrainSizeGuideStyleModel.rGuideStyles != null)
  523. foreach (var rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  524. if (SelectedItem.Equals(rGuideStyle.tag))
  525. cal_CuideModel.DrawGuideLines5(graphics);
  526. }
  527. /// <summary>
  528. /// 获取辅助线的外框矩形
  529. /// </summary>
  530. /// <param name="SelectedItem"></param>
  531. /// <returns></returns>
  532. public RectangleF guideAreaRectLine(object SelectedItem, out bool foundItem, bool guideTypeChanged = true, double physical_Micron = 1.0)
  533. {
  534. PointF pointF = this.guideModel.loctation;
  535. foundItem = false;
  536. RectangleF rectFLine = new RectangleF();
  537. double pppppp = physical_Micron * 1.0;
  538. // 圆形
  539. if (GrainSizeGuideAreaMethodModel.circularGuideStyles != null)
  540. {
  541. foreach (var circularGuideStyle in GrainSizeGuideAreaMethodModel.circularGuideStyles)
  542. {
  543. if (SelectedItem.Equals(circularGuideStyle.tag))
  544. {
  545. rectFLine = new RectangleF(pointF.X - (float)(this.guideModel.lineDiameter / (2.0 * pppppp))
  546. , pointF.Y - (float)(this.guideModel.lineDiameter / (2.0 * pppppp)), (float)(this.guideModel.lineDiameter / pppppp), (float)(this.guideModel.lineDiameter / pppppp));
  547. foundItem = true;
  548. if (guideTypeChanged)
  549. {
  550. this.guideModel.originWidth = (float)(Math.Max(1, guideModel.originLineDiameter / pppppp));
  551. this.guideModel.originHeight = (float)(Math.Max(1, guideModel.originLineDiameter / pppppp));
  552. }
  553. }
  554. }
  555. }
  556. // 矩形
  557. if (GrainSizeGuideAreaMethodModel.rectangleGuideStyles != null)
  558. {
  559. foreach (var rectangleGuideStyle in GrainSizeGuideAreaMethodModel.rectangleGuideStyles)
  560. {
  561. if (SelectedItem.Equals(rectangleGuideStyle.tag))
  562. {
  563. rectFLine = new RectangleF(pointF.X - (float)(this.guideModel.lineRectangleWidth / (2.0 * pppppp))
  564. , pointF.Y - (float)(this.guideModel.lineRectangleHeight / (2.0 * pppppp)), (float)(this.guideModel.lineRectangleWidth / pppppp), (float)(this.guideModel.lineRectangleHeight / pppppp));
  565. foundItem = true;
  566. if (guideTypeChanged)
  567. {
  568. this.guideModel.originWidth = (float)(Math.Max(1, guideModel.originLineRectangleWidth / pppppp));
  569. this.guideModel.originHeight = (float)(Math.Max(1, guideModel.originLineRectangleHeight / pppppp));
  570. }
  571. }
  572. }
  573. }
  574. //if (guideTypeChanged)
  575. //{
  576. // this.originWidth = Math.Max(1, rectFLine.Width);
  577. // this.originHeight = Math.Max(1, rectFLine.Height);
  578. //}
  579. this.guideModel.rectangleFLine = rectFLine;
  580. this.updateRectangleSize(physical_Micron);
  581. return rectFLine;
  582. }
  583. /// <summary>
  584. /// 更新辅助线的外框矩形宽高数值(获取辅助线的外框矩形)
  585. /// </summary>
  586. /// <param name="SelectedItem"></param>
  587. /// <returns></returns>
  588. public RectangleF updateGuideAreaRectLine(object SelectedItem, GrainSizeGuideModel guideModel, out bool foundItem, bool guideTypeChanged = true, double physical_Micron = 1.0)
  589. {
  590. foundItem = false;
  591. RectangleF rectFLine = new RectangleF();
  592. double pppppp = physical_Micron * 1.0;
  593. // 圆形
  594. if (GrainSizeGuideAreaMethodModel.circularGuideStyles != null)
  595. {
  596. foreach (var circularGuideStyle in GrainSizeGuideAreaMethodModel.circularGuideStyles)
  597. {
  598. if (SelectedItem.Equals(circularGuideStyle.tag))
  599. {
  600. //rectFLine = new RectangleF(pointF.X - (float)(this.lineDiameter / (2.0 * pppppp))
  601. // , pointF.Y - (float)(this.lineDiameter / (2.0 * pppppp)), (float)(this.lineDiameter / pppppp), (float)(this.lineDiameter / pppppp));
  602. foundItem = true;
  603. if (guideTypeChanged)
  604. {
  605. guideModel.originWidth = (float)(Math.Max(1, guideModel.originLineDiameter / pppppp));
  606. guideModel.originHeight = (float)(Math.Max(1, guideModel.originLineDiameter / pppppp));
  607. }
  608. }
  609. }
  610. }
  611. // 矩形
  612. if (GrainSizeGuideAreaMethodModel.rectangleGuideStyles != null)
  613. {
  614. foreach (var rectangleGuideStyle in GrainSizeGuideAreaMethodModel.rectangleGuideStyles)
  615. {
  616. if (SelectedItem.Equals(rectangleGuideStyle.tag))
  617. {
  618. //rectFLine = new RectangleF(pointF.X - (float)(this.lineRectangleWidth / (2.0 * pppppp))
  619. // , pointF.Y - (float)(this.lineRectangleHeight / (2.0 * pppppp)), (float)(this.lineRectangleWidth / pppppp), (float)(this.lineRectangleHeight / pppppp));
  620. foundItem = true;
  621. if (guideTypeChanged)
  622. {
  623. guideModel.originWidth = (float)(Math.Max(1, guideModel.originLineRectangleWidth / pppppp));
  624. guideModel.originHeight = (float)(Math.Max(1, guideModel.originLineRectangleHeight / pppppp));
  625. }
  626. }
  627. }
  628. }
  629. return rectFLine;
  630. }
  631. /// <summary>
  632. /// 更新辅助线的外框矩形宽高数值(获取辅助线的外框矩形)
  633. /// </summary>
  634. /// <param name="SelectedItem"></param>
  635. /// <returns></returns>
  636. public RectangleF updateGuideRectLine(object SelectedItem, GrainSizeGuideModel guideModel, out bool foundItem, bool guideTypeChanged = true, double physical_Micron = 1.0)
  637. {
  638. foundItem = false;
  639. RectangleF rectFLine = new RectangleF();
  640. // 垂直辅助线
  641. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.vGuideStyles != null)
  642. {
  643. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  644. {
  645. if (SelectedItem.Equals(vGuideStyle.tag))
  646. {
  647. //rectFLine = new RectangleF(pointF.X - (float)(this.mat_lineSpacing * (this.lineDec - 1)) / 2 - (float)this.lineWidth / 2
  648. // , pointF.Y - (float)this.mat_lineLength / 2, this.mat_lineSpacing * (this.lineDec - 1)/* + this.lineWidth*/, this.mat_lineLength);
  649. foundItem = true;
  650. if (guideTypeChanged)
  651. {
  652. guideModel.originWidth = (float)(Math.Max(1, guideModel.originMat_lineSpacing * (guideModel.lineDec - 1)));
  653. guideModel.originHeight = (float)(Math.Max(1, guideModel.originLineLength / physical_Micron));
  654. }
  655. }
  656. }
  657. }
  658. // 水平辅助线
  659. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.hGuideStyles != null)
  660. {
  661. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  662. {
  663. if (SelectedItem.Equals(hGuideStyle.tag))
  664. {
  665. //rectFLine = new RectangleF(pointF.X - this.mat_lineLength / 2
  666. // , pointF.Y - (float)(this.mat_lineSpacing * (this.lineDec - 1)) / 2 - (float)this.lineWidth / 2
  667. // , this.mat_lineLength, this.mat_lineSpacing * (this.lineDec - 1)/* + this.lineWidth*/);
  668. foundItem = true;
  669. if (guideTypeChanged)
  670. {
  671. guideModel.originWidth = (float)(Math.Max(1, guideModel.originLineLength / physical_Micron));
  672. guideModel.originHeight = (float)(Math.Max(1, guideModel.originMat_lineSpacing * (guideModel.lineDec - 1)));
  673. }
  674. }
  675. }
  676. }
  677. // 单圆辅助线
  678. if (this.gbtType != 1 && GrainSizeGuideStyleModel.cGuideStyles != null)
  679. {
  680. foreach (var cGuideStyle in GrainSizeGuideStyleModel.cGuideStyles)
  681. {
  682. if (SelectedItem.Equals(cGuideStyle.tag))
  683. {
  684. //rectFLine = new RectangleF(pointF.X - this.mat_diameter / 2
  685. // , pointF.Y - this.mat_diameter / 2, this.mat_diameter, this.mat_diameter);
  686. foundItem = true;
  687. if (guideTypeChanged)
  688. {
  689. guideModel.originWidth = (float)(Math.Max(1, guideModel.originDiameter / physical_Micron));
  690. guideModel.originHeight = (float)(Math.Max(1, guideModel.originDiameter / physical_Micron));
  691. }
  692. }
  693. }
  694. }
  695. // 三圆辅助线
  696. if (GrainSizeGuideStyleModel.tCGuideStyles != null)
  697. {
  698. foreach (var tCGuideStyle in GrainSizeGuideStyleModel.tCGuideStyles)
  699. {
  700. if (SelectedItem.Equals(tCGuideStyle.tag))
  701. {
  702. //rectFLine = new RectangleF(pointF.X - this.mat_diameter / 2 - 2 * this.mat_margin
  703. // , pointF.Y - this.mat_diameter / 2 - 2 * this.mat_margin, this.mat_diameter + 4 * this.mat_margin, this.mat_diameter + 4 * this.mat_margin);
  704. foundItem = true;
  705. if (guideTypeChanged)
  706. {
  707. guideModel.originWidth = (float)(Math.Max(1, (guideModel.originDiameter + 4 * guideModel.originMargin) / physical_Micron));
  708. guideModel.originHeight = (float)(Math.Max(1, (guideModel.originDiameter + 4 * guideModel.originMargin) / physical_Micron));
  709. }
  710. }
  711. }
  712. }
  713. // 复合辅助线
  714. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.rGuideStyles != null)
  715. {
  716. foreach (var rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  717. {
  718. if (SelectedItem.Equals(rGuideStyle.tag))
  719. {
  720. // rectFLine = new RectangleF(pointF.X - this.mat_diameter / 2 - this.mat_margin * 2 - this.mat_VLineToCDistance
  721. //, pointF.Y - this.mat_diameter / 2 - this.mat_margin * 2, this.mat_diameter + 4 * this.mat_margin + this.mat_VLineToCDistance, this.mat_diameter + 4 * this.mat_margin + this.mat_HLineToCDistance);
  722. foundItem = true;
  723. if (guideTypeChanged)
  724. {//this.mat_diameter + 4 * this.mat_margin + this.mat_VLineToCDistance
  725. guideModel.originWidth = (float)(Math.Max(1, (guideModel.originDiameter + 4 * guideModel.originMargin + guideModel.originVLineToCDistance) / physical_Micron));
  726. //this.mat_diameter + 4 * this.mat_margin + this.mat_HLineToCDistance
  727. guideModel.originHeight = (float)(Math.Max(1, (guideModel.originDiameter + 4 * guideModel.originMargin + guideModel.originHLineToCDistance) / physical_Micron));
  728. }
  729. }
  730. }
  731. }
  732. return rectFLine;
  733. }
  734. /// <summary>
  735. /// 获取辅助线的外框矩形
  736. /// </summary>
  737. /// <param name="SelectedItem"></param>
  738. /// <returns></returns>
  739. public RectangleF guideRectLine(object SelectedItem, out bool foundItem, bool guideTypeChanged = true, double physical_Micron = 1.0)
  740. {
  741. PointF pointF = this.guideModel.loctation;
  742. foundItem = false;
  743. RectangleF rectFLine = new RectangleF();
  744. // 垂直辅助线
  745. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.vGuideStyles != null)
  746. {
  747. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  748. {
  749. if (SelectedItem.Equals(vGuideStyle.tag))
  750. {
  751. rectFLine = new RectangleF(pointF.X - (float)(this.guideModel.mat_lineSpacing * (this.guideModel.lineDec - 1)) / 2 - (float)this.guideModel.lineWidth / 2
  752. , pointF.Y - (float)this.guideModel.mat_lineLength / 2, this.guideModel.mat_lineSpacing * (this.guideModel.lineDec - 1)/* + this.lineWidth*/, this.guideModel.mat_lineLength);
  753. foundItem = true;
  754. if (guideTypeChanged)
  755. {
  756. this.guideModel.originWidth = (float)(Math.Max(1, guideModel.originMat_lineSpacing * (this.guideModel.lineDec - 1)));
  757. this.guideModel.originHeight = (float)(Math.Max(1, guideModel.originLineLength / physical_Micron));
  758. }
  759. }
  760. }
  761. }
  762. // 水平辅助线
  763. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.hGuideStyles != null)
  764. {
  765. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  766. {
  767. if (SelectedItem.Equals(hGuideStyle.tag))
  768. {
  769. rectFLine = new RectangleF(pointF.X - this.guideModel.mat_lineLength / 2
  770. , pointF.Y - (float)(this.guideModel.mat_lineSpacing * (this.guideModel.lineDec - 1)) / 2 - (float)this.guideModel.lineWidth / 2
  771. , this.guideModel.mat_lineLength, this.guideModel.mat_lineSpacing * (this.guideModel.lineDec - 1)/* + this.lineWidth*/);
  772. foundItem = true;
  773. if (guideTypeChanged)
  774. {
  775. this.guideModel.originWidth = (float)(Math.Max(1, guideModel.originLineLength / physical_Micron));
  776. this.guideModel.originHeight = (float)(Math.Max(1, guideModel.originMat_lineSpacing * (this.guideModel.lineDec - 1)));
  777. }
  778. }
  779. }
  780. }
  781. // 单圆辅助线
  782. if (this.gbtType != 1 && GrainSizeGuideStyleModel.cGuideStyles != null)
  783. {
  784. foreach (var cGuideStyle in GrainSizeGuideStyleModel.cGuideStyles)
  785. {
  786. if (SelectedItem.Equals(cGuideStyle.tag))
  787. {
  788. rectFLine = new RectangleF(pointF.X - this.guideModel.mat_diameter / 2
  789. , pointF.Y - this.guideModel.mat_diameter / 2, this.guideModel.mat_diameter, this.guideModel.mat_diameter);
  790. foundItem = true;
  791. if (guideTypeChanged)
  792. {
  793. this.guideModel.originWidth = (float)(Math.Max(1, guideModel.originDiameter / physical_Micron));
  794. this.guideModel.originHeight = (float)(Math.Max(1, guideModel.originDiameter / physical_Micron));
  795. }
  796. }
  797. }
  798. }
  799. // 三圆辅助线
  800. if (GrainSizeGuideStyleModel.tCGuideStyles != null)
  801. {
  802. foreach (var tCGuideStyle in GrainSizeGuideStyleModel.tCGuideStyles)
  803. {
  804. if (SelectedItem.Equals(tCGuideStyle.tag))
  805. {
  806. rectFLine = new RectangleF(pointF.X - this.guideModel.mat_diameter / 2 - 2 * this.guideModel.mat_margin
  807. , pointF.Y - this.guideModel.mat_diameter / 2 - 2 * this.guideModel.mat_margin, this.guideModel.mat_diameter + 4 * this.guideModel.mat_margin, this.guideModel.mat_diameter + 4 * this.guideModel.mat_margin);
  808. foundItem = true;
  809. if (guideTypeChanged)
  810. {
  811. this.guideModel.originWidth = (float)(Math.Max(1, (guideModel.originDiameter + 4 * guideModel.originMargin) / physical_Micron));
  812. this.guideModel.originHeight = (float)(Math.Max(1, (guideModel.originDiameter + 4 * guideModel.originMargin) / physical_Micron));
  813. }
  814. }
  815. }
  816. }
  817. // 复合辅助线
  818. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.rGuideStyles != null)
  819. {
  820. foreach (var rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  821. {
  822. if (SelectedItem.Equals(rGuideStyle.tag))
  823. {
  824. rectFLine = new RectangleF(pointF.X - this.guideModel.mat_diameter / 2 - this.guideModel.mat_margin * 2 - this.guideModel.mat_VLineToCDistance
  825. , pointF.Y - this.guideModel.mat_diameter / 2 - this.guideModel.mat_margin * 2, this.guideModel.mat_diameter + 4 * this.guideModel.mat_margin + this.guideModel.mat_VLineToCDistance, this.guideModel.mat_diameter + 4 * this.guideModel.mat_margin + this.guideModel.mat_HLineToCDistance);
  826. //List<PointF> pointFs = new List<PointF>();
  827. //PointF rPoint = new PointF(rectFLine.X + rectFLine.Width / 2 + this.mat_VLineToCDistance / 2 - this.mat_hLineLength / 2, rectFLine.Bottom);
  828. //pointFs.Add(rPoint);
  829. //rPoint = new PointF(rectFLine.X + rectFLine.Width / 2 + this.mat_VLineToCDistance / 2 + this.mat_hLineLength / 2, rectFLine.Bottom);
  830. //pointFs.Add(rPoint);
  831. //rPoint = new PointF(rectFLine.X, rectFLine.Y + rectFLine.Height / 2 - this.mat_HLineToCDistance / 2 - this.mat_vLineLength / 2);
  832. //pointFs.Add(rPoint);
  833. //rPoint = new PointF(rectFLine.X, rectFLine.Y + rectFLine.Height / 2 - this.mat_HLineToCDistance / 2 + this.mat_vLineLength / 2);
  834. //pointFs.Add(rPoint);
  835. //// 圆心
  836. //Point center = new Point((int)(rectFLine.X + rectFLine.Width / 2 + this.mat_VLineToCDistance / 2), (int)(rectFLine.Y + rectFLine.Height / 2 - this.mat_HLineToCDistance / 2));
  837. //double len = Math.Sqrt(((this.mat_ToprightLineLength / 2) * (this.mat_ToprightLineLength / 2)) / 2);
  838. //// 左下到右上斜线
  839. //Point a = new Point((int)center.X - (int)len, (int)center.Y + (int)len);
  840. //Point b = new Point((int)center.X + (int)len, (int)center.Y - (int)len);
  841. //pointFs.Add(a);
  842. //pointFs.Add(b);
  843. //len = Math.Sqrt(((this.mat_TopleftLineLength / 2) * (this.mat_TopleftLineLength / 2)) / 2);
  844. //// 左上到右下斜线
  845. //a = new Point((int)center.X - (int)len, (int)center.Y - (int)len);
  846. //b = new Point((int)center.X + (int)len, (int)center.Y + (int)len);
  847. //pointFs.Add(a);
  848. //pointFs.Add(b);
  849. //pointFs.Add(rectFLine.Location);
  850. //pointFs.Add(new PointF(rectFLine.Right, rectFLine.Bottom));
  851. //PointF pointF2 = new PointF(0, 0);
  852. //float maxLiftX = 0;
  853. //float maxLiftY = 0;
  854. //float minRightX = 0;
  855. //float minRightY = 0;
  856. //foreach (var pointF1 in pointFs)
  857. //{
  858. // if (pointF1.X > maxLiftX)
  859. // maxLiftX = pointF1.X;
  860. // if (pointF1.Y > maxLiftY)
  861. // maxLiftY = pointF1.Y;
  862. // if (pointF1.X < minRightX)
  863. // minRightX = pointF1.X;
  864. // if (pointF1.Y < minRightY)
  865. // minRightY = pointF1.Y;
  866. //}
  867. //rectFLine/*rectangleF*/ = new RectangleF(minRightX, minRightY, Math.Abs(minRightX - maxLiftX), Math.Abs(minRightY - maxLiftY));
  868. ////rectFLine = new RectangleF(pointF.X - this.mat_diameter / 2 - this.mat_margin * 2 - this.mat_VLineToCDistance
  869. //// , pointF.Y - this.mat_diameter / 2 - this.mat_margin * 2, this.mat_diameter + 4 * this.mat_margin + this.mat_VLineToCDistance, this.mat_diameter + 4 * this.mat_margin + this.mat_HLineToCDistance);
  870. foundItem = true;
  871. // rectFLine = new RectangleF(pointF.X - this.mat_diameter / 2 - this.mat_margin * 2 - this.mat_VLineToCDistance
  872. //, pointF.Y - this.mat_diameter / 2 - this.mat_margin * 2, this.mat_diameter + 4 * this.mat_margin + this.mat_VLineToCDistance, this.mat_diameter + 4 * this.mat_margin + this.mat_HLineToCDistance);
  873. if (guideTypeChanged)
  874. {//this.mat_diameter + 4 * this.mat_margin + this.mat_VLineToCDistance
  875. this.guideModel.originWidth = (float)(Math.Max(1, (guideModel.originDiameter + 4 * guideModel.originMargin + this.guideModel.originVLineToCDistance) / physical_Micron));
  876. //this.mat_diameter + 4 * this.mat_margin + this.mat_HLineToCDistance
  877. this.guideModel.originHeight = (float)(Math.Max(1, (guideModel.originDiameter + 4 * guideModel.originMargin + this.guideModel.originHLineToCDistance) / physical_Micron));
  878. }
  879. }
  880. }
  881. }
  882. //if (guideTypeChanged)
  883. //{
  884. // this.originWidth = Math.Max(1, rectFLine.Width);
  885. // this.originHeight = Math.Max(1, rectFLine.Height);
  886. //}
  887. this.guideModel.rectangleFLine = rectFLine;
  888. this.updateRectangleSize(physical_Micron);
  889. return rectFLine;
  890. }
  891. /// <summary>
  892. /// 复合辅助线的点的数量
  893. /// </summary>
  894. /// <returns></returns>
  895. public int getAddOfRStyle(PointF point1, object SelectedItem, out RectangleF rectangleF)
  896. {
  897. rectangleF = new RectangleF();
  898. int add = 0;
  899. // 复合辅助线
  900. if (GrainSizeGuideStyleModel.rGuideStyles != null)
  901. {
  902. foreach (var rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  903. {
  904. if (SelectedItem.Equals(rGuideStyle.tag))
  905. {
  906. add++;
  907. List<PointF> pointFs = new List<PointF>();
  908. PointF pointF = new PointF(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width / 2 + this.guideModel.mat_VLineToCDistance / 2 - this.guideModel.mat_hLineLength / 2, this.guideModel.rectangleFLine.Bottom);
  909. pointFs.Add(pointF);
  910. pointF = new PointF(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width / 2 + this.guideModel.mat_VLineToCDistance / 2 + this.guideModel.mat_hLineLength / 2, this.guideModel.rectangleFLine.Bottom);
  911. pointFs.Add(pointF);
  912. pointF = new PointF(this.guideModel.rectangleFLine.X, this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height / 2 - this.guideModel.mat_HLineToCDistance / 2 - this.guideModel.mat_vLineLength / 2);
  913. pointFs.Add(pointF);
  914. pointF = new PointF(this.guideModel.rectangleFLine.X, this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height / 2 - this.guideModel.mat_HLineToCDistance / 2 + this.guideModel.mat_vLineLength / 2);
  915. pointFs.Add(pointF);
  916. // 圆心
  917. Point center = new Point((int)(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width / 2 + this.guideModel.mat_VLineToCDistance / 2), (int)(this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height / 2 - this.guideModel.mat_HLineToCDistance / 2));
  918. double len = Math.Sqrt(((this.guideModel.mat_ToprightLineLength / 2) * (this.guideModel.mat_ToprightLineLength / 2)) / 2);
  919. // 左下到右上斜线
  920. Point a = new Point((int)center.X - (int)len, (int)center.Y + (int)len);
  921. Point b = new Point((int)center.X + (int)len, (int)center.Y - (int)len);
  922. pointFs.Add(a);
  923. pointFs.Add(b);
  924. len = Math.Sqrt(((this.guideModel.mat_TopleftLineLength / 2) * (this.guideModel.mat_TopleftLineLength / 2)) / 2);
  925. // 左上到右下斜线
  926. a = new Point((int)center.X - (int)len, (int)center.Y - (int)len);
  927. b = new Point((int)center.X + (int)len, (int)center.Y + (int)len);
  928. pointFs.Add(a);
  929. pointFs.Add(b);
  930. pointFs.Add(this.guideModel.rectangleFLine.Location);
  931. pointFs.Add(new PointF(this.guideModel.rectangleFLine.Right, this.guideModel.rectangleFLine.Bottom));
  932. PointF pointF2 = new PointF(0, 0);
  933. PointF pointF3 = new PointF();
  934. int big = 0;
  935. float maxLiftX = 0;
  936. float maxLiftY = 0;
  937. float minRightX = 0;
  938. float minRightY = 0;
  939. foreach (var pointF1 in pointFs)
  940. {
  941. if (pointF1.X > maxLiftX)
  942. maxLiftX = pointF1.X;
  943. if (pointF1.Y > maxLiftY)
  944. maxLiftY = pointF1.Y;
  945. if (big == 0)
  946. {
  947. minRightX = pointF1.X;
  948. minRightY = pointF1.Y;
  949. }
  950. else
  951. {
  952. if (point1.X < minRightX)
  953. minRightX = point1.X;//######### Y;
  954. if (point1.Y < minRightY)
  955. minRightY = point1.Y;
  956. }
  957. big++;
  958. }
  959. rectangleF = new RectangleF(minRightX, minRightY, Math.Abs(minRightX - maxLiftX), Math.Abs(minRightY - maxLiftY));
  960. }
  961. }
  962. }
  963. return add;
  964. }
  965. /// <summary>
  966. /// 图形上所有的点
  967. /// </summary>
  968. /// <param name="bitmapW"></param>
  969. /// <param name="bitmapH"></param>
  970. /// <param name="SelectedItem"></param>
  971. /// <param name="physical_Micron"></param>
  972. /// <param name="guideStyle">1 圆形 2 矩形</param>
  973. /// <returns></returns>
  974. public List<PointF> getGuideAreaPointList(int bitmapW, int bitmapH, object SelectedItem, double physical_Micron, out int guideStyle)
  975. {
  976. guideStyle = 2;
  977. List<PointF> linePointList = new List<PointF>();
  978. // 圆形
  979. if (GrainSizeGuideAreaMethodModel.circularGuideStyles != null)
  980. {
  981. double pppppp = physical_Micron * 1.0;
  982. foreach (var circularGuideStyle in GrainSizeGuideAreaMethodModel.circularGuideStyles)
  983. {
  984. if (SelectedItem.Equals(circularGuideStyle.tag))
  985. {
  986. guideStyle = 1;
  987. // 圆心
  988. Point center = new Point((int)(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width / 2), (int)(this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height / 2));
  989. for (int i = 0; i <= 360; i++)
  990. {
  991. Point[] points = roundOutline(center, (int)(guideModel.lineDiameter / (2.0 * pppppp)));
  992. foreach (var point in points)
  993. {
  994. linePointList.Add(new Point(point.X, point.Y));
  995. }
  996. }
  997. }
  998. }
  999. }
  1000. // 矩形
  1001. if (GrainSizeGuideAreaMethodModel.rectangleGuideStyles != null)
  1002. {
  1003. foreach (var rectangleGuideStyle in GrainSizeGuideAreaMethodModel.rectangleGuideStyles)
  1004. {
  1005. if (SelectedItem.Equals(rectangleGuideStyle.tag))
  1006. {
  1007. guideStyle = 2;
  1008. for (int l = (int)this.guideModel.rectangleFLine.Y; l <= this.guideModel.rectangleFLine.Bottom; l++)
  1009. {
  1010. if (this.guideModel.rectangleFLine.X >= 0 && this.guideModel.rectangleFLine.X < bitmapW && l >= 0 && l < bitmapH)
  1011. linePointList.Add(new PointF(this.guideModel.rectangleFLine.X, l));
  1012. }
  1013. for (int t = (int)this.guideModel.rectangleFLine.X; t <= this.guideModel.rectangleFLine.Right; t++)
  1014. {
  1015. if (t >= 0 && t < bitmapW && this.guideModel.rectangleFLine.Y >= 0 && this.guideModel.rectangleFLine.Y < bitmapH)
  1016. linePointList.Add(new PointF(t, this.guideModel.rectangleFLine.Y));
  1017. }
  1018. for (int r = (int)this.guideModel.rectangleFLine.Y; r <= this.guideModel.rectangleFLine.Bottom; r++)
  1019. {
  1020. if (this.guideModel.rectangleFLine.Right >= 0 && this.guideModel.rectangleFLine.Right < bitmapW && r >= 0 && r < bitmapH)
  1021. linePointList.Add(new PointF(this.guideModel.rectangleFLine.Right, r));
  1022. }
  1023. for (int t = (int)this.guideModel.rectangleFLine.X; t <= this.guideModel.rectangleFLine.Right; t++)
  1024. {
  1025. if (t >= 0 && t < bitmapW && this.guideModel.rectangleFLine.Bottom >= 0 && this.guideModel.rectangleFLine.Bottom < bitmapH)
  1026. linePointList.Add(new PointF(t, this.guideModel.rectangleFLine.Bottom));
  1027. }
  1028. }
  1029. }
  1030. }
  1031. return linePointList;
  1032. }
  1033. /// <summary>
  1034. /// 图形上所有的点,并按照直线或者圆圈类型赋值列表
  1035. /// </summary>
  1036. public List<PointF> getGuidePointListAndClassLine(Mat mat, object SelectedItem, out List<List<PointF>> straightLinePointList, out List<List<PointF>> roundLinePointList)
  1037. {
  1038. List<PointF> linePointList = new List<PointF>();
  1039. straightLinePointList = new List<List<PointF>>();///
  1040. roundLinePointList = new List<List<PointF>>();///
  1041. //lineValueList.Clear();//###
  1042. List<PointF> classPointList;
  1043. int lengthI = 0;
  1044. // 垂直辅助线
  1045. if (GrainSizeGuideStyleModel.vGuideStyles != null)
  1046. {
  1047. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  1048. {
  1049. if (SelectedItem.Equals(vGuideStyle.tag))
  1050. {
  1051. if (mat != null)
  1052. {
  1053. int spacing = 0;
  1054. for (int d = 0; d < this.guideModel.lineDec; d++)
  1055. {
  1056. classPointList = new List<PointF>();
  1057. float rectangleFLineX = this.guideModel.rectangleFLine.X /*+ this.lineWidth / 2*/ + spacing;//1019###19638
  1058. spacing += (int)this.guideModel.mat_lineSpacing;
  1059. for (int i = (int)this.guideModel.rectangleFLine.Y; i <= this.guideModel.rectangleFLine.Bottom; i++)
  1060. {
  1061. linePointList.Add(new PointF(rectangleFLineX, i));
  1062. classPointList.Add(new PointF(rectangleFLineX, i));
  1063. }
  1064. straightLinePointList.Add(classPointList);
  1065. }
  1066. }
  1067. }
  1068. }
  1069. }
  1070. // 水平辅助线
  1071. if (GrainSizeGuideStyleModel.hGuideStyles != null)
  1072. {
  1073. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  1074. {
  1075. if (SelectedItem.Equals(hGuideStyle.tag))
  1076. {
  1077. if (mat != null)
  1078. {
  1079. int spacing = 0;
  1080. for (int d = 0; d < this.guideModel.lineDec; d++)
  1081. {
  1082. classPointList = new List<PointF>();
  1083. float rectangleFLineY = this.guideModel.rectangleFLine.Y /*+ this.lineWidth / 2*/ + spacing;
  1084. spacing += (int)this.guideModel.mat_lineSpacing;
  1085. for (int i = (int)this.guideModel.rectangleFLine.X; i <= this.guideModel.rectangleFLine.Right; i++)
  1086. {
  1087. linePointList.Add(new PointF(i, rectangleFLineY));
  1088. classPointList.Add(new PointF(i, rectangleFLineY));
  1089. }
  1090. straightLinePointList.Add(classPointList);
  1091. }
  1092. }
  1093. }
  1094. }
  1095. }
  1096. // 单圆辅助线
  1097. if (GrainSizeGuideStyleModel.cGuideStyles != null)
  1098. {
  1099. foreach (var cGuideStyle in GrainSizeGuideStyleModel.cGuideStyles)
  1100. {
  1101. if (SelectedItem.Equals(cGuideStyle.tag))
  1102. {
  1103. // 圆心
  1104. Point center = new Point((int)(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width / 2), (int)(this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height / 2));
  1105. // 圆上的点集合
  1106. Point[] points = roundOutline(center, (int)this.guideModel.mat_diameter / 2);//0914###18749
  1107. if (mat != null)
  1108. {
  1109. classPointList = new List<PointF>();
  1110. classPointList.Add(new PointF(center.X, center.Y));
  1111. foreach (var point in points)
  1112. {
  1113. linePointList.Add(new PointF(point.X, point.Y));
  1114. classPointList.Add(new PointF(point.X, point.Y));
  1115. }
  1116. roundLinePointList.Add(classPointList);
  1117. }
  1118. }
  1119. }
  1120. }
  1121. // 三圆辅助线
  1122. if (GrainSizeGuideStyleModel.tCGuideStyles != null)
  1123. {
  1124. foreach (var tCGuideStyle in GrainSizeGuideStyleModel.tCGuideStyles)
  1125. {
  1126. if (SelectedItem.Equals(tCGuideStyle.tag))
  1127. {
  1128. // 圆心
  1129. Point center = new Point((int)(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width / 2), (int)(this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height / 2));
  1130. // 圆上的点集合
  1131. List<Point> points = new List<Point>();
  1132. Point[] points1 = roundOutline(center, (int)this.guideModel.mat_diameter / 2);
  1133. Point[] points2 = roundOutline(center, (int)this.guideModel.mat_diameter / 2 + (int)this.guideModel.mat_margin);
  1134. Point[] points3 = roundOutline(center, (int)this.guideModel.mat_diameter / 2 + 2 * (int)this.guideModel.mat_margin);
  1135. classPointList = new List<PointF>();
  1136. classPointList.Add(new PointF(center.X, center.Y));
  1137. foreach (var item in points1)
  1138. {
  1139. points.Add(new Point(item.X, item.Y));
  1140. classPointList.Add(new PointF(item.X, item.Y));
  1141. }
  1142. roundLinePointList.Add(classPointList);
  1143. classPointList = new List<PointF>();
  1144. classPointList.Add(new PointF(center.X, center.Y));
  1145. foreach (var item in points2)
  1146. {
  1147. points.Add(new Point(item.X, item.Y));
  1148. classPointList.Add(new PointF(item.X, item.Y));
  1149. }
  1150. roundLinePointList.Add(classPointList);
  1151. classPointList = new List<PointF>();
  1152. classPointList.Add(new PointF(center.X, center.Y));
  1153. foreach (var item in points3)
  1154. {
  1155. points.Add(new Point(item.X, item.Y));
  1156. classPointList.Add(new PointF(item.X, item.Y));
  1157. }
  1158. roundLinePointList.Add(classPointList);
  1159. if (mat != null)
  1160. {
  1161. foreach (var point in points)
  1162. {
  1163. linePointList.Add(new PointF(point.X, point.Y));
  1164. }
  1165. }
  1166. }
  1167. }
  1168. }
  1169. // 复合辅助线
  1170. if (GrainSizeGuideStyleModel.rGuideStyles != null)
  1171. {
  1172. foreach (var rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  1173. {
  1174. if (SelectedItem.Equals(rGuideStyle.tag))
  1175. {
  1176. // 圆上的点集合
  1177. List<Point> points = new List<Point>();
  1178. if (mat != null)
  1179. {
  1180. classPointList = new List<PointF>();
  1181. for (int i = (int)(this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height / 2 - this.guideModel.mat_HLineToCDistance / 2 - this.guideModel.mat_vLineLength / 2); i <= this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height / 2 - this.guideModel.mat_HLineToCDistance / 2 + this.guideModel.mat_vLineLength / 2; i++)
  1182. {
  1183. points.Add(new Point((int)this.guideModel.rectangleFLine.X, i));
  1184. classPointList.Add(new PointF(this.guideModel.rectangleFLine.X, i));
  1185. }
  1186. straightLinePointList.Add(classPointList);
  1187. }
  1188. if (mat != null)
  1189. {
  1190. classPointList = new List<PointF>();
  1191. for (int i = (int)(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width / 2 + this.guideModel.mat_VLineToCDistance / 2 - this.guideModel.mat_hLineLength / 2); i <= this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width / 2 + this.guideModel.mat_VLineToCDistance / 2 + this.guideModel.mat_hLineLength / 2; i++)
  1192. {
  1193. points.Add(new Point(i, (int)this.guideModel.rectangleFLine.Bottom));
  1194. classPointList.Add(new PointF(i, this.guideModel.rectangleFLine.Bottom));
  1195. }
  1196. straightLinePointList.Add(classPointList);
  1197. }
  1198. // 圆心
  1199. Point center = new Point((int)(this.guideModel.rectangleFLine.X + this.guideModel.rectangleFLine.Width / 2 + this.guideModel.mat_VLineToCDistance / 2), (int)(this.guideModel.rectangleFLine.Y + this.guideModel.rectangleFLine.Height / 2 - this.guideModel.mat_HLineToCDistance / 2));
  1200. double len = Math.Sqrt(((this.guideModel.mat_ToprightLineLength / 2) * (this.guideModel.mat_ToprightLineLength / 2)) / 2);
  1201. // 左下到右上斜线
  1202. Point a = new Point((int)center.X - (int)len, (int)center.Y + (int)len);
  1203. Point b = new Point((int)center.X + (int)len, (int)center.Y - (int)len);
  1204. if (mat != null)
  1205. {
  1206. classPointList = new List<PointF>();
  1207. // 循环x坐标
  1208. for (int i = a.X + 1; i < b.X; i++)
  1209. {
  1210. // 计算斜率1653
  1211. double k = ((double)(a.Y - b.Y)) / (a.X - b.X);
  1212. // 根据斜率,计算y坐标
  1213. double y = k * (i - a.X) + a.Y;
  1214. // 简单判断一下y是不是整数
  1215. double d = y - (int)y;
  1216. if (0.001 > d && d > -0.001)
  1217. {
  1218. points.Add(new Point(i, (int)y));
  1219. classPointList.Add(new PointF(i, (float)y));
  1220. }
  1221. }
  1222. straightLinePointList.Add(classPointList);
  1223. }
  1224. len = Math.Sqrt(((this.guideModel.mat_TopleftLineLength / 2) * (this.guideModel.mat_TopleftLineLength / 2)) / 2);
  1225. // 左上到右下斜线
  1226. a = new Point((int)center.X - (int)len, (int)center.Y - (int)len);
  1227. b = new Point((int)center.X + (int)len, (int)center.Y + (int)len);
  1228. if (mat != null)
  1229. {
  1230. classPointList = new List<PointF>();
  1231. // 循环x坐标
  1232. for (int i = a.X + 1; i < b.X; i++)
  1233. {
  1234. // 计算斜率1653
  1235. double k = ((double)(a.Y - b.Y)) / (a.X - b.X);
  1236. // 根据斜率,计算y坐标
  1237. double y = k * (i - a.X) + a.Y;
  1238. // 简单判断一下y是不是整数
  1239. double d = y - (int)y;
  1240. if (0.001 > d && d > -0.001)
  1241. {
  1242. points.Add(new Point(i, (int)y));
  1243. classPointList.Add(new PointF(i, (float)y));
  1244. }
  1245. }
  1246. straightLinePointList.Add(classPointList);
  1247. }
  1248. if (mat != null)
  1249. {
  1250. // 圆上的点集合
  1251. Point[] points1 = roundOutline(center, (int)this.guideModel.mat_diameter / 2);
  1252. Point[] points2 = roundOutline(center, (int)this.guideModel.mat_diameter / 2 + (int)this.guideModel.mat_margin);
  1253. Point[] points3 = roundOutline(center, (int)this.guideModel.mat_diameter / 2 + 2 * (int)this.guideModel.mat_margin);
  1254. classPointList = new List<PointF>();
  1255. classPointList.Add(new PointF(center.X, center.Y));
  1256. foreach (var item in points1)
  1257. {
  1258. points.Add(new Point(item.X, item.Y));
  1259. classPointList.Add(new PointF(item.X, item.Y));
  1260. }
  1261. roundLinePointList.Add(classPointList);
  1262. classPointList = new List<PointF>();
  1263. classPointList.Add(new PointF(center.X, center.Y));
  1264. foreach (var item in points2)
  1265. {
  1266. points.Add(new Point(item.X, item.Y));
  1267. classPointList.Add(new PointF(item.X, item.Y));
  1268. }
  1269. roundLinePointList.Add(classPointList);
  1270. classPointList = new List<PointF>();
  1271. classPointList.Add(new PointF(center.X, center.Y));
  1272. foreach (var item in points3)
  1273. {
  1274. points.Add(new Point(item.X, item.Y));
  1275. classPointList.Add(new PointF(item.X, item.Y));
  1276. }
  1277. roundLinePointList.Add(classPointList);
  1278. foreach (var point in points)
  1279. {
  1280. linePointList.Add(new PointF(point.X, point.Y));
  1281. }
  1282. }
  1283. }
  1284. }
  1285. }
  1286. return linePointList;
  1287. }
  1288. /// <summary>
  1289. /// 使用圆心及半径得到圆的轮廓
  1290. /// </summary>
  1291. /// <param name="center">圆心</param>
  1292. /// <param name="radius">半径</param>
  1293. /// <returns></returns>
  1294. public Point[] roundOutline(Point center, int radius)
  1295. {
  1296. if (radius < 1)
  1297. radius = 1;
  1298. Mat mat = new Mat((int)(radius * 2.1), (int)(radius * 2.1), MatType.CV_8UC1, new Scalar(0, 0, 0));
  1299. OpenCvSharp.Point point = new OpenCvSharp.Point(mat.Cols / 2, mat.Rows / 2);
  1300. Cv2.Circle(mat, point, radius, new Scalar(255, 255, 255), -1);
  1301. OpenCvSharp.Point[][] contours;
  1302. HierarchyIndex[] hierarchy;
  1303. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
  1304. if (contours.Length > 0)
  1305. {
  1306. OpenCvSharp.Point[] roundOutline = contours[0];
  1307. Point[] roundOutPoints = new Point[roundOutline.Length];
  1308. for (int i = 0; i < roundOutline.Length; i++)
  1309. {
  1310. roundOutPoints[i].X = roundOutline[i].X - point.X + center.X;
  1311. roundOutPoints[i].Y = roundOutline[i].Y - point.Y + center.Y;
  1312. }
  1313. return roundOutPoints;
  1314. }
  1315. return new Point[0];
  1316. }
  1317. /// <summary>
  1318. /// 更新辅助线及其样式
  1319. /// </summary>
  1320. public void UpdateGuideAreaStyle(Mat imageMat, object SelectedItem, bool showMessageAlert, double physical_Micron)//#####################
  1321. {
  1322. if (imageMat == null)//1014###18517
  1323. return;
  1324. Boolean autosized = false;/* if (matOrg == null)//1014###18517 return; */
  1325. double maxSize = Math.Min(imageMat.Width, imageMat.Height);
  1326. if (GrainSizeGuideAreaMethodModel == null)
  1327. return;
  1328. double pppppp = physical_Micron * 1.0;
  1329. // 圆形
  1330. if (GrainSizeGuideAreaMethodModel.circularGuideStyles != null)
  1331. {
  1332. foreach (var circularGuideStyle in GrainSizeGuideAreaMethodModel.circularGuideStyles)
  1333. {
  1334. if (SelectedItem.Equals(circularGuideStyle.tag))
  1335. {
  1336. double multiple = this.physicalGainMultiple(circularGuideStyle.lineDiameter / pppppp, maxSize);
  1337. if (multiple < 1)
  1338. autosized = true;
  1339. this.guideModel.originLineDiameter = 1/*multiple*/ * circularGuideStyle.lineDiameter;
  1340. this.guideModel.lineDiameter = multiple * circularGuideStyle.lineDiameter;
  1341. this.guideModel.lineColor = circularGuideStyle.lineColor;
  1342. this.guideModel.lineWidth = circularGuideStyle.lineWidth;
  1343. }
  1344. }
  1345. }
  1346. // 矩形
  1347. if (GrainSizeGuideAreaMethodModel.rectangleGuideStyles != null)
  1348. {
  1349. foreach (var rectangleGuideStyle in GrainSizeGuideAreaMethodModel.rectangleGuideStyles)
  1350. {
  1351. if (SelectedItem.Equals(rectangleGuideStyle.tag))
  1352. {
  1353. double multiple1 = this.physicalGainMultiple(rectangleGuideStyle.lineRectangleWidth / pppppp, imageMat.Width);
  1354. double multiple2 = this.physicalGainMultiple(rectangleGuideStyle.lineRectangleHeight / pppppp, imageMat.Height);
  1355. double multiple = Math.Min(multiple1, multiple2);
  1356. if (multiple < 1)
  1357. autosized = true;
  1358. this.guideModel.originLineRectangleWidth = 1/*multiple*/ * rectangleGuideStyle.lineRectangleWidth;
  1359. this.guideModel.lineRectangleWidth = multiple * rectangleGuideStyle.lineRectangleWidth;
  1360. this.guideModel.originLineRectangleHeight = 1/*multiple*/ * rectangleGuideStyle.lineRectangleHeight;
  1361. this.guideModel.lineRectangleHeight = multiple * rectangleGuideStyle.lineRectangleHeight;
  1362. this.guideModel.lineColor = rectangleGuideStyle.lineColor;
  1363. this.guideModel.lineWidth = rectangleGuideStyle.lineWidth;
  1364. }
  1365. }
  1366. }
  1367. if (autosized && showMessageAlert)//showMessageBox
  1368. MessageBox.Show(PdnResources.GetString("Menu.Thesizeoftheauxiliaryhepicturesize.text"));
  1369. }
  1370. /// <summary>
  1371. /// 更新辅助线及其样式
  1372. /// </summary>
  1373. public void UpdateGuideStyle(Mat matOrg, object SelectedItem, bool showMessageAlert = true, double physical_Micron = 1.0)
  1374. {
  1375. if (matOrg == null)
  1376. return;
  1377. Boolean autosized = false;
  1378. double maxSize = Math.Min(matOrg.Width, matOrg.Height);
  1379. // 垂直辅助线
  1380. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.vGuideStyles != null)
  1381. {
  1382. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  1383. {
  1384. if (SelectedItem.Equals(vGuideStyle.tag))
  1385. {
  1386. double maxSizeCurrent = vGuideStyle.lineLength;//#21683
  1387. double multiple1 = this.physicalGainMultiple(maxSizeCurrent / physical_Micron, matOrg.Height);
  1388. maxSizeCurrent = vGuideStyle.lineSpacing * (vGuideStyle.lineDec - 1);
  1389. double multiple2 = this.physicalGainMultiple(maxSizeCurrent / physical_Micron, matOrg.Width);
  1390. double multiple = Math.Min(multiple1, multiple2);// this.physicalGainMultiple(maxSizeCurrent / physical_Micron, maxSize);
  1391. if (multiple < 1)
  1392. autosized = true;
  1393. this.guideModel.initWithGrainRGuideStyle1(multiple, physical_Micron, vGuideStyle);
  1394. }
  1395. }
  1396. }
  1397. // 水平辅助线
  1398. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.hGuideStyles != null)
  1399. {
  1400. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  1401. {
  1402. if (SelectedItem.Equals(hGuideStyle.tag))
  1403. {
  1404. double maxSizeCurrent = hGuideStyle.lineLength;//#21683
  1405. double multiple1 = this.physicalGainMultiple(maxSizeCurrent / physical_Micron, matOrg.Width);
  1406. maxSizeCurrent = hGuideStyle.lineSpacing * (hGuideStyle.lineDec - 1);
  1407. double multiple2 = this.physicalGainMultiple(maxSizeCurrent / physical_Micron, matOrg.Height);
  1408. double multiple = Math.Min(multiple1, multiple2);// this.physicalGainMultiple(maxSizeCurrent / physical_Micron, maxSize);
  1409. if (multiple < 1)
  1410. autosized = true;
  1411. this.guideModel.initWithGrainRGuideStyle2(multiple, physical_Micron, hGuideStyle);
  1412. }
  1413. }
  1414. }
  1415. // 单圆辅助线
  1416. if (this.gbtType != 1 && GrainSizeGuideStyleModel.cGuideStyles != null)
  1417. {
  1418. foreach (var cGuideStyle in GrainSizeGuideStyleModel.cGuideStyles)
  1419. {
  1420. if (SelectedItem.Equals(cGuideStyle.tag))
  1421. {
  1422. double multiple = this.physicalGainMultiple(cGuideStyle.diameter / physical_Micron, maxSize);
  1423. if (multiple < 1)
  1424. autosized = true;
  1425. this.guideModel.initWithGrainRGuideStyle3(multiple, physical_Micron, cGuideStyle);
  1426. }
  1427. }
  1428. }
  1429. // 三圆辅助线
  1430. if (GrainSizeGuideStyleModel.tCGuideStyles != null)
  1431. {
  1432. foreach (var tCGuideStyle in GrainSizeGuideStyleModel.tCGuideStyles)
  1433. {
  1434. if (SelectedItem.Equals(tCGuideStyle.tag))
  1435. {
  1436. double multiple = this.physicalGainMultiple((tCGuideStyle.diameter + tCGuideStyle.margin * 4) / physical_Micron, maxSize);
  1437. if (multiple < 1)
  1438. autosized = true;
  1439. this.guideModel.initWithGrainRGuideStyle4(multiple, physical_Micron, tCGuideStyle);
  1440. }
  1441. }
  1442. }
  1443. // 复合辅助线
  1444. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.rGuideStyles != null)
  1445. {
  1446. foreach (GrainSizeGuideStyleModel.RGuideStyle rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  1447. {
  1448. if (SelectedItem.Equals(rGuideStyle.tag))
  1449. {
  1450. double maxSizeCurrent = 0;
  1451. if (rGuideStyle.vLineLength / physical_Micron > maxSizeCurrent)
  1452. {
  1453. maxSizeCurrent = rGuideStyle.vLineLength / physical_Micron;
  1454. }
  1455. if (rGuideStyle.hLineLength / physical_Micron > maxSizeCurrent)
  1456. {
  1457. maxSizeCurrent = rGuideStyle.hLineLength / physical_Micron;
  1458. }
  1459. if ((rGuideStyle.diameter + rGuideStyle.margin * 4 + rGuideStyle.VLineToCDistance) / physical_Micron > maxSizeCurrent)
  1460. {
  1461. maxSizeCurrent = (rGuideStyle.diameter + rGuideStyle.margin * 4 + rGuideStyle.VLineToCDistance) / physical_Micron;
  1462. }
  1463. if ((rGuideStyle.diameter + rGuideStyle.margin * 4 + rGuideStyle.HLineToCDistance) / physical_Micron > maxSizeCurrent)
  1464. {
  1465. maxSizeCurrent = (rGuideStyle.diameter + rGuideStyle.margin * 4 + rGuideStyle.HLineToCDistance) / physical_Micron;
  1466. }
  1467. if ((rGuideStyle.TopleftLineLength / Math.Sqrt(2.0)) / physical_Micron > maxSizeCurrent)
  1468. {
  1469. maxSizeCurrent = (rGuideStyle.TopleftLineLength / Math.Sqrt(2.0)) / physical_Micron;
  1470. }
  1471. if ((rGuideStyle.ToprightLineLength / Math.Sqrt(2.0)) / physical_Micron > maxSizeCurrent)
  1472. {
  1473. maxSizeCurrent = (rGuideStyle.ToprightLineLength / Math.Sqrt(2.0)) / physical_Micron;
  1474. }
  1475. double multiple = this.physicalGainMultiple(maxSizeCurrent, maxSize);
  1476. if (multiple < 1)
  1477. autosized = true;
  1478. this.guideModel.initWithGrainRGuideStyle5(multiple, physical_Micron, rGuideStyle);
  1479. }
  1480. }
  1481. }
  1482. if (autosized && showMessageAlert)//##19846
  1483. MessageBox.Show(PdnResources.GetString("Menu.Thesizeoftheauxiliaryhepicturesize.text"));
  1484. }
  1485. public ArrayList getComboboxArrayAreaList1()
  1486. {
  1487. ArrayList arrayList1 = new ArrayList();
  1488. List<int> indexList1 = new List<int>();
  1489. // 圆形
  1490. if (GrainSizeGuideAreaMethodModel.circularGuideStyles != null)
  1491. {
  1492. foreach (var circularGuideStyle in GrainSizeGuideAreaMethodModel.circularGuideStyles)
  1493. {
  1494. arrayList1.Add(circularGuideStyle.tag/*" "*/);
  1495. indexList1.Add(circularGuideStyle.index);
  1496. }
  1497. }
  1498. // 矩形
  1499. if (GrainSizeGuideAreaMethodModel.rectangleGuideStyles != null)
  1500. {
  1501. foreach (var rectangleGuideStyle in GrainSizeGuideAreaMethodModel.rectangleGuideStyles)
  1502. {
  1503. arrayList1.Add(rectangleGuideStyle.tag/*" "*/);
  1504. indexList1.Add(rectangleGuideStyle.index);
  1505. }
  1506. }
  1507. if (arrayList1.Count > 0)//0916###18839
  1508. {
  1509. //排序算法//0914###18839
  1510. bool sortSuccess = false;
  1511. while (!sortSuccess)
  1512. {
  1513. sortSuccess = true;
  1514. int firstIndex = 0;
  1515. int secondIndex = 0;
  1516. for (int i = 0; i < indexList1.Count; i++)
  1517. {
  1518. for (int j = i + 1; j < indexList1.Count; j++)
  1519. {
  1520. if (indexList1[i] > indexList1[j])
  1521. {
  1522. sortSuccess = false;
  1523. firstIndex = i;
  1524. secondIndex = j;
  1525. }
  1526. }
  1527. if (!sortSuccess)
  1528. break;
  1529. }
  1530. string firstValue = arrayList1[firstIndex] + "";
  1531. arrayList1[firstIndex] = arrayList1[secondIndex] + "";
  1532. arrayList1[secondIndex] = firstValue;
  1533. int firstIndexV = indexList1[firstIndex] + 0;
  1534. indexList1[firstIndex] = indexList1[secondIndex] + 0;
  1535. indexList1[secondIndex] = firstIndexV;
  1536. }
  1537. arrayList1.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
  1538. }
  1539. return arrayList1;
  1540. }
  1541. public ArrayList getComboboxArrayList1()
  1542. {
  1543. ArrayList arrayList1 = new ArrayList();
  1544. List<int> indexList1 = new List<int>();
  1545. // 垂直辅助线
  1546. if (GrainSizeGuideStyleModel.vGuideStyles != null)
  1547. {
  1548. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  1549. {
  1550. arrayList1.Add(vGuideStyle.tag/*""*/);
  1551. indexList1.Add(vGuideStyle.index);
  1552. }
  1553. }
  1554. // 水平辅助线
  1555. if (GrainSizeGuideStyleModel.hGuideStyles != null)
  1556. {
  1557. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  1558. {
  1559. arrayList1.Add(hGuideStyle.tag/*""*/);
  1560. indexList1.Add(hGuideStyle.index);
  1561. }
  1562. }
  1563. // 单圆辅助线
  1564. if (this.gbtType != 1 && GrainSizeGuideStyleModel.cGuideStyles != null)
  1565. {
  1566. foreach (var cGuideStyle in GrainSizeGuideStyleModel.cGuideStyles)
  1567. {
  1568. arrayList1.Add(cGuideStyle.tag);
  1569. indexList1.Add(cGuideStyle.index);
  1570. }
  1571. }
  1572. // 三圆辅助线
  1573. if (GrainSizeGuideStyleModel.tCGuideStyles != null)
  1574. {
  1575. foreach (var tCGuideStyle in GrainSizeGuideStyleModel.tCGuideStyles)
  1576. {
  1577. arrayList1.Add(tCGuideStyle.tag);
  1578. indexList1.Add(tCGuideStyle.index);
  1579. }
  1580. }
  1581. // 复合辅助线
  1582. if (this.gbtType != 13 && this.gbtType != 1 && GrainSizeGuideStyleModel.rGuideStyles != null)
  1583. {
  1584. foreach (var rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  1585. {
  1586. arrayList1.Add(rGuideStyle.tag);//.Add();
  1587. indexList1.Add(rGuideStyle.index);
  1588. }
  1589. }
  1590. if (arrayList1.Count > 0)
  1591. {
  1592. //###//排序算法//0914###18839
  1593. bool sortSuccess = false;
  1594. while (!sortSuccess)
  1595. {
  1596. sortSuccess = true;
  1597. int firstIndex = 0;
  1598. int secondIndex = 0;
  1599. for (int i = 0; i < indexList1.Count; i++)
  1600. {
  1601. for (int j = i + 1; j < indexList1.Count; j++)
  1602. {
  1603. if (indexList1[i] > indexList1[j])
  1604. {
  1605. sortSuccess = false;
  1606. firstIndex = i;
  1607. secondIndex = j;
  1608. }
  1609. }
  1610. if (!sortSuccess)
  1611. break;
  1612. }
  1613. string firstValue = arrayList1[firstIndex] + "";
  1614. arrayList1[firstIndex] = arrayList1[secondIndex] + "";
  1615. arrayList1[secondIndex] = firstValue;
  1616. int firstIndexV = indexList1[firstIndex] + 0;
  1617. indexList1[firstIndex] = indexList1[secondIndex] + 0;
  1618. indexList1[secondIndex] = firstIndexV;
  1619. }
  1620. arrayList1.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
  1621. }
  1622. return arrayList1;
  1623. }
  1624. /// <summary>
  1625. /// 获取辅助线缩放比例
  1626. /// </summary>
  1627. /// <param name="gridSize"> 设置的数值 </param>
  1628. /// <param name="maxSize"> 限制最大值 </param>
  1629. /// <returns></returns>
  1630. private double physicalGainMultiple(double gridSize, double maxSize)
  1631. {
  1632. double multiple = 1.0;
  1633. if (gridSize > maxSize)
  1634. {
  1635. multiple = maxSize / gridSize;
  1636. }
  1637. return multiple;
  1638. }
  1639. /// <summary>
  1640. /// 获取辅助线的面积
  1641. /// </summary>
  1642. /// <returns></returns>
  1643. public double guideArea(GrainSizeGuideModel cal_GuideModel, object SelectedItem, out int isRect, int gbtType)
  1644. {
  1645. // 矩形
  1646. isRect = 0;
  1647. double aec = 0;
  1648. // 圆形
  1649. if (GrainSizeGuideAreaMethodModel.circularGuideStyles != null)
  1650. {
  1651. foreach (var circularGuideStyle in GrainSizeGuideAreaMethodModel.circularGuideStyles)
  1652. {
  1653. if (SelectedItem.Equals(circularGuideStyle.tag))
  1654. {
  1655. aec = cal_GuideModel.lineDiameter / 2.0 * cal_GuideModel.lineDiameter / 2.0 * Math.PI;
  1656. }
  1657. }
  1658. }
  1659. if (GrainSizeGuideAreaMethodModel.rectangleGuideStyles != null)
  1660. {
  1661. foreach (var rectangleGuideStyle in GrainSizeGuideAreaMethodModel.rectangleGuideStyles)
  1662. {
  1663. if (SelectedItem.Equals(rectangleGuideStyle.tag))
  1664. {
  1665. aec = cal_GuideModel.lineRectangleWidth * cal_GuideModel.lineRectangleHeight;
  1666. if (gbtType == 4)
  1667. isRect = 1;// -1;//英文版是+1,中文版可能是翻译问题被改成-1了。。
  1668. else if (gbtType == 3)
  1669. isRect = 1;
  1670. }
  1671. }
  1672. }
  1673. return aec;
  1674. }
  1675. /// <summary>
  1676. /// 获取辅助线的物理长度
  1677. /// </summary>
  1678. /// <returns></returns>
  1679. public double guideLength(GrainSizeGuideModel guideMod)
  1680. {
  1681. double length = 0;
  1682. // 垂直辅助线
  1683. if (GrainSizeGuideStyleModel.vGuideStyles != null)
  1684. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  1685. if (guideMod.oldSelectItem.Equals(vGuideStyle.tag))
  1686. length = guideMod.lineLength * guideMod.lineDec;
  1687. // 水平辅助线
  1688. if (GrainSizeGuideStyleModel.hGuideStyles != null)
  1689. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  1690. if (guideMod.oldSelectItem.Equals(hGuideStyle.tag))
  1691. length = guideMod.lineLength * guideMod.lineDec;
  1692. // 单圆辅助线
  1693. if (GrainSizeGuideStyleModel.cGuideStyles != null)
  1694. foreach (var cGuideStyle in GrainSizeGuideStyleModel.cGuideStyles)
  1695. if (guideMod.oldSelectItem.Equals(cGuideStyle.tag))
  1696. {
  1697. length = guideMod.diameter * Math.PI;
  1698. if (length == 0)
  1699. guideMod.diameter = 0;
  1700. }
  1701. // 三圆辅助线
  1702. if (GrainSizeGuideStyleModel.tCGuideStyles != null)
  1703. foreach (var tCGuideStyle in GrainSizeGuideStyleModel.tCGuideStyles)
  1704. if (guideMod.oldSelectItem.Equals(tCGuideStyle.tag))
  1705. length = guideMod.diameter * Math.PI + (guideMod.diameter + 2 * guideMod.margin) * Math.PI + (guideMod.diameter + 4 * guideMod.margin) * Math.PI;
  1706. // 复合辅助线
  1707. if (GrainSizeGuideStyleModel.rGuideStyles != null)
  1708. foreach (var rGuideStyle in GrainSizeGuideStyleModel.rGuideStyles)
  1709. if (guideMod.oldSelectItem.Equals(rGuideStyle.tag))
  1710. length = guideMod.hLineLength + guideMod.vLineLength + guideMod.TopleftLineLength + guideMod.ToprightLineLength
  1711. + guideMod.diameter * Math.PI + (guideMod.diameter + 2 * guideMod.margin) * Math.PI + (guideMod.diameter + 4 * guideMod.margin) * Math.PI;
  1712. return length;
  1713. }
  1714. /// <summary>
  1715. /// 是否 垂直/水平辅助线
  1716. /// </summary>
  1717. /// <param name="SelectedItem"></param>
  1718. /// <returns></returns>
  1719. public bool IsVGuideStylesOrHGuideStyles(object SelectedItem)
  1720. {
  1721. bool vGuideStylesOrHGuideStyles = false;
  1722. // 垂直辅助线
  1723. if (GrainSizeGuideStyleModel.vGuideStyles != null)
  1724. {
  1725. foreach (var vGuideStyle in GrainSizeGuideStyleModel.vGuideStyles)
  1726. {
  1727. if (SelectedItem.Equals(vGuideStyle.tag))
  1728. {
  1729. vGuideStylesOrHGuideStyles = true;
  1730. break;
  1731. }
  1732. }
  1733. }
  1734. // 水平辅助线
  1735. if (GrainSizeGuideStyleModel.hGuideStyles != null)
  1736. {
  1737. foreach (var hGuideStyle in GrainSizeGuideStyleModel.hGuideStyles)
  1738. {
  1739. if (SelectedItem.Equals(hGuideStyle.tag))
  1740. {
  1741. vGuideStylesOrHGuideStyles = true;
  1742. break;
  1743. }
  1744. }
  1745. }
  1746. return vGuideStylesOrHGuideStyles;
  1747. }
  1748. }
  1749. }