MethodKInclusionEditDialog.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978
  1. using OpenCvSharp;
  2. using PaintDotNet;
  3. using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.InclusionsGlobalSettings;
  14. namespace Metis.DedicatedAnalysis.Inclusions.New_DIN50602_1985
  15. {
  16. internal partial class MethodKInclusionEditDialog : Form
  17. {
  18. private System.ComponentModel.IContainer components = null;
  19. private ImageList imageList1;
  20. private AppWorkspace appWorkspace;
  21. private List<Inclusion> inclusionList;
  22. private Mat OriginalImage;
  23. private List<InclusionEditModel> inclusionEditModelList = new List<InclusionEditModel>();
  24. private GroupBox groupBox1;
  25. private TextBox textBox1;
  26. private Label label3;
  27. private Label label2;
  28. private Label label1;
  29. private Label label4;
  30. private Label label5;
  31. private ComboBox comboBox1;
  32. private Button button1;
  33. private Button button4;
  34. private Button button3;
  35. private Button button2;
  36. private GroupBox groupBox2;
  37. private GroupBox groupBox6groupBox_analysisResult2;
  38. private ListView listView_analysisResult;
  39. private GroupBox groupBox3;
  40. private Button button5;
  41. private GroupBox groupBox4;
  42. private Button button8;
  43. private Button button7;
  44. private Button button6;
  45. private RadioButton radioButton1;
  46. private RadioButton radioButton2;
  47. private Label label6;
  48. private TextBox textBox2;
  49. private PictureBox pictureBox1;
  50. private ListView listView1;
  51. private System.Windows.Forms.ContextMenuStrip contextRootEdit;
  52. private System.Windows.Forms.ToolStripMenuItem rootEdit;
  53. private System.Windows.Forms.ToolStripMenuItem rootDelete;
  54. private System.Windows.Forms.ToolStripMenuItem rootSS;
  55. private System.Windows.Forms.ToolStripMenuItem rootOS;
  56. private System.Windows.Forms.ToolStripMenuItem rootOA;
  57. private System.Windows.Forms.ToolStripMenuItem rootOG;
  58. private MethodKDialog methodKDialog;
  59. public MethodKInclusionEditDialog(AppWorkspace appWorkspace,List<Inclusion> inclusionList,Mat OriginalImage, MethodKDialog methodKDialog)
  60. {
  61. this.appWorkspace = appWorkspace;
  62. this.inclusionList = inclusionList;
  63. this.OriginalImage = OriginalImage;
  64. this.methodKDialog = methodKDialog;
  65. this.SpiltPicture();
  66. InitializeComponent();
  67. InitListView1Data();
  68. InitList();
  69. }
  70. /// <summary>
  71. /// 初始化列表
  72. /// </summary>
  73. private void InitList()
  74. {
  75. // 初始化报告列表
  76. this.listView_analysisResult.View = View.Details;
  77. this.listView_analysisResult.BeginUpdate();
  78. List<string> headerList = new List<string>() { "长度","宽度","面积","类型","级别"};
  79. // 构建头
  80. foreach (var item in headerList)
  81. {
  82. ColumnHeader header = new ColumnHeader();
  83. header.Text = item;
  84. header.Width = 200;
  85. this.listView_analysisResult.Columns.Add(header);
  86. }
  87. foreach (var item in this.inclusionEditModelList)
  88. {
  89. ListViewItem lvi = new ListViewItem();
  90. lvi.Text = item.data.physicalLength.ToString();
  91. lvi.SubItems.Add(item.data.physicalWidth.ToString());
  92. lvi.SubItems.Add(item.data.areaK.ToString());
  93. lvi.SubItems.Add(item.data.type.type.ToString());
  94. lvi.SubItems.Add(item.data.rating.ToString());
  95. this.listView_analysisResult.Items.Add(lvi);
  96. }
  97. this.listView_analysisResult.EndUpdate();
  98. }
  99. /// <summary>
  100. /// Required method for Designer support - do not modify
  101. /// the contents of this method with the code editor.
  102. /// </summary>
  103. private void InitializeComponent()
  104. {
  105. this.components = new System.ComponentModel.Container();
  106. this.rootEdit = new System.Windows.Forms.ToolStripMenuItem();
  107. this.rootDelete = new System.Windows.Forms.ToolStripMenuItem();
  108. this.rootSS = new System.Windows.Forms.ToolStripMenuItem();
  109. this.rootOS = new System.Windows.Forms.ToolStripMenuItem();
  110. this.rootOA = new System.Windows.Forms.ToolStripMenuItem();
  111. this.rootOG = new System.Windows.Forms.ToolStripMenuItem();
  112. this.groupBox1 = new System.Windows.Forms.GroupBox();
  113. this.button4 = new System.Windows.Forms.Button();
  114. this.button3 = new System.Windows.Forms.Button();
  115. this.button2 = new System.Windows.Forms.Button();
  116. this.button1 = new System.Windows.Forms.Button();
  117. this.comboBox1 = new System.Windows.Forms.ComboBox();
  118. this.label5 = new System.Windows.Forms.Label();
  119. this.label4 = new System.Windows.Forms.Label();
  120. this.label3 = new System.Windows.Forms.Label();
  121. this.label2 = new System.Windows.Forms.Label();
  122. this.label1 = new System.Windows.Forms.Label();
  123. this.textBox1 = new System.Windows.Forms.TextBox();
  124. this.groupBox2 = new System.Windows.Forms.GroupBox();
  125. this.listView1 = new System.Windows.Forms.ListView();
  126. this.contextRootEdit = new System.Windows.Forms.ContextMenuStrip(this.components);
  127. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  128. this.groupBox6groupBox_analysisResult2 = new System.Windows.Forms.GroupBox();
  129. this.listView_analysisResult = new System.Windows.Forms.ListView();
  130. this.groupBox3 = new System.Windows.Forms.GroupBox();
  131. this.textBox2 = new System.Windows.Forms.TextBox();
  132. this.label6 = new System.Windows.Forms.Label();
  133. this.radioButton2 = new System.Windows.Forms.RadioButton();
  134. this.radioButton1 = new System.Windows.Forms.RadioButton();
  135. this.button8 = new System.Windows.Forms.Button();
  136. this.button7 = new System.Windows.Forms.Button();
  137. this.button6 = new System.Windows.Forms.Button();
  138. this.groupBox4 = new System.Windows.Forms.GroupBox();
  139. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  140. this.button5 = new System.Windows.Forms.Button();
  141. this.groupBox1.SuspendLayout();
  142. this.groupBox2.SuspendLayout();
  143. this.contextRootEdit.SuspendLayout();
  144. this.groupBox6groupBox_analysisResult2.SuspendLayout();
  145. this.groupBox3.SuspendLayout();
  146. this.groupBox4.SuspendLayout();
  147. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  148. this.SuspendLayout();
  149. //
  150. // rootEdit
  151. //
  152. this.rootEdit.Name = "rootEdit";
  153. this.rootEdit.Size = new System.Drawing.Size(152, 30);
  154. this.rootEdit.Text = "编辑";
  155. this.rootEdit.Click += new System.EventHandler(this.rootEditClick);
  156. //
  157. // rootDelete
  158. //
  159. this.rootDelete.Name = "rootDelete";
  160. this.rootDelete.Size = new System.Drawing.Size(152, 30);
  161. this.rootDelete.Text = "去除假象";
  162. this.rootDelete.Click += new System.EventHandler(this.rootDeleteClick);
  163. //
  164. // rootSS
  165. //
  166. this.rootSS.Name = "rootSS";
  167. this.rootSS.Size = new System.Drawing.Size(152, 30);
  168. this.rootSS.Text = "SS";
  169. this.rootSS.Click += new System.EventHandler(this.rootTypeClick);
  170. //
  171. // rootOS
  172. //
  173. this.rootOS.Name = "rootOS";
  174. this.rootOS.Size = new System.Drawing.Size(152, 30);
  175. this.rootOS.Text = "OS";
  176. this.rootOS.Click += new System.EventHandler(this.rootTypeClick);
  177. //
  178. // rootOA
  179. //
  180. this.rootOA.Name = "rootOA";
  181. this.rootOA.Size = new System.Drawing.Size(152, 30);
  182. this.rootOA.Text = "OA";
  183. this.rootOA.Click += new System.EventHandler(this.rootTypeClick);
  184. //
  185. // rootOG
  186. //
  187. this.rootOG.Name = "rootOG";
  188. this.rootOG.Size = new System.Drawing.Size(152, 30);
  189. this.rootOG.Text = "OG";
  190. this.rootOG.Click += new System.EventHandler(this.rootTypeClick);
  191. //
  192. // groupBox1
  193. //
  194. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  195. | System.Windows.Forms.AnchorStyles.Right)));
  196. this.groupBox1.Controls.Add(this.button4);
  197. this.groupBox1.Controls.Add(this.button3);
  198. this.groupBox1.Controls.Add(this.button2);
  199. this.groupBox1.Controls.Add(this.button1);
  200. this.groupBox1.Controls.Add(this.comboBox1);
  201. this.groupBox1.Controls.Add(this.label5);
  202. this.groupBox1.Controls.Add(this.label4);
  203. this.groupBox1.Controls.Add(this.label3);
  204. this.groupBox1.Controls.Add(this.label2);
  205. this.groupBox1.Controls.Add(this.label1);
  206. this.groupBox1.Controls.Add(this.textBox1);
  207. this.groupBox1.Location = new System.Drawing.Point(18, 18);
  208. this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  209. this.groupBox1.Name = "groupBox1";
  210. this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
  211. this.groupBox1.Size = new System.Drawing.Size(1438, 80);
  212. this.groupBox1.TabIndex = 13;
  213. this.groupBox1.TabStop = false;
  214. //
  215. // button4
  216. //
  217. this.button4.Location = new System.Drawing.Point(1317, 22);
  218. this.button4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  219. this.button4.Name = "button4";
  220. this.button4.Size = new System.Drawing.Size(112, 34);
  221. this.button4.TabIndex = 10;
  222. this.button4.Text = "保存";
  223. this.button4.UseVisualStyleBackColor = true;
  224. //
  225. // button3
  226. //
  227. this.button3.Location = new System.Drawing.Point(1196, 22);
  228. this.button3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  229. this.button3.Name = "button3";
  230. this.button3.Size = new System.Drawing.Size(112, 34);
  231. this.button3.TabIndex = 9;
  232. this.button3.Text = "确定";
  233. this.button3.UseVisualStyleBackColor = true;
  234. this.button3.Click += new System.EventHandler(this.button3_Click);
  235. //
  236. // button2
  237. //
  238. this.button2.Location = new System.Drawing.Point(1074, 22);
  239. this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  240. this.button2.Name = "button2";
  241. this.button2.Size = new System.Drawing.Size(112, 34);
  242. this.button2.TabIndex = 8;
  243. this.button2.Text = "刷新";
  244. this.button2.UseVisualStyleBackColor = true;
  245. //
  246. // button1
  247. //
  248. this.button1.Location = new System.Drawing.Point(548, 26);
  249. this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  250. this.button1.Name = "button1";
  251. this.button1.Size = new System.Drawing.Size(112, 34);
  252. this.button1.TabIndex = 7;
  253. this.button1.Text = "检索";
  254. this.button1.UseVisualStyleBackColor = true;
  255. this.button1.Click += new System.EventHandler(this.button1_Click);
  256. //
  257. // comboBox1
  258. //
  259. this.comboBox1.FormattingEnabled = true;
  260. this.comboBox1.Items.AddRange(new object[] {
  261. "全部",
  262. "SS",
  263. "OS",
  264. "OA",
  265. "OG"});
  266. this.comboBox1.Location = new System.Drawing.Point(357, 27);
  267. this.comboBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  268. this.comboBox1.Name = "comboBox1";
  269. this.comboBox1.Size = new System.Drawing.Size(180, 26);
  270. this.comboBox1.TabIndex = 6;
  271. //
  272. // label5
  273. //
  274. this.label5.AutoSize = true;
  275. this.label5.Location = new System.Drawing.Point(286, 33);
  276. this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  277. this.label5.Name = "label5";
  278. this.label5.Size = new System.Drawing.Size(62, 18);
  279. this.label5.TabIndex = 5;
  280. this.label5.Text = "类型:";
  281. //
  282. // label4
  283. //
  284. this.label4.AutoSize = true;
  285. this.label4.Location = new System.Drawing.Point(958, 33);
  286. this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  287. this.label4.Name = "label4";
  288. this.label4.Size = new System.Drawing.Size(62, 18);
  289. this.label4.TabIndex = 4;
  290. this.label4.Text = "1.2mm2";
  291. //
  292. // label3
  293. //
  294. this.label3.AutoSize = true;
  295. this.label3.Location = new System.Drawing.Point(866, 33);
  296. this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  297. this.label3.Name = "label3";
  298. this.label3.Size = new System.Drawing.Size(98, 18);
  299. this.label3.TabIndex = 3;
  300. this.label3.Text = "分析面积:";
  301. //
  302. // label2
  303. //
  304. this.label2.AutoSize = true;
  305. this.label2.Location = new System.Drawing.Point(26, 33);
  306. this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  307. this.label2.Name = "label2";
  308. this.label2.Size = new System.Drawing.Size(116, 18);
  309. this.label2.TabIndex = 2;
  310. this.label2.Text = "显示夹杂物前";
  311. //
  312. // label1
  313. //
  314. this.label1.AutoSize = true;
  315. this.label1.Location = new System.Drawing.Point(208, 33);
  316. this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  317. this.label1.Name = "label1";
  318. this.label1.Size = new System.Drawing.Size(26, 18);
  319. this.label1.TabIndex = 1;
  320. this.label1.Text = "条";
  321. //
  322. // textBox1
  323. //
  324. this.textBox1.Location = new System.Drawing.Point(150, 24);
  325. this.textBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  326. this.textBox1.Name = "textBox1";
  327. this.textBox1.Size = new System.Drawing.Size(48, 28);
  328. this.textBox1.TabIndex = 0;
  329. this.textBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyUp);
  330. //
  331. // groupBox2
  332. //
  333. this.groupBox2.Controls.Add(this.listView1);
  334. this.groupBox2.Location = new System.Drawing.Point(18, 106);
  335. this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  336. this.groupBox2.Name = "groupBox2";
  337. this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
  338. this.groupBox2.Size = new System.Drawing.Size(1107, 616);
  339. this.groupBox2.TabIndex = 14;
  340. this.groupBox2.TabStop = false;
  341. //
  342. // listView1
  343. //
  344. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  345. | System.Windows.Forms.AnchorStyles.Left)
  346. | System.Windows.Forms.AnchorStyles.Right)));
  347. this.listView1.ContextMenuStrip = this.contextRootEdit;
  348. this.listView1.HideSelection = false;
  349. this.listView1.LargeImageList = this.imageList1;
  350. this.listView1.Location = new System.Drawing.Point(9, 30);
  351. this.listView1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  352. this.listView1.MultiSelect = false;
  353. this.listView1.Name = "listView1";
  354. this.listView1.Size = new System.Drawing.Size(1087, 576);
  355. this.listView1.TabIndex = 2;
  356. this.listView1.UseCompatibleStateImageBehavior = false;
  357. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  358. this.listView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseClick);
  359. this.listView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseUp);
  360. //
  361. // contextRootEdit
  362. //
  363. this.contextRootEdit.ImageScalingSize = new System.Drawing.Size(20, 20);
  364. this.contextRootEdit.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
  365. this.rootEdit,
  366. this.rootDelete,
  367. this.rootSS,
  368. this.rootOS,
  369. this.rootOA,
  370. this.rootOG});
  371. this.contextRootEdit.Name = "contextRootEdit";
  372. this.contextRootEdit.Size = new System.Drawing.Size(153, 184);
  373. //
  374. // imageList1
  375. //
  376. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  377. this.imageList1.ImageSize = new System.Drawing.Size(75, 75);
  378. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  379. //
  380. // groupBox6groupBox_analysisResult2
  381. //
  382. this.groupBox6groupBox_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  383. | System.Windows.Forms.AnchorStyles.Right)));
  384. this.groupBox6groupBox_analysisResult2.Controls.Add(this.listView_analysisResult);
  385. this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(18, 732);
  386. this.groupBox6groupBox_analysisResult2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  387. this.groupBox6groupBox_analysisResult2.Name = "groupBox6groupBox_analysisResult2";
  388. this.groupBox6groupBox_analysisResult2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
  389. this.groupBox6groupBox_analysisResult2.Size = new System.Drawing.Size(1438, 216);
  390. this.groupBox6groupBox_analysisResult2.TabIndex = 33;
  391. this.groupBox6groupBox_analysisResult2.TabStop = false;
  392. //
  393. // listView_analysisResult
  394. //
  395. this.listView_analysisResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  396. | System.Windows.Forms.AnchorStyles.Right)));
  397. this.listView_analysisResult.FullRowSelect = true;
  398. this.listView_analysisResult.GridLines = true;
  399. this.listView_analysisResult.HideSelection = false;
  400. this.listView_analysisResult.Location = new System.Drawing.Point(9, 20);
  401. this.listView_analysisResult.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  402. this.listView_analysisResult.MultiSelect = false;
  403. this.listView_analysisResult.Name = "listView_analysisResult";
  404. this.listView_analysisResult.Size = new System.Drawing.Size(1418, 186);
  405. this.listView_analysisResult.TabIndex = 2;
  406. this.listView_analysisResult.UseCompatibleStateImageBehavior = false;
  407. //
  408. // groupBox3
  409. //
  410. this.groupBox3.Controls.Add(this.textBox2);
  411. this.groupBox3.Controls.Add(this.label6);
  412. this.groupBox3.Controls.Add(this.radioButton2);
  413. this.groupBox3.Controls.Add(this.radioButton1);
  414. this.groupBox3.Controls.Add(this.button8);
  415. this.groupBox3.Controls.Add(this.button7);
  416. this.groupBox3.Controls.Add(this.button6);
  417. this.groupBox3.Controls.Add(this.groupBox4);
  418. this.groupBox3.Controls.Add(this.button5);
  419. this.groupBox3.Location = new System.Drawing.Point(1134, 106);
  420. this.groupBox3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  421. this.groupBox3.Name = "groupBox3";
  422. this.groupBox3.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
  423. this.groupBox3.Size = new System.Drawing.Size(322, 616);
  424. this.groupBox3.TabIndex = 34;
  425. this.groupBox3.TabStop = false;
  426. //
  427. // textBox2
  428. //
  429. this.textBox2.Location = new System.Drawing.Point(6, 480);
  430. this.textBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  431. this.textBox2.Multiline = true;
  432. this.textBox2.Name = "textBox2";
  433. this.textBox2.Size = new System.Drawing.Size(302, 126);
  434. this.textBox2.TabIndex = 7;
  435. //
  436. // label6
  437. //
  438. this.label6.AutoSize = true;
  439. this.label6.Location = new System.Drawing.Point(12, 458);
  440. this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  441. this.label6.Name = "label6";
  442. this.label6.Size = new System.Drawing.Size(134, 18);
  443. this.label6.TabIndex = 6;
  444. this.label6.Text = "请输入备注信息";
  445. //
  446. // radioButton2
  447. //
  448. this.radioButton2.AutoSize = true;
  449. this.radioButton2.Location = new System.Drawing.Point(15, 387);
  450. this.radioButton2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  451. this.radioButton2.Name = "radioButton2";
  452. this.radioButton2.Size = new System.Drawing.Size(105, 22);
  453. this.radioButton2.TabIndex = 5;
  454. this.radioButton2.TabStop = true;
  455. this.radioButton2.Text = "图库预览";
  456. this.radioButton2.UseVisualStyleBackColor = true;
  457. //
  458. // radioButton1
  459. //
  460. this.radioButton1.AutoSize = true;
  461. this.radioButton1.Location = new System.Drawing.Point(204, 387);
  462. this.radioButton1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  463. this.radioButton1.Name = "radioButton1";
  464. this.radioButton1.Size = new System.Drawing.Size(105, 22);
  465. this.radioButton1.TabIndex = 5;
  466. this.radioButton1.TabStop = true;
  467. this.radioButton1.Text = "实时预览";
  468. this.radioButton1.UseVisualStyleBackColor = true;
  469. //
  470. // button8
  471. //
  472. this.button8.Location = new System.Drawing.Point(10, 344);
  473. this.button8.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  474. this.button8.Name = "button8";
  475. this.button8.Size = new System.Drawing.Size(303, 34);
  476. this.button8.TabIndex = 4;
  477. this.button8.Text = "移动载物台到夹杂物";
  478. this.button8.UseVisualStyleBackColor = true;
  479. //
  480. // button7
  481. //
  482. this.button7.Location = new System.Drawing.Point(201, 300);
  483. this.button7.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  484. this.button7.Name = "button7";
  485. this.button7.Size = new System.Drawing.Size(112, 34);
  486. this.button7.TabIndex = 3;
  487. this.button7.Text = "下一个";
  488. this.button7.UseVisualStyleBackColor = true;
  489. this.button7.Click += new System.EventHandler(this.button7_Click);
  490. //
  491. // button6
  492. //
  493. this.button6.Location = new System.Drawing.Point(9, 300);
  494. this.button6.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  495. this.button6.Name = "button6";
  496. this.button6.Size = new System.Drawing.Size(112, 34);
  497. this.button6.TabIndex = 2;
  498. this.button6.Text = "上一个";
  499. this.button6.UseVisualStyleBackColor = true;
  500. this.button6.Click += new System.EventHandler(this.button6_Click);
  501. //
  502. // groupBox4
  503. //
  504. this.groupBox4.Controls.Add(this.pictureBox1);
  505. this.groupBox4.Location = new System.Drawing.Point(10, 74);
  506. this.groupBox4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  507. this.groupBox4.Name = "groupBox4";
  508. this.groupBox4.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
  509. this.groupBox4.Size = new System.Drawing.Size(300, 213);
  510. this.groupBox4.TabIndex = 1;
  511. this.groupBox4.TabStop = false;
  512. //
  513. // pictureBox1
  514. //
  515. this.pictureBox1.Location = new System.Drawing.Point(4, 16);
  516. this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  517. this.pictureBox1.Name = "pictureBox1";
  518. this.pictureBox1.Size = new System.Drawing.Size(286, 188);
  519. this.pictureBox1.TabIndex = 0;
  520. this.pictureBox1.TabStop = false;
  521. //
  522. // button5
  523. //
  524. this.button5.Location = new System.Drawing.Point(10, 30);
  525. this.button5.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  526. this.button5.Name = "button5";
  527. this.button5.Size = new System.Drawing.Size(300, 34);
  528. this.button5.TabIndex = 0;
  529. this.button5.Text = "全图模式";
  530. this.button5.UseVisualStyleBackColor = true;
  531. //
  532. // MethodKInclusionEditDialog
  533. //
  534. this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
  535. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  536. this.ClientSize = new System.Drawing.Size(1474, 966);
  537. this.Controls.Add(this.groupBox3);
  538. this.Controls.Add(this.groupBox6groupBox_analysisResult2);
  539. this.Controls.Add(this.groupBox2);
  540. this.Controls.Add(this.groupBox1);
  541. this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  542. this.Name = "MethodKInclusionEditDialog";
  543. this.Text = "MethodKInclusionEditDialog";
  544. this.groupBox1.ResumeLayout(false);
  545. this.groupBox1.PerformLayout();
  546. this.groupBox2.ResumeLayout(false);
  547. this.contextRootEdit.ResumeLayout(false);
  548. this.groupBox6groupBox_analysisResult2.ResumeLayout(false);
  549. this.groupBox3.ResumeLayout(false);
  550. this.groupBox3.PerformLayout();
  551. this.groupBox4.ResumeLayout(false);
  552. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  553. this.ResumeLayout(false);
  554. }
  555. /// <summary>
  556. /// 类型修改
  557. /// </summary>
  558. /// <param name="sender"></param>
  559. /// <param name="e"></param>
  560. private void rootTypeClick(object sender, EventArgs e)
  561. {
  562. if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
  563. {
  564. return;
  565. }
  566. ToolStripMenuItem item = (ToolStripMenuItem)sender;
  567. int index = this.listView1.FocusedItem.Index;
  568. listView1.Items[index].Text = item.Text;
  569. listView1.Update();
  570. InclusionEditModel model = (InclusionEditModel)this.listView1.FocusedItem.Tag;
  571. var edit = inclusionEditModelList.Where(m => m.dataId == model.dataId).FirstOrDefault();
  572. Dictionary<string, Color> dic = new Dictionary<string, Color>()
  573. {
  574. {"SS",Color.Red },
  575. {"OA",Color.Yellow },
  576. {"OS",Color.Orange },
  577. {"OG",Color.Green },
  578. };
  579. if (edit != null)
  580. {
  581. TypesOfInclusions typesOfInclusions = new TypesOfInclusions(item.Text);
  582. typesOfInclusions.showColor = dic[item.Text].ToArgb();
  583. edit.dataType = item.Text;
  584. edit.data.type = typesOfInclusions;
  585. //edit.data.type.showColor = dic[item.Text].ToArgb();
  586. }
  587. this.button1_Click(null, null);
  588. }
  589. /// <summary>
  590. /// 编辑
  591. /// </summary>
  592. /// <param name="sender"></param>
  593. /// <param name="e"></param>
  594. private void rootEditClick(object sender, EventArgs e)
  595. {
  596. if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
  597. {
  598. return;
  599. }
  600. InclusionEditModel model = (InclusionEditModel)this.listView1.FocusedItem.Tag;
  601. MethodKInclusionEditSec methodKInclusionEditSec = new MethodKInclusionEditSec(model,this.appWorkspace,this,this.OriginalImage);
  602. methodKInclusionEditSec.StartPosition = FormStartPosition.CenterScreen;
  603. methodKInclusionEditSec.ShowDialog();
  604. }
  605. #region [编辑回调]
  606. /// <summary>
  607. /// 编辑
  608. /// </summary>
  609. /// <param name="sender"></param>
  610. /// <param name="e"></param>
  611. public void rootEditCallBack(InclusionEditModel model)
  612. {
  613. if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
  614. {
  615. return;
  616. }
  617. this.listView1.FocusedItem.Tag = model;
  618. var edit = inclusionEditModelList.Where(m => m.dataId == model.dataId).FirstOrDefault();
  619. if (edit != null)
  620. {
  621. edit = model;
  622. }
  623. button1_Click(null, null);
  624. }
  625. #endregion
  626. /// <summary>
  627. /// 去除假象
  628. /// </summary>
  629. /// <param name="sender"></param>
  630. /// <param name="e"></param>
  631. public void rootDeleteClick(object sender, EventArgs e)
  632. {
  633. if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
  634. {
  635. return;
  636. }
  637. int index = this.listView1.FocusedItem.Index;
  638. listView1.Items.RemoveAt(index);
  639. listView1.Update();
  640. InclusionEditModel model = (InclusionEditModel)this.listView1.FocusedItem.Tag;
  641. var edit = inclusionEditModelList.Where(m => m.dataId == model.dataId).FirstOrDefault();
  642. if (edit != null)
  643. {
  644. inclusionEditModelList.Remove(edit);
  645. }
  646. }
  647. /// <summary>
  648. /// 初始化图片列表
  649. /// </summary>
  650. private void InitListView1Data()
  651. {
  652. this.imageList1.Images.Clear();
  653. this.listView1.Items.Clear();
  654. for (int i = 0; i < this.inclusionEditModelList.Count; i++)
  655. {
  656. //原图
  657. Bitmap primaryBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.inclusionEditModelList[i].dataMat);
  658. //克隆原图
  659. Bitmap newBit = primaryBitmap.Clone(new Rectangle(0, 0, primaryBitmap.Width, primaryBitmap.Height), primaryBitmap.PixelFormat);
  660. this.imageList1.ImageSize = new System.Drawing.Size(75, 75);
  661. this.imageList1.Images.Add("img" + i, newBit);
  662. this.listView1.Items.Add("", i);
  663. this.listView1.Items[i].ImageIndex = i;
  664. this.listView1.Items[i].Tag = this.inclusionEditModelList[i];
  665. this.listView1.Items[i].Text = this.inclusionEditModelList[i].dataType;
  666. }
  667. this.textBox1.Text = this.inclusionEditModelList.Count().ToString();
  668. this.comboBox1.SelectedIndex = 0;
  669. //this.label4.Text =
  670. }
  671. /// <summary>
  672. /// 分解图片
  673. /// </summary>
  674. /// <param name="mat"></param>
  675. private List<Mat> SpiltPicture()
  676. {
  677. foreach (var inclusion in this.inclusionList)
  678. {
  679. InclusionEditModel inclusionEditModel = new InclusionEditModel();
  680. Mat inclusionMat = new Mat(this.OriginalImage,new Rect(inclusion.rectProfile.X, inclusion.rectProfile.Y, inclusion.rectProfile.Width, inclusion.rectProfile.Height));
  681. inclusionEditModel.dataOriginalMat = inclusionMat;
  682. Mat dst = new Mat();
  683. //(输入,输出,缩放后图像大小,缩放比列,插值方式)
  684. Cv2.Resize(inclusionMat, dst, new OpenCvSharp.Size(64 ,64), 0, 0, InterpolationFlags.Cubic);
  685. inclusionEditModel.dataType = inclusion.type.type;
  686. inclusionEditModel.dataMat = dst;
  687. inclusionEditModel.dataId = Guid.NewGuid().ToString();
  688. inclusionEditModel.data = inclusion;
  689. inclusionEditModelList.Add(inclusionEditModel);
  690. //this.everyInclusionMatList.Add(dst);
  691. }
  692. return new List<Mat>();
  693. }
  694. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  695. {
  696. if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
  697. {
  698. return;
  699. }
  700. this.pictureBox1.Image = this.imageList1.Images[this.listView1.FocusedItem.Index];
  701. this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
  702. }
  703. /// <summary>
  704. /// 不可点击空白区域
  705. /// </summary>
  706. /// <param name="sender"></param>
  707. /// <param name="e"></param>
  708. private void listView1_MouseUp(object sender, MouseEventArgs e)
  709. {
  710. if (e.Button == MouseButtons.Left)
  711. {
  712. if (listView1.SelectedItems.Count > 0)
  713. {
  714. }
  715. else if (listView1.SelectedItems.Count <= 0)//点击空白区
  716. {
  717. if (this.listView1.FocusedItem != null)
  718. {
  719. ListViewItem item = this.listView1.GetItemAt(e.X, e.Y);
  720. if (item == null)
  721. {
  722. this.listView1.FocusedItem.Selected = true;
  723. }
  724. }
  725. }
  726. }
  727. }
  728. /// <summary>
  729. /// 上一个
  730. /// </summary>
  731. /// <param name="sender"></param>
  732. /// <param name="e"></param>
  733. private void button6_Click(object sender, EventArgs e)
  734. {
  735. if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
  736. {
  737. return;
  738. }
  739. int index = this.listView1.FocusedItem.Index;
  740. if (index > 0)
  741. {
  742. //滚动到指定的行位置
  743. this.listView1.EnsureVisible(index - 1);
  744. this.listView1.Items[index - 1].Focused = true;
  745. this.listView1.Items[index - 1].Selected = true;
  746. }
  747. }
  748. /// <summary>
  749. /// 下一个
  750. /// </summary>
  751. /// <param name="sender"></param>
  752. /// <param name="e"></param>
  753. private void button7_Click(object sender, EventArgs e)
  754. {
  755. if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
  756. {
  757. return;
  758. }
  759. int index = this.listView1.FocusedItem.Index;
  760. if (index < this.listView1.Items.Count - 1)
  761. {
  762. //滚动到指定的行位置
  763. this.listView1.EnsureVisible(index + 1);
  764. this.listView1.Items[index + 1].Focused = true;
  765. this.listView1.Items[index + 1].Selected = true;
  766. }
  767. }
  768. /// <summary>
  769. ///
  770. /// </summary>
  771. /// <param name="sender"></param>
  772. /// <param name="e"></param>
  773. private void listView1_MouseClick(object sender, MouseEventArgs e)
  774. {
  775. if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
  776. {
  777. return;
  778. }
  779. if (e.Button == MouseButtons.Right)
  780. {
  781. ListViewItem item = this.listView1.GetItemAt(e.X, e.Y);
  782. if (item != null)
  783. {
  784. this.contextRootEdit.Show(this.listView1, e.Location);
  785. }
  786. }
  787. }
  788. private void textBox1_KeyUp(object sender, KeyEventArgs e)
  789. {
  790. if (e.KeyCode == Keys.Control || e.KeyCode == Keys.Enter)
  791. {
  792. int count = this.inclusionEditModelList.Count();
  793. try
  794. {
  795. count = Convert.ToInt32(textBox1.Text);
  796. if (count > this.inclusionEditModelList.Count())
  797. {
  798. count = this.inclusionEditModelList.Count();
  799. textBox1.Text = count.ToString();
  800. }
  801. }
  802. catch (Exception ex)
  803. {
  804. count = this.inclusionEditModelList.Count();
  805. textBox1.Text = count.ToString();
  806. }
  807. this.imageList1.Images.Clear();
  808. this.listView1.Items.Clear();
  809. for (int i = 0; i < count; i++)
  810. {
  811. //原图
  812. Bitmap primaryBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.inclusionEditModelList[i].dataMat);
  813. //克隆原图
  814. Bitmap newBit = primaryBitmap.Clone(new Rectangle(0, 0, primaryBitmap.Width, primaryBitmap.Height), primaryBitmap.PixelFormat);
  815. this.imageList1.ImageSize = new System.Drawing.Size(75, 75);
  816. this.imageList1.Images.Add("img" + i, newBit);
  817. this.listView1.Items.Add("", i);
  818. this.listView1.Items[i].ImageIndex = i;
  819. this.listView1.Items[i].Tag = this.inclusionEditModelList[i];
  820. this.listView1.Items[i].Text = this.inclusionEditModelList[i].dataType;
  821. }
  822. }
  823. }
  824. /// <summary>
  825. /// 检索
  826. /// </summary>
  827. /// <param name="sender"></param>
  828. /// <param name="e"></param>
  829. private void button1_Click(object sender, EventArgs e)
  830. {
  831. int index = this.comboBox1.SelectedIndex;
  832. List<InclusionEditModel> list = new List<InclusionEditModel>();
  833. switch (index)
  834. {
  835. case 0:
  836. list = inclusionEditModelList;
  837. break;
  838. case 1:
  839. list = inclusionEditModelList.Where(m => m.dataType == "SS").ToList();
  840. break;
  841. case 2:
  842. list = inclusionEditModelList.Where(m => m.dataType == "OS").ToList();
  843. break;
  844. case 3:
  845. list = inclusionEditModelList.Where(m => m.dataType == "OA").ToList();
  846. break;
  847. case 4:
  848. list = inclusionEditModelList.Where(m => m.dataType == "OG").ToList();
  849. break;
  850. }
  851. this.imageList1.Images.Clear();
  852. this.listView1.Items.Clear();
  853. for (int i = 0; i < list.Count(); i++)
  854. {
  855. //原图
  856. Bitmap primaryBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(list[i].dataMat);
  857. //克隆原图
  858. Bitmap newBit = primaryBitmap.Clone(new Rectangle(0, 0, primaryBitmap.Width, primaryBitmap.Height), primaryBitmap.PixelFormat);
  859. this.imageList1.ImageSize = new System.Drawing.Size(75, 75);
  860. this.imageList1.Images.Add("img" + i, newBit);
  861. this.listView1.Items.Add("", i);
  862. this.listView1.Items[i].ImageIndex = i;
  863. this.listView1.Items[i].Tag = this.inclusionEditModelList[i];
  864. this.listView1.Items[i].Text = list[i].dataType;
  865. }
  866. this.listView_analysisResult.BeginUpdate();
  867. this.listView_analysisResult.Items.Clear();
  868. foreach (var item in list)
  869. {
  870. ListViewItem lvi = new ListViewItem();
  871. lvi.Text = item.data.physicalLength.ToString();
  872. lvi.SubItems.Add(item.data.physicalWidth.ToString());
  873. lvi.SubItems.Add(item.data.areaK.ToString());
  874. lvi.SubItems.Add(item.data.type.type.ToString());
  875. lvi.SubItems.Add(item.data.rating.ToString());
  876. this.listView_analysisResult.Items.Add(lvi);
  877. }
  878. this.listView_analysisResult.EndUpdate();
  879. }
  880. /// <summary>
  881. /// 确定
  882. /// </summary>
  883. /// <param name="sender"></param>
  884. /// <param name="e"></param>
  885. private void button3_Click(object sender, EventArgs e)
  886. {
  887. for (int i = 0; i < this.inclusionList.Count; i++)
  888. {
  889. var inclusion = this.inclusionList[i];
  890. foreach (var item in this.inclusionEditModelList)
  891. {
  892. if (!item.data.Equals(inclusion))
  893. {
  894. continue;
  895. }
  896. inclusion = item.data;
  897. }
  898. }
  899. this.Close();
  900. this.methodKDialog.inclusionEditDialogCloseCallback(this.inclusionList);
  901. }
  902. }
  903. }