BatteryPrimaryDialog.cs 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778
  1. using OpenCvSharp;
  2. using PaintDotNet.Annotation;
  3. using PaintDotNet.Annotation.Enum;
  4. using PaintDotNet.Base.CommTool;
  5. using PaintDotNet.Base.Functionodel;
  6. using PaintDotNet.Base.SettingModel;
  7. using PaintDotNet.CustomControl;
  8. using PaintDotNet.DbOpreate.DbBll;
  9. using PaintDotNet.DbOpreate.DbModel;
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.ComponentModel;
  14. using System.Configuration;
  15. using System.Data;
  16. using System.Drawing;
  17. using System.Drawing.Drawing2D;
  18. using System.IO;
  19. using System.Linq;
  20. using System.Text;
  21. using System.Windows.Forms;
  22. namespace PaintDotNet.DedicatedAnalysis.Battery
  23. {
  24. internal partial class BatteryPrimaryDialog : PdnBaseForm
  25. {
  26. #region 属性
  27. //二值化集成1
  28. BinaryClassForB binaryClass;
  29. private int menuId;
  30. /// <summary>
  31. /// 选中图片的bitmap
  32. /// </summary>
  33. private Bitmap bitmap;
  34. /// <summary>
  35. /// 存在视场标记
  36. /// </summary>
  37. private bool existViewFlag = false;
  38. private int changeCount;
  39. /// <summary>
  40. /// 主空间
  41. /// </summary>
  42. private AppWorkspace appWorkspace;
  43. /// <summary>
  44. /// 图像面板
  45. /// </summary>
  46. private DocumentWorkspaceWindow documentWorkspace;
  47. /// <summary>
  48. /// 公共控件
  49. /// </summary>
  50. private GeneralAnalysisCommonControlButtons commonControlButtons;
  51. /// <summary>
  52. /// 图片测量记录
  53. /// </summary>
  54. private List<DataTable> pictureDataTables = new List<DataTable>();
  55. /// <summary>
  56. /// 网格Xml
  57. /// </summary>
  58. private GrainSizePointCountingMethodModel grainSizePointCountingMethodModel;
  59. /// <summary>
  60. /// 数据变化
  61. /// </summary>
  62. private bool saveSuccess = false;
  63. private BinaryControlSmaller bc;
  64. #endregion 属性
  65. #region 数据属性
  66. /// <summary>
  67. /// 折线点的集合
  68. /// </summary>
  69. public List<System.Drawing.Point> pointArray = new List<System.Drawing.Point>();
  70. /// <summary>
  71. /// 存储所有轮廓线的点集合
  72. /// </summary>
  73. private List<PointF> pointList = new List<PointF>();
  74. /// <summary>
  75. /// 存储所有轮廓线集合
  76. /// </summary>
  77. private List<List<PointF>> lineList = new List<List<PointF>>();
  78. /// <summary>
  79. /// 存储所有增加颗粒的点集合
  80. /// </summary>
  81. private List<PointF> kongPointList = new List<PointF>();
  82. /// <summary>
  83. /// 存储所有孔隙线集合
  84. /// </summary>
  85. private List<List<PointF>> kongLineList = new List<List<PointF>>();
  86. /// <summary>
  87. /// 存储所有删除孔隙线的点集合
  88. /// </summary>
  89. private List<PointF> delPointList = new List<PointF>();
  90. /// <summary>
  91. /// 存储所有删除孔隙线集合
  92. /// </summary>
  93. private List<List<PointF>> delLineList = new List<List<PointF>>();
  94. //轮廓修改状态
  95. bool isLunKuo = false;
  96. //添加孔隙状态
  97. bool isAddKong = false;
  98. //删除孔隙状态
  99. bool isDelKong = false;
  100. /// <summary>
  101. /// 0:添加 1:选择 2:删除
  102. /// </summary>
  103. private int operationK = -1;
  104. /// <summary>
  105. /// 被选择的线
  106. /// </summary>
  107. private int selected = -1;
  108. /// <summary>
  109. /// 起止点
  110. /// </summary>
  111. private System.Drawing.PointF startPoint, endPoint;
  112. /// <summary>
  113. /// 存储所有线的点集合
  114. /// </summary>
  115. private List<PointF[]> pointList1 = new List<PointF[]>();
  116. /// <summary>
  117. /// 存储当前线的点集合
  118. /// </summary>
  119. private PointF[] nowLine;
  120. /// <summary>
  121. /// 辅助计算偏移量-移动线两端的点
  122. /// </summary>
  123. private PointF lastPoint = new PointF(0, 0);
  124. /// <summary>
  125. /// 辅助计算偏移量-移动线中间的点
  126. /// </summary>
  127. private PointF tempPoint = new PointF(0, 0);
  128. /// <summary>
  129. /// 判断图形是否可移动
  130. /// </summary>
  131. private bool canMove = false;
  132. /// <summary>
  133. /// 测量点
  134. /// </summary>
  135. public List<RectangleF> rectangleFList = new List<RectangleF>();
  136. /// <summary>
  137. /// 移动线上的哪一个点
  138. /// </summary>
  139. private int movePointIndex = -1;
  140. /// <summary>
  141. /// 线的总数
  142. /// </summary>
  143. private int lineCount = 0;
  144. /// <summary>
  145. /// 单位标尺
  146. /// </summary>
  147. private double unitLength = 1;
  148. #endregion
  149. System.Windows.Forms.DataVisualization.Charting.Chart chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
  150. /// <summary>
  151. ///
  152. /// </summary>
  153. /// <param name="appWorkspace"></param>
  154. public BatteryPrimaryDialog(AppWorkspace appWorkspace, int menuId)
  155. {
  156. this.KeyPreview = true;
  157. this.KeyDown += OnKeyDown;
  158. this.menuId = menuId;
  159. binaryClass = new BinaryClassForB(menuId);
  160. InitializeComponent();
  161. InitializeLanguageText();
  162. ColumnHeader header0 = new ColumnHeader();
  163. header0.Text = "";
  164. header0.Width = 180;
  165. this.appWorkspace = appWorkspace;
  166. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  167. this.documentWorkspace.Dock = DockStyle.Fill;
  168. this.documentWorkspace.HookMouseEvents();
  169. this.documentWorkspace.AuxiliaryLineEnabled = false;
  170. this.documentWorkspace.Visible = false;
  171. this.documentWorkspace.panel.Paint += Panel_Paint;
  172. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  173. this.documentWorkspace.panel.MouseUp += OnMouseUp;
  174. this.documentWorkspace.panel.Paint += Panel_Paint;
  175. this.documentWorkspace.panel.MouseMove += onMouseMove;
  176. this.documentWorkspace.activeTool = DrawToolType.Pointer;
  177. this.groupBox7.Controls.Add(this.documentWorkspace);
  178. this.commonControlButtons = new GeneralAnalysisCommonControlButtons();
  179. this.commonControlButtons.Dock = DockStyle.Top;
  180. this.commonControlButtons.Height = 30;
  181. this.commonControlButtons.HideZoomToWindowAndActualSize();
  182. this.commonControlButtons.trackLabel.Text = "单击开始画线,右键停止。";
  183. this.commonControlButtons.trackLabel.Visible = true;
  184. this.commonControlButtons.trackLabel.Width = 300;
  185. this.commonControlButtons.Visible = false;
  186. this.groupBox7.Controls.Add(commonControlButtons);
  187. //获取
  188. //Startup.instance.rules.TryGetValue(MeasurementUnit.Micron, out ruleValue);
  189. //double ruleValue = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  190. ////double physical_area_length_Micron = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
  191. chart1.Size = new System.Drawing.Size(1150, 180);
  192. chart1.Location = new System.Drawing.Point(5, 15);
  193. //二值化集成2
  194. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  195. binaryClass.imageType = 6;
  196. binaryClass.createDocumentItemsSmaller(new string[] { "bp1" }, this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
  197. //binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件(参数改变时,重新处理图像)
  198. binaryClass.parentPrimary = this;
  199. this.ckChanged.CheckedChanged += new EventHandler(this.CheckedChanged);
  200. InitCommonButtonEvent();
  201. InitGridStyle();
  202. InitPicList();
  203. // SetAnalyzeModelFromXml(getModelName());
  204. }
  205. private void ShowImgEvent(object sender, EventArgs e)
  206. {
  207. if (this.listView1.Items.Count == 0)
  208. {
  209. return;
  210. }
  211. listView1.Focus();
  212. this.listView1.Items[0].Focused = true;
  213. this.listView1.Items[0].Selected = true;
  214. }
  215. #region 二值化相关方法
  216. private void InclusionsStandardDialog_FormClosing(object sender, FormClosingEventArgs e)
  217. {
  218. //binaryClass.saveParams();
  219. }
  220. private void ShownChoiseItemAndInitData(object sender, EventArgs e)
  221. {
  222. binaryClass.RefreshHistogramControl1Values();
  223. }
  224. /// <summary>
  225. /// 添加参数改变的监听
  226. /// </summary>
  227. /// <param name="sender"></param>
  228. /// <param name="e"></param>
  229. private void GrainSizePointCountingMethodDialog_Load(object sender, EventArgs e)
  230. {
  231. this.dataGridView1.SortCompare += DataGridView4_SortCompare;
  232. this.binaryClass.loadParams();
  233. }
  234. private bool bcBinaryChecked()
  235. {
  236. return bc != null && bc.BinaryChecked;
  237. }
  238. private bool bcOriginChecked()
  239. {
  240. return bc != null && bc.OriginChecked;
  241. }
  242. /// <summary>
  243. /// 显示原图/原图+二值图
  244. /// </summary>
  245. /// <param name="sender"></param>
  246. /// <param name="e"></param>
  247. private void bcOriginCheckedChanged(object sender, EventArgs e)
  248. {
  249. if (!bcOriginChecked())
  250. {
  251. if (bcBinaryChecked())
  252. this.documentWorkspace.PhaseModels[0].choise = true;
  253. }
  254. else
  255. this.documentWorkspace.PhaseModels[0].choise = false;
  256. this.documentWorkspace.Refresh();
  257. }
  258. /// <summary>
  259. /// 显示原图/原图+二值图
  260. /// </summary>
  261. /// <param name="sender"></param>
  262. /// <param name="e"></param>
  263. private void CheckedChanged(object sender, EventArgs e)
  264. {
  265. if (!ckChanged.Checked)
  266. {
  267. this.documentWorkspace.PhaseModels[0].choise = true;
  268. }
  269. else
  270. this.documentWorkspace.PhaseModels[0].choise = false;
  271. this.documentWorkspace.Refresh();
  272. }
  273. #endregion
  274. /// <summary>
  275. /// 初始化画面数据
  276. /// </summary>
  277. private void InitGridStyle()
  278. {
  279. grainSizePointCountingMethodModel = XmlSerializeHelper.DESerializer<GrainSizePointCountingMethodModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizePointCountingMethodModel.xml", FileMode.Open));
  280. if (grainSizePointCountingMethodModel.GridStyleList != null)
  281. {
  282. ArrayList arrayList = new ArrayList();
  283. foreach (var GridStyle in grainSizePointCountingMethodModel.GridStyleList)
  284. {
  285. arrayList.Add(GridStyle.gridName);
  286. }
  287. if (grainSizePointCountingMethodModel.GridStyleList.Count == 0)
  288. {
  289. }
  290. }
  291. }
  292. /// <summary>
  293. /// 初始化图片列表数据
  294. /// </summary>
  295. public void InitPicList()
  296. {
  297. //初始化图片列表
  298. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  299. {
  300. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  301. this.listView1.Items.Add("", i);
  302. this.listView1.Items[i].ImageIndex = i;
  303. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  304. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  305. }
  306. this.Shown += ShowImgEvent;
  307. }
  308. #region 初始化
  309. private void InitializeLanguageText()
  310. {
  311. this.bc = new PaintDotNet.CustomControl.BinaryControlSmaller();
  312. //
  313. // bc
  314. //
  315. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  316. this.bc.BinaryChecked = false;
  317. this.bc.BinaryStyle = 1;
  318. this.bc.Location = new System.Drawing.Point(152, 7);
  319. this.bc.Name = "bc";
  320. this.bc.OriginChecked = false;
  321. this.bc.scope1End = 170D;
  322. this.bc.scope1Start = 80D;
  323. this.bc.scope2End = 0D;
  324. this.bc.scope2Start = 0D;
  325. this.bc.scope3End = 0D;
  326. this.bc.scope3Start = 0D;
  327. this.bc.Size = new System.Drawing.Size(360, 247);
  328. this.bc.TabIndex = 3;
  329. // this.Controls.Add(this.bc);
  330. // this.Controls.SetChildIndex(this.bc, 0);
  331. //this.groupBox9.Controls.Add(chart1);
  332. this.groupBox8.Controls.Add(chart1);
  333. chart1.Visible = false;
  334. //this.label10.Visible = true;
  335. //this.label10.Text = "【" + tn.Name + "】图";
  336. chart1.Titles.Add("单晶尺寸分布图");
  337. }
  338. #endregion
  339. #region 公共按钮
  340. private void InitCommonButtonEvent()
  341. {
  342. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  343. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  344. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  345. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  346. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  347. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  348. }
  349. private void zoomInButton_Click(object sender, EventArgs e)
  350. {
  351. this.documentWorkspace.ZoomIn();
  352. }
  353. private void zoomOutButton_Click(object sender, EventArgs e)
  354. {
  355. this.documentWorkspace.ZoomOut();
  356. }
  357. private void zoomToWindowButton_Click(object sender, EventArgs e)
  358. {
  359. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  360. }
  361. private void actualSizeButton_Click(object sender, EventArgs e)
  362. {
  363. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  364. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  365. }
  366. private void pointerButton_Click(object sender, EventArgs e)
  367. {
  368. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  369. }
  370. private void mobileModeButton_Click(object sender, EventArgs e)
  371. {
  372. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  373. }
  374. #endregion
  375. private void listView1_MouseDown(object sender, MouseEventArgs e)
  376. {
  377. this.changeCount = 0;
  378. }
  379. private void DataGridView4_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  380. {
  381. // 如果是数据的列,则按浮点数处理
  382. if (e.Column.Index > 1)//###20186
  383. {
  384. e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0;
  385. }
  386. //否则,按字符串比较
  387. else
  388. {
  389. e.SortResult = System.String.Compare(Convert.ToString(e.CellValue1), Convert.ToString(e.CellValue2));
  390. }
  391. e.Handled = true;//不能省掉,不然没效果
  392. }
  393. private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
  394. {
  395. if (unitLength == 1)
  396. unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  397. this.changeCount++;
  398. }
  399. /// <summary>
  400. /// 切换图片
  401. /// </summary>
  402. /// <param name="sender"></param>
  403. /// <param name="e"></param>
  404. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  405. {
  406. SelectedIndexChanged();
  407. }
  408. List<PointF> list = new List<PointF>();
  409. /// <summary>
  410. /// 切换图片
  411. /// </summary>
  412. private void SelectedIndexChanged()
  413. {
  414. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  415. {
  416. existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.IsExsitView();
  417. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  418. lineList.Clear();
  419. pointList.Clear();
  420. kongLineList.Clear();
  421. kongPointList.Clear();
  422. delLineList.Clear();
  423. delPointList.Clear();
  424. isLunKuo = false;
  425. isAddKong = false;
  426. isDelKong = false;
  427. this.documentWorkspace.Refresh();
  428. this.dataGridView1.Rows.Clear();
  429. this.dataGridView2.Rows.Clear();
  430. Init();
  431. this.documentWorkspace.GridRectangleEnabled = false;
  432. //getimage();
  433. //getbian(bitmap);
  434. double minpoint = Convert.ToDouble(numericUpDown11.Value);
  435. if (!ckMin.Checked)
  436. minpoint = 0.01;
  437. binaryClass.pointsize = Convert.ToDouble(minpoint);
  438. int border = Convert.ToInt32(numericMax.Value);
  439. if (!ckMax.Checked)
  440. border = 0;
  441. binaryClass.border = border;
  442. double HW = Convert.ToDouble(numericHW.Value);
  443. if (!ckHW.Checked)
  444. HW = 100;
  445. binaryClass.HW = HW;
  446. double AreaRatio = Convert.ToDouble(numericArea.Value);
  447. if (!ckArea.Checked)
  448. AreaRatio = 0.01;
  449. binaryClass.AreaRatio = AreaRatio;
  450. //二值化集成4
  451. binaryClass.listView1_SelectedIndexChanged(this.bitmap);
  452. // binaryClass.bcDefault();
  453. this.documentWorkspace.Refresh();
  454. }
  455. }
  456. #region 原始事件
  457. private void Init()
  458. {
  459. this.commonControlButtons.Visible = true;
  460. this.dataGridView1.Rows.Clear();
  461. this.documentWorkspace.phaseModels.Clear();
  462. }
  463. /// <summary>
  464. /// 画布绘制
  465. /// </summary>
  466. /// <param name="sender"></param>
  467. /// <param name="e"></param>
  468. private void Panel_Paint(object sender, PaintEventArgs e)
  469. {
  470. if (this.documentWorkspace.CompositionSurface != null)
  471. {
  472. //
  473. // 以下是计算绘制图片的位置和大小并绘制图片
  474. //
  475. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  476. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  477. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  478. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  479. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  480. //if (pointArray.Count > 1)
  481. //{
  482. // e.Graphics.DrawLines(new Pen(Color.FromArgb(0, 0, 0), 2), pointArray.ToArray());
  483. //}
  484. //
  485. // 以下是绘制网格、标注、测量、视场等开始
  486. //
  487. e.Graphics.TranslateTransform(x, y);
  488. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  489. Draw(e.Graphics);
  490. //e.Graphics.DrawLines(new Pen(this.panel1.BackColor, Convert.ToInt32(this.txt_LeftLineWeight.Text)), list.ToArray());
  491. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  492. e.Graphics.TranslateTransform(-x, -y);
  493. }
  494. if (bc.isedit)
  495. {
  496. bc.isedit = false;
  497. List<List<int>> CircleDate = bc.data;
  498. bindGrid(CircleDate);
  499. }
  500. }
  501. // <summary>
  502. /// 存储字号与颜色字典
  503. /// </summary>
  504. public Dictionary<string, Color> colourFont = new Dictionary<string, Color>() { { "20", Color.White } };
  505. /// <summary>
  506. /// 绘制
  507. /// </summary>
  508. private void Draw(Graphics graphics)
  509. {
  510. //轮廓手动干预线
  511. if (lineList.Count > 0)
  512. {
  513. for (int i = 0; i < lineList.Count; i++)
  514. {
  515. graphics.DrawLines(new Pen(Color.FromArgb(255, 0, 255), 2), lineList[i].ToArray());
  516. }
  517. }
  518. if (pointList.Count > 1)
  519. {
  520. graphics.DrawLines(new Pen(Color.FromArgb(255, 0, 255), 2), pointList.ToArray());
  521. }
  522. //添加颗粒
  523. Color color = bc.BinaryBackColor;
  524. if (kongLineList.Count > 0)
  525. {
  526. for (int i = 0; i < kongLineList.Count; i++)
  527. {
  528. if (kongLineList[i].Count > 1)
  529. {
  530. graphics.DrawLines(new Pen(color, 2), kongLineList[i].ToArray());
  531. }
  532. }
  533. }
  534. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  535. Pen standardPen = new Pen(Color.FromArgb(0, 255, 0), 4);//基准线画笔
  536. Pen surfacePen = new Pen(Color.FromArgb(255, 0, 0), 4);//钢样表面画笔
  537. Pen completePen = new Pen(Color.FromArgb(0, 0, 255), 4);//完全脱碳层画笔
  538. Pen validPen = new Pen(Color.FromArgb(255, 255, 255), 4);//有效脱碳层画笔
  539. Pen partPen = new Pen(Color.FromArgb(0, 0, 0), 2);//部分脱碳层画笔
  540. Pen borderPen = new Pen(Color.Black);//填充点外圈
  541. SolidBrush insideBrush = new SolidBrush(Color.White);//填充点内圈
  542. Pen rectPen = new Pen(Color.Black);
  543. rectPen.DashStyle = DashStyle.Custom;
  544. float[] dashArray = { 2.0f, 3.0f };
  545. rectPen.DashPattern = dashArray;
  546. if (pointList1.Count > 0)
  547. {
  548. foreach (PointF[] pointFs in pointList1)
  549. {
  550. PointF[] pf = pointFs;
  551. if (pointFs.Count() > 1 && pointFs[0] != pointFs[1])
  552. {
  553. float lineLength = 12;
  554. double angle = Math.Round(BasicCalculationHelper.AngleText(pointFs[0], pointFs[1], new PointF(pointFs[0].X + lineLength, pointFs[0].Y)), 10);
  555. //判断第二个点相对于第一个点的象限
  556. int x2 = (int)(pointFs[1].X - pointFs[0].X);
  557. if (x2 == 0)
  558. x2 = 1;
  559. int y2 = (int)(pointFs[1].Y - pointFs[0].Y);
  560. if (y2 == 0)
  561. y2 = 1;
  562. int i2 = 0;
  563. if (x2 > 0 && y2 > 0) //第4象限
  564. {
  565. i2 = 4;
  566. }
  567. else if (x2 > 0 && y2 < 0) //第1象限
  568. {
  569. i2 = 1;
  570. }
  571. else if (x2 < 0 && y2 < 0) //第2象限
  572. {
  573. i2 = 2;
  574. }
  575. else if (x2 < 0 && y2 > 0) //第3象限
  576. {
  577. i2 = 3;
  578. }
  579. double sAngle1;
  580. double eAngle1;
  581. double sAngle2;
  582. double eAngle2;
  583. if (i2 == 1 || i2 == 2)
  584. {
  585. sAngle1 = 360 - angle;
  586. eAngle1 = 180 - angle;
  587. sAngle2 = 270 - angle;
  588. eAngle2 = 90 - angle;
  589. }
  590. else
  591. {
  592. sAngle1 = angle;
  593. eAngle1 = 180 + angle;
  594. sAngle2 = 270 + angle;
  595. eAngle2 = 90 + angle;
  596. }
  597. graphics.DrawLine(standardPen, pointFs[0], pointFs[1]);
  598. if (!double.IsNaN(sAngle1) && !double.IsNaN(eAngle1) && !double.IsNaN(sAngle2) && !double.IsNaN(eAngle2))
  599. {
  600. PointF assistPoint1 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[0].X + lineLength), pointFs[0].Y), pointFs[0], sAngle2);
  601. PointF assistPoint2 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[0].X + lineLength), pointFs[0].Y), pointFs[0], eAngle2);
  602. PointF assistPoint3 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[1].X + lineLength), pointFs[1].Y), pointFs[1], sAngle2);
  603. PointF assistPoint4 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[1].X + lineLength), pointFs[1].Y), pointFs[1], eAngle2);
  604. graphics.DrawLine(surfacePen, assistPoint1, assistPoint2);
  605. graphics.DrawLine(partPen, assistPoint3, assistPoint4);
  606. //PointF[] pf = pointFs;
  607. if (i2 == 1 || i2 == 2)
  608. {
  609. graphics.DrawString(Math.Round((BasicCalculationHelper.GetDistance(pf[1], pf[0], 4) * unitLength), 2).ToString(), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint4.X, assistPoint4.Y - 10);
  610. }
  611. else
  612. {
  613. graphics.DrawString(Math.Round((BasicCalculationHelper.GetDistance(pf[1], pf[0], 4) * unitLength), 2).ToString(), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint3.X, assistPoint3.Y - 10);
  614. }
  615. }
  616. }
  617. }
  618. if (selected > -1)
  619. {
  620. int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1));
  621. int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1));
  622. graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList1[selected][0].X - tempLess), (int)(pointList1[selected][0].Y - tempLess), tempPlus, tempPlus));
  623. graphics.FillRectangle(insideBrush, new RectangleF(pointList1[selected][0].X - tempLess, pointList1[selected][0].Y - tempLess, tempPlus, tempPlus));
  624. graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList1[selected][1].X - tempLess), (int)(pointList1[selected][1].Y - tempLess), tempPlus, tempPlus));
  625. graphics.FillRectangle(insideBrush, new RectangleF(pointList1[selected][1].X - tempLess, pointList1[selected][1].Y - tempLess, tempPlus, tempPlus));
  626. graphics.DrawRectangle(rectPen, rectangleFList[selected].X, rectangleFList[selected].Y, rectangleFList[selected].Width, rectangleFList[selected].Height);
  627. }
  628. }
  629. standardPen.Dispose();
  630. surfacePen.Dispose();
  631. completePen.Dispose();
  632. validPen.Dispose();
  633. partPen.Dispose();
  634. borderPen.Dispose();
  635. insideBrush.Dispose();
  636. rectPen.Dispose();
  637. }
  638. //最长直径
  639. double MaxM = 0;
  640. double MinM = 0;
  641. double MeanM = 0;
  642. private void bindGrid(List<List<int>> dataList)
  643. {
  644. if (dataList.Count < 1)
  645. {
  646. return;
  647. }
  648. chart1.Visible = true;
  649. List<int> CircleDate = dataList[0];
  650. //标尺 微米/像素
  651. double d = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  652. dataGridView1.Rows.Clear();
  653. dataGridView2.Rows.Clear();
  654. chart1.Series.Clear();
  655. chart1.ChartAreas.Clear();
  656. List<Color> colorList = new List<Color>() { Color.FromArgb(255, 0, 0), Color.FromArgb(0, 255, 0), Color.FromArgb(139, 0, 0), Color.FromArgb(128, 0, 128), Color.FromArgb(122, 160, 255) };
  657. List<double> diameterPI = new List<double>() { };
  658. List<double> diameter = new List<double>() { };
  659. List<double> diameterMax = new List<double>() { };
  660. for (int i = 0; i < dataList.Count; i++)
  661. {
  662. int newPo = dataGridView1.Rows.Add();
  663. //序号
  664. dataGridView1.Rows[newPo].Cells[0].Value = (newPo + 1).ToString();
  665. //XY
  666. dataGridView1.Rows[newPo].Cells[1].Value = "X:" + dataList[i][0].ToString() + ",Y:" + dataList[i][1].ToString();
  667. //直径
  668. double w = Convert.ToDouble(dataList[i][2]);
  669. double h = Convert.ToDouble(dataList[i][3]);
  670. double dd = (w + h) * 0.5 * d;
  671. double area = Convert.ToDouble(dataList[i][4]) * d * d;
  672. double r = Math.Sqrt(area / Math.PI) * 2;
  673. diameterPI.Add(r);
  674. diameter.Add(dd);
  675. double maxD = w > h ? w : h;
  676. double minD = w < h ? w : h;
  677. diameterMax.Add(maxD * d);
  678. dataGridView1.Rows[newPo].Cells[2].Value = Math.Round(dd, 2).ToString();
  679. dataGridView1.Rows[newPo].Cells[3].Value = dataList[i][5];
  680. dataGridView1.Rows[newPo].Cells[4].Value = Math.Round(maxD * d, 2).ToString();
  681. dataGridView1.Rows[newPo].Cells[5].Value = Math.Round(minD * d, 2).ToString();
  682. dataGridView1.Rows[newPo].Cells[6].Value = Math.Round(dataList[i][9] * d, 2).ToString();
  683. dataGridView1.Rows[newPo].Cells[7].Value = Math.Round(dataList[i][4] * d * d, 2).ToString();
  684. }
  685. diameterMax.Sort();
  686. MinM = diameterMax[0];
  687. MaxM = diameterMax[diameterMax.Count - 1];
  688. foreach (var item in diameterMax)
  689. {
  690. MeanM += Math.Round(item, 1);
  691. }
  692. MeanM = MeanM / diameterMax.Count;
  693. DataTable dt = new DataTable();
  694. dt = CreatTable(diameter, diameterPI);
  695. CreatChart(dt);
  696. diameter.Sort();
  697. double total = 0;
  698. foreach (var item in diameter)
  699. {
  700. total += item;
  701. }
  702. total = total / diameter.Count;
  703. int newRow = dataGridView2.Rows.Add();
  704. dataGridView2.Rows[newRow].Cells[0].Value = (1).ToString();
  705. dataGridView2.Rows[newRow].Cells[1].Value = "平均值";
  706. dataGridView2.Rows[newRow].Cells[2].Value = Math.Round(total, 2).ToString();
  707. int newRow1 = dataGridView2.Rows.Add();
  708. dataGridView2.Rows[newRow1].Cells[0].Value = (2).ToString();
  709. dataGridView2.Rows[newRow1].Cells[1].Value = "最大值";
  710. dataGridView2.Rows[newRow1].Cells[2].Value = Math.Round(diameter[diameter.Count - 1], 2).ToString();
  711. int newRow2 = dataGridView2.Rows.Add();
  712. dataGridView2.Rows[newRow2].Cells[0].Value = (3).ToString();
  713. dataGridView2.Rows[newRow2].Cells[1].Value = "最小值";
  714. dataGridView2.Rows[newRow2].Cells[2].Value = Math.Round(diameter[0], 2).ToString();
  715. int count = diameter.Count;
  716. int d10 = Convert.ToInt32(count * 0.1);
  717. int d50 = Convert.ToInt32(count * 0.5);
  718. int d90 = Convert.ToInt32(count * 0.9);
  719. int newRow3 = dataGridView2.Rows.Add();
  720. dataGridView2.Rows[newRow3].Cells[0].Value = (4).ToString();
  721. dataGridView2.Rows[newRow3].Cells[1].Value = "D10";
  722. dataGridView2.Rows[newRow3].Cells[2].Value = Math.Round(diameter[d10], 2).ToString();
  723. int newRow4 = dataGridView2.Rows.Add();
  724. dataGridView2.Rows[newRow4].Cells[0].Value = (5).ToString();
  725. dataGridView2.Rows[newRow4].Cells[1].Value = "D50";
  726. dataGridView2.Rows[newRow4].Cells[2].Value = Math.Round(diameter[d50], 2).ToString();
  727. int newRow5 = dataGridView2.Rows.Add();
  728. dataGridView2.Rows[newRow5].Cells[0].Value = (5).ToString();
  729. dataGridView2.Rows[newRow5].Cells[1].Value = "D90";
  730. dataGridView2.Rows[newRow5].Cells[2].Value = Math.Round(diameter[d90], 2).ToString();
  731. }
  732. /// <summary>
  733. /// 准备用来处理单个颗粒的选中事件
  734. /// </summary>
  735. /// <param name="sender"></param>
  736. /// <param name="e"></param>
  737. private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
  738. {
  739. //当点击表头部的列时,e.RowIndex==-1
  740. if (e.RowIndex > -1)
  741. {
  742. string selectrow = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
  743. int x = Convert.ToInt32(selectrow);
  744. binaryClass.DrwCrystalSelected(x);
  745. this.documentWorkspace.Refresh();
  746. }
  747. }
  748. //外接矩形
  749. double MaxP = 0;
  750. double Minp = 0;
  751. double MeanP = 0;
  752. //拟圆直径
  753. double MaxP2 = 0;
  754. double Minp2 = 0;
  755. double MeanP2 = 0;
  756. private DataTable CreatTable(List<double> diameter, List<double> diameterPI)
  757. {
  758. diameter.Sort();
  759. double max = diameter[diameter.Count - 1];
  760. double total = max * 2;
  761. double min = 0;
  762. Minp = diameter[0];
  763. MaxP = diameter[diameter.Count - 1];
  764. diameterPI.Sort();
  765. Minp2 = diameterPI[0];
  766. MaxP2 = diameterPI[diameterPI.Count - 1];
  767. foreach (var item in diameter)
  768. {
  769. MeanP += Math.Round(item, 2);
  770. }
  771. foreach (var item in diameterPI)
  772. {
  773. MeanP2 += Math.Round(item, 2);
  774. }
  775. MeanP = MeanP / diameter.Count;
  776. MeanP2 = MeanP2 / diameterPI.Count;
  777. //int eval =Convert.ToInt32( (max - min) / 20);
  778. double eval =Math.Round( max / 15,1);
  779. List<double[]> vs = new List<double[]>();
  780. double rightmax = 0;
  781. for (int i = 0; eval * i < max; i++)
  782. {
  783. vs.Add(new double[] { eval * i, eval * (i + 1) });
  784. rightmax = eval * (i + 1);
  785. }
  786. DataTable dt = new DataTable();
  787. dt.Columns.Add("diameter");
  788. dt.Columns.Add("sum");
  789. dt.Columns.Add("sum1");
  790. for (int i = 0; i < vs.Count; i++)
  791. {
  792. DataRow dr;
  793. dr = dt.NewRow();
  794. double low = eval * i;
  795. double hight = eval * (i + 1);
  796. dr["diameter"] = string.Format("{0}", hight);
  797. var emp = diameter.FindAll(e => e > low && e <= hight);
  798. dr["sum"] = emp.Count;
  799. var emp1 = diameterPI.FindAll(e => e > low && e <= hight);
  800. dr["sum1"] = emp1.Count;
  801. dt.Rows.Add(dr);
  802. }
  803. return dt;
  804. }
  805. private void CreatChart(DataTable dt)
  806. {
  807. if (dt == null || dt.Rows.Count == 0)
  808. {
  809. return;
  810. }
  811. chart1.Series.Clear();
  812. chart1.ChartAreas.Clear();
  813. chart1.Legends.Clear();
  814. //定义一个chart
  815. System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
  816. //定义一个绘图区域
  817. System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
  818. System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
  819. //定义一个绘图区域
  820. System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
  821. chartArea1.Name = "ChartArea1";
  822. chart1.Series.Add(series1);
  823. //chart1.Series.Add(series2);
  824. chart1.ChartAreas.Add(chartArea1);
  825. chart1.Legends.Add(legend1);
  826. series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
  827. chart1.Series[0].LegendText = "";
  828. chart1.Series[0].Label = "#VALY";
  829. chart1.Series[0].LabelBackColor = Color.Transparent;
  830. chart1.Series[0].ToolTip = "#VALY";
  831. chart1.Series[0]["PointWidth"] = "0.5";
  832. chart1.Series[0].XValueMember = "diameter";
  833. chart1.Series[0].YValueMembers = "sum";
  834. chart1.Series[0].LegendText = "卡规直径";
  835. //chart1.Series[1].LegendText = "";
  836. //chart1.Series[1].Label = "#VALY";
  837. //chart1.Series[1].LabelBackColor = Color.Transparent;
  838. //chart1.Series[1].ToolTip = "#VALY";
  839. //chart1.Series[1]["PointWidth"] = "0.5";
  840. //chart1.Series[1].XValueMember = "diameter";
  841. //chart1.Series[1].YValueMembers = "sum1";
  842. //chart1.Series[1].LegendText = "拟圆直径";
  843. chart1.ChartAreas[0].AxisX.Interval = 1;
  844. chart1.ChartAreas[0].AxisX.Title = "尺寸(μm)";
  845. chart1.ChartAreas[0].Axes[0].MajorGrid.Enabled = false; //X轴上网格
  846. chart1.ChartAreas[0].Axes[1].MajorGrid.Enabled = false; //y轴上网格
  847. series1.Color = Color.DarkSeaGreen;
  848. series2.Color = Color.PaleTurquoise;
  849. chart1.DataSource = dt;
  850. chart1.DataBind();
  851. }
  852. #region 手动干预
  853. /// <summary>
  854. /// 修改轮廓
  855. /// </summary>
  856. /// <param name="sender"></param>
  857. /// <param name="e"></param>
  858. private void btnLunkuo_Click(object sender, EventArgs e)
  859. {
  860. isLunKuo = true;
  861. isAddKong = false;
  862. isDelKong = false;
  863. operationK = -1;
  864. }
  865. /// <summary>
  866. /// 添加孔隙
  867. /// </summary>
  868. /// <param name="sender"></param>
  869. /// <param name="e"></param>
  870. private void btnAddKong_Click(object sender, EventArgs e)
  871. {
  872. isLunKuo = false;
  873. isAddKong = true;
  874. isDelKong = false;
  875. operationK = -1;
  876. }
  877. /// <summary>
  878. /// 删除孔隙
  879. /// </summary>
  880. /// <param name="sender"></param>
  881. /// <param name="e"></param>
  882. private void btnDelKong_Click(object sender, EventArgs e)
  883. {
  884. isLunKuo = false;
  885. isAddKong = false;
  886. isDelKong = true;
  887. operationK = -1;
  888. }
  889. /// <summary>
  890. /// 重新统计
  891. /// </summary>
  892. /// <param name="sender"></param>
  893. /// <param name="e"></param>
  894. private void btnReDrw_Click(object sender, EventArgs e)
  895. {
  896. double minpoint = Convert.ToDouble(numericUpDown11.Value);
  897. if (!ckMin.Checked)
  898. minpoint = 0.01;
  899. binaryClass.pointsize = minpoint;
  900. int border = Convert.ToInt32(numericMax.Value);
  901. if (!ckMax.Checked)
  902. border = 0;
  903. binaryClass.border = border;
  904. double HW = Convert.ToDouble(numericHW.Value);
  905. if (!ckHW.Checked)
  906. HW = 100;
  907. binaryClass.HW = HW;
  908. double AreaRatio = Convert.ToDouble(numericArea.Value);
  909. if (!ckArea.Checked)
  910. AreaRatio = 0.01;
  911. binaryClass.AreaRatio = AreaRatio;
  912. if (lineList.Count > 0)
  913. {
  914. List<OpenCvSharp.Point> contour = new List<OpenCvSharp.Point>();
  915. for (int i = 0; i < lineList.Count; i++)
  916. {
  917. if (lineList[i].Count > 0)
  918. {
  919. for (int j = 0; j < lineList[i].Count; j++)
  920. {
  921. contour.Add(new OpenCvSharp.Point(lineList[i][j].X, lineList[i][j].Y));
  922. }
  923. }
  924. }
  925. if (contour.Count > 0)
  926. binaryClass.Contour = contour;
  927. }
  928. else
  929. {
  930. binaryClass.Contour = null;
  931. }
  932. List<List<int>> CircleDate = binaryClass.ForgetPrimary(minpoint);
  933. bindGrid(CircleDate);
  934. }
  935. /// <summary>
  936. /// 计算外接矩形
  937. /// </summary>
  938. private RectangleF CalcOtherRectangle(PointF p1, PointF p2)
  939. {
  940. RectangleF rectangleF = new RectangleF();
  941. if (p1.X > p2.X)
  942. rectangleF.X = p2.X;
  943. else
  944. rectangleF.X = p1.X;
  945. if (p1.Y > p2.Y)
  946. rectangleF.Y = p2.Y;
  947. else
  948. rectangleF.Y = p1.Y;
  949. rectangleF.Width = Math.Abs(p2.X - p1.X);
  950. rectangleF.Height = Math.Abs(p2.Y - p1.Y);
  951. int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  952. int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  953. return new RectangleF(rectangleF.X - tempLess, rectangleF.Y - tempLess, rectangleF.Width + tempPlus, rectangleF.Height + tempPlus);
  954. }
  955. /// <summary>
  956. /// 移动
  957. /// </summary>
  958. /// <param name="sender"></param>
  959. /// <param name="e"></param>
  960. private void onMouseMove(object sender, MouseEventArgs e)
  961. {
  962. //if (e.Button == MouseButtons.Left)
  963. //{
  964. if (isLunKuo)
  965. {
  966. int cou = pointList.Count;
  967. if (cou > 0)
  968. { // 换算后的点
  969. PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);
  970. pointList[cou - 1] = movePoint;
  971. }
  972. }
  973. if (isAddKong && e.Button == MouseButtons.Left)
  974. {
  975. if (kongLineList.Count > 0)
  976. { // 换算后的点
  977. PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);
  978. //kongPointList[kongPointList.Count - 1] = movePoint;
  979. kongLineList[kongLineList.Count - 1].Add(movePoint);
  980. }
  981. }
  982. if (isDelKong)
  983. {
  984. //if (delPointList.Count > 0)
  985. //{ // 换算后的点
  986. // PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);
  987. // delPointList[delPointList.Count - 1] = movePoint;
  988. //}
  989. }
  990. if (operationK >= 0 && e.Button == MouseButtons.Left)
  991. {
  992. PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);
  993. if (operationK == 0)
  994. {
  995. this.endPoint = movePoint;
  996. pointList1[lineCount][1] = endPoint;
  997. }
  998. else if (operationK == 1 && selected > -1 && canMove)
  999. {
  1000. float dx = movePoint.X - lastPoint.X;
  1001. float dy = movePoint.Y - lastPoint.Y;
  1002. float dxTemp = movePoint.X - tempPoint.X;
  1003. float dyTemp = movePoint.Y - tempPoint.Y;
  1004. lastPoint.X = movePoint.X;
  1005. lastPoint.Y = movePoint.Y;
  1006. if (movePointIndex == -1)
  1007. {
  1008. RectangleF rectangleF = new RectangleF();
  1009. rectangleF = rectangleFList[selected];
  1010. if (rectangleF.Contains(movePoint))
  1011. this.documentWorkspace.panel.Cursor = Cursors.SizeAll;
  1012. rectangleF.X += dx;
  1013. rectangleF.Y += dy;
  1014. rectangleFList[selected] = rectangleF;
  1015. for (int i = 0; i < pointList1[selected].Count(); i++)
  1016. {
  1017. if (pointList1[selected][i] == PointF.Empty)
  1018. continue;
  1019. pointList1[selected][i].X += dx;
  1020. pointList1[selected][i].Y += dy;
  1021. }
  1022. }
  1023. else if (movePointIndex == 0)
  1024. {
  1025. pointList1[selected][0].X += dx;
  1026. pointList1[selected][0].Y += dy;
  1027. rectangleFList[selected] = CalcOtherRectangle(pointList1[selected][0], pointList1[selected][1]);
  1028. }
  1029. else if (movePointIndex == 1)
  1030. {
  1031. pointList1[selected][1].X += dx;
  1032. pointList1[selected][1].Y += dy;
  1033. rectangleFList[selected] = CalcOtherRectangle(pointList1[selected][0], pointList1[selected][1]);
  1034. }
  1035. }
  1036. this.documentWorkspace.Refresh();
  1037. }
  1038. this.documentWorkspace.Refresh();
  1039. // }
  1040. }
  1041. /// <summary>
  1042. /// 鼠标抬起
  1043. /// </summary>
  1044. /// <param name="sender"></param>
  1045. /// <param name="e"></param>
  1046. private void OnMouseUp(object sender, MouseEventArgs e)
  1047. {
  1048. if (e.Button == MouseButtons.Left)
  1049. {
  1050. if (operationK == 0)
  1051. {
  1052. if (startPoint != null && endPoint != null && startPoint != endPoint)
  1053. {
  1054. RectangleF rectangleF = CalcOtherRectangle(pointList1[lineCount][0], pointList1[lineCount][1]);
  1055. rectangleFList.Add(rectangleF);
  1056. lineCount++;
  1057. // AddContentToDataGridView();
  1058. }
  1059. else
  1060. {
  1061. if (pointList.Count > 0)
  1062. pointList.RemoveAt(pointList.Count - 1);
  1063. }
  1064. this.documentWorkspace.Refresh();
  1065. }
  1066. else if (operationK == 1)
  1067. {
  1068. canMove = false;
  1069. movePointIndex = -1;
  1070. // RefreshDataGridView1();
  1071. }
  1072. else if (isAddKong)
  1073. {
  1074. if (kongLineList[kongLineList.Count - 1].Count > 3)
  1075. {
  1076. isAddKong = false;
  1077. List<List<int>> CircleDate = binaryClass.DeletePrimary(delPointList, kongLineList);
  1078. bindGrid(CircleDate);
  1079. }
  1080. else
  1081. {
  1082. kongLineList.RemoveAt(kongLineList.Count - 1);
  1083. }
  1084. }
  1085. }
  1086. if (operationK >= 0 && e.Button == MouseButtons.Left)
  1087. {
  1088. PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location);
  1089. if (operationK == 0)
  1090. {
  1091. startPoint = endPoint = downPoint;
  1092. pointList1[lineCount - 1][1] = endPoint;
  1093. }
  1094. else if (operationK == 1)
  1095. {
  1096. lastPoint.X = downPoint.X;
  1097. lastPoint.Y = downPoint.Y;
  1098. tempPoint.X = downPoint.X;
  1099. tempPoint.Y = downPoint.Y;
  1100. for (int i = rectangleFList.Count - 1; i >= 0; i--)
  1101. {
  1102. if (rectangleFList[i].Contains(downPoint))
  1103. {
  1104. selected = i;
  1105. canMove = true;
  1106. }
  1107. }
  1108. if (selected > -1 && pointList1 != null && pointList1.Count > 0)
  1109. {
  1110. int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  1111. int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  1112. if (new RectangleF(pointList1[selected][0].X - tempLess, pointList1[selected][0].Y - tempLess, tempPlus, tempPlus).Contains(downPoint))
  1113. movePointIndex = 0;
  1114. else if (new RectangleF(pointList1[selected][1].X - tempLess, pointList1[selected][1].Y - tempLess, tempPlus, tempPlus).Contains(downPoint))
  1115. movePointIndex = 1;
  1116. else
  1117. movePointIndex = -1;
  1118. this.documentWorkspace.Refresh();
  1119. }
  1120. if (canMove)
  1121. return;
  1122. selected = -1;
  1123. }
  1124. }
  1125. }
  1126. /// <summary>
  1127. /// 鼠标按下
  1128. /// </summary>
  1129. /// <param name="drawArea"></param>
  1130. /// <param name="e"></param>
  1131. private void OnMouseDown(object sender, MouseEventArgs e)
  1132. {
  1133. PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location);
  1134. if (operationK >= 0 && e.Button == MouseButtons.Left)
  1135. {
  1136. if (operationK == 0)
  1137. {
  1138. startPoint = endPoint = downPoint;
  1139. nowLine = new PointF[4];
  1140. nowLine[0] = startPoint;
  1141. nowLine[1] = endPoint;
  1142. pointList1.Add(nowLine);
  1143. }
  1144. else if (operationK == 1)
  1145. {
  1146. lastPoint.X = downPoint.X;
  1147. lastPoint.Y = downPoint.Y;
  1148. tempPoint.X = downPoint.X;
  1149. tempPoint.Y = downPoint.Y;
  1150. for (int i = rectangleFList.Count - 1; i >= 0; i--)
  1151. {
  1152. if (rectangleFList[i].Contains(downPoint))
  1153. {
  1154. selected = i;
  1155. canMove = true;
  1156. }
  1157. }
  1158. if (selected > -1 && pointList1 != null && pointList1.Count > 0)
  1159. {
  1160. int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  1161. int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  1162. if (new RectangleF(pointList1[selected][0].X - tempLess, pointList1[selected][0].Y - tempLess, tempPlus, tempPlus).Contains(downPoint))
  1163. movePointIndex = 0;
  1164. else if (new RectangleF(pointList1[selected][1].X - tempLess, pointList1[selected][1].Y - tempLess, tempPlus, tempPlus).Contains(downPoint))
  1165. movePointIndex = 1;
  1166. else
  1167. movePointIndex = -1;
  1168. this.documentWorkspace.Refresh();
  1169. }
  1170. if (canMove)
  1171. return;
  1172. selected = -1;
  1173. }
  1174. }
  1175. else if (e.Button == MouseButtons.Left)
  1176. {
  1177. if (isLunKuo)
  1178. {
  1179. if (pointList.Count == 0)
  1180. {
  1181. pointList.Add(downPoint);
  1182. pointList.Add(downPoint);
  1183. }
  1184. else
  1185. {
  1186. pointList.Add(downPoint);
  1187. }
  1188. }
  1189. if (isAddKong)
  1190. {
  1191. List<PointF> pl = new List<PointF>();
  1192. pl.Add(downPoint);
  1193. kongLineList.Add(pl);
  1194. //if (kongPointList.Count == 0)
  1195. //{
  1196. // kongPointList.Add(downPoint);
  1197. // kongPointList.Add(downPoint);
  1198. //}
  1199. //else
  1200. //{
  1201. // kongPointList.Add(downPoint);
  1202. //}
  1203. }
  1204. if (isDelKong)
  1205. {
  1206. delPointList.Add(downPoint);
  1207. List<List<int>> CircleDate = binaryClass.DeletePrimary(delPointList, kongLineList);
  1208. bindGrid(CircleDate);
  1209. }
  1210. }
  1211. if (e.Button == MouseButtons.Right)
  1212. {
  1213. if (isLunKuo)
  1214. {
  1215. if (pointList.Count > 2)
  1216. {
  1217. pointList.RemoveAt(pointList.Count - 1);
  1218. List<PointF> pointFs = new List<PointF>(pointList.ToArray());
  1219. lineList.Add(pointFs);
  1220. }
  1221. pointList.Clear();
  1222. }
  1223. if (isAddKong)
  1224. {
  1225. if (kongPointList.Count > 2)
  1226. {
  1227. kongPointList.RemoveAt(kongPointList.Count - 1);
  1228. List<PointF> pointFs = new List<PointF>(kongPointList.ToArray());
  1229. kongLineList.Add(pointFs);
  1230. List<List<int>> CircleDate = binaryClass.DeletePrimary(delPointList, kongLineList);
  1231. bindGrid(CircleDate);
  1232. }
  1233. kongPointList.Clear();
  1234. }
  1235. if (isDelKong)
  1236. {
  1237. //if (delPointList.Count > 2)
  1238. //{
  1239. // delPointList.RemoveAt(delPointList.Count - 1);
  1240. // List<PointF> pointFs = new List<PointF>(delPointList.ToArray());
  1241. // delLineList.Add(pointFs);
  1242. //}
  1243. //delPointList.Clear();
  1244. }
  1245. isLunKuo = false;
  1246. isAddKong = false;
  1247. isDelKong = false;
  1248. }
  1249. }
  1250. /// <summary>
  1251. /// Ctrl+z
  1252. /// </summary>
  1253. private void OnKeyDown(object sender, KeyEventArgs e)
  1254. {
  1255. if (e.Control && e.KeyCode == Keys.Z)
  1256. {
  1257. if (isLunKuo)
  1258. {
  1259. int cou = pointList.Count;
  1260. if (cou > 1)
  1261. {
  1262. if (cou == 2)
  1263. {
  1264. pointList.Clear();
  1265. }
  1266. else
  1267. {
  1268. pointList.RemoveAt(cou - 1);
  1269. }
  1270. }
  1271. else if (lineList.Count > 0)
  1272. {
  1273. pointList = lineList[lineList.Count - 1];
  1274. lineList.RemoveAt(lineList.Count - 1);
  1275. pointList.RemoveAt(pointList.Count - 1);
  1276. }
  1277. }
  1278. if (isAddKong)
  1279. {
  1280. if (kongLineList.Count > 0)
  1281. {
  1282. kongLineList.RemoveAt(kongLineList.Count - 1);
  1283. List<List<int>> CircleDate = binaryClass.DeletePrimary(delPointList, kongLineList);
  1284. bindGrid(CircleDate);
  1285. }
  1286. }
  1287. if (isDelKong)
  1288. {
  1289. int cou = delPointList.Count;
  1290. if (cou > 0)
  1291. {
  1292. delPointList.RemoveAt(cou - 1);
  1293. List<List<int>> CircleDate = binaryClass.DeletePrimary(delPointList, kongLineList);
  1294. bindGrid(CircleDate);
  1295. }
  1296. }
  1297. this.documentWorkspace.Refresh();
  1298. }
  1299. }
  1300. #endregion
  1301. /// <summary>
  1302. /// 导出孔隙信息
  1303. /// </summary>
  1304. /// <param name="sender"></param>
  1305. /// <param name="e"></param>
  1306. private void button14_Click(object sender, EventArgs e)
  1307. {
  1308. SaveFileDialog exe = new SaveFileDialog();
  1309. exe.Filter = "Image Files (*.jpg)|*.jpg";
  1310. exe.FilterIndex = 0;
  1311. exe.RestoreDirectory = true;
  1312. //exe.CreatePrompt = true;
  1313. exe.Title = "Image Files";
  1314. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1315. exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "单晶";
  1316. DialogResult dr = exe.ShowDialog();
  1317. if (dr != DialogResult.OK)
  1318. {
  1319. return;
  1320. }
  1321. string GR_Path = exe.FileName + ".jpg";
  1322. chart1.SaveImage(GR_Path, System.Windows.Forms.DataVisualization.Charting.ChartImageFormat.Jpeg);
  1323. }
  1324. /// <summary>
  1325. /// 不可点击空白区域
  1326. /// </summary>
  1327. /// <param name="sender"></param>
  1328. /// <param name="e"></param>
  1329. private void listView1_MouseUp(object sender, MouseEventArgs e)
  1330. {
  1331. if (e.Button == MouseButtons.Left)
  1332. {
  1333. if (listView1.SelectedItems.Count > 0)
  1334. {
  1335. }
  1336. else if (listView1.SelectedItems.Count <= 0)//点击空白区
  1337. {
  1338. if (this.listView1.FocusedItem != null)
  1339. {
  1340. ListViewItem item = this.listView1.GetItemAt(e.X, e.Y);
  1341. if (item == null)
  1342. {
  1343. this.listView1.FocusedItem.Selected = true;
  1344. }
  1345. }
  1346. }
  1347. }
  1348. }
  1349. /// <summary>
  1350. /// 生成孔隙率
  1351. /// </summary>
  1352. /// <param name="sender"></param>
  1353. /// <param name="e"></param>
  1354. private void button13_Click(object sender, EventArgs e)
  1355. {
  1356. string name = this.listView1.FocusedItem.Name.Split('.')[0] + "-";
  1357. SaveFileDialog exe = new SaveFileDialog();
  1358. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1359. exe.FilterIndex = 0;
  1360. exe.RestoreDirectory = true;
  1361. //exe.CreatePrompt = true;
  1362. exe.Title = "Export Excel File";
  1363. // exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1364. exe.FileName = name;
  1365. String str = System.Configuration.ConfigurationManager.AppSettings["FolderSelectedPath"];
  1366. DialogResult dr = exe.ShowDialog();
  1367. if (dr != DialogResult.OK)
  1368. {
  1369. return;
  1370. }
  1371. DataTable dtb = new DataTable();
  1372. dtb.Columns.Add("序号");
  1373. dtb.Columns.Add("位置");
  1374. dtb.Columns.Add("卡规直径/微米");
  1375. dtb.Columns.Add("长径/微米");
  1376. dtb.Columns.Add("短径/微米");
  1377. dtb.Columns.Add("周长/微米");
  1378. dtb.Columns.Add("面积/平方微米");
  1379. for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
  1380. {
  1381. DataRow dataRow = dtb.NewRow();
  1382. dataRow[0] = dataGridView1.Rows[r].Cells[0].Value.ToString();
  1383. dataRow[1] = dataGridView1.Rows[r].Cells[1].Value.ToString();
  1384. dataRow[2] = dataGridView1.Rows[r].Cells[2].Value.ToString();
  1385. dataRow[3] = dataGridView1.Rows[r].Cells[4].Value.ToString();
  1386. dataRow[4] = dataGridView1.Rows[r].Cells[5].Value.ToString();
  1387. dataRow[5] = dataGridView1.Rows[r].Cells[6].Value.ToString();
  1388. dataRow[6] = dataGridView1.Rows[r].Cells[7].Value.ToString();
  1389. dtb.Rows.Add(dataRow);
  1390. }
  1391. DataTable dtb1 = new DataTable();
  1392. dtb1.Columns.Add("序号");
  1393. dtb1.Columns.Add("名称");
  1394. dtb1.Columns.Add("值/微米");
  1395. for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
  1396. {
  1397. DataRow dataRow = dtb1.NewRow();
  1398. dataRow[0] = dataGridView2.Rows[r].Cells[0].Value.ToString();
  1399. dataRow[1] = dataGridView2.Rows[r].Cells[1].Value.ToString();
  1400. dataRow[2] = dataGridView2.Rows[r].Cells[2].Value.ToString();
  1401. dtb1.Rows.Add(dataRow);
  1402. }
  1403. //DataRow dataRow2 = dtb1.NewRow();
  1404. //dataRow2[0] = "1";
  1405. //dataRow2[1] = "卡规直径";
  1406. //dataRow2[2] = Math.Round(MaxP, 2).ToString();
  1407. //dataRow2[3] = Math.Round(Minp, 2).ToString();
  1408. //dataRow2[4] = Math.Round(MeanP, 2).ToString();
  1409. //dtb1.Rows.Add(dataRow2);
  1410. //DataRow dataRow3 = dtb1.NewRow();
  1411. //dataRow3[0] = "2";
  1412. //dataRow3[1] = "长径";
  1413. //dataRow3[2] = Math.Round(MaxP2, 2).ToString();
  1414. //dataRow3[3] = Math.Round(Minp2, 2).ToString();
  1415. //dataRow3[4] = Math.Round(MeanP2, 2).ToString();
  1416. ////dtb1.Rows.Add(dataRow3);
  1417. //DataRow dataRow4 = dtb1.NewRow();
  1418. //dataRow4[0] = "3";
  1419. //dataRow4[1] = "短径";
  1420. //dataRow4[2] = Math.Round(MaxM, 2).ToString();
  1421. //dataRow4[3] = Math.Round(MinM, 2).ToString();
  1422. //dataRow4[4] = Math.Round(MeanM, 2).ToString();
  1423. //dtb1.Rows.Add(dataRow4);
  1424. int index = exe.FileName.LastIndexOf('\\');
  1425. string GR_Path = exe.FileName.Remove(index) + "\\" + name + ".jpg";
  1426. chart1.SaveImage(GR_Path, System.Windows.Forms.DataVisualization.Charting.ChartImageFormat.Jpeg);
  1427. //保存处理后的图片
  1428. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1429. List<Bitmap> tempBit = new List<Bitmap>();
  1430. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1431. originalBit.Tag = pantographRatio;
  1432. tempBit.Add(originalBit);
  1433. Bitmap processedBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  1434. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1435. Graphics graphics = Graphics.FromImage(newBit);
  1436. graphics.DrawImage(processedBit, new PointF(0, 0));
  1437. Draw(graphics);
  1438. newBit.Tag = pantographRatio;
  1439. tempBit.Add(newBit);
  1440. string GR_Path1 = exe.FileName.Remove(index) + "\\" + name + "1.jpg";
  1441. newBit.Save(GR_Path1);
  1442. List<DataTable> list = new List<DataTable>();
  1443. list.Add(dtb1);
  1444. list.Add(dtb);
  1445. List<string> pics = new List<string>() { GR_Path+",400,200,"+ chart1.Width+","+ chart1.Height, GR_Path1 + ",400,420," + newBit.Width + "," + newBit.Height };
  1446. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true, null,null,pics);
  1447. }
  1448. #region 辅助测量
  1449. /// <summary>
  1450. /// 添加测量线
  1451. /// </summary>
  1452. /// <param name="sender"></param>
  1453. /// <param name="e"></param>
  1454. private void btnAddCeliang_Click(object sender, EventArgs e)
  1455. {
  1456. operationK = 0;
  1457. selected = -1;
  1458. this.documentWorkspace.Refresh();
  1459. }
  1460. /// <summary>
  1461. /// 选择测量线
  1462. /// </summary>
  1463. /// <param name="sender"></param>
  1464. /// <param name="e"></param>
  1465. private void btnSelCeliang_Click(object sender, EventArgs e)
  1466. {
  1467. operationK = 1;
  1468. }
  1469. /// <summary>
  1470. /// 删除测量线
  1471. /// </summary>
  1472. /// <param name="sender"></param>
  1473. /// <param name="e"></param>
  1474. private void btnDelCeliang_Click(object sender, EventArgs e)
  1475. {
  1476. if (selected > -1)
  1477. {
  1478. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodmeasurementline.text") + "?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1479. if (dr == DialogResult.OK)
  1480. {
  1481. this.pointList1.Remove(this.pointList1[selected]);
  1482. this.rectangleFList.Remove(this.rectangleFList[selected]);
  1483. selected = -1;
  1484. lineCount--;
  1485. this.documentWorkspace.Refresh();
  1486. }
  1487. }
  1488. else
  1489. MessageBox.Show("请先选择测量线");
  1490. }
  1491. /// <summary>
  1492. /// 添加测量线按钮失去焦点
  1493. /// </summary>
  1494. /// <param name="sender"></param>
  1495. /// <param name="e"></param>
  1496. private void btnAddCeliang_LostFocus(object sender, EventArgs e)
  1497. {
  1498. operationK = -1;
  1499. selected = -1;
  1500. this.documentWorkspace.Refresh();
  1501. }
  1502. #endregion
  1503. #region 内部类
  1504. internal class LocalListViewItem
  1505. {
  1506. public DocumentWorkspace Value { get; }
  1507. public string Display { get; }
  1508. public LocalListViewItem(DocumentWorkspace Value, string Display)
  1509. {
  1510. this.Value = Value;
  1511. this.Display = Display;
  1512. }
  1513. }
  1514. internal class DocumentItem
  1515. {
  1516. public Bitmap bitmap;
  1517. public GraphicsList graphicsList;
  1518. public List<PhaseModel> phaseModels;
  1519. //public AnalysisResult analysisResult;
  1520. public DocumentItem(Bitmap bitmap, GraphicsList graphicsList, List<PhaseModel> phaseModels)
  1521. {
  1522. this.bitmap = bitmap;
  1523. this.graphicsList = graphicsList;
  1524. this.phaseModels = phaseModels;
  1525. }
  1526. }
  1527. #endregion
  1528. #endregion
  1529. }
  1530. }