| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978 |
- using OpenCvSharp;
- using PaintDotNet;
- using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.InclusionsGlobalSettings;
- namespace Metis.DedicatedAnalysis.Inclusions.New_DIN50602_1985
- {
- internal partial class MethodKInclusionEditDialog : Form
- {
- private System.ComponentModel.IContainer components = null;
- private ImageList imageList1;
- private AppWorkspace appWorkspace;
- private List<Inclusion> inclusionList;
- private Mat OriginalImage;
- private List<InclusionEditModel> inclusionEditModelList = new List<InclusionEditModel>();
- private GroupBox groupBox1;
- private TextBox textBox1;
- private Label label3;
- private Label label2;
- private Label label1;
- private Label label4;
- private Label label5;
- private ComboBox comboBox1;
- private Button button1;
- private Button button4;
- private Button button3;
- private Button button2;
- private GroupBox groupBox2;
- private GroupBox groupBox6groupBox_analysisResult2;
- private ListView listView_analysisResult;
- private GroupBox groupBox3;
- private Button button5;
- private GroupBox groupBox4;
- private Button button8;
- private Button button7;
- private Button button6;
- private RadioButton radioButton1;
- private RadioButton radioButton2;
- private Label label6;
- private TextBox textBox2;
- private PictureBox pictureBox1;
- private ListView listView1;
- private System.Windows.Forms.ContextMenuStrip contextRootEdit;
- private System.Windows.Forms.ToolStripMenuItem rootEdit;
- private System.Windows.Forms.ToolStripMenuItem rootDelete;
- private System.Windows.Forms.ToolStripMenuItem rootSS;
- private System.Windows.Forms.ToolStripMenuItem rootOS;
- private System.Windows.Forms.ToolStripMenuItem rootOA;
- private System.Windows.Forms.ToolStripMenuItem rootOG;
- private MethodKDialog methodKDialog;
- public MethodKInclusionEditDialog(AppWorkspace appWorkspace,List<Inclusion> inclusionList,Mat OriginalImage, MethodKDialog methodKDialog)
- {
- this.appWorkspace = appWorkspace;
- this.inclusionList = inclusionList;
- this.OriginalImage = OriginalImage;
- this.methodKDialog = methodKDialog;
- this.SpiltPicture();
- InitializeComponent();
- InitListView1Data();
- InitList();
- }
- /// <summary>
- /// 初始化列表
- /// </summary>
- private void InitList()
- {
- // 初始化报告列表
- this.listView_analysisResult.View = View.Details;
- this.listView_analysisResult.BeginUpdate();
- List<string> headerList = new List<string>() { "长度","宽度","面积","类型","级别"};
- // 构建头
- foreach (var item in headerList)
- {
- ColumnHeader header = new ColumnHeader();
- header.Text = item;
- header.Width = 200;
- this.listView_analysisResult.Columns.Add(header);
- }
- foreach (var item in this.inclusionEditModelList)
- {
- ListViewItem lvi = new ListViewItem();
- lvi.Text = item.data.physicalLength.ToString();
- lvi.SubItems.Add(item.data.physicalWidth.ToString());
- lvi.SubItems.Add(item.data.areaK.ToString());
- lvi.SubItems.Add(item.data.type.type.ToString());
- lvi.SubItems.Add(item.data.rating.ToString());
- this.listView_analysisResult.Items.Add(lvi);
- }
- this.listView_analysisResult.EndUpdate();
- }
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.rootEdit = new System.Windows.Forms.ToolStripMenuItem();
- this.rootDelete = new System.Windows.Forms.ToolStripMenuItem();
- this.rootSS = new System.Windows.Forms.ToolStripMenuItem();
- this.rootOS = new System.Windows.Forms.ToolStripMenuItem();
- this.rootOA = new System.Windows.Forms.ToolStripMenuItem();
- this.rootOG = new System.Windows.Forms.ToolStripMenuItem();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button4 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.label5 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.listView1 = new System.Windows.Forms.ListView();
- this.contextRootEdit = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.groupBox6groupBox_analysisResult2 = new System.Windows.Forms.GroupBox();
- this.listView_analysisResult = new System.Windows.Forms.ListView();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label6 = new System.Windows.Forms.Label();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.button8 = new System.Windows.Forms.Button();
- this.button7 = new System.Windows.Forms.Button();
- this.button6 = new System.Windows.Forms.Button();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.button5 = new System.Windows.Forms.Button();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.contextRootEdit.SuspendLayout();
- this.groupBox6groupBox_analysisResult2.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.groupBox4.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
- this.SuspendLayout();
- //
- // rootEdit
- //
- this.rootEdit.Name = "rootEdit";
- this.rootEdit.Size = new System.Drawing.Size(152, 30);
- this.rootEdit.Text = "编辑";
- this.rootEdit.Click += new System.EventHandler(this.rootEditClick);
- //
- // rootDelete
- //
- this.rootDelete.Name = "rootDelete";
- this.rootDelete.Size = new System.Drawing.Size(152, 30);
- this.rootDelete.Text = "去除假象";
- this.rootDelete.Click += new System.EventHandler(this.rootDeleteClick);
- //
- // rootSS
- //
- this.rootSS.Name = "rootSS";
- this.rootSS.Size = new System.Drawing.Size(152, 30);
- this.rootSS.Text = "SS";
- this.rootSS.Click += new System.EventHandler(this.rootTypeClick);
- //
- // rootOS
- //
- this.rootOS.Name = "rootOS";
- this.rootOS.Size = new System.Drawing.Size(152, 30);
- this.rootOS.Text = "OS";
- this.rootOS.Click += new System.EventHandler(this.rootTypeClick);
- //
- // rootOA
- //
- this.rootOA.Name = "rootOA";
- this.rootOA.Size = new System.Drawing.Size(152, 30);
- this.rootOA.Text = "OA";
- this.rootOA.Click += new System.EventHandler(this.rootTypeClick);
- //
- // rootOG
- //
- this.rootOG.Name = "rootOG";
- this.rootOG.Size = new System.Drawing.Size(152, 30);
- this.rootOG.Text = "OG";
- this.rootOG.Click += new System.EventHandler(this.rootTypeClick);
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.button4);
- this.groupBox1.Controls.Add(this.button3);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Controls.Add(this.comboBox1);
- this.groupBox1.Controls.Add(this.label5);
- this.groupBox1.Controls.Add(this.label4);
- this.groupBox1.Controls.Add(this.label3);
- this.groupBox1.Controls.Add(this.label2);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Controls.Add(this.textBox1);
- this.groupBox1.Location = new System.Drawing.Point(18, 18);
- this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox1.Size = new System.Drawing.Size(1438, 80);
- this.groupBox1.TabIndex = 13;
- this.groupBox1.TabStop = false;
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(1317, 22);
- this.button4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(112, 34);
- this.button4.TabIndex = 10;
- this.button4.Text = "保存";
- this.button4.UseVisualStyleBackColor = true;
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(1196, 22);
- this.button3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(112, 34);
- this.button3.TabIndex = 9;
- this.button3.Text = "确定";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(1074, 22);
- this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(112, 34);
- this.button2.TabIndex = 8;
- this.button2.Text = "刷新";
- this.button2.UseVisualStyleBackColor = true;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(548, 26);
- this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(112, 34);
- this.button1.TabIndex = 7;
- this.button1.Text = "检索";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // comboBox1
- //
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Items.AddRange(new object[] {
- "全部",
- "SS",
- "OS",
- "OA",
- "OG"});
- this.comboBox1.Location = new System.Drawing.Point(357, 27);
- this.comboBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(180, 26);
- this.comboBox1.TabIndex = 6;
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(286, 33);
- this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(62, 18);
- this.label5.TabIndex = 5;
- this.label5.Text = "类型:";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(958, 33);
- this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(62, 18);
- this.label4.TabIndex = 4;
- this.label4.Text = "1.2mm2";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(866, 33);
- this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(98, 18);
- this.label3.TabIndex = 3;
- this.label3.Text = "分析面积:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(26, 33);
- this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(116, 18);
- this.label2.TabIndex = 2;
- this.label2.Text = "显示夹杂物前";
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(208, 33);
- this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(26, 18);
- this.label1.TabIndex = 1;
- this.label1.Text = "条";
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(150, 24);
- this.textBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(48, 28);
- this.textBox1.TabIndex = 0;
- this.textBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyUp);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.listView1);
- this.groupBox2.Location = new System.Drawing.Point(18, 106);
- this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox2.Size = new System.Drawing.Size(1107, 616);
- this.groupBox2.TabIndex = 14;
- this.groupBox2.TabStop = false;
- //
- // listView1
- //
- this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.listView1.ContextMenuStrip = this.contextRootEdit;
- this.listView1.HideSelection = false;
- this.listView1.LargeImageList = this.imageList1;
- this.listView1.Location = new System.Drawing.Point(9, 30);
- this.listView1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.listView1.MultiSelect = false;
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(1087, 576);
- this.listView1.TabIndex = 2;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
- this.listView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseClick);
- this.listView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseUp);
- //
- // contextRootEdit
- //
- this.contextRootEdit.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.contextRootEdit.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.rootEdit,
- this.rootDelete,
- this.rootSS,
- this.rootOS,
- this.rootOA,
- this.rootOG});
- this.contextRootEdit.Name = "contextRootEdit";
- this.contextRootEdit.Size = new System.Drawing.Size(153, 184);
- //
- // imageList1
- //
- this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
- this.imageList1.ImageSize = new System.Drawing.Size(75, 75);
- this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
- //
- // groupBox6groupBox_analysisResult2
- //
- this.groupBox6groupBox_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox6groupBox_analysisResult2.Controls.Add(this.listView_analysisResult);
- this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(18, 732);
- this.groupBox6groupBox_analysisResult2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox6groupBox_analysisResult2.Name = "groupBox6groupBox_analysisResult2";
- this.groupBox6groupBox_analysisResult2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox6groupBox_analysisResult2.Size = new System.Drawing.Size(1438, 216);
- this.groupBox6groupBox_analysisResult2.TabIndex = 33;
- this.groupBox6groupBox_analysisResult2.TabStop = false;
- //
- // listView_analysisResult
- //
- this.listView_analysisResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.listView_analysisResult.FullRowSelect = true;
- this.listView_analysisResult.GridLines = true;
- this.listView_analysisResult.HideSelection = false;
- this.listView_analysisResult.Location = new System.Drawing.Point(9, 20);
- this.listView_analysisResult.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.listView_analysisResult.MultiSelect = false;
- this.listView_analysisResult.Name = "listView_analysisResult";
- this.listView_analysisResult.Size = new System.Drawing.Size(1418, 186);
- this.listView_analysisResult.TabIndex = 2;
- this.listView_analysisResult.UseCompatibleStateImageBehavior = false;
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.textBox2);
- this.groupBox3.Controls.Add(this.label6);
- this.groupBox3.Controls.Add(this.radioButton2);
- this.groupBox3.Controls.Add(this.radioButton1);
- this.groupBox3.Controls.Add(this.button8);
- this.groupBox3.Controls.Add(this.button7);
- this.groupBox3.Controls.Add(this.button6);
- this.groupBox3.Controls.Add(this.groupBox4);
- this.groupBox3.Controls.Add(this.button5);
- this.groupBox3.Location = new System.Drawing.Point(1134, 106);
- this.groupBox3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox3.Size = new System.Drawing.Size(322, 616);
- this.groupBox3.TabIndex = 34;
- this.groupBox3.TabStop = false;
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(6, 480);
- this.textBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.textBox2.Multiline = true;
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(302, 126);
- this.textBox2.TabIndex = 7;
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(12, 458);
- this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(134, 18);
- this.label6.TabIndex = 6;
- this.label6.Text = "请输入备注信息";
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(15, 387);
- this.radioButton2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(105, 22);
- this.radioButton2.TabIndex = 5;
- this.radioButton2.TabStop = true;
- this.radioButton2.Text = "图库预览";
- this.radioButton2.UseVisualStyleBackColor = true;
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Location = new System.Drawing.Point(204, 387);
- this.radioButton1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(105, 22);
- this.radioButton1.TabIndex = 5;
- this.radioButton1.TabStop = true;
- this.radioButton1.Text = "实时预览";
- this.radioButton1.UseVisualStyleBackColor = true;
- //
- // button8
- //
- this.button8.Location = new System.Drawing.Point(10, 344);
- this.button8.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.button8.Name = "button8";
- this.button8.Size = new System.Drawing.Size(303, 34);
- this.button8.TabIndex = 4;
- this.button8.Text = "移动载物台到夹杂物";
- this.button8.UseVisualStyleBackColor = true;
- //
- // button7
- //
- this.button7.Location = new System.Drawing.Point(201, 300);
- this.button7.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.button7.Name = "button7";
- this.button7.Size = new System.Drawing.Size(112, 34);
- this.button7.TabIndex = 3;
- this.button7.Text = "下一个";
- this.button7.UseVisualStyleBackColor = true;
- this.button7.Click += new System.EventHandler(this.button7_Click);
- //
- // button6
- //
- this.button6.Location = new System.Drawing.Point(9, 300);
- this.button6.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(112, 34);
- this.button6.TabIndex = 2;
- this.button6.Text = "上一个";
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.pictureBox1);
- this.groupBox4.Location = new System.Drawing.Point(10, 74);
- this.groupBox4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.groupBox4.Size = new System.Drawing.Size(300, 213);
- this.groupBox4.TabIndex = 1;
- this.groupBox4.TabStop = false;
- //
- // pictureBox1
- //
- this.pictureBox1.Location = new System.Drawing.Point(4, 16);
- this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(286, 188);
- this.pictureBox1.TabIndex = 0;
- this.pictureBox1.TabStop = false;
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(10, 30);
- this.button5.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(300, 34);
- this.button5.TabIndex = 0;
- this.button5.Text = "全图模式";
- this.button5.UseVisualStyleBackColor = true;
- //
- // MethodKInclusionEditDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1474, 966);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox6groupBox_analysisResult2);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
- this.Name = "MethodKInclusionEditDialog";
- this.Text = "MethodKInclusionEditDialog";
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox2.ResumeLayout(false);
- this.contextRootEdit.ResumeLayout(false);
- this.groupBox6groupBox_analysisResult2.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- this.groupBox4.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 类型修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void rootTypeClick(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
- {
- return;
- }
- ToolStripMenuItem item = (ToolStripMenuItem)sender;
- int index = this.listView1.FocusedItem.Index;
- listView1.Items[index].Text = item.Text;
- listView1.Update();
- InclusionEditModel model = (InclusionEditModel)this.listView1.FocusedItem.Tag;
- var edit = inclusionEditModelList.Where(m => m.dataId == model.dataId).FirstOrDefault();
- Dictionary<string, Color> dic = new Dictionary<string, Color>()
- {
- {"SS",Color.Red },
- {"OA",Color.Yellow },
- {"OS",Color.Orange },
- {"OG",Color.Green },
- };
- if (edit != null)
- {
- TypesOfInclusions typesOfInclusions = new TypesOfInclusions(item.Text);
- typesOfInclusions.showColor = dic[item.Text].ToArgb();
- edit.dataType = item.Text;
- edit.data.type = typesOfInclusions;
- //edit.data.type.showColor = dic[item.Text].ToArgb();
- }
- this.button1_Click(null, null);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void rootEditClick(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
- {
- return;
- }
- InclusionEditModel model = (InclusionEditModel)this.listView1.FocusedItem.Tag;
- MethodKInclusionEditSec methodKInclusionEditSec = new MethodKInclusionEditSec(model,this.appWorkspace,this,this.OriginalImage);
- methodKInclusionEditSec.StartPosition = FormStartPosition.CenterScreen;
- methodKInclusionEditSec.ShowDialog();
- }
- #region [编辑回调]
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void rootEditCallBack(InclusionEditModel model)
- {
- if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
- {
- return;
- }
- this.listView1.FocusedItem.Tag = model;
- var edit = inclusionEditModelList.Where(m => m.dataId == model.dataId).FirstOrDefault();
- if (edit != null)
- {
- edit = model;
- }
- button1_Click(null, null);
- }
- #endregion
- /// <summary>
- /// 去除假象
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void rootDeleteClick(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
- {
- return;
- }
- int index = this.listView1.FocusedItem.Index;
- listView1.Items.RemoveAt(index);
- listView1.Update();
- InclusionEditModel model = (InclusionEditModel)this.listView1.FocusedItem.Tag;
- var edit = inclusionEditModelList.Where(m => m.dataId == model.dataId).FirstOrDefault();
- if (edit != null)
- {
- inclusionEditModelList.Remove(edit);
- }
- }
- /// <summary>
- /// 初始化图片列表
- /// </summary>
- private void InitListView1Data()
- {
- this.imageList1.Images.Clear();
- this.listView1.Items.Clear();
- for (int i = 0; i < this.inclusionEditModelList.Count; i++)
- {
- //原图
- Bitmap primaryBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.inclusionEditModelList[i].dataMat);
- //克隆原图
- Bitmap newBit = primaryBitmap.Clone(new Rectangle(0, 0, primaryBitmap.Width, primaryBitmap.Height), primaryBitmap.PixelFormat);
- this.imageList1.ImageSize = new System.Drawing.Size(75, 75);
- this.imageList1.Images.Add("img" + i, newBit);
- this.listView1.Items.Add("", i);
- this.listView1.Items[i].ImageIndex = i;
- this.listView1.Items[i].Tag = this.inclusionEditModelList[i];
- this.listView1.Items[i].Text = this.inclusionEditModelList[i].dataType;
- }
- this.textBox1.Text = this.inclusionEditModelList.Count().ToString();
- this.comboBox1.SelectedIndex = 0;
- //this.label4.Text =
- }
- /// <summary>
- /// 分解图片
- /// </summary>
- /// <param name="mat"></param>
- private List<Mat> SpiltPicture()
- {
- foreach (var inclusion in this.inclusionList)
- {
- InclusionEditModel inclusionEditModel = new InclusionEditModel();
- Mat inclusionMat = new Mat(this.OriginalImage,new Rect(inclusion.rectProfile.X, inclusion.rectProfile.Y, inclusion.rectProfile.Width, inclusion.rectProfile.Height));
- inclusionEditModel.dataOriginalMat = inclusionMat;
- Mat dst = new Mat();
- //(输入,输出,缩放后图像大小,缩放比列,插值方式)
- Cv2.Resize(inclusionMat, dst, new OpenCvSharp.Size(64 ,64), 0, 0, InterpolationFlags.Cubic);
-
- inclusionEditModel.dataType = inclusion.type.type;
- inclusionEditModel.dataMat = dst;
- inclusionEditModel.dataId = Guid.NewGuid().ToString();
- inclusionEditModel.data = inclusion;
- inclusionEditModelList.Add(inclusionEditModel);
- //this.everyInclusionMatList.Add(dst);
- }
- return new List<Mat>();
- }
- private void listView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
- {
- return;
- }
-
- this.pictureBox1.Image = this.imageList1.Images[this.listView1.FocusedItem.Index];
- this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
- }
- /// <summary>
- /// 不可点击空白区域
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView1_MouseUp(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- if (listView1.SelectedItems.Count > 0)
- {
- }
- else if (listView1.SelectedItems.Count <= 0)//点击空白区
- {
- if (this.listView1.FocusedItem != null)
- {
- ListViewItem item = this.listView1.GetItemAt(e.X, e.Y);
- if (item == null)
- {
- this.listView1.FocusedItem.Selected = true;
- }
- }
- }
- }
- }
- /// <summary>
- /// 上一个
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
- {
- return;
- }
- int index = this.listView1.FocusedItem.Index;
- if (index > 0)
- {
- //滚动到指定的行位置
- this.listView1.EnsureVisible(index - 1);
- this.listView1.Items[index - 1].Focused = true;
- this.listView1.Items[index - 1].Selected = true;
- }
- }
- /// <summary>
- /// 下一个
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_Click(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
- {
- return;
- }
- int index = this.listView1.FocusedItem.Index;
- if (index < this.listView1.Items.Count - 1)
- {
- //滚动到指定的行位置
- this.listView1.EnsureVisible(index + 1);
- this.listView1.Items[index + 1].Focused = true;
- this.listView1.Items[index + 1].Selected = true;
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView1_MouseClick(object sender, MouseEventArgs e)
- {
- if (this.listView1.FocusedItem == null || this.listView1.FocusedItem.Index == -1)
- {
- return;
- }
- if (e.Button == MouseButtons.Right)
- {
- ListViewItem item = this.listView1.GetItemAt(e.X, e.Y);
- if (item != null)
- {
- this.contextRootEdit.Show(this.listView1, e.Location);
- }
- }
- }
- private void textBox1_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Control || e.KeyCode == Keys.Enter)
- {
- int count = this.inclusionEditModelList.Count();
- try
- {
- count = Convert.ToInt32(textBox1.Text);
- if (count > this.inclusionEditModelList.Count())
- {
- count = this.inclusionEditModelList.Count();
- textBox1.Text = count.ToString();
- }
- }
- catch (Exception ex)
- {
- count = this.inclusionEditModelList.Count();
- textBox1.Text = count.ToString();
- }
- this.imageList1.Images.Clear();
- this.listView1.Items.Clear();
- for (int i = 0; i < count; i++)
- {
- //原图
- Bitmap primaryBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.inclusionEditModelList[i].dataMat);
- //克隆原图
- Bitmap newBit = primaryBitmap.Clone(new Rectangle(0, 0, primaryBitmap.Width, primaryBitmap.Height), primaryBitmap.PixelFormat);
- this.imageList1.ImageSize = new System.Drawing.Size(75, 75);
- this.imageList1.Images.Add("img" + i, newBit);
- this.listView1.Items.Add("", i);
- this.listView1.Items[i].ImageIndex = i;
- this.listView1.Items[i].Tag = this.inclusionEditModelList[i];
- this.listView1.Items[i].Text = this.inclusionEditModelList[i].dataType;
- }
- }
- }
- /// <summary>
- /// 检索
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- int index = this.comboBox1.SelectedIndex;
- List<InclusionEditModel> list = new List<InclusionEditModel>();
- switch (index)
- {
- case 0:
- list = inclusionEditModelList;
- break;
- case 1:
- list = inclusionEditModelList.Where(m => m.dataType == "SS").ToList();
- break;
- case 2:
- list = inclusionEditModelList.Where(m => m.dataType == "OS").ToList();
- break;
- case 3:
- list = inclusionEditModelList.Where(m => m.dataType == "OA").ToList();
- break;
- case 4:
- list = inclusionEditModelList.Where(m => m.dataType == "OG").ToList();
- break;
- }
- this.imageList1.Images.Clear();
- this.listView1.Items.Clear();
- for (int i = 0; i < list.Count(); i++)
- {
- //原图
- Bitmap primaryBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(list[i].dataMat);
- //克隆原图
- Bitmap newBit = primaryBitmap.Clone(new Rectangle(0, 0, primaryBitmap.Width, primaryBitmap.Height), primaryBitmap.PixelFormat);
- this.imageList1.ImageSize = new System.Drawing.Size(75, 75);
- this.imageList1.Images.Add("img" + i, newBit);
- this.listView1.Items.Add("", i);
- this.listView1.Items[i].ImageIndex = i;
- this.listView1.Items[i].Tag = this.inclusionEditModelList[i];
- this.listView1.Items[i].Text = list[i].dataType;
- }
- this.listView_analysisResult.BeginUpdate();
- this.listView_analysisResult.Items.Clear();
- foreach (var item in list)
- {
- ListViewItem lvi = new ListViewItem();
- lvi.Text = item.data.physicalLength.ToString();
- lvi.SubItems.Add(item.data.physicalWidth.ToString());
- lvi.SubItems.Add(item.data.areaK.ToString());
- lvi.SubItems.Add(item.data.type.type.ToString());
- lvi.SubItems.Add(item.data.rating.ToString());
- this.listView_analysisResult.Items.Add(lvi);
- }
- this.listView_analysisResult.EndUpdate();
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- for (int i = 0; i < this.inclusionList.Count; i++)
- {
- var inclusion = this.inclusionList[i];
- foreach (var item in this.inclusionEditModelList)
- {
- if (!item.data.Equals(inclusion))
- {
- continue;
- }
- inclusion = item.data;
- }
- }
- this.Close();
- this.methodKDialog.inclusionEditDialogCloseCallback(this.inclusionList);
- }
- }
- }
|